Reviewers: rossberg,

Description:
Refactor part of handles.cc

[email protected]
BUG=

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

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

Affected files (+27, -39 lines):
  src/compiler.cc
  src/handles.h
  src/handles.cc
  src/runtime.cc


Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 01e261a95b6470f4857bc8ef841d59727df87741..2c906a25c87ab35289101329cb62fb9a446e0b47 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -555,6 +555,17 @@ static bool DebuggerWantsEagerCompilation(CompilationInfo* info,
 }


+// Sets the expected number of properties based on estimate from compiler.
+void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared,
+                                          int estimate) {
+  // See the comment in SetExpectedNofProperties.
+  if (shared->live_objects_may_exist()) return;
+
+  shared->set_expected_nof_properties(
+      ExpectedNofPropertiesFromEstimate(estimate));
+}
+
+
 static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) {
   Isolate* isolate = info->isolate();
   PostponeInterruptsScope postpone(isolate);
Index: src/handles.cc
diff --git a/src/handles.cc b/src/handles.cc
index 20fe116dde996afe8fd1a8b8ff4ce89c82c9cd76..742c368004ad29d25e553fac155006bbea7b3b90 100644
--- a/src/handles.cc
+++ b/src/handles.cc
@@ -150,25 +150,6 @@ Handle<JSGlobalProxy> ReinitializeJSGlobalProxy(
 }


-void SetExpectedNofProperties(Handle<JSFunction> func, int nof) {
-  // If objects constructed from this function exist then changing
-  // 'estimated_nof_properties' is dangerous since the previous value might
- // have been compiled into the fast construct stub. More over, the inobject
-  // slack tracking logic might have adjusted the previous value, so even
-  // passing the same value is risky.
-  if (func->shared()->live_objects_may_exist()) return;
-
-  func->shared()->set_expected_nof_properties(nof);
-  if (func->has_initial_map()) {
-    Handle<Map> new_initial_map =
-        func->GetIsolate()->factory()->CopyMap(
-            Handle<Map>(func->initial_map()));
-    new_initial_map->set_unused_property_fields(nof);
-    func->set_initial_map(*new_initial_map);
-  }
-}
-
-
 static int ExpectedNofPropertiesFromEstimate(int estimate) {
   // If no properties are added in the constructor, they are more likely
   // to be added later.
@@ -188,16 +169,6 @@ static int ExpectedNofPropertiesFromEstimate(int estimate) {
 }


-void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared,
-                                          int estimate) {
-  // See the comment in SetExpectedNofProperties.
-  if (shared->live_objects_may_exist()) return;
-
-  shared->set_expected_nof_properties(
-      ExpectedNofPropertiesFromEstimate(estimate));
-}
-
-
 void FlattenString(Handle<String> string) {
   CALL_HEAP_FUNCTION_VOID(string->GetIsolate(), string->TryFlatten());
 }
Index: src/handles.h
diff --git a/src/handles.h b/src/handles.h
index c1400ed841c4f8d842ba4731ca0c27b6d7533658..cfdecac190de1e0f262ff323a0ce675d043afa4a 100644
--- a/src/handles.h
+++ b/src/handles.h
@@ -299,14 +299,6 @@ Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object,
 Handle<FixedArray> UnionOfKeys(Handle<FixedArray> first,
                                Handle<FixedArray> second);

-// Sets the expected number of properties for the function's instances.
-void SetExpectedNofProperties(Handle<JSFunction> func, int nof);
-
-// Sets the expected number of properties based on estimate from compiler.
-void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared,
-                                          int estimate);
-
-
 Handle<JSGlobalProxy> ReinitializeJSGlobalProxy(
     Handle<JSFunction> constructor,
     Handle<JSGlobalProxy> global);
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index fe4d089d7918c91c10882030db25675ab77c5e25..360401603b875e01cc2585e8af43540368bc6973 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -2973,10 +2973,24 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) {
 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) {
   HandleScope scope(isolate);
   ASSERT(args.length() == 2);
-  CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
+  CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
   CONVERT_SMI_ARG_CHECKED(num, 1);
   RUNTIME_ASSERT(num >= 0);
-  SetExpectedNofProperties(function, num);
+  // If objects constructed from this function exist then changing
+  // 'estimated_nof_properties' is dangerous since the previous value might
+ // have been compiled into the fast construct stub. More over, the inobject
+  // slack tracking logic might have adjusted the previous value, so even
+  // passing the same value is risky.
+  if (func->shared()->live_objects_may_exist()) return;
+
+  func->shared()->set_expected_nof_properties(nof);
+  if (func->has_initial_map()) {
+    Handle<Map> new_initial_map =
+        func->GetIsolate()->factory()->CopyMap(
+            Handle<Map>(func->initial_map()));
+    new_initial_map->set_unused_property_fields(num);
+    func->set_initial_map(*new_initial_map);
+  }
   return isolate->heap()->undefined_value();
 }



--
--
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/groups/opt_out.

Reply via email to