Commit 80c81d96 authored by vitalyr@chromium.org's avatar vitalyr@chromium.org

Fix issue 582: preserve construct stub on first allocation in case we can't optimize it.

BUG=582
TEST=cctest/test-api/NativeFunctionConstructCall

Review URL: http://codereview.chromium.org/546088

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3659 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 453d0a13
......@@ -4782,7 +4782,7 @@ static Code* ComputeConstructStub(Handle<SharedFunctionInfo> shared) {
return Code::cast(code);
}
return Builtins::builtin(Builtins::JSConstructStubGeneric);
return shared->construct_stub();
}
......
......@@ -2839,12 +2839,16 @@ THREADED_TEST(NativeFunctionConstructCall) {
static const char* exts[1] = { "functiontest" };
v8::ExtensionConfiguration config(1, exts);
LocalContext context(&config);
CHECK_EQ(v8::Integer::New(8),
Script::Compile(v8_str("(new A()).data"))->Run());
CHECK_EQ(v8::Integer::New(7),
Script::Compile(v8_str("(new B()).data"))->Run());
CHECK_EQ(v8::Integer::New(6),
Script::Compile(v8_str("(new C()).data"))->Run());
for (int i = 0; i < 10; i++) {
// Run a few times to ensure that allocation of objects doesn't
// change behavior of a constructor function.
CHECK_EQ(v8::Integer::New(8),
Script::Compile(v8_str("(new A()).data"))->Run());
CHECK_EQ(v8::Integer::New(7),
Script::Compile(v8_str("(new B()).data"))->Run());
CHECK_EQ(v8::Integer::New(6),
Script::Compile(v8_str("(new C()).data"))->Run());
}
}
......
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