Revision: 6692
Author: [email protected]
Date: Tue Feb  8 12:13:08 2011
Log: Do sanity check of exception state when returning from native to JS.

If --debug-code is on, check that returned value and Top::has_pending_exception
agree on exception state.

Review URL: http://codereview.chromium.org/6450004
http://code.google.com/p/v8/source/detail?r=6692

Modified:
 /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc

=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Thu Feb 3 04:50:50 2011 +++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Tue Feb 8 12:13:08 2011
@@ -4722,6 +4722,23 @@
   // Lower 2 bits of ecx are 0 iff eax has failure tag.
   __ test(ecx, Immediate(kFailureTagMask));
   __ j(zero, &failure_returned, not_taken);
+
+ ExternalReference pending_exception_address(Top::k_pending_exception_address);
+
+  // Check that there is no pending exception, otherwise we
+  // should have returned some failure value.
+  if (FLAG_debug_code) {
+    __ push(edx);
+    __ mov(edx, Operand::StaticVariable(
+           ExternalReference::the_hole_value_location()));
+    NearLabel okay;
+    __ cmp(edx, Operand::StaticVariable(pending_exception_address));
+    // Cannot use check here as it attempts to generate call into runtime.
+    __ j(equal, &okay);
+    __ int3();
+    __ bind(&okay);
+    __ pop(edx);
+  }

   // Exit the JavaScript to C++ exit frame.
   __ LeaveExitFrame(save_doubles_);
@@ -4741,7 +4758,6 @@
   __ j(equal, throw_out_of_memory_exception);

   // Retrieve the pending exception and clear the variable.
- ExternalReference pending_exception_address(Top::k_pending_exception_address);
   __ mov(eax, Operand::StaticVariable(pending_exception_address));
   __ mov(edx,
Operand::StaticVariable(ExternalReference::the_hole_value_location()));

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to