Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 9e389492eca14cf87aec73a292b6a4794bd21e3e..d36bf622f9e84d6f2a4d69cae5c7c39060ec0265 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -12792,6 +12792,45 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { |
} |
+// 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) { |
+ HandleScope scope(isolate); |
+ ASSERT(args.length() == 2); |
+ |
+ // Check arguments. |
+ Object* check; |
+ { MaybeObject* maybe_check = Runtime_CheckExecutionState( |
+ RUNTIME_ARGUMENTS(isolate, args)); |
+ if (!maybe_check->ToObject(&check)) return maybe_check; |
+ } |
+ CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
+ Heap* heap = isolate->heap(); |
+ |
+ // Find the relevant frame with the requested index. |
+ StackFrame::Id id = isolate->debug()->break_frame_id(); |
+ if (id == StackFrame::NO_ID) { |
+ // If there are no JavaScript stack frames return undefined. |
+ return heap->undefined_value(); |
+ } |
+ |
+ int count = 0; |
+ JavaScriptFrameIterator it(isolate, id); |
+ for (; !it.done(); it.Advance()) { |
+ if (index < count + it.frame()->GetInlineCount()) break; |
+ count += it.frame()->GetInlineCount(); |
+ } |
+ if (it.done()) return heap->undefined_value(); |
+ |
+ const char* error_message = |
+ LiveEdit::RestartFrame(it.frame(), isolate->zone()); |
+ if (error_message) { |
+ return *(isolate->factory()->LookupAsciiSymbol(error_message)); |
+ } |
+ return heap->true_value(); |
+} |
+ |
+ |
// A testing entry. Returns statement position which is the closest to |
// source_position. |
RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) { |