Index: src/ia32/stub-cache-ia32.cc |
diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc |
index 734b89b0f3a1b21523d6503b8f788e44283b89ac..e148e2f525c34959d492ba838e5666b392da9f33 100644 |
--- a/src/ia32/stub-cache-ia32.cc |
+++ b/src/ia32/stub-cache-ia32.cc |
@@ -1129,13 +1129,20 @@ void StubCompiler::GenerateLoadInterceptor(Handle<JSObject> object, |
name, miss); |
ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1)); |
+ // Preserve the receiver register explicitly whenever it is different from |
+ // the holder and it is needed should the interceptor return without any |
+ // result. The CALLBACKS case needs the receiver to be passed into C++ code, |
+ // the FIELD case might cause a miss during the prototype check. |
+ bool must_perfrom_prototype_check = *interceptor_holder != lookup->holder(); |
+ bool must_preserve_receiver_reg = !receiver.is(holder_reg) && |
+ (lookup->type() == CALLBACKS || must_perfrom_prototype_check); |
+ |
// Save necessary data before invoking an interceptor. |
// Requires a frame to make GC aware of pushed pointers. |
{ |
FrameScope frame_scope(masm(), StackFrame::INTERNAL); |
- if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { |
- // CALLBACKS case needs a receiver to be passed into C++ callback. |
+ if (must_preserve_receiver_reg) { |
__ push(receiver); |
} |
__ push(holder_reg); |
@@ -1158,10 +1165,17 @@ void StubCompiler::GenerateLoadInterceptor(Handle<JSObject> object, |
frame_scope.GenerateLeaveFrame(); |
__ ret(0); |
+ // Clobber registers when generating debug-code to provoke errors. |
__ bind(&interceptor_failed); |
+ if (FLAG_debug_code) { |
+ __ mov(receiver, Immediate(BitCast<int32_t>(kZapValue))); |
+ __ mov(holder_reg, Immediate(BitCast<int32_t>(kZapValue))); |
+ __ mov(name_reg, Immediate(BitCast<int32_t>(kZapValue))); |
+ } |
+ |
__ pop(name_reg); |
__ pop(holder_reg); |
- if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { |
+ if (must_preserve_receiver_reg) { |
__ pop(receiver); |
} |
@@ -1170,7 +1184,7 @@ void StubCompiler::GenerateLoadInterceptor(Handle<JSObject> object, |
// Check that the maps from interceptor's holder to lookup's holder |
// haven't changed. And load lookup's holder into holder_reg. |
- if (*interceptor_holder != lookup->holder()) { |
+ if (must_perfrom_prototype_check) { |
holder_reg = CheckPrototypes(interceptor_holder, |
holder_reg, |
Handle<JSObject>(lookup->holder()), |