| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 9656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9667 | 9667 |
| 9668 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source); | 9668 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source); |
| 9669 | 9669 |
| 9670 if (Top::has_pending_exception()) { | 9670 if (Top::has_pending_exception()) { |
| 9671 return Failure::Exception(); | 9671 return Failure::Exception(); |
| 9672 } | 9672 } |
| 9673 | 9673 |
| 9674 return result; | 9674 return result; |
| 9675 } | 9675 } |
| 9676 | 9676 |
| 9677 // Changes the source of the script to a new_source and creates a new | 9677 // Changes the source of the script to a new_source. |
| 9678 // script representing the old version of the script source. | 9678 // If old_script_name is provided (i.e. is a String), also creates a copy of |
| 9679 // the script with its original source and sends notification to debugger. |
| 9679 static Object* Runtime_LiveEditReplaceScript(Arguments args) { | 9680 static Object* Runtime_LiveEditReplaceScript(Arguments args) { |
| 9680 ASSERT(args.length() == 3); | 9681 ASSERT(args.length() == 3); |
| 9681 HandleScope scope; | 9682 HandleScope scope; |
| 9682 CONVERT_CHECKED(JSValue, original_script_value, args[0]); | 9683 CONVERT_CHECKED(JSValue, original_script_value, args[0]); |
| 9683 CONVERT_ARG_CHECKED(String, new_source, 1); | 9684 CONVERT_ARG_CHECKED(String, new_source, 1); |
| 9684 CONVERT_ARG_CHECKED(String, old_script_name, 2); | 9685 Handle<Object> old_script_name(args[2]); |
| 9685 Handle<Script> original_script = | |
| 9686 Handle<Script>(Script::cast(original_script_value->value())); | |
| 9687 | 9686 |
| 9688 Handle<String> original_source(String::cast(original_script->source())); | 9687 CONVERT_CHECKED(Script, original_script_pointer, |
| 9688 original_script_value->value()); |
| 9689 Handle<Script> original_script(original_script_pointer); |
| 9689 | 9690 |
| 9690 original_script->set_source(*new_source); | 9691 Object* old_script = LiveEdit::ChangeScriptSource(original_script, |
| 9691 Handle<Script> old_script = Factory::NewScript(original_source); | 9692 new_source, |
| 9692 old_script->set_name(*old_script_name); | 9693 old_script_name); |
| 9693 old_script->set_line_offset(original_script->line_offset()); | |
| 9694 old_script->set_column_offset(original_script->column_offset()); | |
| 9695 old_script->set_data(original_script->data()); | |
| 9696 old_script->set_type(original_script->type()); | |
| 9697 old_script->set_context_data(original_script->context_data()); | |
| 9698 old_script->set_compilation_type(original_script->compilation_type()); | |
| 9699 old_script->set_eval_from_shared(original_script->eval_from_shared()); | |
| 9700 old_script->set_eval_from_instructions_offset( | |
| 9701 original_script->eval_from_instructions_offset()); | |
| 9702 | 9694 |
| 9703 // Drop line ends so that they will be recalculated. | 9695 if (old_script->IsScript()) { |
| 9704 original_script->set_line_ends(Heap::undefined_value()); | 9696 Handle<Script> script_handle(Script::cast(old_script)); |
| 9705 | 9697 return *(GetScriptWrapper(script_handle)); |
| 9706 Debugger::OnAfterCompile(old_script, Debugger::SEND_WHEN_DEBUGGING); | 9698 } else { |
| 9707 | 9699 return Heap::null_value(); |
| 9708 return *(GetScriptWrapper(old_script)); | 9700 } |
| 9709 } | 9701 } |
| 9710 | 9702 |
| 9711 // Replaces code of SharedFunctionInfo with a new one. | 9703 // Replaces code of SharedFunctionInfo with a new one. |
| 9712 static Object* Runtime_LiveEditReplaceFunctionCode(Arguments args) { | 9704 static Object* Runtime_LiveEditReplaceFunctionCode(Arguments args) { |
| 9713 ASSERT(args.length() == 2); | 9705 ASSERT(args.length() == 2); |
| 9714 HandleScope scope; | 9706 HandleScope scope; |
| 9715 CONVERT_ARG_CHECKED(JSArray, new_compile_info, 0); | 9707 CONVERT_ARG_CHECKED(JSArray, new_compile_info, 0); |
| 9716 CONVERT_ARG_CHECKED(JSArray, shared_info, 1); | 9708 CONVERT_ARG_CHECKED(JSArray, shared_info, 1); |
| 9717 | 9709 |
| 9718 LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); | 9710 LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); |
| 9719 | 9711 |
| 9720 return Heap::undefined_value(); | 9712 return Heap::undefined_value(); |
| 9721 } | 9713 } |
| 9722 | 9714 |
| 9723 // Connects SharedFunctionInfo to another script. | 9715 // Connects SharedFunctionInfo to another script. |
| 9724 static Object* Runtime_LiveEditRelinkFunctionToScript(Arguments args) { | 9716 static Object* Runtime_LiveEditFunctionSetScript(Arguments args) { |
| 9725 ASSERT(args.length() == 2); | 9717 ASSERT(args.length() == 2); |
| 9726 HandleScope scope; | 9718 HandleScope scope; |
| 9727 CONVERT_ARG_CHECKED(JSArray, shared_info_array, 0); | 9719 Handle<Object> function_object(args[0]); |
| 9728 CONVERT_ARG_CHECKED(JSValue, script_value, 1); | 9720 Handle<Object> script_object(args[1]); |
| 9729 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); | |
| 9730 | 9721 |
| 9731 LiveEdit::RelinkFunctionToScript(shared_info_array, script); | 9722 if (function_object->IsJSValue()) { |
| 9723 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); |
| 9724 if (script_object->IsJSValue()) { |
| 9725 CONVERT_CHECKED(Script, script, JSValue::cast(*script_object)->value()); |
| 9726 script_object = Handle<Object>(script); |
| 9727 } |
| 9728 |
| 9729 LiveEdit::SetFunctionScript(function_wrapper, script_object); |
| 9730 } else { |
| 9731 // Just ignore this. We may not have a SharedFunctionInfo for some functions |
| 9732 // and we check it in this function. |
| 9733 } |
| 9732 | 9734 |
| 9733 return Heap::undefined_value(); | 9735 return Heap::undefined_value(); |
| 9734 } | 9736 } |
| 9735 | 9737 |
| 9738 |
| 9739 // In a code of a parent function replaces original function as embedded object |
| 9740 // with a substitution one. |
| 9741 static Object* Runtime_LiveEditReplaceRefToNestedFunction(Arguments args) { |
| 9742 ASSERT(args.length() == 3); |
| 9743 HandleScope scope; |
| 9744 |
| 9745 CONVERT_ARG_CHECKED(JSValue, parent_wrapper, 0); |
| 9746 CONVERT_ARG_CHECKED(JSValue, orig_wrapper, 1); |
| 9747 CONVERT_ARG_CHECKED(JSValue, subst_wrapper, 2); |
| 9748 |
| 9749 LiveEdit::ReplaceRefToNestedFunction(parent_wrapper, orig_wrapper, |
| 9750 subst_wrapper); |
| 9751 |
| 9752 return Heap::undefined_value(); |
| 9753 } |
| 9754 |
| 9755 |
| 9736 // Updates positions of a shared function info (first parameter) according | 9756 // Updates positions of a shared function info (first parameter) according |
| 9737 // to script source change. Text change is described in second parameter as | 9757 // to script source change. Text change is described in second parameter as |
| 9738 // array of groups of 3 numbers: | 9758 // array of groups of 3 numbers: |
| 9739 // (change_begin, change_end, change_end_new_position). | 9759 // (change_begin, change_end, change_end_new_position). |
| 9740 // Each group describes a change in text; groups are sorted by change_begin. | 9760 // Each group describes a change in text; groups are sorted by change_begin. |
| 9741 // Returns an array of pairs (new source position, breakpoint_object/array) | |
| 9742 // so that JS side could update positions in breakpoint objects. | |
| 9743 static Object* Runtime_LiveEditPatchFunctionPositions(Arguments args) { | 9761 static Object* Runtime_LiveEditPatchFunctionPositions(Arguments args) { |
| 9744 ASSERT(args.length() == 2); | 9762 ASSERT(args.length() == 2); |
| 9745 HandleScope scope; | 9763 HandleScope scope; |
| 9746 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); | 9764 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); |
| 9747 CONVERT_ARG_CHECKED(JSArray, position_change_array, 1); | 9765 CONVERT_ARG_CHECKED(JSArray, position_change_array, 1); |
| 9748 | 9766 |
| 9749 Handle<Object> result = | 9767 LiveEdit::PatchFunctionPositions(shared_array, position_change_array); |
| 9750 LiveEdit::PatchFunctionPositions(shared_array, position_change_array); | |
| 9751 | 9768 |
| 9752 return *result; | 9769 return Heap::undefined_value(); |
| 9753 } | 9770 } |
| 9754 | 9771 |
| 9755 | 9772 |
| 9756 // For array of SharedFunctionInfo's (each wrapped in JSValue) | 9773 // For array of SharedFunctionInfo's (each wrapped in JSValue) |
| 9757 // checks that none of them have activations on stacks (of any thread). | 9774 // checks that none of them have activations on stacks (of any thread). |
| 9758 // Returns array of the same length with corresponding results of | 9775 // Returns array of the same length with corresponding results of |
| 9759 // LiveEdit::FunctionPatchabilityStatus type. | 9776 // LiveEdit::FunctionPatchabilityStatus type. |
| 9760 static Object* Runtime_LiveEditCheckAndDropActivations(Arguments args) { | 9777 static Object* Runtime_LiveEditCheckAndDropActivations(Arguments args) { |
| 9761 ASSERT(args.length() == 2); | 9778 ASSERT(args.length() == 2); |
| 9762 HandleScope scope; | 9779 HandleScope scope; |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10202 } else { | 10219 } else { |
| 10203 // Handle last resort GC and make sure to allow future allocations | 10220 // Handle last resort GC and make sure to allow future allocations |
| 10204 // to grow the heap without causing GCs (if possible). | 10221 // to grow the heap without causing GCs (if possible). |
| 10205 Counters::gc_last_resort_from_js.Increment(); | 10222 Counters::gc_last_resort_from_js.Increment(); |
| 10206 Heap::CollectAllGarbage(false); | 10223 Heap::CollectAllGarbage(false); |
| 10207 } | 10224 } |
| 10208 } | 10225 } |
| 10209 | 10226 |
| 10210 | 10227 |
| 10211 } } // namespace v8::internal | 10228 } } // namespace v8::internal |
| OLD | NEW |