Reviewers: Mads Ager,
Description:
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.).
Please review this at http://codereview.chromium.org/3191026/show
Affected files:
M src/runtime.h
M src/runtime.cc
M src/v8natives.js
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
1122d331a4fd0519799fc6bf2b97ace49889109c..f908036469a07699028bc95517926ba648ef6304
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -1701,7 +1701,6 @@ static Object* Runtime_SetCode(Arguments args) {
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();
@@ -1746,6 +1745,17 @@ static Object* Runtime_SetCode(Arguments args) {
}
+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) {
uint32_t code;
if (char_code->ToArrayIndex(&code)) {
Index: src/runtime.h
diff --git a/src/runtime.h b/src/runtime.h
index
1d2c4f2adbff1f80bf56f370173e013a1c71eec5..71d95cf30a6bd2316e9daf72c065e062f923eb92
100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -201,6 +201,7 @@ namespace internal {
\
F(ClassOf, 1, 1) \
F(SetCode, 2, 1) \
+ F(SetExpectedNumberOfProperties, 2, 1) \
\
F(CreateApiFunction, 1, 1) \
F(IsTemplate, 1, 1) \
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index
85540e85df94ebe6b48f8dff1e8ff4804421747f..93e4f8bf3208150a8342cd34d1b4441e066ab1ad
100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -836,6 +836,7 @@ function ObjectIsExtensible(obj) {
}
});
+%SetExpectedNumberOfProperties($Object, 4);
//
----------------------------------------------------------------------------
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev