Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 40b37d96e1dcb4405cb0bf0b94ad5b1997e53686..fe4ad9518d3f58bc36cbbd4aac5f87df8b5b996f 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -9693,41 +9693,18 @@ static Object* Runtime_LiveEditPatchFunctionPositions(Arguments args) { |
} |
-static LiveEdit::FunctionPatchabilityStatus FindFunctionCodeOnStacks( |
- Handle<SharedFunctionInfo> shared) { |
- // TODO(635): check all threads, not only the current one. |
- for (StackFrameIterator it; !it.done(); it.Advance()) { |
- StackFrame* frame = it.frame(); |
- if (frame->code() == shared->code()) { |
- return LiveEdit::FUNCTION_BLOCKED_ON_STACK; |
- } |
- } |
- return LiveEdit::FUNCTION_AVAILABLE_FOR_PATCH; |
-} |
- |
// For array of SharedFunctionInfo's (each wrapped in JSValue) |
// checks that none of them have activations on stacks (of any thread). |
// Returns array of the same length with corresponding results of |
// LiveEdit::FunctionPatchabilityStatus type. |
-static Object* Runtime_LiveEditCheckStackActivations(Arguments args) { |
- ASSERT(args.length() == 1); |
+static Object* Runtime_LiveEditCheckAndDropActivations(Arguments args) { |
+ ASSERT(args.length() == 2); |
HandleScope scope; |
CONVERT_ARG_CHECKED(JSArray, shared_array, 0); |
+ CONVERT_BOOLEAN_CHECKED(do_drop, args[1]); |
- int len = Smi::cast(shared_array->length())->value(); |
- Handle<JSArray> result = Factory::NewJSArray(len); |
- |
- for (int i = 0; i < len; i++) { |
- JSValue* wrapper = JSValue::cast(shared_array->GetElement(i)); |
- Handle<SharedFunctionInfo> shared( |
- SharedFunctionInfo::cast(wrapper->value())); |
- LiveEdit::FunctionPatchabilityStatus check_res = |
- FindFunctionCodeOnStacks(shared); |
- SetElement(result, i, Handle<Smi>(Smi::FromInt(check_res))); |
- } |
- |
- return *result; |
+ return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); |
} |
@@ -9761,6 +9738,35 @@ static Object* Runtime_GetFunctionCodePositionFromSource(Arguments args) { |
} |
+// Calls specified function with or without entering the debugger. |
+// This is used in unit tests to run code as if debugger is entered or simply |
+// to have a stack with C++ frame in the middle. |
+static Object* Runtime_ExecuteInDebugContext(Arguments args) { |
+ ASSERT(args.length() == 2); |
+ HandleScope scope; |
+ CONVERT_ARG_CHECKED(JSFunction, function, 0); |
+ CONVERT_BOOLEAN_CHECKED(without_debugger, args[1]); |
+ |
+ Handle<Object> result; |
+ bool pending_exception; |
+ { |
+ if (without_debugger) { |
+ result = Execution::Call(function, Top::global(), 0, NULL, |
+ &pending_exception); |
+ } else { |
+ EnterDebugger enter_debugger; |
+ result = Execution::Call(function, Top::global(), 0, NULL, |
+ &pending_exception); |
+ } |
+ } |
+ if (!pending_exception) { |
+ return *result; |
+ } else { |
+ return Failure::Exception(); |
+ } |
+} |
+ |
+ |
#endif // ENABLE_DEBUGGER_SUPPORT |
#ifdef ENABLE_LOGGING_AND_PROFILING |