Index: src/ia32/code-stubs-ia32.cc |
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc |
index 817b71dc60d9c4bb72bd807f755bf8df2ae69331..3e12f6c63b6c31639a68f08b34b0e79f271e0ef0 100644 |
--- a/src/ia32/code-stubs-ia32.cc |
+++ b/src/ia32/code-stubs-ia32.cc |
@@ -2564,22 +2564,38 @@ void InstanceOfStub::Generate(MacroAssembler* masm) { |
// Loop through the prototype chain looking for the {function} prototype. |
// Assume true, and change to false if not found. |
- Label done, loop, proxy_case; |
+ Label done, loop, proxy_case, global_object_case; |
__ mov(eax, isolate()->factory()->true_value()); |
__ bind(&loop); |
+ __ CmpInstanceType(object_map, JS_GLOBAL_OBJECT_TYPE); |
+ __ j(equal, &global_object_case); |
+ __ CmpInstanceType(object_map, JS_GLOBAL_PROXY_TYPE); |
+ __ j(equal, &global_object_case); |
__ CmpInstanceType(object_map, JS_PROXY_TYPE); |
__ j(equal, &proxy_case, Label::kNear); |
__ mov(object, FieldOperand(object_map, Map::kPrototypeOffset)); |
__ cmp(object, function_prototype); |
__ j(equal, &done, Label::kNear); |
- __ cmp(object, isolate()->factory()->null_value()); |
__ mov(object_map, FieldOperand(object, HeapObject::kMapOffset)); |
+ __ cmp(object, isolate()->factory()->null_value()); |
__ j(not_equal, &loop); |
__ mov(eax, isolate()->factory()->false_value()); |
+ |
__ bind(&done); |
__ StoreRoot(eax, scratch, Heap::kInstanceofCacheAnswerRootIndex); |
__ ret(0); |
+ // Global object needs access checks, jump to the runtime. |
+ __ bind(&global_object_case); |
+ __ PopReturnAddressTo(scratch); |
+ __ Push(object); |
+ __ Push(function_prototype); |
+ __ PushReturnAddressFrom(scratch); |
+ // Invalidate the instanceof cache. |
+ __ Move(eax, Immediate(Smi::FromInt(0))); |
+ __ StoreRoot(eax, scratch, Heap::kInstanceofCacheFunctionRootIndex); |
+ __ TailCallRuntime(Runtime::kHasInPrototypeChain, 2, 1); |
+ |
// Proxy-case: Call the %HasInPrototypeChain runtime function. |
__ bind(&proxy_case); |
__ PopReturnAddressTo(scratch); |