Commit 9f65b1e3 authored by vitalyr@chromium.org's avatar vitalyr@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5348 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4ad1b6d7
......@@ -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)) {
......
......@@ -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) \
......
......@@ -836,6 +836,7 @@ function ObjectIsExtensible(obj) {
}
});
%SetExpectedNumberOfProperties($Object, 4);
// ----------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment