Handle<FixedArrayBase> elements(boilerplate->elements());
if (elements->length() > 0 &&
elements->map() != isolate->heap()->fixed_cow_array_map()) {
- if (boilerplate->HasFastObjectElements()) {
+ if (boilerplate->HasFastSmiOrObjectElements()) {
Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements);
int length = elements->length();
for (int i = 0; i < length; i++) {
Add<HConstant>(constants),
Add<HConstant>(flags));
- // TODO(mvstanton): Consider a flag to turn off creation of any
- // AllocationMementos for this call: we are in crankshaft and should have
- // learned enough about transition behavior to stop emitting mementos.
Runtime::FunctionId function_id = Runtime::kCreateArrayLiteral;
literal = Add<HCallRuntime>(isolate()->factory()->empty_string(),
Runtime::FunctionForId(function_id),
4);
- // De-opt if elements kind changed from boilerplate_elements_kind.
- Handle<Map> map = Handle<Map>(boilerplate_object->map(), isolate());
- literal = Add<HCheckMaps>(literal, map);
+ // Register to deopt if the boilerplate ElementsKind changes.
+ AllocationSite::RegisterForDeoptOnTransitionChange(site, top_info());
}
// The array is expected in the bailout environment during computation
HValue* constructor = environment()->ExpressionStackAt(argument_count);
// Register on the site for deoptimization if the transition feedback changes.
- AllocationSite::AddDependentCompilationInfo(
- site, AllocationSite::TRANSITIONS, top_info());
+ AllocationSite::RegisterForDeoptOnTransitionChange(site, top_info());
ElementsKind kind = site->GetElementsKind();
HInstruction* site_instruction = Add<HConstant>(site);
Handle<AllocationSite> allocation_site = expr->allocation_site();
allocation_mode = HAllocationMode(allocation_site);
// Take a dependency on allocation site.
- AllocationSite::AddDependentCompilationInfo(allocation_site,
- AllocationSite::TENURING,
- top_info());
+ AllocationSite::RegisterForDeoptOnTenureChange(allocation_site,
+ top_info());
}
}
if (!allocation_mode.feedback_site().is_null()) {
DCHECK(!graph()->info()->IsStub());
Handle<AllocationSite> site(allocation_mode.feedback_site());
- AllocationSite::AddDependentCompilationInfo(
- site, AllocationSite::TENURING, top_info());
+ AllocationSite::RegisterForDeoptOnTenureChange(site, top_info());
}
// Inline the string addition into the stub when creating allocation
boilerplate_object->map()->instance_size());
PretenureFlag pretenure_flag = NOT_TENURED;
+ Handle<AllocationSite> site(site_context->current());
if (FLAG_allocation_site_pretenuring) {
pretenure_flag = site_context->current()->GetPretenureMode();
- Handle<AllocationSite> site(site_context->current());
- AllocationSite::AddDependentCompilationInfo(
- site, AllocationSite::TENURING, top_info());
+ AllocationSite::RegisterForDeoptOnTenureChange(site, top_info());
}
+ AllocationSite::RegisterForDeoptOnTransitionChange(site, top_info());
+
HInstruction* object = Add<HAllocate>(object_size_constant, type,
pretenure_flag, instance_type, site_context->current());
// static
-void AllocationSite::AddDependentCompilationInfo(Handle<AllocationSite> site,
- Reason reason,
- CompilationInfo* info) {
- DependentCode::DependencyGroup group = site->ToDependencyGroup(reason);
+void AllocationSite::RegisterForDeoptOnTenureChange(Handle<AllocationSite> site,
+ CompilationInfo* info) {
+ AddDependentCompilationInfo(
+ site, DependentCode::kAllocationSiteTenuringChangedGroup, info);
+}
+
+
+// static
+void AllocationSite::RegisterForDeoptOnTransitionChange(
+ Handle<AllocationSite> site, CompilationInfo* info) {
+ // Do nothing if the object doesn't have any useful element transitions left.
+ ElementsKind kind =
+ site->SitePointsToLiteral()
+ ? JSObject::cast(site->transition_info())->GetElementsKind()
+ : site->GetElementsKind();
+ if (AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE) {
+ AddDependentCompilationInfo(
+ site, DependentCode::kAllocationSiteTransitionChangedGroup, info);
+ }
+}
+
+
+// static
+void AllocationSite::AddDependentCompilationInfo(
+ Handle<AllocationSite> site, DependentCode::DependencyGroup group,
+ CompilationInfo* info) {
Handle<DependentCode> dep(site->dependent_code());
Handle<DependentCode> codes =
DependentCode::Insert(dep, group, info->object_wrapper());
static void DigestTransitionFeedback(Handle<AllocationSite> site,
ElementsKind to_kind);
- enum Reason {
- TENURING,
- TRANSITIONS
- };
+ static void RegisterForDeoptOnTenureChange(Handle<AllocationSite> site,
+ CompilationInfo* info);
- static void AddDependentCompilationInfo(Handle<AllocationSite> site,
- Reason reason,
- CompilationInfo* info);
+ static void RegisterForDeoptOnTransitionChange(Handle<AllocationSite> site,
+ CompilationInfo* info);
DECLARE_PRINTER(AllocationSite)
DECLARE_VERIFIER(AllocationSite)
kSize> BodyDescriptor;
private:
- inline DependentCode::DependencyGroup ToDependencyGroup(Reason reason);
+ static void AddDependentCompilationInfo(Handle<AllocationSite> site,
+ DependentCode::DependencyGroup group,
+ CompilationInfo* info);
+
bool PretenuringDecisionMade() {
return pretenure_decision() != kUndecided;
}