Revision: 12472
Author: [email protected]
Date: Mon Sep 10 02:24:17 2012
Log: Enable/disable LiveEdit using the (C++) debug API.
BUG=
Review URL: https://chromiumcodereview.appspot.com/10875072
http://code.google.com/p/v8/source/detail?r=12472
Modified:
/branches/bleeding_edge/include/v8-debug.h
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/debug.cc
/branches/bleeding_edge/src/debug.h
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/cctest/cctest.status
/branches/bleeding_edge/test/cctest/test-debug.cc
=======================================
--- /branches/bleeding_edge/include/v8-debug.h Wed Sep 21 04:34:05 2011
+++ /branches/bleeding_edge/include/v8-debug.h Mon Sep 10 02:24:17 2012
@@ -321,7 +321,7 @@
* \endcode
*/
static Local<Value> Call(v8::Handle<v8::Function> fun,
- Handle<Value> data = Handle<Value>());
+ Handle<Value> data = Handle<Value>());
/**
* Returns a mirror object for the given object.
@@ -388,6 +388,14 @@
* to change.
*/
static Local<Context> GetDebugContext();
+
+
+ /**
+ * Enable/disable LiveEdit functionality for the given Isolate
+ * (default Isolate if not provided). V8 will abort if LiveEdit is
+ * unexpectedly used. LiveEdit is enabled by default.
+ */
+ static void SetLiveEditEnabled(bool enable, Isolate* isolate = NULL);
};
=======================================
--- /branches/bleeding_edge/src/api.cc Wed Sep 5 09:06:53 2012
+++ /branches/bleeding_edge/src/api.cc Mon Sep 10 02:24:17 2012
@@ -5840,6 +5840,7 @@
void Debug::ProcessDebugMessages() {
i::Execution::ProcessDebugMessages(true);
}
+
Local<Context> Debug::GetDebugContext() {
i::Isolate* isolate = i::Isolate::Current();
@@ -5847,6 +5848,20 @@
ENTER_V8(isolate);
return
Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext());
}
+
+
+void Debug::SetLiveEditEnabled(bool enable, Isolate* isolate) {
+ // If no isolate is supplied, use the default isolate.
+ i::Debugger* debugger;
+ if (isolate != NULL) {
+ i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ debugger = internal_isolate->debugger();
+ } else {
+ debugger = i::Isolate::GetDefaultIsolateDebugger();
+ }
+ debugger->set_live_edit_enabled(enable);
+}
+
#endif // ENABLE_DEBUGGER_SUPPORT
=======================================
--- /branches/bleeding_edge/src/debug.cc Mon Sep 3 07:23:00 2012
+++ /branches/bleeding_edge/src/debug.cc Mon Sep 10 02:24:17 2012
@@ -2514,6 +2514,7 @@
event_listener_data_(Handle<Object>()),
compiling_natives_(false),
is_loading_debugger_(false),
+ live_edit_enabled_(true),
never_unload_debugger_(false),
force_debugger_active_(false),
message_handler_(NULL),
=======================================
--- /branches/bleeding_edge/src/debug.h Mon Sep 3 07:23:00 2012
+++ /branches/bleeding_edge/src/debug.h Mon Sep 10 02:24:17 2012
@@ -875,6 +875,8 @@
bool compiling_natives() const { return compiling_natives_; }
void set_loading_debugger(bool v) { is_loading_debugger_ = v; }
bool is_loading_debugger() const { return is_loading_debugger_; }
+ void set_live_edit_enabled(bool v) { live_edit_enabled_ = v; }
+ bool live_edit_enabled() const { return live_edit_enabled_; }
void set_force_debugger_active(bool force_debugger_active) {
force_debugger_active_ = force_debugger_active;
}
@@ -903,6 +905,7 @@
Handle<Object> event_listener_data_;
bool compiling_natives_; // Are we compiling natives?
bool is_loading_debugger_; // Are we loading the debugger?
+ bool live_edit_enabled_; // Enable LiveEdit.
bool never_unload_debugger_; // Can we unload the debugger?
bool force_debugger_active_; // Activate debugger without event
listeners.
v8::Debug::MessageHandler2 message_handler_;
=======================================
--- /branches/bleeding_edge/src/runtime.cc Mon Sep 10 01:35:26 2012
+++ /branches/bleeding_edge/src/runtime.cc Mon Sep 10 02:24:17 2012
@@ -12252,6 +12252,7 @@
// in OpaqueReferences.
RUNTIME_FUNCTION(MaybeObject*,
Runtime_LiveEditFindSharedFunctionInfosForScript) {
+ CHECK(isolate->debugger()->live_edit_enabled());
ASSERT(args.length() == 1);
HandleScope scope(isolate);
CONVERT_ARG_CHECKED(JSValue, script_value, 0);
@@ -12298,6 +12299,7 @@
// each function with all its descendant is always stored in a continues
range
// with the function itself going first. The root function is a script
function.
RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditGatherCompileInfo) {
+ CHECK(isolate->debugger()->live_edit_enabled());
ASSERT(args.length() == 2);
HandleScope scope(isolate);
CONVERT_ARG_CHECKED(JSValue, script, 0);
@@ -12319,6 +12321,7 @@
// If old_script_name is provided (i.e. is a String), also creates a copy
of
// the script with its original source and sends notification to debugger.
RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceScript) {
+ CHECK(isolate->debugger()->live_edit_enabled());
ASSERT(args.length() == 3);
HandleScope scope(isolate);
CONVERT_ARG_CHECKED(JSValue, original_script_value, 0);
@@ -12342,6 +12345,7 @@
RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSourceUpdated) {
+ CHECK(isolate->debugger()->live_edit_enabled());
ASSERT(args.length() == 1);
HandleScope scope(isolate);
CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 0);
@@ -12351,6 +12355,7 @@
// Replaces code of SharedFunctionInfo with a new one.
RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceFunctionCode) {
+ CHECK(isolate->debugger()->live_edit_enabled());
ASSERT(args.length() == 2);
HandleScope scope(isolate);
CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0);
@@ -12361,6 +12366,7 @@
// Connects SharedFunctionInfo to another script.
RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSetScript) {
+ CHECK(isolate->debugger()->live_edit_enabled());
ASSERT(args.length() == 2);
HandleScope scope(isolate);
Handle<Object> function_object(args[0], isolate);
@@ -12387,6 +12393,7 @@
// In a code of a parent function replaces original function as embedded
object
// with a substitution one.
RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceRefToNestedFunction)
{
+ CHECK(isolate->debugger()->live_edit_enabled());
ASSERT(args.length() == 3);
HandleScope scope(isolate);
@@ -12407,6 +12414,7 @@
// (change_begin, change_end, change_end_new_position).
// Each group describes a change in text; groups are sorted by
change_begin.
RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditPatchFunctionPositions) {
+ CHECK(isolate->debugger()->live_edit_enabled());
ASSERT(args.length() == 2);
HandleScope scope(isolate);
CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0);
@@ -12421,6 +12429,7 @@
// Returns array of the same length with corresponding results of
// LiveEdit::FunctionPatchabilityStatus type.
RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) {
+ CHECK(isolate->debugger()->live_edit_enabled());
ASSERT(args.length() == 2);
HandleScope scope(isolate);
CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0);
@@ -12434,6 +12443,7 @@
// of JSArray of triplets (pos1, pos1_end, pos2_end) describing list
// of diff chunks.
RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) {
+ CHECK(isolate->debugger()->live_edit_enabled());
ASSERT(args.length() == 2);
HandleScope scope(isolate);
CONVERT_ARG_HANDLE_CHECKED(String, s1, 0);
@@ -12446,6 +12456,7 @@
// Restarts a call frame and completely drops all frames above.
// Returns true if successful. Otherwise returns undefined or an error
message.
RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditRestartFrame) {
+ CHECK(isolate->debugger()->live_edit_enabled());
HandleScope scope(isolate);
ASSERT(args.length() == 2);
@@ -12485,6 +12496,7 @@
// A testing entry. Returns statement position which is the closest to
// source_position.
RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) {
+ CHECK(isolate->debugger()->live_edit_enabled());
ASSERT(args.length() == 2);
HandleScope scope(isolate);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
=======================================
--- /branches/bleeding_edge/test/cctest/cctest.status Fri Jul 20 03:00:31
2012
+++ /branches/bleeding_edge/test/cctest/cctest.status Mon Sep 10 02:24:17
2012
@@ -44,6 +44,9 @@
test-serialize/TestThatAlwaysFails: FAIL
test-serialize/DependentTestThatAlwaysFails: FAIL
+# This test always fails. It tests that LiveEdit causes abort when turned
off.
+test-debug/LiveEditDisabled: FAIL
+
# TODO(gc): Temporarily disabled in the GC branch.
test-log/EquivalenceOfLoggingAndTraversal: PASS || FAIL
=======================================
--- /branches/bleeding_edge/test/cctest/test-debug.cc Fri Aug 17 02:03:08
2012
+++ /branches/bleeding_edge/test/cctest/test-debug.cc Mon Sep 10 02:24:17
2012
@@ -7419,5 +7419,24 @@
v8::Debug::SetDebugEventListener(NULL);
}
+
+
+TEST(LiveEditEnabled) {
+ v8::internal::FLAG_allow_natives_syntax = true;
+ v8::HandleScope scope;
+ LocalContext context;
+ v8::Debug::SetLiveEditEnabled(true);
+ CompileRun("%LiveEditCompareStrings('', '')");
+}
+
+
+TEST(LiveEditDisabled) {
+ v8::internal::FLAG_allow_natives_syntax = true;
+ v8::HandleScope scope;
+ LocalContext context;
+ v8::Debug::SetLiveEditEnabled(false);
+ CompileRun("%LiveEditCompareStrings('', '')");
+}
+
#endif // ENABLE_DEBUGGER_SUPPORT
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev