diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index a9bfd47930..5c7bd2b866 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -3407,8 +3407,8 @@ HCheckMaps* HCheckMaps::New(Zone* zone, // TODO(titzer): collect dependent map checks into a list. check_map->omit_ = true; if (map->CanTransition()) { - map->AddDependentCompilationInfo( - DependentCode::kPrototypeCheckGroup, info); + Map::AddDependentCompilationInfo( + map, DependentCode::kPrototypeCheckGroup, info); } } return check_map; diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 4a2bf1007b..075fb1bb93 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -6601,7 +6601,8 @@ class HStoreNamedField V8_FINAL : public HTemplateInstruction<3> { ASSERT(!has_transition()); // Only set once. Handle map = Handle::cast(map_constant->handle(info->isolate())); if (map->CanBeDeprecated()) { - map->AddDependentCompilationInfo(DependentCode::kTransitionGroup, info); + Map::AddDependentCompilationInfo( + map, DependentCode::kTransitionGroup, info); } SetOperandAt(2, map_constant); has_transition_ = true; diff --git a/src/hydrogen.cc b/src/hydrogen.cc index c64c0e0462..b93df48286 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -4925,7 +4925,7 @@ void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) { Handle global(current_info()->global_object()); Handle cell(global->GetPropertyCell(&lookup)); if (cell->type()->IsConstant()) { - cell->AddDependentCompilationInfo(top_info()); + PropertyCell::AddDependentCompilationInfo(cell, top_info()); Handle constant_object = cell->type()->AsConstant(); if (constant_object->IsConsString()) { constant_object = @@ -5552,11 +5552,12 @@ void HOptimizedGraphBuilder::PropertyAccessInfo::LoadFieldMap(Handle map) { Handle field_map = field_type->AsClass(); if (field_map->is_stable()) { field_map_ = field_map; - field_map_->AddDependentCompilationInfo( - DependentCode::kPrototypeCheckGroup, top_info()); + Map::AddDependentCompilationInfo( + field_map_, DependentCode::kPrototypeCheckGroup, top_info()); // Add dependency on the map that introduced the field. - lookup_.GetFieldOwnerFromMap(*map)->AddDependentCompilationInfo( + Map::AddDependentCompilationInfo( + handle(lookup_.GetFieldOwnerFromMap(*map), isolate()), DependentCode::kFieldTypeGroup, top_info()); } } @@ -6826,16 +6827,16 @@ void HOptimizedGraphBuilder::VisitProperty(Property* expr) { HInstruction* HGraphBuilder::BuildConstantMapCheck(Handle constant, CompilationInfo* info) { HConstant* constant_value = New(constant); + Handle map(constant->map(), info->isolate()); if (constant->map()->CanOmitMapChecks()) { - constant->map()->AddDependentCompilationInfo( - DependentCode::kPrototypeCheckGroup, info); + Map::AddDependentCompilationInfo( + map, DependentCode::kPrototypeCheckGroup, info); return constant_value; } AddInstruction(constant_value); - HCheckMaps* check = - Add(constant_value, handle(constant->map()), info); + HCheckMaps* check = Add(constant_value, map, info); check->ClearDependsOnFlag(kElementsKind); return check; } diff --git a/src/hydrogen.h b/src/hydrogen.h index 4250dc7fd6..d01a6ae4fe 100644 --- a/src/hydrogen.h +++ b/src/hydrogen.h @@ -438,9 +438,11 @@ class HGraph V8_FINAL : public ZoneObject { void MarkDependsOnEmptyArrayProtoElements() { // Add map dependency if not already added. if (depends_on_empty_array_proto_elements_) return; - isolate()->initial_object_prototype()->map()->AddDependentCompilationInfo( + Map::AddDependentCompilationInfo( + handle(isolate()->initial_object_prototype()->map()), DependentCode::kElementsCantBeAddedGroup, info()); - isolate()->initial_array_prototype()->map()->AddDependentCompilationInfo( + Map::AddDependentCompilationInfo( + handle(isolate()->initial_array_prototype()->map()), DependentCode::kElementsCantBeAddedGroup, info()); depends_on_empty_array_proto_elements_ = true; } diff --git a/src/ic.cc b/src/ic.cc index e10b0fdc61..ecf0e9a8d6 100644 --- a/src/ic.cc +++ b/src/ic.cc @@ -442,7 +442,7 @@ void IC::RegisterWeakMapDependency(Handle stub) { MapHandleList maps; stub->FindAllMaps(&maps); if (maps.length() == 1 && stub->IsWeakObjectInIC(*maps.at(0))) { - maps.at(0)->AddDependentIC(stub); + Map::AddDependentIC(maps.at(0), stub); stub->mark_as_weak_stub(); if (FLAG_enable_ool_constant_pool) { stub->constant_pool()->set_weak_object_state( diff --git a/src/lithium-codegen.cc b/src/lithium-codegen.cc index 3cd16db37d..949f1b35d6 100644 --- a/src/lithium-codegen.cc +++ b/src/lithium-codegen.cc @@ -211,7 +211,7 @@ void LCodeGenBase::RegisterWeakObjectsInOptimizedCode(Handle code) { NoWeakObjectVerificationScope disable_verification_of_embedded_objects; #endif for (int i = 0; i < maps.length(); i++) { - maps.at(i)->AddDependentCode(DependentCode::kWeakCodeGroup, code); + Map::AddDependentCode(maps.at(i), DependentCode::kWeakCodeGroup, code); } for (int i = 0; i < objects.length(); i++) { AddWeakObjectToCodeDependency(isolate()->heap(), objects.at(i), code); diff --git a/src/objects.cc b/src/objects.cc index 256f555895..396f470784 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -11689,35 +11689,41 @@ void Map::ZapPrototypeTransitions() { } -void Map::AddDependentCompilationInfo(DependentCode::DependencyGroup group, +// static +void Map::AddDependentCompilationInfo(Handle map, + DependentCode::DependencyGroup group, CompilationInfo* info) { - Handle dep(dependent_code()); Handle codes = - DependentCode::Insert(dep, group, info->object_wrapper()); - if (*codes != dependent_code()) set_dependent_code(*codes); - info->dependencies(group)->Add(Handle(this), info->zone()); + DependentCode::Insert(handle(map->dependent_code(), info->isolate()), + group, info->object_wrapper()); + if (*codes != map->dependent_code()) map->set_dependent_code(*codes); + info->dependencies(group)->Add(map, info->zone()); } -void Map::AddDependentCode(DependentCode::DependencyGroup group, +// static +void Map::AddDependentCode(Handle map, + DependentCode::DependencyGroup group, Handle code) { Handle codes = DependentCode::Insert( - Handle(dependent_code()), group, code); - if (*codes != dependent_code()) set_dependent_code(*codes); + Handle(map->dependent_code()), group, code); + if (*codes != map->dependent_code()) map->set_dependent_code(*codes); } -void Map::AddDependentIC(Handle stub) { +// static +void Map::AddDependentIC(Handle map, + Handle stub) { ASSERT(stub->next_code_link()->IsUndefined()); - int n = dependent_code()->number_of_entries(DependentCode::kWeakICGroup); + int n = map->dependent_code()->number_of_entries(DependentCode::kWeakICGroup); if (n == 0) { // Slow path: insert the head of the list with possible heap allocation. - AddDependentCode(DependentCode::kWeakICGroup, stub); + Map::AddDependentCode(map, DependentCode::kWeakICGroup, stub); } else { // Fast path: link the stub to the existing head of the list without any // heap allocation. ASSERT(n == 1); - dependent_code()->AddToDependentICList(stub); + map->dependent_code()->AddToDependentICList(stub); } } @@ -16604,14 +16610,16 @@ void PropertyCell::SetValueInferType(Handle cell, } -void PropertyCell::AddDependentCompilationInfo(CompilationInfo* info) { - Handle dep(dependent_code()); +// static +void PropertyCell::AddDependentCompilationInfo(Handle cell, + CompilationInfo* info) { Handle codes = - DependentCode::Insert(dep, DependentCode::kPropertyCellChangedGroup, + DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), + DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); - if (*codes != dependent_code()) set_dependent_code(*codes); + if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( - Handle(this), info->zone()); + cell, info->zone()); } diff --git a/src/objects.h b/src/objects.h index cfb899a60b..ebc4da81f8 100644 --- a/src/objects.h +++ b/src/objects.h @@ -6558,12 +6558,15 @@ class Map: public HeapObject { inline bool CanOmitMapChecks(); - void AddDependentCompilationInfo(DependentCode::DependencyGroup group, - CompilationInfo* info); + static void AddDependentCompilationInfo(Handle map, + DependentCode::DependencyGroup group, + CompilationInfo* info); - void AddDependentCode(DependentCode::DependencyGroup group, - Handle code); - void AddDependentIC(Handle stub); + static void AddDependentCode(Handle map, + DependentCode::DependencyGroup group, + Handle code); + static void AddDependentIC(Handle map, + Handle stub); bool IsMapInArrayPrototypeChain(); @@ -9806,9 +9809,8 @@ class PropertyCell: public Cell { static Handle UpdatedType(Handle cell, Handle value); - void AddDependentCompilationInfo(CompilationInfo* info); - - void AddDependentCode(Handle code); + static void AddDependentCompilationInfo(Handle cell, + CompilationInfo* info); // Casting. static inline PropertyCell* cast(Object* obj);