OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 | 404 |
405 // Only allow non-global compiles for eval. | 405 // Only allow non-global compiles for eval. |
406 ASSERT(is_eval || is_global); | 406 ASSERT(is_eval || is_global); |
407 | 407 |
408 // Build AST. | 408 // Build AST. |
409 ScriptDataImpl* pre_data = NULL; | 409 ScriptDataImpl* pre_data = NULL; |
410 FunctionLiteral* lit = MakeAST(is_global, script, extension, pre_data); | 410 FunctionLiteral* lit = MakeAST(is_global, script, extension, pre_data); |
411 | 411 |
412 // Check for parse errors. | 412 // Check for parse errors. |
413 if (lit == NULL) { | 413 if (lit == NULL) { |
414 ASSERT(Top::has_pending_exception()); | 414 ASSERT(Isolate::Current()->has_pending_exception()); |
415 return; | 415 return; |
416 } | 416 } |
417 | 417 |
418 // Compile the code. | 418 // Compile the code. |
419 CompilationInfo info(lit, script, is_eval); | 419 CompilationInfo info(lit, script, is_eval); |
420 | 420 |
421 LiveEditFunctionTracker tracker(lit); | 421 LiveEditFunctionTracker tracker(lit); |
422 Handle<Code> code = MakeCodeForLiveEdit(&info); | 422 Handle<Code> code = MakeCodeForLiveEdit(&info); |
423 | 423 |
424 // Check for stack-overflow exceptions. | 424 // Check for stack-overflow exceptions. |
425 if (code.is_null()) { | 425 if (code.is_null()) { |
426 Top::StackOverflow(); | 426 Isolate::Current()->StackOverflow(); |
427 return; | 427 return; |
428 } | 428 } |
429 tracker.RecordRootFunctionInfo(code); | 429 tracker.RecordRootFunctionInfo(code); |
430 } | 430 } |
431 | 431 |
432 // Unwraps JSValue object, returning its field "value" | 432 // Unwraps JSValue object, returning its field "value" |
433 static Handle<Object> UnwrapJSValue(Handle<JSValue> jsValue) { | 433 static Handle<Object> UnwrapJSValue(Handle<JSValue> jsValue) { |
434 return Handle<Object>(jsValue->value()); | 434 return Handle<Object>(jsValue->value()); |
435 } | 435 } |
436 | 436 |
437 // Wraps any object into a OpaqueReference, that will hide the object | 437 // Wraps any object into a OpaqueReference, that will hide the object |
438 // from JavaScript. | 438 // from JavaScript. |
439 static Handle<JSValue> WrapInJSValue(Object* object) { | 439 static Handle<JSValue> WrapInJSValue(Object* object) { |
440 Handle<JSFunction> constructor = Top::opaque_reference_function(); | 440 Handle<JSFunction> constructor = |
| 441 Isolate::Current()->opaque_reference_function(); |
441 Handle<JSValue> result = | 442 Handle<JSValue> result = |
442 Handle<JSValue>::cast(Factory::NewJSObject(constructor)); | 443 Handle<JSValue>::cast(Factory::NewJSObject(constructor)); |
443 result->set_value(object); | 444 result->set_value(object); |
444 return result; | 445 return result; |
445 } | 446 } |
446 | 447 |
447 // Simple helper class that creates more or less typed structures over | 448 // Simple helper class that creates more or less typed structures over |
448 // JSArray object. This is an adhoc method of passing structures from C++ | 449 // JSArray object. This is an adhoc method of passing structures from C++ |
449 // to JavaScript. | 450 // to JavaScript. |
450 template<typename S> | 451 template<typename S> |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 }; | 787 }; |
787 | 788 |
788 class FrameUncookingThreadVisitor : public ThreadVisitor { | 789 class FrameUncookingThreadVisitor : public ThreadVisitor { |
789 public: | 790 public: |
790 void VisitThread(ThreadLocalTop* top) { | 791 void VisitThread(ThreadLocalTop* top) { |
791 StackFrame::UncookFramesForThread(top); | 792 StackFrame::UncookFramesForThread(top); |
792 } | 793 } |
793 }; | 794 }; |
794 | 795 |
795 static void IterateAllThreads(ThreadVisitor* visitor) { | 796 static void IterateAllThreads(ThreadVisitor* visitor) { |
796 Top::IterateThread(visitor); | 797 Isolate::Current()->IterateThread(visitor); |
797 ThreadManager::IterateArchivedThreads(visitor); | 798 ThreadManager::IterateArchivedThreads(visitor); |
798 } | 799 } |
799 | 800 |
800 // Finds all references to original and replaces them with substitution. | 801 // Finds all references to original and replaces them with substitution. |
801 static void ReplaceCodeObject(Code* original, Code* substitution) { | 802 static void ReplaceCodeObject(Code* original, Code* substitution) { |
802 ASSERT(!HEAP->InNewSpace(substitution)); | 803 ASSERT(!HEAP->InNewSpace(substitution)); |
803 | 804 |
804 AssertNoAllocation no_allocations_please; | 805 AssertNoAllocation no_allocations_please; |
805 | 806 |
806 // A zone scope for ReferenceCollectorVisitor. | 807 // A zone scope for ReferenceCollectorVisitor. |
(...skipping 30 matching lines...) Expand all Loading... |
837 static bool IsJSFunctionCode(Code* code) { | 838 static bool IsJSFunctionCode(Code* code) { |
838 return code->kind() == Code::FUNCTION; | 839 return code->kind() == Code::FUNCTION; |
839 } | 840 } |
840 | 841 |
841 | 842 |
842 Object* LiveEdit::ReplaceFunctionCode(Handle<JSArray> new_compile_info_array, | 843 Object* LiveEdit::ReplaceFunctionCode(Handle<JSArray> new_compile_info_array, |
843 Handle<JSArray> shared_info_array) { | 844 Handle<JSArray> shared_info_array) { |
844 HandleScope scope; | 845 HandleScope scope; |
845 | 846 |
846 if (!SharedInfoWrapper::IsInstance(shared_info_array)) { | 847 if (!SharedInfoWrapper::IsInstance(shared_info_array)) { |
847 return Top::ThrowIllegalOperation(); | 848 return Isolate::Current()->ThrowIllegalOperation(); |
848 } | 849 } |
849 | 850 |
850 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); | 851 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); |
851 SharedInfoWrapper shared_info_wrapper(shared_info_array); | 852 SharedInfoWrapper shared_info_wrapper(shared_info_array); |
852 | 853 |
853 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); | 854 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); |
854 | 855 |
855 if (IsJSFunctionCode(shared_info->code())) { | 856 if (IsJSFunctionCode(shared_info->code())) { |
856 ReplaceCodeObject(shared_info->code(), | 857 ReplaceCodeObject(shared_info->code(), |
857 *(compile_info_wrapper.GetFunctionCode())); | 858 *(compile_info_wrapper.GetFunctionCode())); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 Handle<Code> result(Factory::CopyCode(code, buffer)); | 1032 Handle<Code> result(Factory::CopyCode(code, buffer)); |
1032 return result; | 1033 return result; |
1033 } | 1034 } |
1034 } | 1035 } |
1035 | 1036 |
1036 | 1037 |
1037 Object* LiveEdit::PatchFunctionPositions( | 1038 Object* LiveEdit::PatchFunctionPositions( |
1038 Handle<JSArray> shared_info_array, Handle<JSArray> position_change_array) { | 1039 Handle<JSArray> shared_info_array, Handle<JSArray> position_change_array) { |
1039 | 1040 |
1040 if (!SharedInfoWrapper::IsInstance(shared_info_array)) { | 1041 if (!SharedInfoWrapper::IsInstance(shared_info_array)) { |
1041 return Top::ThrowIllegalOperation(); | 1042 return Isolate::Current()->ThrowIllegalOperation(); |
1042 } | 1043 } |
1043 | 1044 |
1044 SharedInfoWrapper shared_info_wrapper(shared_info_array); | 1045 SharedInfoWrapper shared_info_wrapper(shared_info_array); |
1045 Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo(); | 1046 Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo(); |
1046 | 1047 |
1047 int old_function_start = info->start_position(); | 1048 int old_function_start = info->start_position(); |
1048 int new_function_start = TranslatePosition(old_function_start, | 1049 int new_function_start = TranslatePosition(old_function_start, |
1049 position_change_array); | 1050 position_change_array); |
1050 info->set_start_position(new_function_start); | 1051 info->set_start_position(new_function_start); |
1051 info->set_end_position(TranslatePosition(info->end_position(), | 1052 info->set_end_position(TranslatePosition(info->end_position(), |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 } | 1160 } |
1160 return false; | 1161 return false; |
1161 } | 1162 } |
1162 | 1163 |
1163 | 1164 |
1164 // Iterates over handler chain and removes all elements that are inside | 1165 // Iterates over handler chain and removes all elements that are inside |
1165 // frames being dropped. | 1166 // frames being dropped. |
1166 static bool FixTryCatchHandler(StackFrame* top_frame, | 1167 static bool FixTryCatchHandler(StackFrame* top_frame, |
1167 StackFrame* bottom_frame) { | 1168 StackFrame* bottom_frame) { |
1168 Address* pointer_address = | 1169 Address* pointer_address = |
1169 &Memory::Address_at(Top::get_address_from_id(Top::k_handler_address)); | 1170 &Memory::Address_at(Isolate::Current()->get_address_from_id( |
| 1171 Isolate::k_handler_address)); |
1170 | 1172 |
1171 while (*pointer_address < top_frame->sp()) { | 1173 while (*pointer_address < top_frame->sp()) { |
1172 pointer_address = &Memory::Address_at(*pointer_address); | 1174 pointer_address = &Memory::Address_at(*pointer_address); |
1173 } | 1175 } |
1174 Address* above_frame_address = pointer_address; | 1176 Address* above_frame_address = pointer_address; |
1175 while (*pointer_address < bottom_frame->fp()) { | 1177 while (*pointer_address < bottom_frame->fp()) { |
1176 pointer_address = &Memory::Address_at(*pointer_address); | 1178 pointer_address = &Memory::Address_at(*pointer_address); |
1177 } | 1179 } |
1178 bool change = *above_frame_address != *pointer_address; | 1180 bool change = *above_frame_address != *pointer_address; |
1179 *above_frame_address = *pointer_address; | 1181 *above_frame_address = *pointer_address; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1459 | 1461 |
1460 bool LiveEditFunctionTracker::IsActive() { | 1462 bool LiveEditFunctionTracker::IsActive() { |
1461 return false; | 1463 return false; |
1462 } | 1464 } |
1463 | 1465 |
1464 #endif // ENABLE_DEBUGGER_SUPPORT | 1466 #endif // ENABLE_DEBUGGER_SUPPORT |
1465 | 1467 |
1466 | 1468 |
1467 | 1469 |
1468 } } // namespace v8::internal | 1470 } } // namespace v8::internal |
OLD | NEW |