| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdlib.h> | 5 #include <stdlib.h> |
| 6 #include <limits> | 6 #include <limits> |
| 7 | 7 |
| 8 #include "v8.h" | 8 #include "v8.h" |
| 9 | 9 |
| 10 #include "accessors.h" | 10 #include "accessors.h" |
| (...skipping 5575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5586 object_array->set(store_index, *value); | 5586 object_array->set(store_index, *value); |
| 5587 } | 5587 } |
| 5588 return *object; | 5588 return *object; |
| 5589 } | 5589 } |
| 5590 | 5590 |
| 5591 | 5591 |
| 5592 // Check whether debugger and is about to step into the callback that is passed | 5592 // Check whether debugger and is about to step into the callback that is passed |
| 5593 // to a built-in function such as Array.forEach. | 5593 // to a built-in function such as Array.forEach. |
| 5594 RUNTIME_FUNCTION(Runtime_DebugCallbackSupportsStepping) { | 5594 RUNTIME_FUNCTION(Runtime_DebugCallbackSupportsStepping) { |
| 5595 ASSERT(args.length() == 1); | 5595 ASSERT(args.length() == 1); |
| 5596 if (!isolate->debugger()->is_active() || !isolate->debug()->StepInActive()) { | 5596 if (!isolate->debug()->is_active() || !isolate->debug()->StepInActive()) { |
| 5597 return isolate->heap()->false_value(); | 5597 return isolate->heap()->false_value(); |
| 5598 } | 5598 } |
| 5599 CONVERT_ARG_CHECKED(Object, callback, 0); | 5599 CONVERT_ARG_CHECKED(Object, callback, 0); |
| 5600 // We do not step into the callback if it's a builtin or not even a function. | 5600 // We do not step into the callback if it's a builtin or not even a function. |
| 5601 return isolate->heap()->ToBoolean( | 5601 return isolate->heap()->ToBoolean( |
| 5602 callback->IsJSFunction() && !JSFunction::cast(callback)->IsBuiltin()); | 5602 callback->IsJSFunction() && !JSFunction::cast(callback)->IsBuiltin()); |
| 5603 } | 5603 } |
| 5604 | 5604 |
| 5605 | 5605 |
| 5606 // Set one shot breakpoints for the callback function that is passed to a | 5606 // Set one shot breakpoints for the callback function that is passed to a |
| (...skipping 5126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10733 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 10733 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 10734 isolate, result, | 10734 isolate, result, |
| 10735 JSObject::GetAccessor(Handle<JSObject>::cast(receiver), name, component)); | 10735 JSObject::GetAccessor(Handle<JSObject>::cast(receiver), name, component)); |
| 10736 return *result; | 10736 return *result; |
| 10737 } | 10737 } |
| 10738 | 10738 |
| 10739 | 10739 |
| 10740 RUNTIME_FUNCTION(Runtime_DebugBreak) { | 10740 RUNTIME_FUNCTION(Runtime_DebugBreak) { |
| 10741 SealHandleScope shs(isolate); | 10741 SealHandleScope shs(isolate); |
| 10742 ASSERT(args.length() == 0); | 10742 ASSERT(args.length() == 0); |
| 10743 Execution::DebugBreakHelper(isolate); | 10743 isolate->debug()->HandleDebugBreak(); |
| 10744 return isolate->heap()->undefined_value(); | 10744 return isolate->heap()->undefined_value(); |
| 10745 } | 10745 } |
| 10746 | 10746 |
| 10747 | 10747 |
| 10748 // Helper functions for wrapping and unwrapping stack frame ids. | 10748 // Helper functions for wrapping and unwrapping stack frame ids. |
| 10749 static Smi* WrapFrameId(StackFrame::Id id) { | 10749 static Smi* WrapFrameId(StackFrame::Id id) { |
| 10750 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); | 10750 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); |
| 10751 return Smi::FromInt(id >> 2); | 10751 return Smi::FromInt(id >> 2); |
| 10752 } | 10752 } |
| 10753 | 10753 |
| 10754 | 10754 |
| 10755 static StackFrame::Id UnwrapFrameId(int wrapped) { | 10755 static StackFrame::Id UnwrapFrameId(int wrapped) { |
| 10756 return static_cast<StackFrame::Id>(wrapped << 2); | 10756 return static_cast<StackFrame::Id>(wrapped << 2); |
| 10757 } | 10757 } |
| 10758 | 10758 |
| 10759 | 10759 |
| 10760 // Adds a JavaScript function as a debug event listener. | 10760 // Adds a JavaScript function as a debug event listener. |
| 10761 // args[0]: debug event listener function to set or null or undefined for | 10761 // args[0]: debug event listener function to set or null or undefined for |
| 10762 // clearing the event listener function | 10762 // clearing the event listener function |
| 10763 // args[1]: object supplied during callback | 10763 // args[1]: object supplied during callback |
| 10764 RUNTIME_FUNCTION(Runtime_SetDebugEventListener) { | 10764 RUNTIME_FUNCTION(Runtime_SetDebugEventListener) { |
| 10765 SealHandleScope shs(isolate); | 10765 SealHandleScope shs(isolate); |
| 10766 ASSERT(args.length() == 2); | 10766 ASSERT(args.length() == 2); |
| 10767 RUNTIME_ASSERT(args[0]->IsJSFunction() || | 10767 RUNTIME_ASSERT(args[0]->IsJSFunction() || |
| 10768 args[0]->IsUndefined() || | 10768 args[0]->IsUndefined() || |
| 10769 args[0]->IsNull()); | 10769 args[0]->IsNull()); |
| 10770 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); | 10770 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); |
| 10771 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); | 10771 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); |
| 10772 isolate->debugger()->SetEventListener(callback, data); | 10772 isolate->debug()->SetEventListener(callback, data); |
| 10773 | 10773 |
| 10774 return isolate->heap()->undefined_value(); | 10774 return isolate->heap()->undefined_value(); |
| 10775 } | 10775 } |
| 10776 | 10776 |
| 10777 | 10777 |
| 10778 RUNTIME_FUNCTION(Runtime_Break) { | 10778 RUNTIME_FUNCTION(Runtime_Break) { |
| 10779 SealHandleScope shs(isolate); | 10779 SealHandleScope shs(isolate); |
| 10780 ASSERT(args.length() == 0); | 10780 ASSERT(args.length() == 0); |
| 10781 isolate->stack_guard()->RequestDebugBreak(); | 10781 isolate->stack_guard()->RequestDebugBreak(); |
| 10782 return isolate->heap()->undefined_value(); | 10782 return isolate->heap()->undefined_value(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10850 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 10850 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 10851 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 10851 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 10852 | 10852 |
| 10853 // Make sure to set the current context to the context before the debugger was | 10853 // Make sure to set the current context to the context before the debugger was |
| 10854 // entered (if the debugger is entered). The reason for switching context here | 10854 // entered (if the debugger is entered). The reason for switching context here |
| 10855 // is that for some property lookups (accessors and interceptors) callbacks | 10855 // is that for some property lookups (accessors and interceptors) callbacks |
| 10856 // into the embedding application can occour, and the embedding application | 10856 // into the embedding application can occour, and the embedding application |
| 10857 // could have the assumption that its own native context is the current | 10857 // could have the assumption that its own native context is the current |
| 10858 // context and not some internal debugger context. | 10858 // context and not some internal debugger context. |
| 10859 SaveContext save(isolate); | 10859 SaveContext save(isolate); |
| 10860 if (isolate->debug()->InDebugger()) { | 10860 if (isolate->debug()->in_debug_scope()) { |
| 10861 isolate->set_context(*isolate->debug()->debugger_entry()->GetContext()); | 10861 isolate->set_context(*isolate->debug()->debugger_entry()->GetContext()); |
| 10862 } | 10862 } |
| 10863 | 10863 |
| 10864 // Skip the global proxy as it has no properties and always delegates to the | 10864 // Skip the global proxy as it has no properties and always delegates to the |
| 10865 // real global object. | 10865 // real global object. |
| 10866 if (obj->IsJSGlobalProxy()) { | 10866 if (obj->IsJSGlobalProxy()) { |
| 10867 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype())); | 10867 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype())); |
| 10868 } | 10868 } |
| 10869 | 10869 |
| 10870 | 10870 |
| (...skipping 2026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12897 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12897 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 12898 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12898 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 12899 | 12899 |
| 12900 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12900 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
| 12901 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 12901 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
| 12902 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); | 12902 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); |
| 12903 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); | 12903 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); |
| 12904 CONVERT_ARG_HANDLE_CHECKED(Object, context_extension, 5); | 12904 CONVERT_ARG_HANDLE_CHECKED(Object, context_extension, 5); |
| 12905 | 12905 |
| 12906 // Handle the processing of break. | 12906 // Handle the processing of break. |
| 12907 DisableBreak disable_break_save(isolate, disable_break); | 12907 DisableBreak disable_break_scope(isolate->debug(), disable_break); |
| 12908 | 12908 |
| 12909 // Get the frame where the debugging is performed. | 12909 // Get the frame where the debugging is performed. |
| 12910 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 12910 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
| 12911 JavaScriptFrameIterator it(isolate, id); | 12911 JavaScriptFrameIterator it(isolate, id); |
| 12912 JavaScriptFrame* frame = it.frame(); | 12912 JavaScriptFrame* frame = it.frame(); |
| 12913 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); | 12913 FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); |
| 12914 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); | 12914 Handle<JSFunction> function(JSFunction::cast(frame_inspector.GetFunction())); |
| 12915 | 12915 |
| 12916 // Traverse the saved contexts chain to find the active context for the | 12916 // Traverse the saved contexts chain to find the active context for the |
| 12917 // selected frame. | 12917 // selected frame. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12961 // evaluated. | 12961 // evaluated. |
| 12962 ASSERT(args.length() == 4); | 12962 ASSERT(args.length() == 4); |
| 12963 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12963 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 12964 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12964 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 12965 | 12965 |
| 12966 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 12966 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
| 12967 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); | 12967 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); |
| 12968 CONVERT_ARG_HANDLE_CHECKED(Object, context_extension, 3); | 12968 CONVERT_ARG_HANDLE_CHECKED(Object, context_extension, 3); |
| 12969 | 12969 |
| 12970 // Handle the processing of break. | 12970 // Handle the processing of break. |
| 12971 DisableBreak disable_break_save(isolate, disable_break); | 12971 DisableBreak disable_break_scope(isolate->debug(), disable_break); |
| 12972 | 12972 |
| 12973 // Enter the top context from before the debugger was invoked. | 12973 // Enter the top context from before the debugger was invoked. |
| 12974 SaveContext save(isolate); | 12974 SaveContext save(isolate); |
| 12975 SaveContext* top = &save; | 12975 SaveContext* top = &save; |
| 12976 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) { | 12976 while (top != NULL && *top->context() == *isolate->debug()->debug_context()) { |
| 12977 top = top->prev(); | 12977 top = top->prev(); |
| 12978 } | 12978 } |
| 12979 if (top != NULL) { | 12979 if (top != NULL) { |
| 12980 isolate->set_context(*top->context()); | 12980 isolate->set_context(*top->context()); |
| 12981 } | 12981 } |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13329 } | 13329 } |
| 13330 return counter; | 13330 return counter; |
| 13331 } | 13331 } |
| 13332 | 13332 |
| 13333 | 13333 |
| 13334 // For a script finds all SharedFunctionInfo's in the heap that points | 13334 // For a script finds all SharedFunctionInfo's in the heap that points |
| 13335 // to this script. Returns JSArray of SharedFunctionInfo wrapped | 13335 // to this script. Returns JSArray of SharedFunctionInfo wrapped |
| 13336 // in OpaqueReferences. | 13336 // in OpaqueReferences. |
| 13337 RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) { | 13337 RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) { |
| 13338 HandleScope scope(isolate); | 13338 HandleScope scope(isolate); |
| 13339 CHECK(isolate->debugger()->live_edit_enabled()); | 13339 CHECK(isolate->debug()->live_edit_enabled()); |
| 13340 ASSERT(args.length() == 1); | 13340 ASSERT(args.length() == 1); |
| 13341 CONVERT_ARG_CHECKED(JSValue, script_value, 0); | 13341 CONVERT_ARG_CHECKED(JSValue, script_value, 0); |
| 13342 | 13342 |
| 13343 RUNTIME_ASSERT(script_value->value()->IsScript()); | 13343 RUNTIME_ASSERT(script_value->value()->IsScript()); |
| 13344 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); | 13344 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); |
| 13345 | 13345 |
| 13346 const int kBufferSize = 32; | 13346 const int kBufferSize = 32; |
| 13347 | 13347 |
| 13348 Handle<FixedArray> array; | 13348 Handle<FixedArray> array; |
| 13349 array = isolate->factory()->NewFixedArray(kBufferSize); | 13349 array = isolate->factory()->NewFixedArray(kBufferSize); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 13374 | 13374 |
| 13375 // For a script calculates compilation information about all its functions. | 13375 // For a script calculates compilation information about all its functions. |
| 13376 // The script source is explicitly specified by the second argument. | 13376 // The script source is explicitly specified by the second argument. |
| 13377 // The source of the actual script is not used, however it is important that | 13377 // The source of the actual script is not used, however it is important that |
| 13378 // all generated code keeps references to this particular instance of script. | 13378 // all generated code keeps references to this particular instance of script. |
| 13379 // Returns a JSArray of compilation infos. The array is ordered so that | 13379 // Returns a JSArray of compilation infos. The array is ordered so that |
| 13380 // each function with all its descendant is always stored in a continues range | 13380 // each function with all its descendant is always stored in a continues range |
| 13381 // with the function itself going first. The root function is a script function. | 13381 // with the function itself going first. The root function is a script function. |
| 13382 RUNTIME_FUNCTION(Runtime_LiveEditGatherCompileInfo) { | 13382 RUNTIME_FUNCTION(Runtime_LiveEditGatherCompileInfo) { |
| 13383 HandleScope scope(isolate); | 13383 HandleScope scope(isolate); |
| 13384 CHECK(isolate->debugger()->live_edit_enabled()); | 13384 CHECK(isolate->debug()->live_edit_enabled()); |
| 13385 ASSERT(args.length() == 2); | 13385 ASSERT(args.length() == 2); |
| 13386 CONVERT_ARG_CHECKED(JSValue, script, 0); | 13386 CONVERT_ARG_CHECKED(JSValue, script, 0); |
| 13387 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 13387 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
| 13388 | 13388 |
| 13389 RUNTIME_ASSERT(script->value()->IsScript()); | 13389 RUNTIME_ASSERT(script->value()->IsScript()); |
| 13390 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); | 13390 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
| 13391 | 13391 |
| 13392 Handle<JSArray> result; | 13392 Handle<JSArray> result; |
| 13393 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13393 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 13394 isolate, result, LiveEdit::GatherCompileInfo(script_handle, source)); | 13394 isolate, result, LiveEdit::GatherCompileInfo(script_handle, source)); |
| 13395 return *result; | 13395 return *result; |
| 13396 } | 13396 } |
| 13397 | 13397 |
| 13398 | 13398 |
| 13399 // Changes the source of the script to a new_source. | 13399 // Changes the source of the script to a new_source. |
| 13400 // If old_script_name is provided (i.e. is a String), also creates a copy of | 13400 // If old_script_name is provided (i.e. is a String), also creates a copy of |
| 13401 // the script with its original source and sends notification to debugger. | 13401 // the script with its original source and sends notification to debugger. |
| 13402 RUNTIME_FUNCTION(Runtime_LiveEditReplaceScript) { | 13402 RUNTIME_FUNCTION(Runtime_LiveEditReplaceScript) { |
| 13403 HandleScope scope(isolate); | 13403 HandleScope scope(isolate); |
| 13404 CHECK(isolate->debugger()->live_edit_enabled()); | 13404 CHECK(isolate->debug()->live_edit_enabled()); |
| 13405 ASSERT(args.length() == 3); | 13405 ASSERT(args.length() == 3); |
| 13406 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0); | 13406 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0); |
| 13407 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1); | 13407 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1); |
| 13408 CONVERT_ARG_HANDLE_CHECKED(Object, old_script_name, 2); | 13408 CONVERT_ARG_HANDLE_CHECKED(Object, old_script_name, 2); |
| 13409 | 13409 |
| 13410 RUNTIME_ASSERT(original_script_value->value()->IsScript()); | 13410 RUNTIME_ASSERT(original_script_value->value()->IsScript()); |
| 13411 Handle<Script> original_script(Script::cast(original_script_value->value())); | 13411 Handle<Script> original_script(Script::cast(original_script_value->value())); |
| 13412 | 13412 |
| 13413 Handle<Object> old_script = LiveEdit::ChangeScriptSource( | 13413 Handle<Object> old_script = LiveEdit::ChangeScriptSource( |
| 13414 original_script, new_source, old_script_name); | 13414 original_script, new_source, old_script_name); |
| 13415 | 13415 |
| 13416 if (old_script->IsScript()) { | 13416 if (old_script->IsScript()) { |
| 13417 Handle<Script> script_handle = Handle<Script>::cast(old_script); | 13417 Handle<Script> script_handle = Handle<Script>::cast(old_script); |
| 13418 return *Script::GetWrapper(script_handle); | 13418 return *Script::GetWrapper(script_handle); |
| 13419 } else { | 13419 } else { |
| 13420 return isolate->heap()->null_value(); | 13420 return isolate->heap()->null_value(); |
| 13421 } | 13421 } |
| 13422 } | 13422 } |
| 13423 | 13423 |
| 13424 | 13424 |
| 13425 RUNTIME_FUNCTION(Runtime_LiveEditFunctionSourceUpdated) { | 13425 RUNTIME_FUNCTION(Runtime_LiveEditFunctionSourceUpdated) { |
| 13426 HandleScope scope(isolate); | 13426 HandleScope scope(isolate); |
| 13427 CHECK(isolate->debugger()->live_edit_enabled()); | 13427 CHECK(isolate->debug()->live_edit_enabled()); |
| 13428 ASSERT(args.length() == 1); | 13428 ASSERT(args.length() == 1); |
| 13429 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 0); | 13429 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 0); |
| 13430 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); | 13430 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); |
| 13431 | 13431 |
| 13432 LiveEdit::FunctionSourceUpdated(shared_info); | 13432 LiveEdit::FunctionSourceUpdated(shared_info); |
| 13433 return isolate->heap()->undefined_value(); | 13433 return isolate->heap()->undefined_value(); |
| 13434 } | 13434 } |
| 13435 | 13435 |
| 13436 | 13436 |
| 13437 // Replaces code of SharedFunctionInfo with a new one. | 13437 // Replaces code of SharedFunctionInfo with a new one. |
| 13438 RUNTIME_FUNCTION(Runtime_LiveEditReplaceFunctionCode) { | 13438 RUNTIME_FUNCTION(Runtime_LiveEditReplaceFunctionCode) { |
| 13439 HandleScope scope(isolate); | 13439 HandleScope scope(isolate); |
| 13440 CHECK(isolate->debugger()->live_edit_enabled()); | 13440 CHECK(isolate->debug()->live_edit_enabled()); |
| 13441 ASSERT(args.length() == 2); | 13441 ASSERT(args.length() == 2); |
| 13442 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0); | 13442 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0); |
| 13443 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1); | 13443 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1); |
| 13444 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); | 13444 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); |
| 13445 | 13445 |
| 13446 LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); | 13446 LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); |
| 13447 return isolate->heap()->undefined_value(); | 13447 return isolate->heap()->undefined_value(); |
| 13448 } | 13448 } |
| 13449 | 13449 |
| 13450 | 13450 |
| 13451 // Connects SharedFunctionInfo to another script. | 13451 // Connects SharedFunctionInfo to another script. |
| 13452 RUNTIME_FUNCTION(Runtime_LiveEditFunctionSetScript) { | 13452 RUNTIME_FUNCTION(Runtime_LiveEditFunctionSetScript) { |
| 13453 HandleScope scope(isolate); | 13453 HandleScope scope(isolate); |
| 13454 CHECK(isolate->debugger()->live_edit_enabled()); | 13454 CHECK(isolate->debug()->live_edit_enabled()); |
| 13455 ASSERT(args.length() == 2); | 13455 ASSERT(args.length() == 2); |
| 13456 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); | 13456 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); |
| 13457 CONVERT_ARG_HANDLE_CHECKED(Object, script_object, 1); | 13457 CONVERT_ARG_HANDLE_CHECKED(Object, script_object, 1); |
| 13458 | 13458 |
| 13459 if (function_object->IsJSValue()) { | 13459 if (function_object->IsJSValue()) { |
| 13460 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); | 13460 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); |
| 13461 if (script_object->IsJSValue()) { | 13461 if (script_object->IsJSValue()) { |
| 13462 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript()); | 13462 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript()); |
| 13463 Script* script = Script::cast(JSValue::cast(*script_object)->value()); | 13463 Script* script = Script::cast(JSValue::cast(*script_object)->value()); |
| 13464 script_object = Handle<Object>(script, isolate); | 13464 script_object = Handle<Object>(script, isolate); |
| 13465 } | 13465 } |
| 13466 RUNTIME_ASSERT(function_wrapper->value()->IsSharedFunctionInfo()); | 13466 RUNTIME_ASSERT(function_wrapper->value()->IsSharedFunctionInfo()); |
| 13467 LiveEdit::SetFunctionScript(function_wrapper, script_object); | 13467 LiveEdit::SetFunctionScript(function_wrapper, script_object); |
| 13468 } else { | 13468 } else { |
| 13469 // Just ignore this. We may not have a SharedFunctionInfo for some functions | 13469 // Just ignore this. We may not have a SharedFunctionInfo for some functions |
| 13470 // and we check it in this function. | 13470 // and we check it in this function. |
| 13471 } | 13471 } |
| 13472 | 13472 |
| 13473 return isolate->heap()->undefined_value(); | 13473 return isolate->heap()->undefined_value(); |
| 13474 } | 13474 } |
| 13475 | 13475 |
| 13476 | 13476 |
| 13477 // In a code of a parent function replaces original function as embedded object | 13477 // In a code of a parent function replaces original function as embedded object |
| 13478 // with a substitution one. | 13478 // with a substitution one. |
| 13479 RUNTIME_FUNCTION(Runtime_LiveEditReplaceRefToNestedFunction) { | 13479 RUNTIME_FUNCTION(Runtime_LiveEditReplaceRefToNestedFunction) { |
| 13480 HandleScope scope(isolate); | 13480 HandleScope scope(isolate); |
| 13481 CHECK(isolate->debugger()->live_edit_enabled()); | 13481 CHECK(isolate->debug()->live_edit_enabled()); |
| 13482 ASSERT(args.length() == 3); | 13482 ASSERT(args.length() == 3); |
| 13483 | 13483 |
| 13484 CONVERT_ARG_HANDLE_CHECKED(JSValue, parent_wrapper, 0); | 13484 CONVERT_ARG_HANDLE_CHECKED(JSValue, parent_wrapper, 0); |
| 13485 CONVERT_ARG_HANDLE_CHECKED(JSValue, orig_wrapper, 1); | 13485 CONVERT_ARG_HANDLE_CHECKED(JSValue, orig_wrapper, 1); |
| 13486 CONVERT_ARG_HANDLE_CHECKED(JSValue, subst_wrapper, 2); | 13486 CONVERT_ARG_HANDLE_CHECKED(JSValue, subst_wrapper, 2); |
| 13487 RUNTIME_ASSERT(parent_wrapper->value()->IsSharedFunctionInfo()); | 13487 RUNTIME_ASSERT(parent_wrapper->value()->IsSharedFunctionInfo()); |
| 13488 RUNTIME_ASSERT(orig_wrapper->value()->IsSharedFunctionInfo()); | 13488 RUNTIME_ASSERT(orig_wrapper->value()->IsSharedFunctionInfo()); |
| 13489 RUNTIME_ASSERT(subst_wrapper->value()->IsSharedFunctionInfo()); | 13489 RUNTIME_ASSERT(subst_wrapper->value()->IsSharedFunctionInfo()); |
| 13490 | 13490 |
| 13491 LiveEdit::ReplaceRefToNestedFunction( | 13491 LiveEdit::ReplaceRefToNestedFunction( |
| 13492 parent_wrapper, orig_wrapper, subst_wrapper); | 13492 parent_wrapper, orig_wrapper, subst_wrapper); |
| 13493 return isolate->heap()->undefined_value(); | 13493 return isolate->heap()->undefined_value(); |
| 13494 } | 13494 } |
| 13495 | 13495 |
| 13496 | 13496 |
| 13497 // Updates positions of a shared function info (first parameter) according | 13497 // Updates positions of a shared function info (first parameter) according |
| 13498 // to script source change. Text change is described in second parameter as | 13498 // to script source change. Text change is described in second parameter as |
| 13499 // array of groups of 3 numbers: | 13499 // array of groups of 3 numbers: |
| 13500 // (change_begin, change_end, change_end_new_position). | 13500 // (change_begin, change_end, change_end_new_position). |
| 13501 // Each group describes a change in text; groups are sorted by change_begin. | 13501 // Each group describes a change in text; groups are sorted by change_begin. |
| 13502 RUNTIME_FUNCTION(Runtime_LiveEditPatchFunctionPositions) { | 13502 RUNTIME_FUNCTION(Runtime_LiveEditPatchFunctionPositions) { |
| 13503 HandleScope scope(isolate); | 13503 HandleScope scope(isolate); |
| 13504 CHECK(isolate->debugger()->live_edit_enabled()); | 13504 CHECK(isolate->debug()->live_edit_enabled()); |
| 13505 ASSERT(args.length() == 2); | 13505 ASSERT(args.length() == 2); |
| 13506 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); | 13506 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); |
| 13507 CONVERT_ARG_HANDLE_CHECKED(JSArray, position_change_array, 1); | 13507 CONVERT_ARG_HANDLE_CHECKED(JSArray, position_change_array, 1); |
| 13508 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_array)) | 13508 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_array)) |
| 13509 | 13509 |
| 13510 LiveEdit::PatchFunctionPositions(shared_array, position_change_array); | 13510 LiveEdit::PatchFunctionPositions(shared_array, position_change_array); |
| 13511 return isolate->heap()->undefined_value(); | 13511 return isolate->heap()->undefined_value(); |
| 13512 } | 13512 } |
| 13513 | 13513 |
| 13514 | 13514 |
| 13515 // For array of SharedFunctionInfo's (each wrapped in JSValue) | 13515 // For array of SharedFunctionInfo's (each wrapped in JSValue) |
| 13516 // checks that none of them have activations on stacks (of any thread). | 13516 // checks that none of them have activations on stacks (of any thread). |
| 13517 // Returns array of the same length with corresponding results of | 13517 // Returns array of the same length with corresponding results of |
| 13518 // LiveEdit::FunctionPatchabilityStatus type. | 13518 // LiveEdit::FunctionPatchabilityStatus type. |
| 13519 RUNTIME_FUNCTION(Runtime_LiveEditCheckAndDropActivations) { | 13519 RUNTIME_FUNCTION(Runtime_LiveEditCheckAndDropActivations) { |
| 13520 HandleScope scope(isolate); | 13520 HandleScope scope(isolate); |
| 13521 CHECK(isolate->debugger()->live_edit_enabled()); | 13521 CHECK(isolate->debug()->live_edit_enabled()); |
| 13522 ASSERT(args.length() == 2); | 13522 ASSERT(args.length() == 2); |
| 13523 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); | 13523 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); |
| 13524 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); | 13524 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); |
| 13525 RUNTIME_ASSERT(shared_array->length()->IsSmi()); | 13525 RUNTIME_ASSERT(shared_array->length()->IsSmi()); |
| 13526 int array_length = Smi::cast(shared_array->length())->value(); | 13526 int array_length = Smi::cast(shared_array->length())->value(); |
| 13527 for (int i = 0; i < array_length; i++) { | 13527 for (int i = 0; i < array_length; i++) { |
| 13528 Handle<Object> element = | 13528 Handle<Object> element = |
| 13529 Object::GetElement(isolate, shared_array, i).ToHandleChecked(); | 13529 Object::GetElement(isolate, shared_array, i).ToHandleChecked(); |
| 13530 RUNTIME_ASSERT( | 13530 RUNTIME_ASSERT( |
| 13531 element->IsJSValue() && | 13531 element->IsJSValue() && |
| 13532 Handle<JSValue>::cast(element)->value()->IsSharedFunctionInfo()); | 13532 Handle<JSValue>::cast(element)->value()->IsSharedFunctionInfo()); |
| 13533 } | 13533 } |
| 13534 | 13534 |
| 13535 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); | 13535 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); |
| 13536 } | 13536 } |
| 13537 | 13537 |
| 13538 | 13538 |
| 13539 // Compares 2 strings line-by-line, then token-wise and returns diff in form | 13539 // Compares 2 strings line-by-line, then token-wise and returns diff in form |
| 13540 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list | 13540 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list |
| 13541 // of diff chunks. | 13541 // of diff chunks. |
| 13542 RUNTIME_FUNCTION(Runtime_LiveEditCompareStrings) { | 13542 RUNTIME_FUNCTION(Runtime_LiveEditCompareStrings) { |
| 13543 HandleScope scope(isolate); | 13543 HandleScope scope(isolate); |
| 13544 CHECK(isolate->debugger()->live_edit_enabled()); | 13544 CHECK(isolate->debug()->live_edit_enabled()); |
| 13545 ASSERT(args.length() == 2); | 13545 ASSERT(args.length() == 2); |
| 13546 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); | 13546 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); |
| 13547 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); | 13547 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); |
| 13548 | 13548 |
| 13549 return *LiveEdit::CompareStrings(s1, s2); | 13549 return *LiveEdit::CompareStrings(s1, s2); |
| 13550 } | 13550 } |
| 13551 | 13551 |
| 13552 | 13552 |
| 13553 // Restarts a call frame and completely drops all frames above. | 13553 // Restarts a call frame and completely drops all frames above. |
| 13554 // Returns true if successful. Otherwise returns undefined or an error message. | 13554 // Returns true if successful. Otherwise returns undefined or an error message. |
| 13555 RUNTIME_FUNCTION(Runtime_LiveEditRestartFrame) { | 13555 RUNTIME_FUNCTION(Runtime_LiveEditRestartFrame) { |
| 13556 HandleScope scope(isolate); | 13556 HandleScope scope(isolate); |
| 13557 CHECK(isolate->debugger()->live_edit_enabled()); | 13557 CHECK(isolate->debug()->live_edit_enabled()); |
| 13558 ASSERT(args.length() == 2); | 13558 ASSERT(args.length() == 2); |
| 13559 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 13559 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 13560 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 13560 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
| 13561 | 13561 |
| 13562 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 13562 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
| 13563 Heap* heap = isolate->heap(); | 13563 Heap* heap = isolate->heap(); |
| 13564 | 13564 |
| 13565 // Find the relevant frame with the requested index. | 13565 // Find the relevant frame with the requested index. |
| 13566 StackFrame::Id id = isolate->debug()->break_frame_id(); | 13566 StackFrame::Id id = isolate->debug()->break_frame_id(); |
| 13567 if (id == StackFrame::NO_ID) { | 13567 if (id == StackFrame::NO_ID) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 13582 return *(isolate->factory()->InternalizeUtf8String(error_message)); | 13582 return *(isolate->factory()->InternalizeUtf8String(error_message)); |
| 13583 } | 13583 } |
| 13584 return heap->true_value(); | 13584 return heap->true_value(); |
| 13585 } | 13585 } |
| 13586 | 13586 |
| 13587 | 13587 |
| 13588 // A testing entry. Returns statement position which is the closest to | 13588 // A testing entry. Returns statement position which is the closest to |
| 13589 // source_position. | 13589 // source_position. |
| 13590 RUNTIME_FUNCTION(Runtime_GetFunctionCodePositionFromSource) { | 13590 RUNTIME_FUNCTION(Runtime_GetFunctionCodePositionFromSource) { |
| 13591 HandleScope scope(isolate); | 13591 HandleScope scope(isolate); |
| 13592 CHECK(isolate->debugger()->live_edit_enabled()); | 13592 CHECK(isolate->debug()->live_edit_enabled()); |
| 13593 ASSERT(args.length() == 2); | 13593 ASSERT(args.length() == 2); |
| 13594 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 13594 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 13595 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 13595 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
| 13596 | 13596 |
| 13597 Handle<Code> code(function->code(), isolate); | 13597 Handle<Code> code(function->code(), isolate); |
| 13598 | 13598 |
| 13599 if (code->kind() != Code::FUNCTION && | 13599 if (code->kind() != Code::FUNCTION && |
| 13600 code->kind() != Code::OPTIMIZED_FUNCTION) { | 13600 code->kind() != Code::OPTIMIZED_FUNCTION) { |
| 13601 return isolate->heap()->undefined_value(); | 13601 return isolate->heap()->undefined_value(); |
| 13602 } | 13602 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 13632 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1); | 13632 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1); |
| 13633 | 13633 |
| 13634 MaybeHandle<Object> maybe_result; | 13634 MaybeHandle<Object> maybe_result; |
| 13635 if (without_debugger) { | 13635 if (without_debugger) { |
| 13636 maybe_result = Execution::Call(isolate, | 13636 maybe_result = Execution::Call(isolate, |
| 13637 function, | 13637 function, |
| 13638 isolate->global_object(), | 13638 isolate->global_object(), |
| 13639 0, | 13639 0, |
| 13640 NULL); | 13640 NULL); |
| 13641 } else { | 13641 } else { |
| 13642 EnterDebugger enter_debugger(isolate); | 13642 DebugScope debug_scope(isolate->debug()); |
| 13643 maybe_result = Execution::Call(isolate, | 13643 maybe_result = Execution::Call(isolate, |
| 13644 function, | 13644 function, |
| 13645 isolate->global_object(), | 13645 isolate->global_object(), |
| 13646 0, | 13646 0, |
| 13647 NULL); | 13647 NULL); |
| 13648 } | 13648 } |
| 13649 Handle<Object> result; | 13649 Handle<Object> result; |
| 13650 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); | 13650 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); |
| 13651 return *result; | 13651 return *result; |
| 13652 } | 13652 } |
| (...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15188 } | 15188 } |
| 15189 return NULL; | 15189 return NULL; |
| 15190 } | 15190 } |
| 15191 | 15191 |
| 15192 | 15192 |
| 15193 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15193 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
| 15194 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15194 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
| 15195 } | 15195 } |
| 15196 | 15196 |
| 15197 } } // namespace v8::internal | 15197 } } // namespace v8::internal |
| OLD | NEW |