| Index: src/debug/debug.cc
|
| diff --git a/src/debug/debug.cc b/src/debug/debug.cc
|
| index 1bd69cbc882ddf5faf10280abc9d1bd0a59b3602..7ccfe719db301a2fdd780d343c5a158d41d97b1a 100644
|
| --- a/src/debug/debug.cc
|
| +++ b/src/debug/debug.cc
|
| @@ -42,6 +42,7 @@ Debug::Debug(Isolate* isolate)
|
| command_received_(0),
|
| command_queue_(isolate->logger(), kQueueInitialSize),
|
| is_active_(false),
|
| + hook_on_function_call_(false),
|
| is_suppressed_(false),
|
| live_edit_enabled_(true), // TODO(yangguo): set to false by default.
|
| break_disabled_(false),
|
| @@ -49,6 +50,8 @@ Debug::Debug(Isolate* isolate)
|
| in_debug_event_listener_(false),
|
| break_on_exception_(false),
|
| break_on_uncaught_exception_(false),
|
| + needs_side_effect_check_(false),
|
| + side_effect_check_failed_(false),
|
| debug_info_list_(NULL),
|
| feature_tracker_(isolate),
|
| isolate_(isolate) {
|
| @@ -405,6 +408,7 @@ void Debug::ThreadInit() {
|
| // TODO(isolates): frames_are_dropped_?
|
| base::NoBarrier_Store(&thread_local_.current_debug_scope_,
|
| static_cast<base::AtomicWord>(0));
|
| + UpdateHookOnFunctionCall();
|
| }
|
|
|
|
|
| @@ -904,16 +908,19 @@ bool Debug::IsBreakOnException(ExceptionBreakType type) {
|
|
|
| void Debug::PrepareStepIn(Handle<JSFunction> function) {
|
| CHECK(last_step_action() >= StepIn);
|
| - if (!is_active()) return;
|
| + if (ignore_events()) return;
|
| if (in_debug_scope()) return;
|
| + if (break_disabled()) return;
|
| FloodWithOneShot(function);
|
| }
|
|
|
| void Debug::PrepareStepInSuspendedGenerator() {
|
| CHECK(has_suspended_generator());
|
| - if (!is_active()) return;
|
| + if (ignore_events()) return;
|
| if (in_debug_scope()) return;
|
| + if (break_disabled()) return;
|
| thread_local_.last_step_action_ = StepIn;
|
| + UpdateHookOnFunctionCall();
|
| Handle<JSFunction> function(
|
| JSGeneratorObject::cast(thread_local_.suspended_generator_)->function());
|
| FloodWithOneShot(function);
|
| @@ -921,9 +928,10 @@ void Debug::PrepareStepInSuspendedGenerator() {
|
| }
|
|
|
| void Debug::PrepareStepOnThrow() {
|
| - if (!is_active()) return;
|
| if (last_step_action() == StepNone) return;
|
| + if (ignore_events()) return;
|
| if (in_debug_scope()) return;
|
| + if (break_disabled()) return;
|
|
|
| ClearOneShot();
|
|
|
| @@ -974,6 +982,7 @@ void Debug::PrepareStep(StepAction step_action) {
|
| feature_tracker()->Track(DebugFeatureTracker::kStepping);
|
|
|
| thread_local_.last_step_action_ = step_action;
|
| + UpdateHookOnFunctionCall();
|
|
|
| // If the function on the top frame is unresolved perform step out. This will
|
| // be the case when calling unknown function and having the debugger stopped
|
| @@ -1104,6 +1113,7 @@ void Debug::ClearStepping() {
|
| thread_local_.last_statement_position_ = kNoSourcePosition;
|
| thread_local_.last_fp_ = 0;
|
| thread_local_.target_fp_ = 0;
|
| + UpdateHookOnFunctionCall();
|
| }
|
|
|
|
|
| @@ -2078,6 +2088,11 @@ void Debug::UpdateState() {
|
| is_active_ = is_active;
|
| }
|
|
|
| +void Debug::UpdateHookOnFunctionCall() {
|
| + hook_on_function_call_ =
|
| + thread_local_.last_step_action_ >= StepIn || needs_side_effect_check_;
|
| +}
|
| +
|
| // Calls the registered debug message handler. This callback is part of the
|
| // public API.
|
| void Debug::InvokeMessageHandler(MessageImpl message) {
|
| @@ -2275,6 +2290,39 @@ DebugScope::~DebugScope() {
|
| debug_->UpdateState();
|
| }
|
|
|
| +bool Debug::PerformSideEffectCheck(Handle<JSFunction> function) {
|
| + DCHECK(needs_side_effect_check_);
|
| + if (!Compiler::Compile(function, Compiler::KEEP_EXCEPTION)) return false;
|
| + Deoptimizer::DeoptimizeFunction(*function);
|
| + if (!function->shared()->HasNoSideEffect()) {
|
| + if (FLAG_trace_side_effect_free_debug_evaluate) {
|
| + PrintF("[debug-evaluate] Function %s failed side effect check.\n",
|
| + function->shared()->DebugName()->ToCString().get());
|
| + }
|
| + side_effect_check_failed_ = true;
|
| + // Throw an uncatchable termination exception.
|
| + isolate_->TerminateExecution();
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +NoSideEffectScope::~NoSideEffectScope() {
|
| + Isolate* isolate = debug_->isolate_;
|
| + if (debug_->needs_side_effect_check_ && debug_->side_effect_check_failed_) {
|
| + DCHECK(isolate->has_pending_exception());
|
| + DCHECK_EQ(isolate->heap()->termination_exception(),
|
| + isolate->pending_exception());
|
| + // Convert the termination exception into a regular exception.
|
| + isolate->CancelTerminateExecution();
|
| + isolate->Throw(*isolate->factory()->NewEvalError(
|
| + MessageTemplate::kNoSideEffectDebugEvaluate));
|
| + }
|
| + debug_->needs_side_effect_check_ = old_needs_side_effect_check_;
|
| + debug_->UpdateHookOnFunctionCall();
|
| + debug_->side_effect_check_failed_ = false;
|
| +}
|
| +
|
| MessageImpl MessageImpl::NewEvent(DebugEvent event, bool running,
|
| Handle<JSObject> exec_state,
|
| Handle<JSObject> event_data) {
|
|
|