Index: src/ia32/code-stubs-ia32.cc |
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc |
index 215a194d04486e2a125c6bf8a78135c61d1caac2..01d8591c9f3703722dcb9a99a521fa6543daffe4 100644 |
--- a/src/ia32/code-stubs-ia32.cc |
+++ b/src/ia32/code-stubs-ia32.cc |
@@ -2212,6 +2212,13 @@ void CallICStub::Generate(MacroAssembler* masm) { |
__ cmp(edi, ecx); |
__ j(equal, &miss); |
+ // Make sure the function belongs to the same native context (which implies |
+ // the same global object). |
+ __ mov(ecx, FieldOperand(edi, JSFunction::kContextOffset)); |
+ __ mov(ecx, ContextOperand(ecx, Context::GLOBAL_OBJECT_INDEX)); |
+ __ cmp(ecx, GlobalObjectOperand()); |
+ __ j(not_equal, &miss); |
+ |
// Update stats. |
__ add(FieldOperand(ebx, with_types_offset), Immediate(Smi::FromInt(1))); |