Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index e8abdef7f5c17f27468cf1ef7901206b3dc7b281..6d3a158068f556761c7a0a9db0a51366a4867526 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -8443,6 +8443,44 @@ 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); |
+ HandleScope scope; |
+ CONVERT_ARG_CHECKED(JSArray, shared_array, 0); |
+ |
+ |
+ 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; |
+} |
+ |
+ |
#endif // ENABLE_DEBUGGER_SUPPORT |
#ifdef ENABLE_LOGGING_AND_PROFILING |