Revision: 5348
Author: [email protected]
Date: Wed Aug 25 10:50:37 2010
Log: Explicitly set expected number of properties for instances of builtin types.

We used to inherit an estimate on the expected number of properties in
%SetCode. It is not accurate and does not help for the types where
adding custom properties is rare (String, Date, etc.).

Review URL: http://codereview.chromium.org/3191026
http://code.google.com/p/v8/source/detail?r=5348

Modified:
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/src/runtime.h
 /branches/bleeding_edge/src/v8natives.js

=======================================
--- /branches/bleeding_edge/src/runtime.cc      Tue Aug 24 03:53:44 2010
+++ /branches/bleeding_edge/src/runtime.cc      Wed Aug 25 10:50:37 2010
@@ -1701,7 +1701,6 @@
     RUNTIME_ASSERT(code->IsJSFunction());
     Handle<JSFunction> fun = Handle<JSFunction>::cast(code);
     Handle<SharedFunctionInfo> shared(fun->shared());
-    SetExpectedNofProperties(target, shared->expected_nof_properties());

     if (!EnsureCompiled(shared, KEEP_EXCEPTION)) {
       return Failure::Exception();
@@ -1744,6 +1743,17 @@
   target->set_context(*context);
   return *target;
 }
+
+
+static Object* Runtime_SetExpectedNumberOfProperties(Arguments args) {
+  HandleScope scope;
+  ASSERT(args.length() == 2);
+  CONVERT_ARG_CHECKED(JSFunction, function, 0);
+  CONVERT_SMI_CHECKED(num, args[1]);
+  RUNTIME_ASSERT(num >= 0);
+  SetExpectedNofProperties(function, num);
+  return Heap::undefined_value();
+}


 static Object* CharFromCode(Object* char_code) {
=======================================
--- /branches/bleeding_edge/src/runtime.h       Tue Aug 24 03:53:44 2010
+++ /branches/bleeding_edge/src/runtime.h       Wed Aug 25 10:50:37 2010
@@ -201,6 +201,7 @@
   \
   F(ClassOf, 1, 1) \
   F(SetCode, 2, 1) \
+  F(SetExpectedNumberOfProperties, 2, 1) \
   \
   F(CreateApiFunction, 1, 1) \
   F(IsTemplate, 1, 1) \
=======================================
--- /branches/bleeding_edge/src/v8natives.js    Thu Aug  5 03:56:15 2010
+++ /branches/bleeding_edge/src/v8natives.js    Wed Aug 25 10:50:37 2010
@@ -836,6 +836,7 @@
   }
 });

+%SetExpectedNumberOfProperties($Object, 4);

// ----------------------------------------------------------------------------

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to