Commit cdae8654 authored by jgruber's avatar jgruber Committed by Commit bot

Clear exceptions in Invoke instead of JSEntryStub

A corresponding flag was added as well to help us find out what breaks when we
do not clear pending exceptions on each JS entry.

BUG=5259

Review-Url: https://codereview.chromium.org/2208663002
Cr-Commit-Position: refs/heads/master@{#38292}
parent 7036d96b
...@@ -1105,12 +1105,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) { ...@@ -1105,12 +1105,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// restores all kCalleeSaved registers (including cp and fp) to their // restores all kCalleeSaved registers (including cp and fp) to their
// saved values before returning a failure to C. // saved values before returning a failure to C.
// Clear any pending exceptions.
__ mov(r5, Operand(isolate()->factory()->the_hole_value()));
__ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress,
isolate())));
__ str(r5, MemOperand(ip));
// Invoke the function by calling through JS entry trampoline builtin. // Invoke the function by calling through JS entry trampoline builtin.
// Notice that we cannot store a reference to the trampoline code directly in // Notice that we cannot store a reference to the trampoline code directly in
// this stub, because runtime stubs are not traversed when doing GC. // this stub, because runtime stubs are not traversed when doing GC.
......
...@@ -1214,12 +1214,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) { ...@@ -1214,12 +1214,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// restores all callee-saved registers (including cp and fp) to their // restores all callee-saved registers (including cp and fp) to their
// saved values before returning a failure to C. // saved values before returning a failure to C.
// Clear any pending exceptions.
__ Mov(x10, Operand(isolate()->factory()->the_hole_value()));
__ Mov(x11, Operand(ExternalReference(Isolate::kPendingExceptionAddress,
isolate())));
__ Str(x10, MemOperand(x11));
// Invoke the function by calling through the JS entry trampoline builtin. // Invoke the function by calling through the JS entry trampoline builtin.
// Notice that we cannot store a reference to the trampoline code directly in // Notice that we cannot store a reference to the trampoline code directly in
// this stub, because runtime stubs are not traversed when doing GC. // this stub, because runtime stubs are not traversed when doing GC.
......
...@@ -99,6 +99,8 @@ MUST_USE_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, bool is_construct, ...@@ -99,6 +99,8 @@ MUST_USE_RESULT MaybeHandle<Object> Invoke(Isolate* isolate, bool is_construct,
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
JSEntryFunction stub_entry = FUNCTION_CAST<JSEntryFunction>(code->entry()); JSEntryFunction stub_entry = FUNCTION_CAST<JSEntryFunction>(code->entry());
if (FLAG_clear_exceptions_on_js_entry) isolate->clear_pending_exception();
// Call the function through the right JS entry stub. // Call the function through the right JS entry stub.
Object* orig_func = *new_target; Object* orig_func = *new_target;
Object* func = *target; Object* func = *target;
......
...@@ -767,6 +767,10 @@ DEFINE_BOOL(scavenge_reclaim_unmodified_objects, true, ...@@ -767,6 +767,10 @@ DEFINE_BOOL(scavenge_reclaim_unmodified_objects, true,
DEFINE_INT(heap_growing_percent, 0, DEFINE_INT(heap_growing_percent, 0,
"specifies heap growing factor as (1 + heap_growing_percent/100)") "specifies heap growing factor as (1 + heap_growing_percent/100)")
// execution.cc, messages.cc
DEFINE_BOOL(clear_exceptions_on_js_entry, true,
"clear pending exceptions when entering JavaScript")
// counters.cc // counters.cc
DEFINE_INT(histogram_interval, 600000, DEFINE_INT(histogram_interval, 600000,
"time interval in ms for aggregating memory histograms") "time interval in ms for aggregating memory histograms")
......
...@@ -1847,10 +1847,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) { ...@@ -1847,10 +1847,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ bind(&invoke); __ bind(&invoke);
__ PushStackHandler(); __ PushStackHandler();
// Clear any pending exceptions.
__ mov(edx, Immediate(isolate()->factory()->the_hole_value()));
__ mov(Operand::StaticVariable(pending_exception), edx);
// Fake a receiver (NULL). // Fake a receiver (NULL).
__ push(Immediate(0)); // receiver __ push(Immediate(0)); // receiver
......
...@@ -884,10 +884,13 @@ MaybeHandle<Object> ErrorUtils::MakeGenericError( ...@@ -884,10 +884,13 @@ MaybeHandle<Object> ErrorUtils::MakeGenericError(
Isolate* isolate, Handle<JSFunction> constructor, int template_index, Isolate* isolate, Handle<JSFunction> constructor, int template_index,
Handle<Object> arg0, Handle<Object> arg1, Handle<Object> arg2, Handle<Object> arg0, Handle<Object> arg1, Handle<Object> arg2,
FrameSkipMode mode) { FrameSkipMode mode) {
// This function used to be implemented in JavaScript, and JSEntryStub clears if (FLAG_clear_exceptions_on_js_entry) {
// any pending exceptions - so whenever we'd call this from C++, pending // This function used to be implemented in JavaScript, and JSEntryStub
// exceptions would be cleared. Preserve this behavior. // clears
isolate->clear_pending_exception(); // any pending exceptions - so whenever we'd call this from C++, pending
// exceptions would be cleared. Preserve this behavior.
isolate->clear_pending_exception();
}
DCHECK(mode != SKIP_UNTIL_SEEN); DCHECK(mode != SKIP_UNTIL_SEEN);
......
...@@ -1221,12 +1221,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) { ...@@ -1221,12 +1221,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// restores all kCalleeSaved registers (including cp and fp) to their // restores all kCalleeSaved registers (including cp and fp) to their
// saved values before returning a failure to C. // saved values before returning a failure to C.
// Clear any pending exceptions.
__ LoadRoot(t1, Heap::kTheHoleValueRootIndex);
__ li(t0, Operand(ExternalReference(Isolate::kPendingExceptionAddress,
isolate)));
__ sw(t1, MemOperand(t0));
// Invoke the function by calling through JS entry trampoline builtin. // Invoke the function by calling through JS entry trampoline builtin.
// Notice that we cannot store a reference to the trampoline code directly in // Notice that we cannot store a reference to the trampoline code directly in
// this stub, because runtime stubs are not traversed when doing GC. // this stub, because runtime stubs are not traversed when doing GC.
......
...@@ -1217,12 +1217,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) { ...@@ -1217,12 +1217,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
// restores all kCalleeSaved registers (including cp and fp) to their // restores all kCalleeSaved registers (including cp and fp) to their
// saved values before returning a failure to C. // saved values before returning a failure to C.
// Clear any pending exceptions.
__ LoadRoot(a5, Heap::kTheHoleValueRootIndex);
__ li(a4, Operand(ExternalReference(Isolate::kPendingExceptionAddress,
isolate)));
__ sd(a5, MemOperand(a4));
// Invoke the function by calling through JS entry trampoline builtin. // Invoke the function by calling through JS entry trampoline builtin.
// Notice that we cannot store a reference to the trampoline code directly in // Notice that we cannot store a reference to the trampoline code directly in
// this stub, because runtime stubs are not traversed when doing GC. // this stub, because runtime stubs are not traversed when doing GC.
......
...@@ -1789,10 +1789,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) { ...@@ -1789,10 +1789,6 @@ void JSEntryStub::Generate(MacroAssembler* masm) {
__ bind(&invoke); __ bind(&invoke);
__ PushStackHandler(); __ PushStackHandler();
// Clear any pending exceptions.
__ LoadRoot(rax, Heap::kTheHoleValueRootIndex);
__ Store(pending_exception, rax);
// Fake a receiver (NULL). // Fake a receiver (NULL).
__ Push(Immediate(0)); // receiver __ Push(Immediate(0)); // receiver
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment