Reviewers: Igor Sheludko,

Message:
PTAL

Description:
Handlify AddDependentCode(), AddDependentCompilationInfo() and AddDependentIC().

Please review this at https://codereview.chromium.org/236193014/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+53, -38 lines):
  M src/hydrogen.h
  M src/hydrogen.cc
  M src/hydrogen-instructions.h
  M src/hydrogen-instructions.cc
  M src/ic.cc
  M src/lithium-codegen.cc
  M src/objects.h
  M src/objects.cc


Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index a9bfd479308e62e4334ac8b7667b762600b7579a..5c7bd2b8663ec530c220cb3bb8d5ee049457f4a2 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;
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index 4a2bf1007bd6f06c2fa73811799610432e8070fb..075fb1bb93e4b66b6f2228e284b675389e961923 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> map = Handle<Map>::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;
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index c64c0e0462b081c5c59bd4b65c9c0afb76ee6fae..078c38b2dc80cfdb3340a3a44b55878a42844fd5 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -4925,7 +4925,7 @@ void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) {
         Handle<GlobalObject> global(current_info()->global_object());
         Handle<PropertyCell> cell(global->GetPropertyCell(&lookup));
         if (cell->type()->IsConstant()) {
-          cell->AddDependentCompilationInfo(top_info());
+          PropertyCell::AddDependentCompilationInfo(cell, top_info());
           Handle<Object> constant_object = cell->type()->AsConstant();
           if (constant_object->IsConsString()) {
             constant_object =
@@ -5552,11 +5552,12 @@ void HOptimizedGraphBuilder::PropertyAccessInfo::LoadFieldMap(Handle<Map> map) {
     Handle<Map> 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());
     }
   }
@@ -6828,7 +6829,8 @@ HInstruction* HGraphBuilder::BuildConstantMapCheck(Handle<JSObject> constant,
   HConstant* constant_value = New<HConstant>(constant);

   if (constant->map()->CanOmitMapChecks()) {
-    constant->map()->AddDependentCompilationInfo(
+    Map::AddDependentCompilationInfo(
+        handle(constant->map(), info->isolate()),
         DependentCode::kPrototypeCheckGroup, info);
     return constant_value;
   }
Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index 4250dc7fd6d6112473029a94a7583884a5b7edd0..d01a6ae4fe8254f5a10833584abcf51c85ae58bc 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;
   }
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index e10b0fdc6139f5a5117c290228013e5f62f37b39..ecf0e9a8d68eca7fb8e611118f2aefc7f58eeeed 100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -442,7 +442,7 @@ void IC::RegisterWeakMapDependency(Handle<Code> 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(
Index: src/lithium-codegen.cc
diff --git a/src/lithium-codegen.cc b/src/lithium-codegen.cc
index 3cd16db37da9ad5329d897b1d0d967693c16db5d..949f1b35d628b2abcf248ccd36ee94c8da35bf77 100644
--- a/src/lithium-codegen.cc
+++ b/src/lithium-codegen.cc
@@ -211,7 +211,7 @@ void LCodeGenBase::RegisterWeakObjectsInOptimizedCode(Handle<Code> 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);
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index e765aaee23074a41347a715936b9d5c5bd90b28a..ee49408dd8a7c77d99bfc40b09584786ed12b8f9 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> map,
+                                      DependentCode::DependencyGroup group,
                                       CompilationInfo* info) {
-  Handle<DependentCode> dep(dependent_code());
   Handle<DependentCode> codes =
-      DependentCode::Insert(dep, group, info->object_wrapper());
-  if (*codes != dependent_code()) set_dependent_code(*codes);
-  info->dependencies(group)->Add(Handle<HeapObject>(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> map,
+                           DependentCode::DependencyGroup group,
                            Handle<Code> code) {
   Handle<DependentCode> codes = DependentCode::Insert(
-      Handle<DependentCode>(dependent_code()), group, code);
-  if (*codes != dependent_code()) set_dependent_code(*codes);
+      Handle<DependentCode>(map->dependent_code()), group, code);
+  if (*codes != map->dependent_code()) map->set_dependent_code(*codes);
 }


-void Map::AddDependentIC(Handle<Code> stub) {
+// static
+void Map::AddDependentIC(Handle<Map> map,
+                         Handle<Code> 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);
   }
 }

@@ -12973,7 +12979,7 @@ void AllocationSite::AddDependentCompilationInfo(Handle<AllocationSite> site,
   Handle<DependentCode> codes =
       DependentCode::Insert(dep, group, info->object_wrapper());
   if (*codes != site->dependent_code()) site->set_dependent_code(*codes);
-  info->dependencies(group)->Add(Handle<HeapObject>(*site), info->zone());
+  info->dependencies(group)->Add(site, info->zone());
 }


@@ -16676,14 +16682,16 @@ void PropertyCell::SetValueInferType(Handle<PropertyCell> cell,
 }


-void PropertyCell::AddDependentCompilationInfo(CompilationInfo* info) {
-  Handle<DependentCode> dep(dependent_code());
+// static
+void PropertyCell::AddDependentCompilationInfo(Handle<PropertyCell> cell,
+                                               CompilationInfo* info) {
   Handle<DependentCode> 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<HeapObject>(this), info->zone());
+      cell, info->zone());
 }


Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index fdc60676cf4d92fb05c69c3f248d1eecb418ae60..3b76144fcc39d9b1f571a8901aa4cea51c4b244e 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -6576,12 +6576,15 @@ class Map: public HeapObject {

   inline bool CanOmitMapChecks();

-  void AddDependentCompilationInfo(DependentCode::DependencyGroup group,
-                                   CompilationInfo* info);
+  static void AddDependentCompilationInfo(Handle<Map> map,
+ DependentCode::DependencyGroup group,
+                                          CompilationInfo* info);

-  void AddDependentCode(DependentCode::DependencyGroup group,
-                        Handle<Code> code);
-  void AddDependentIC(Handle<Code> stub);
+  static void AddDependentCode(Handle<Map> map,
+                               DependentCode::DependencyGroup group,
+                               Handle<Code> code);
+  static void AddDependentIC(Handle<Map> map,
+                             Handle<Code> stub);

   bool IsMapInArrayPrototypeChain();

@@ -9824,9 +9827,8 @@ class PropertyCell: public Cell {
   static Handle<HeapType> UpdatedType(Handle<PropertyCell> cell,
                                       Handle<Object> value);

-  void AddDependentCompilationInfo(CompilationInfo* info);
-
-  void AddDependentCode(Handle<Code> code);
+  static void AddDependentCompilationInfo(Handle<PropertyCell> cell,
+                                          CompilationInfo* info);

   // Casting.
   static inline PropertyCell* cast(Object* obj);


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to