Skip to content

Commit

Permalink
v8: backport faf5f52627c from upstream v8
Browse files Browse the repository at this point in the history
Original commit message:
    [debugger,api] deprecate everything in v8-debug.h
    R=clemensh@chromium.org, jgruber@chromium.org
    BUG=v8:5530

    Review-Url: https://codereview.chromium.org/2727393003
    Cr-Commit-Position: refs/heads/master@{#43714}

PR-URL: #13217
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
psmarshall authored and jasnell committed May 28, 2017
1 parent a56f969 commit 1061e43
Show file tree
Hide file tree
Showing 6 changed files with 323 additions and 353 deletions.
43 changes: 24 additions & 19 deletions deps/v8/include/v8-debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include "v8.h" // NOLINT(build/include)

/**
* Debugger support for the V8 JavaScript engine.
* ATTENTION: The debugger API exposed by this file is deprecated and will be
* removed by the end of 2017. Please use the V8 inspector declared
* in include/v8-inspector.h instead.
*/
namespace v8 {

Expand Down Expand Up @@ -140,21 +142,19 @@ class V8_EXPORT Debug {
*/
typedef void (*MessageHandler)(const Message& message);

/**
* This is now a no-op.
*/
typedef void (*DebugMessageDispatchHandler)();

static bool SetDebugEventListener(Isolate* isolate, EventCallback that,
Local<Value> data = Local<Value>());
V8_DEPRECATED("No longer supported", static bool SetDebugEventListener(
Isolate* isolate, EventCallback that,
Local<Value> data = Local<Value>()));

// Schedule a debugger break to happen when JavaScript code is run
// in the given isolate.
static void DebugBreak(Isolate* isolate);
V8_DEPRECATED("No longer supported",
static void DebugBreak(Isolate* isolate));

// Remove scheduled debugger break in given isolate if it has not
// happened yet.
static void CancelDebugBreak(Isolate* isolate);
V8_DEPRECATED("No longer supported",
static void CancelDebugBreak(Isolate* isolate));

// Check if a debugger break is scheduled in the given isolate.
V8_DEPRECATED("No longer supported",
Expand Down Expand Up @@ -189,10 +189,10 @@ class V8_EXPORT Debug {
* }
* \endcode
*/
// TODO(dcarney): data arg should be a MaybeLocal
static MaybeLocal<Value> Call(Local<Context> context,
v8::Local<v8::Function> fun,
Local<Value> data = Local<Value>());
V8_DEPRECATED("No longer supported",
static MaybeLocal<Value> Call(
Local<Context> context, v8::Local<v8::Function> fun,
Local<Value> data = Local<Value>()));

// This is now a no-op.
V8_DEPRECATED("No longer supported",
Expand Down Expand Up @@ -221,23 +221,28 @@ class V8_EXPORT Debug {
* (default Isolate if not provided). V8 will abort if LiveEdit is
* unexpectedly used. LiveEdit is enabled by default.
*/
static void SetLiveEditEnabled(Isolate* isolate, bool enable);
V8_DEPRECATED("No longer supported",
static void SetLiveEditEnabled(Isolate* isolate, bool enable));

/**
* Returns array of internal properties specific to the value type. Result has
* the following format: [<name>, <value>,...,<name>, <value>]. Result array
* will be allocated in the current context.
*/
static MaybeLocal<Array> GetInternalProperties(Isolate* isolate,
Local<Value> value);
V8_DEPRECATED("No longer supported",
static MaybeLocal<Array> GetInternalProperties(
Isolate* isolate, Local<Value> value));

/**
* Defines if the ES2015 tail call elimination feature is enabled or not.
* The change of this flag triggers deoptimization of all functions that
* contain calls at tail position.
*/
static bool IsTailCallEliminationEnabled(Isolate* isolate);
static void SetTailCallEliminationEnabled(Isolate* isolate, bool enabled);
V8_DEPRECATED("No longer supported",
static bool IsTailCallEliminationEnabled(Isolate* isolate));
V8_DEPRECATED("No longer supported",
static void SetTailCallEliminationEnabled(Isolate* isolate,
bool enabled));
};


Expand Down
69 changes: 32 additions & 37 deletions deps/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8931,17 +8931,12 @@ bool Debug::SetDebugEventListener(Isolate* isolate, EventCallback that,
return true;
}

void Debug::DebugBreak(Isolate* isolate) {
reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->RequestDebugBreak();
}

void Debug::DebugBreak(Isolate* isolate) { debug::DebugBreak(isolate); }

void Debug::CancelDebugBreak(Isolate* isolate) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->stack_guard()->ClearDebugBreak();
debug::CancelDebugBreak(isolate);
}


bool Debug::CheckDebugBreak(Isolate* isolate) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
return internal_isolate->stack_guard()->CheckDebugBreak();
Expand All @@ -8956,29 +8951,15 @@ void Debug::SendCommand(Isolate* isolate, const uint16_t* command, int length,
MaybeLocal<Value> Debug::Call(Local<Context> context,
v8::Local<v8::Function> fun,
v8::Local<v8::Value> data) {
PREPARE_FOR_EXECUTION(context, Debug, Call, Value);
i::Handle<i::Object> data_obj;
if (data.IsEmpty()) {
data_obj = isolate->factory()->undefined_value();
} else {
data_obj = Utils::OpenHandle(*data);
}
Local<Value> result;
has_pending_exception =
!ToLocal<Value>(isolate->debug()->Call(Utils::OpenHandle(*fun), data_obj),
&result);
RETURN_ON_FAILED_EXECUTION(Value);
RETURN_ESCAPED(result);
return debug::Call(context, fun, data);
}


void Debug::ProcessDebugMessages(Isolate* isolate) {}

Local<Context> Debug::GetDebugContext(Isolate* isolate) {
return debug::GetDebugContext(isolate);
}


MaybeLocal<Context> Debug::GetDebuggedContext(Isolate* isolate) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
ENTER_V8(i_isolate);
Expand All @@ -8989,8 +8970,7 @@ MaybeLocal<Context> Debug::GetDebuggedContext(Isolate* isolate) {
}

void Debug::SetLiveEditEnabled(Isolate* isolate, bool enable) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->debug()->set_live_edit_enabled(enable);
debug::SetLiveEditEnabled(isolate, enable);
}

bool Debug::IsTailCallEliminationEnabled(Isolate* isolate) {
Expand All @@ -9005,13 +8985,7 @@ void Debug::SetTailCallEliminationEnabled(Isolate* isolate, bool enabled) {

MaybeLocal<Array> Debug::GetInternalProperties(Isolate* v8_isolate,
Local<Value> value) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ENTER_V8(isolate);
i::Handle<i::Object> val = Utils::OpenHandle(*value);
i::Handle<i::JSArray> result;
if (!i::Runtime::GetInternalProperties(isolate, val).ToHandle(&result))
return MaybeLocal<Array>();
return Utils::ToLocal(result);
return debug::GetInternalProperties(v8_isolate, value);
}

Local<Context> debug::GetDebugContext(Isolate* isolate) {
Expand All @@ -9023,22 +8997,43 @@ Local<Context> debug::GetDebugContext(Isolate* isolate) {
MaybeLocal<Value> debug::Call(Local<Context> context,
v8::Local<v8::Function> fun,
v8::Local<v8::Value> data) {
return Debug::Call(context, fun, data);
PREPARE_FOR_EXECUTION(context, Debug, Call, Value);
i::Handle<i::Object> data_obj;
if (data.IsEmpty()) {
data_obj = isolate->factory()->undefined_value();
} else {
data_obj = Utils::OpenHandle(*data);
}
Local<Value> result;
has_pending_exception = !ToLocal<Value>(
isolate->debug()->Call(Utils::OpenHandle(*fun), data_obj), &result);
RETURN_ON_FAILED_EXECUTION(Value);
RETURN_ESCAPED(result);
}

void debug::SetLiveEditEnabled(Isolate* isolate, bool enable) {
Debug::SetLiveEditEnabled(isolate, enable);
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->debug()->set_live_edit_enabled(enable);
}

void debug::DebugBreak(Isolate* isolate) { Debug::DebugBreak(isolate); }
void debug::DebugBreak(Isolate* isolate) {
reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->RequestDebugBreak();
}

void debug::CancelDebugBreak(Isolate* isolate) {
Debug::CancelDebugBreak(isolate);
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->stack_guard()->ClearDebugBreak();
}

MaybeLocal<Array> debug::GetInternalProperties(Isolate* isolate,
MaybeLocal<Array> debug::GetInternalProperties(Isolate* v8_isolate,
Local<Value> value) {
return Debug::GetInternalProperties(isolate, value);
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ENTER_V8(isolate);
i::Handle<i::Object> val = Utils::OpenHandle(*value);
i::Handle<i::JSArray> result;
if (!i::Runtime::GetInternalProperties(isolate, val).ToHandle(&result))
return MaybeLocal<Array>();
return Utils::ToLocal(result);
}

void debug::ChangeBreakOnException(Isolate* isolate, ExceptionBreakState type) {
Expand Down
11 changes: 4 additions & 7 deletions deps/v8/test/cctest/cctest.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <memory>

#include "include/libplatform/libplatform.h"
#include "include/v8-debug.h"
#include "src/debug/debug-interface.h"
#include "src/utils.h"
#include "src/v8.h"
#include "src/zone/accounting-allocator.h"
Expand Down Expand Up @@ -547,18 +547,15 @@ static inline void CheckDoubleEquals(double expected, double actual) {
CHECK_GE(expected, actual - kEpsilon);
}


static void DummyDebugEventListener(
const v8::Debug::EventDetails& event_details) {}

static v8::debug::DebugDelegate dummy_delegate;

static inline void EnableDebugger(v8::Isolate* isolate) {
v8::Debug::SetDebugEventListener(isolate, &DummyDebugEventListener);
v8::debug::SetDebugDelegate(isolate, &dummy_delegate);
}


static inline void DisableDebugger(v8::Isolate* isolate) {
v8::Debug::SetDebugEventListener(isolate, nullptr);
v8::debug::SetDebugDelegate(isolate, nullptr);
}


Expand Down
21 changes: 14 additions & 7 deletions deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "src/compilation-info.h"
#include "src/compiler/pipeline.h"
#include "src/debug/debug-interface.h"
#include "src/execution.h"
#include "src/handles.h"
#include "src/interpreter/bytecode-array-builder.h"
Expand Down Expand Up @@ -2966,16 +2967,22 @@ TEST(BytecodeGraphBuilderIllegalConstDeclaration) {
}
}

static int debug_break_count = 0;
static void DebugEventCounter(const v8::Debug::EventDetails& event_details) {
if (event_details.GetEvent() == v8::Break) debug_break_count++;
}
class CountBreakDebugDelegate : public v8::debug::DebugDelegate {
public:
void BreakProgramRequested(v8::Local<v8::Context> paused_context,
v8::Local<v8::Object> exec_state,
v8::Local<v8::Value> break_points_hit) override {
debug_break_count++;
}
int debug_break_count = 0;
};

TEST(BytecodeGraphBuilderDebuggerStatement) {
CountBreakDebugDelegate delegate;
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();

v8::Debug::SetDebugEventListener(CcTest::isolate(), DebugEventCounter);
v8::debug::SetDebugDelegate(CcTest::isolate(), &delegate);

ExpectedSnippet<0> snippet = {
"function f() {"
Expand All @@ -2988,9 +2995,9 @@ TEST(BytecodeGraphBuilderDebuggerStatement) {
auto callable = tester.GetCallable<>();
Handle<Object> return_value = callable().ToHandleChecked();

v8::Debug::SetDebugEventListener(CcTest::isolate(), nullptr);
v8::debug::SetDebugDelegate(CcTest::isolate(), nullptr);
CHECK(return_value.is_identical_to(snippet.return_value()));
CHECK_EQ(2, debug_break_count);
CHECK_EQ(2, delegate.debug_break_count);
}

} // namespace compiler
Expand Down
Loading

0 comments on commit 1061e43

Please sign in to comment.