Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 6450004: Do sanity check of exception state when returning from native to JS. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4705 matching lines...) Expand 10 before | Expand all | Expand 10 after
4716 } 4716 }
4717 4717
4718 // Check for failure result. 4718 // Check for failure result.
4719 Label failure_returned; 4719 Label failure_returned;
4720 STATIC_ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0); 4720 STATIC_ASSERT(((kFailureTag + 1) & kFailureTagMask) == 0);
4721 __ lea(ecx, Operand(eax, 1)); 4721 __ lea(ecx, Operand(eax, 1));
4722 // Lower 2 bits of ecx are 0 iff eax has failure tag. 4722 // Lower 2 bits of ecx are 0 iff eax has failure tag.
4723 __ test(ecx, Immediate(kFailureTagMask)); 4723 __ test(ecx, Immediate(kFailureTagMask));
4724 __ j(zero, &failure_returned, not_taken); 4724 __ j(zero, &failure_returned, not_taken);
4725 4725
4726 ExternalReference pending_exception_address(Top::k_pending_exception_address);
4727
4728 // Check that there is no pending exception, otherwise we
4729 // should have returned some failure value.
4730 if (FLAG_debug_code) {
4731 __ push(edx);
4732 __ mov(edx, Operand::StaticVariable(
4733 ExternalReference::the_hole_value_location()));
4734 NearLabel okay;
4735 __ cmp(edx, Operand::StaticVariable(pending_exception_address));
4736 // Cannot use check here as it attempts to generate call into runtime.
4737 __ j(equal, &okay);
4738 __ int3();
4739 __ bind(&okay);
4740 __ pop(edx);
4741 }
4742
4726 // Exit the JavaScript to C++ exit frame. 4743 // Exit the JavaScript to C++ exit frame.
4727 __ LeaveExitFrame(save_doubles_); 4744 __ LeaveExitFrame(save_doubles_);
4728 __ ret(0); 4745 __ ret(0);
4729 4746
4730 // Handling of failure. 4747 // Handling of failure.
4731 __ bind(&failure_returned); 4748 __ bind(&failure_returned);
4732 4749
4733 Label retry; 4750 Label retry;
4734 // If the returned exception is RETRY_AFTER_GC continue at retry label 4751 // If the returned exception is RETRY_AFTER_GC continue at retry label
4735 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); 4752 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0);
4736 __ test(eax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); 4753 __ test(eax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize));
4737 __ j(zero, &retry, taken); 4754 __ j(zero, &retry, taken);
4738 4755
4739 // Special handling of out of memory exceptions. 4756 // Special handling of out of memory exceptions.
4740 __ cmp(eax, reinterpret_cast<int32_t>(Failure::OutOfMemoryException())); 4757 __ cmp(eax, reinterpret_cast<int32_t>(Failure::OutOfMemoryException()));
4741 __ j(equal, throw_out_of_memory_exception); 4758 __ j(equal, throw_out_of_memory_exception);
4742 4759
4743 // Retrieve the pending exception and clear the variable. 4760 // Retrieve the pending exception and clear the variable.
4744 ExternalReference pending_exception_address(Top::k_pending_exception_address);
4745 __ mov(eax, Operand::StaticVariable(pending_exception_address)); 4761 __ mov(eax, Operand::StaticVariable(pending_exception_address));
4746 __ mov(edx, 4762 __ mov(edx,
4747 Operand::StaticVariable(ExternalReference::the_hole_value_location())); 4763 Operand::StaticVariable(ExternalReference::the_hole_value_location()));
4748 __ mov(Operand::StaticVariable(pending_exception_address), edx); 4764 __ mov(Operand::StaticVariable(pending_exception_address), edx);
4749 4765
4750 // Special handling of termination exceptions which are uncatchable 4766 // Special handling of termination exceptions which are uncatchable
4751 // by javascript code. 4767 // by javascript code.
4752 __ cmp(eax, Factory::termination_exception()); 4768 __ cmp(eax, Factory::termination_exception());
4753 __ j(equal, throw_termination_exception); 4769 __ j(equal, throw_termination_exception);
4754 4770
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after
6557 __ SmiTag(result); 6573 __ SmiTag(result);
6558 __ ret(0); 6574 __ ret(0);
6559 } 6575 }
6560 6576
6561 6577
6562 #undef __ 6578 #undef __
6563 6579
6564 } } // namespace v8::internal 6580 } } // namespace v8::internal
6565 6581
6566 #endif // V8_TARGET_ARCH_IA32 6582 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698