MIPS: Fix the context check in LoadGlobalFunctionPrototype

Port r18958 (5cd635d0)

BUG=
R=verwaest@chromium.org

Review URL: https://codereview.chromium.org/132883017

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18968 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
palfia@homejinni.com 2014-01-31 00:49:07 +00:00
parent 71971764fe
commit c7f94b8049

View File

@ -287,15 +287,19 @@ void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype(
Register prototype, Register prototype,
Label* miss) { Label* miss) {
Isolate* isolate = masm->isolate(); Isolate* isolate = masm->isolate();
// Check we're still in the same context.
__ lw(prototype,
MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
ASSERT(!prototype.is(at));
__ li(at, isolate->global_object());
__ Branch(miss, ne, prototype, Operand(at));
// Get the global function with the given index. // Get the global function with the given index.
Handle<JSFunction> function( Handle<JSFunction> function(
JSFunction::cast(isolate->native_context()->get(index))); JSFunction::cast(isolate->native_context()->get(index)));
// Check we're still in the same context.
Register scratch = prototype;
const int offset = Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX);
__ lw(scratch, MemOperand(cp, offset));
__ lw(scratch, FieldMemOperand(scratch, GlobalObject::kNativeContextOffset));
__ lw(scratch, MemOperand(scratch, Context::SlotOffset(index)));
__ li(at, function);
__ Branch(miss, ne, at, Operand(scratch));
// Load its initial map. The global functions all have initial maps. // Load its initial map. The global functions all have initial maps.
__ li(prototype, Handle<Map>(function->initial_map())); __ li(prototype, Handle<Map>(function->initial_map()));
// Load the prototype from the initial map. // Load the prototype from the initial map.