Fix optimized code caching in FastNewClosureStub.
This fixes a corner-case on ARM and MIPS where optimized code was not shared immediately across closures when a function was used in several global contexts at once. R=ulan@chromium.org TEST=cctest/test-compiler/OptimizedCodeSharing Review URL: https://chromiumcodereview.appspot.com/10544205 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11850 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
f6b5dc6628
commit
b1fe586e6b
@ -158,7 +158,6 @@ void FastNewClosureStub::Generate(MacroAssembler* masm) {
|
||||
__ ldr(r5, FieldMemOperand(r1, FixedArray::kHeaderSize));
|
||||
__ cmp(r2, r5);
|
||||
__ b(eq, &install_optimized);
|
||||
__ b(&install_unoptimized);
|
||||
|
||||
// Iterate through the rest of map backwards. r4 holds an index as a Smi.
|
||||
Label loop;
|
||||
|
@ -159,7 +159,6 @@ void FastNewClosureStub::Generate(MacroAssembler* masm) {
|
||||
__ lw(t0, FieldMemOperand(a1, FixedArray::kHeaderSize + kPointerSize));
|
||||
__ lw(t1, FieldMemOperand(a1, FixedArray::kHeaderSize));
|
||||
__ Branch(&install_optimized, eq, a2, Operand(t1));
|
||||
__ Branch(&install_unoptimized);
|
||||
|
||||
// Iterate through the rest of map backwards. t0 holds an index as a Smi.
|
||||
Label loop;
|
||||
|
@ -352,6 +352,35 @@ TEST(GetScriptLineNumber) {
|
||||
}
|
||||
|
||||
|
||||
// Test that optimized code for different closures is actually shared
|
||||
// immediately by the FastNewClosureStub when run in the same context.
|
||||
TEST(OptimizedCodeSharing) {
|
||||
FLAG_allow_natives_syntax = true;
|
||||
InitializeVM();
|
||||
v8::HandleScope scope;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
LocalContext env;
|
||||
env->Global()->Set(v8::String::New("x"), v8::Integer::New(i));
|
||||
CompileRun("function MakeClosure() {"
|
||||
" return function() { return x; };"
|
||||
"}"
|
||||
"var closure0 = MakeClosure();"
|
||||
"%DebugPrint(closure0());"
|
||||
"%OptimizeFunctionOnNextCall(closure0);"
|
||||
"%DebugPrint(closure0());"
|
||||
"var closure1 = MakeClosure();"
|
||||
"var closure2 = MakeClosure();");
|
||||
Handle<JSFunction> fun1 = v8::Utils::OpenHandle(
|
||||
*v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("closure1"))));
|
||||
Handle<JSFunction> fun2 = v8::Utils::OpenHandle(
|
||||
*v8::Local<v8::Function>::Cast(env->Global()->Get(v8_str("closure2"))));
|
||||
CHECK(fun1->IsOptimized() || !FLAG_crankshaft);
|
||||
CHECK(fun2->IsOptimized() || !FLAG_crankshaft);
|
||||
CHECK_EQ(fun1->code(), fun2->code());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
static Handle<JSFunction> GetJSFunction(v8::Handle<v8::Object> obj,
|
||||
const char* property_name) {
|
||||
|
Loading…
Reference in New Issue
Block a user