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 9675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9686 HandleScope scope; | 9686 HandleScope scope; |
9687 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); | 9687 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); |
9688 CONVERT_ARG_CHECKED(JSArray, position_change_array, 1); | 9688 CONVERT_ARG_CHECKED(JSArray, position_change_array, 1); |
9689 | 9689 |
9690 LiveEdit::PatchFunctionPositions(shared_array, position_change_array); | 9690 LiveEdit::PatchFunctionPositions(shared_array, position_change_array); |
9691 | 9691 |
9692 return Heap::undefined_value(); | 9692 return Heap::undefined_value(); |
9693 } | 9693 } |
9694 | 9694 |
9695 | 9695 |
9696 static LiveEdit::FunctionPatchabilityStatus FindFunctionCodeOnStacks( | |
9697 Handle<SharedFunctionInfo> shared) { | |
9698 // TODO(635): check all threads, not only the current one. | |
9699 for (StackFrameIterator it; !it.done(); it.Advance()) { | |
9700 StackFrame* frame = it.frame(); | |
9701 if (frame->code() == shared->code()) { | |
9702 return LiveEdit::FUNCTION_BLOCKED_ON_STACK; | |
9703 } | |
9704 } | |
9705 return LiveEdit::FUNCTION_AVAILABLE_FOR_PATCH; | |
9706 } | |
9707 | |
9708 // For array of SharedFunctionInfo's (each wrapped in JSValue) | 9696 // For array of SharedFunctionInfo's (each wrapped in JSValue) |
9709 // checks that none of them have activations on stacks (of any thread). | 9697 // checks that none of them have activations on stacks (of any thread). |
9710 // Returns array of the same length with corresponding results of | 9698 // Returns array of the same length with corresponding results of |
9711 // LiveEdit::FunctionPatchabilityStatus type. | 9699 // LiveEdit::FunctionPatchabilityStatus type. |
9712 static Object* Runtime_LiveEditCheckStackActivations(Arguments args) { | 9700 static Object* Runtime_LiveEditCheckAndDropActivations(Arguments args) { |
9713 ASSERT(args.length() == 1); | 9701 ASSERT(args.length() == 2); |
9714 HandleScope scope; | 9702 HandleScope scope; |
9715 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); | 9703 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); |
| 9704 CONVERT_BOOLEAN_CHECKED(do_drop, args[1]); |
9716 | 9705 |
9717 | 9706 |
9718 int len = Smi::cast(shared_array->length())->value(); | 9707 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); |
9719 Handle<JSArray> result = Factory::NewJSArray(len); | |
9720 | |
9721 for (int i = 0; i < len; i++) { | |
9722 JSValue* wrapper = JSValue::cast(shared_array->GetElement(i)); | |
9723 Handle<SharedFunctionInfo> shared( | |
9724 SharedFunctionInfo::cast(wrapper->value())); | |
9725 LiveEdit::FunctionPatchabilityStatus check_res = | |
9726 FindFunctionCodeOnStacks(shared); | |
9727 SetElement(result, i, Handle<Smi>(Smi::FromInt(check_res))); | |
9728 } | |
9729 | |
9730 return *result; | |
9731 } | 9708 } |
9732 | 9709 |
9733 | 9710 |
9734 // A testing entry. Returns statement position which is the closest to | 9711 // A testing entry. Returns statement position which is the closest to |
9735 // source_position. | 9712 // source_position. |
9736 static Object* Runtime_GetFunctionCodePositionFromSource(Arguments args) { | 9713 static Object* Runtime_GetFunctionCodePositionFromSource(Arguments args) { |
9737 ASSERT(args.length() == 2); | 9714 ASSERT(args.length() == 2); |
9738 HandleScope scope; | 9715 HandleScope scope; |
9739 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 9716 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
9740 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 9717 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
(...skipping 13 matching lines...) Expand all Loading... |
9754 // Check whether we can't get any closer. | 9731 // Check whether we can't get any closer. |
9755 if (distance == 0) break; | 9732 if (distance == 0) break; |
9756 } | 9733 } |
9757 it.next(); | 9734 it.next(); |
9758 } | 9735 } |
9759 | 9736 |
9760 return Smi::FromInt(closest_pc); | 9737 return Smi::FromInt(closest_pc); |
9761 } | 9738 } |
9762 | 9739 |
9763 | 9740 |
| 9741 // Calls specified function with or without entering the debugger. |
| 9742 // This is used in unit tests to run code as if debugger is entered or simply |
| 9743 // to have a stack with C++ frame in the middle. |
| 9744 static Object* Runtime_ExecuteInDebugContext(Arguments args) { |
| 9745 ASSERT(args.length() == 2); |
| 9746 HandleScope scope; |
| 9747 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| 9748 CONVERT_BOOLEAN_CHECKED(without_debugger, args[1]); |
| 9749 |
| 9750 Handle<Object> result; |
| 9751 bool pending_exception; |
| 9752 { |
| 9753 if (without_debugger) { |
| 9754 result = Execution::Call(function, Top::global(), 0, NULL, |
| 9755 &pending_exception); |
| 9756 } else { |
| 9757 EnterDebugger enter_debugger; |
| 9758 result = Execution::Call(function, Top::global(), 0, NULL, |
| 9759 &pending_exception); |
| 9760 } |
| 9761 } |
| 9762 if (!pending_exception) { |
| 9763 return *result; |
| 9764 } else { |
| 9765 return Failure::Exception(); |
| 9766 } |
| 9767 } |
| 9768 |
| 9769 |
9764 #endif // ENABLE_DEBUGGER_SUPPORT | 9770 #endif // ENABLE_DEBUGGER_SUPPORT |
9765 | 9771 |
9766 #ifdef ENABLE_LOGGING_AND_PROFILING | 9772 #ifdef ENABLE_LOGGING_AND_PROFILING |
9767 | 9773 |
9768 static Object* Runtime_ProfilerResume(Arguments args) { | 9774 static Object* Runtime_ProfilerResume(Arguments args) { |
9769 NoHandleAllocation ha; | 9775 NoHandleAllocation ha; |
9770 ASSERT(args.length() == 2); | 9776 ASSERT(args.length() == 2); |
9771 | 9777 |
9772 CONVERT_CHECKED(Smi, smi_modules, args[0]); | 9778 CONVERT_CHECKED(Smi, smi_modules, args[0]); |
9773 CONVERT_CHECKED(Smi, smi_tag, args[1]); | 9779 CONVERT_CHECKED(Smi, smi_tag, args[1]); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10039 } else { | 10045 } else { |
10040 // Handle last resort GC and make sure to allow future allocations | 10046 // Handle last resort GC and make sure to allow future allocations |
10041 // to grow the heap without causing GCs (if possible). | 10047 // to grow the heap without causing GCs (if possible). |
10042 Counters::gc_last_resort_from_js.Increment(); | 10048 Counters::gc_last_resort_from_js.Increment(); |
10043 Heap::CollectAllGarbage(false); | 10049 Heap::CollectAllGarbage(false); |
10044 } | 10050 } |
10045 } | 10051 } |
10046 | 10052 |
10047 | 10053 |
10048 } } // namespace v8::internal | 10054 } } // namespace v8::internal |
OLD | NEW |