From c47d9d07e7facd49e828be1c38f0e53bd61f0d1c Mon Sep 17 00:00:00 2001 From: yangguo Date: Fri, 14 Aug 2015 00:36:36 -0700 Subject: [PATCH] Debugger: simplify calling into Javascript. R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/1292533003 Cr-Commit-Position: refs/heads/master@{#30170} --- src/debug/debug.cc | 91 +++++++++++++++--------------------------------------- src/debug/debug.h | 10 ++---- 2 files changed, 27 insertions(+), 74 deletions(-) diff --git a/src/debug/debug.cc b/src/debug/debug.cc index f51acfe..6434f18 100644 --- a/src/debug/debug.cc +++ b/src/debug/debug.cc @@ -632,6 +632,18 @@ Handle Debug::CheckBreakPoints(Handle break_point_objects) { } +MaybeHandle Debug::CallFunction(const char* name, int argc, + Handle args[]) { + PostponeInterruptsScope no_interrupts(isolate_); + AssertDebugContext(); + Handle holder = isolate_->natives_utils_object(); + Handle fun = Handle::cast( + Object::GetProperty(isolate_, holder, name, STRICT).ToHandleChecked()); + Handle undefined = isolate_->factory()->undefined_value(); + return Execution::TryCall(fun, undefined, argc, args); +} + + // Check whether a single break point object is triggered. bool Debug::CheckBreakPoint(Handle break_point_object) { Factory* factory = isolate_->factory(); @@ -640,25 +652,14 @@ bool Debug::CheckBreakPoint(Handle break_point_object) { // Ignore check if break point object is not a JSObject. if (!break_point_object->IsJSObject()) return true; - // Get the function IsBreakPointTriggered (defined in debug.js). - Handle is_break_point_triggered_string = - factory->InternalizeOneByteString( - STATIC_CHAR_VECTOR("IsBreakPointTriggered")); - Handle debug_global(debug_context()->global_object()); - Handle check_break_point = Handle::cast( - Object::GetProperty(debug_utils(), is_break_point_triggered_string) - .ToHandleChecked()); - // Get the break id as an object. Handle break_id = factory->NewNumberFromInt(Debug::break_id()); - // Call HandleBreakPointx. + // Call IsBreakPointTriggered. Handle argv[] = { break_id, break_point_object }; Handle result; - if (!Execution::TryCall(check_break_point, - isolate_->js_builtins_object(), - arraysize(argv), - argv).ToHandle(&result)) { + if (!CallFunction("IsBreakPointTriggered", arraysize(argv), argv) + .ToHandle(&result)) { return false; } @@ -1669,13 +1670,7 @@ bool Debug::IsDebugGlobal(GlobalObject* global) { void Debug::ClearMirrorCache() { PostponeInterruptsScope postpone(isolate_); HandleScope scope(isolate_); - AssertDebugContext(); - - Handle fun = - Object::GetProperty(isolate_, debug_utils(), "ClearMirrorCache") - .ToHandleChecked(); - Handle undefined = isolate_->factory()->undefined_value(); - Execution::TryCall(Handle::cast(fun), undefined, 0, NULL); + CallFunction("ClearMirrorCache", 0, NULL); } @@ -1747,29 +1742,10 @@ void Debug::RecordEvalCaller(Handle