| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 | 624 |
| 625 | 625 |
| 626 // Unwraps JSValue object, returning its field "value" | 626 // Unwraps JSValue object, returning its field "value" |
| 627 static Handle<Object> UnwrapJSValue(Handle<JSValue> jsValue) { | 627 static Handle<Object> UnwrapJSValue(Handle<JSValue> jsValue) { |
| 628 return Handle<Object>(jsValue->value(), jsValue->GetIsolate()); | 628 return Handle<Object>(jsValue->value(), jsValue->GetIsolate()); |
| 629 } | 629 } |
| 630 | 630 |
| 631 | 631 |
| 632 // Wraps any object into a OpaqueReference, that will hide the object | 632 // Wraps any object into a OpaqueReference, that will hide the object |
| 633 // from JavaScript. | 633 // from JavaScript. |
| 634 static Handle<JSValue> WrapInJSValue(Handle<Object> object) { | 634 static Handle<JSValue> WrapInJSValue(Handle<HeapObject> object) { |
| 635 Isolate* isolate = Isolate::Current(); | 635 Isolate* isolate = object->GetIsolate(); |
| 636 Handle<JSFunction> constructor = isolate->opaque_reference_function(); | 636 Handle<JSFunction> constructor = isolate->opaque_reference_function(); |
| 637 Handle<JSValue> result = | 637 Handle<JSValue> result = |
| 638 Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor)); | 638 Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor)); |
| 639 result->set_value(*object); | 639 result->set_value(*object); |
| 640 return result; | 640 return result; |
| 641 } | 641 } |
| 642 | 642 |
| 643 | 643 |
| 644 static Handle<SharedFunctionInfo> UnwrapSharedFunctionInfoFromJSValue( | 644 static Handle<SharedFunctionInfo> UnwrapSharedFunctionInfoFromJSValue( |
| 645 Handle<JSValue> jsValue) { | 645 Handle<JSValue> jsValue) { |
| 646 Object* shared = jsValue->value(); | 646 Object* shared = jsValue->value(); |
| 647 CHECK(shared->IsSharedFunctionInfo()); | 647 CHECK(shared->IsSharedFunctionInfo()); |
| 648 return Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(shared)); | 648 return Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(shared)); |
| 649 } | 649 } |
| 650 | 650 |
| 651 | 651 |
| 652 static int GetArrayLength(Handle<JSArray> array) { | 652 static int GetArrayLength(Handle<JSArray> array) { |
| 653 Object* length = array->length(); | 653 Object* length = array->length(); |
| 654 CHECK(length->IsSmi()); | 654 CHECK(length->IsSmi()); |
| 655 return Smi::cast(length)->value(); | 655 return Smi::cast(length)->value(); |
| 656 } | 656 } |
| 657 | 657 |
| 658 | 658 |
| 659 // Simple helper class that creates more or less typed structures over | 659 // Simple helper class that creates more or less typed structures over |
| 660 // JSArray object. This is an adhoc method of passing structures from C++ | 660 // JSArray object. This is an adhoc method of passing structures from C++ |
| 661 // to JavaScript. | 661 // to JavaScript. |
| 662 template<typename S> | 662 template<typename S> |
| 663 class JSArrayBasedStruct { | 663 class JSArrayBasedStruct { |
| 664 public: | 664 public: |
| 665 static S Create() { | 665 static S Create(Isolate* isolate) { |
| 666 Factory* factory = Isolate::Current()->factory(); | 666 Factory* factory = isolate->factory(); |
| 667 Handle<JSArray> array = factory->NewJSArray(S::kSize_); | 667 Handle<JSArray> array = factory->NewJSArray(S::kSize_); |
| 668 return S(array); | 668 return S(array); |
| 669 } | 669 } |
| 670 static S cast(Object* object) { | 670 static S cast(Object* object) { |
| 671 JSArray* array = JSArray::cast(object); | 671 JSArray* array = JSArray::cast(object); |
| 672 Handle<JSArray> array_handle(array); | 672 Handle<JSArray> array_handle(array); |
| 673 return S(array_handle); | 673 return S(array_handle); |
| 674 } | 674 } |
| 675 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) { | 675 explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) { |
| 676 } | 676 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 int literal_count, int parent_index) { | 717 int literal_count, int parent_index) { |
| 718 HandleScope scope(isolate()); | 718 HandleScope scope(isolate()); |
| 719 this->SetField(kFunctionNameOffset_, name); | 719 this->SetField(kFunctionNameOffset_, name); |
| 720 this->SetSmiValueField(kStartPositionOffset_, start_position); | 720 this->SetSmiValueField(kStartPositionOffset_, start_position); |
| 721 this->SetSmiValueField(kEndPositionOffset_, end_position); | 721 this->SetSmiValueField(kEndPositionOffset_, end_position); |
| 722 this->SetSmiValueField(kParamNumOffset_, param_num); | 722 this->SetSmiValueField(kParamNumOffset_, param_num); |
| 723 this->SetSmiValueField(kLiteralNumOffset_, literal_count); | 723 this->SetSmiValueField(kLiteralNumOffset_, literal_count); |
| 724 this->SetSmiValueField(kParentIndexOffset_, parent_index); | 724 this->SetSmiValueField(kParentIndexOffset_, parent_index); |
| 725 } | 725 } |
| 726 void SetFunctionCode(Handle<Code> function_code, | 726 void SetFunctionCode(Handle<Code> function_code, |
| 727 Handle<Object> code_scope_info) { | 727 Handle<HeapObject> code_scope_info) { |
| 728 Handle<JSValue> code_wrapper = WrapInJSValue(function_code); | 728 Handle<JSValue> code_wrapper = WrapInJSValue(function_code); |
| 729 this->SetField(kCodeOffset_, code_wrapper); | 729 this->SetField(kCodeOffset_, code_wrapper); |
| 730 | 730 |
| 731 Handle<JSValue> scope_wrapper = WrapInJSValue(code_scope_info); | 731 Handle<JSValue> scope_wrapper = WrapInJSValue(code_scope_info); |
| 732 this->SetField(kCodeScopeInfoOffset_, scope_wrapper); | 732 this->SetField(kCodeScopeInfoOffset_, scope_wrapper); |
| 733 } | 733 } |
| 734 void SetOuterScopeInfo(Handle<Object> scope_info_array) { | 734 void SetOuterScopeInfo(Handle<Object> scope_info_array) { |
| 735 this->SetField(kOuterScopeInfoOffset_, scope_info_array); | 735 this->SetField(kOuterScopeInfoOffset_, scope_info_array); |
| 736 } | 736 } |
| 737 void SetSharedFunctionInfo(Handle<SharedFunctionInfo> info) { | 737 void SetSharedFunctionInfo(Handle<SharedFunctionInfo> info) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 class FunctionInfoListener { | 826 class FunctionInfoListener { |
| 827 public: | 827 public: |
| 828 explicit FunctionInfoListener(Isolate* isolate) { | 828 explicit FunctionInfoListener(Isolate* isolate) { |
| 829 current_parent_index_ = -1; | 829 current_parent_index_ = -1; |
| 830 len_ = 0; | 830 len_ = 0; |
| 831 result_ = isolate->factory()->NewJSArray(10); | 831 result_ = isolate->factory()->NewJSArray(10); |
| 832 } | 832 } |
| 833 | 833 |
| 834 void FunctionStarted(FunctionLiteral* fun) { | 834 void FunctionStarted(FunctionLiteral* fun) { |
| 835 HandleScope scope(isolate()); | 835 HandleScope scope(isolate()); |
| 836 FunctionInfoWrapper info = FunctionInfoWrapper::Create(); | 836 FunctionInfoWrapper info = FunctionInfoWrapper::Create(isolate()); |
| 837 info.SetInitialProperties(fun->name(), fun->start_position(), | 837 info.SetInitialProperties(fun->name(), fun->start_position(), |
| 838 fun->end_position(), fun->parameter_count(), | 838 fun->end_position(), fun->parameter_count(), |
| 839 fun->materialized_literal_count(), | 839 fun->materialized_literal_count(), |
| 840 current_parent_index_); | 840 current_parent_index_); |
| 841 current_parent_index_ = len_; | 841 current_parent_index_ = len_; |
| 842 SetElementNonStrict(result_, len_, info.GetJSArray()); | 842 SetElementNonStrict(result_, len_, info.GetJSArray()); |
| 843 len_++; | 843 len_++; |
| 844 } | 844 } |
| 845 | 845 |
| 846 void FunctionDone() { | 846 void FunctionDone() { |
| 847 HandleScope scope(isolate()); | 847 HandleScope scope(isolate()); |
| 848 FunctionInfoWrapper info = | 848 FunctionInfoWrapper info = |
| 849 FunctionInfoWrapper::cast( | 849 FunctionInfoWrapper::cast( |
| 850 result_->GetElementNoExceptionThrown( | 850 result_->GetElementNoExceptionThrown( |
| 851 isolate(), current_parent_index_)); | 851 isolate(), current_parent_index_)); |
| 852 current_parent_index_ = info.GetParentIndex(); | 852 current_parent_index_ = info.GetParentIndex(); |
| 853 } | 853 } |
| 854 | 854 |
| 855 // Saves only function code, because for a script function we | 855 // Saves only function code, because for a script function we |
| 856 // may never create a SharedFunctionInfo object. | 856 // may never create a SharedFunctionInfo object. |
| 857 void FunctionCode(Handle<Code> function_code) { | 857 void FunctionCode(Handle<Code> function_code) { |
| 858 FunctionInfoWrapper info = | 858 FunctionInfoWrapper info = |
| 859 FunctionInfoWrapper::cast( | 859 FunctionInfoWrapper::cast( |
| 860 result_->GetElementNoExceptionThrown( | 860 result_->GetElementNoExceptionThrown( |
| 861 isolate(), current_parent_index_)); | 861 isolate(), current_parent_index_)); |
| 862 info.SetFunctionCode(function_code, | 862 info.SetFunctionCode(function_code, |
| 863 Handle<Object>(isolate()->heap()->null_value(), | 863 Handle<HeapObject>(isolate()->heap()->null_value())); |
| 864 isolate())); | |
| 865 } | 864 } |
| 866 | 865 |
| 867 // Saves full information about a function: its code, its scope info | 866 // Saves full information about a function: its code, its scope info |
| 868 // and a SharedFunctionInfo object. | 867 // and a SharedFunctionInfo object. |
| 869 void FunctionInfo(Handle<SharedFunctionInfo> shared, Scope* scope, | 868 void FunctionInfo(Handle<SharedFunctionInfo> shared, Scope* scope, |
| 870 Zone* zone) { | 869 Zone* zone) { |
| 871 if (!shared->IsSharedFunctionInfo()) { | 870 if (!shared->IsSharedFunctionInfo()) { |
| 872 return; | 871 return; |
| 873 } | 872 } |
| 874 FunctionInfoWrapper info = | 873 FunctionInfoWrapper info = |
| 875 FunctionInfoWrapper::cast( | 874 FunctionInfoWrapper::cast( |
| 876 result_->GetElementNoExceptionThrown( | 875 result_->GetElementNoExceptionThrown( |
| 877 isolate(), current_parent_index_)); | 876 isolate(), current_parent_index_)); |
| 878 info.SetFunctionCode(Handle<Code>(shared->code()), | 877 info.SetFunctionCode(Handle<Code>(shared->code()), |
| 879 Handle<Object>(shared->scope_info(), isolate())); | 878 Handle<HeapObject>(shared->scope_info())); |
| 880 info.SetSharedFunctionInfo(shared); | 879 info.SetSharedFunctionInfo(shared); |
| 881 | 880 |
| 882 Handle<Object> scope_info_list(SerializeFunctionScope(scope, zone), | 881 Handle<Object> scope_info_list(SerializeFunctionScope(scope, zone), |
| 883 isolate()); | 882 isolate()); |
| 884 info.SetOuterScopeInfo(scope_info_list); | 883 info.SetOuterScopeInfo(scope_info_list); |
| 885 } | 884 } |
| 886 | 885 |
| 887 Handle<JSArray> GetResult() { return result_; } | 886 Handle<JSArray> GetResult() { return result_; } |
| 888 | 887 |
| 889 private: | 888 private: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 } | 931 } |
| 933 | 932 |
| 934 Handle<JSArray> result_; | 933 Handle<JSArray> result_; |
| 935 int len_; | 934 int len_; |
| 936 int current_parent_index_; | 935 int current_parent_index_; |
| 937 }; | 936 }; |
| 938 | 937 |
| 939 | 938 |
| 940 JSArray* LiveEdit::GatherCompileInfo(Handle<Script> script, | 939 JSArray* LiveEdit::GatherCompileInfo(Handle<Script> script, |
| 941 Handle<String> source) { | 940 Handle<String> source) { |
| 942 Isolate* isolate = Isolate::Current(); | 941 Isolate* isolate = script->GetIsolate(); |
| 943 | 942 |
| 944 FunctionInfoListener listener(isolate); | 943 FunctionInfoListener listener(isolate); |
| 945 Handle<Object> original_source = | 944 Handle<Object> original_source = |
| 946 Handle<Object>(script->source(), isolate); | 945 Handle<Object>(script->source(), isolate); |
| 947 script->set_source(*source); | 946 script->set_source(*source); |
| 948 isolate->set_active_function_info_listener(&listener); | 947 isolate->set_active_function_info_listener(&listener); |
| 949 | 948 |
| 950 { | 949 { |
| 951 // Creating verbose TryCatch from public API is currently the only way to | 950 // Creating verbose TryCatch from public API is currently the only way to |
| 952 // force code save location. We do not use this the object directly. | 951 // force code save location. We do not use this the object directly. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 } | 1003 } |
| 1005 | 1004 |
| 1006 | 1005 |
| 1007 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { | 1006 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { |
| 1008 Isolate* isolate = array->GetIsolate(); | 1007 Isolate* isolate = array->GetIsolate(); |
| 1009 HandleScope scope(isolate); | 1008 HandleScope scope(isolate); |
| 1010 int len = GetArrayLength(array); | 1009 int len = GetArrayLength(array); |
| 1011 for (int i = 0; i < len; i++) { | 1010 for (int i = 0; i < len; i++) { |
| 1012 Handle<SharedFunctionInfo> info( | 1011 Handle<SharedFunctionInfo> info( |
| 1013 SharedFunctionInfo::cast( | 1012 SharedFunctionInfo::cast( |
| 1014 array->GetElementNoExceptionThrown(array->GetIsolate(), i))); | 1013 array->GetElementNoExceptionThrown(isolate, i))); |
| 1015 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); | 1014 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(isolate); |
| 1016 Handle<String> name_handle(String::cast(info->name())); | 1015 Handle<String> name_handle(String::cast(info->name())); |
| 1017 info_wrapper.SetProperties(name_handle, info->start_position(), | 1016 info_wrapper.SetProperties(name_handle, info->start_position(), |
| 1018 info->end_position(), info); | 1017 info->end_position(), info); |
| 1019 SetElementNonStrict(array, i, info_wrapper.GetJSArray()); | 1018 SetElementNonStrict(array, i, info_wrapper.GetJSArray()); |
| 1020 } | 1019 } |
| 1021 } | 1020 } |
| 1022 | 1021 |
| 1023 | 1022 |
| 1024 // Visitor that finds all references to a particular code object, | 1023 // Visitor that finds all references to a particular code object, |
| 1025 // including "CODE_TARGET" references in other code objects and replaces | 1024 // including "CODE_TARGET" references in other code objects and replaces |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 DisallowHeapAllocation no_allocation; | 1267 DisallowHeapAllocation no_allocation; |
| 1269 | 1268 |
| 1270 DependentFunctionFilter filter(function_info); | 1269 DependentFunctionFilter filter(function_info); |
| 1271 Deoptimizer::DeoptimizeAllFunctionsWith(function_info->GetIsolate(), &filter); | 1270 Deoptimizer::DeoptimizeAllFunctionsWith(function_info->GetIsolate(), &filter); |
| 1272 } | 1271 } |
| 1273 | 1272 |
| 1274 | 1273 |
| 1275 MaybeObject* LiveEdit::ReplaceFunctionCode( | 1274 MaybeObject* LiveEdit::ReplaceFunctionCode( |
| 1276 Handle<JSArray> new_compile_info_array, | 1275 Handle<JSArray> new_compile_info_array, |
| 1277 Handle<JSArray> shared_info_array) { | 1276 Handle<JSArray> shared_info_array) { |
| 1278 Isolate* isolate = Isolate::Current(); | 1277 Isolate* isolate = new_compile_info_array->GetIsolate(); |
| 1279 HandleScope scope(isolate); | 1278 HandleScope scope(isolate); |
| 1280 | 1279 |
| 1281 if (!SharedInfoWrapper::IsInstance(shared_info_array)) { | 1280 if (!SharedInfoWrapper::IsInstance(shared_info_array)) { |
| 1282 return isolate->ThrowIllegalOperation(); | 1281 return isolate->ThrowIllegalOperation(); |
| 1283 } | 1282 } |
| 1284 | 1283 |
| 1285 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); | 1284 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); |
| 1286 SharedInfoWrapper shared_info_wrapper(shared_info_array); | 1285 SharedInfoWrapper shared_info_wrapper(shared_info_array); |
| 1287 | 1286 |
| 1288 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); | 1287 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 } | 1341 } |
| 1343 | 1342 |
| 1344 | 1343 |
| 1345 void LiveEdit::SetFunctionScript(Handle<JSValue> function_wrapper, | 1344 void LiveEdit::SetFunctionScript(Handle<JSValue> function_wrapper, |
| 1346 Handle<Object> script_handle) { | 1345 Handle<Object> script_handle) { |
| 1347 Handle<SharedFunctionInfo> shared_info = | 1346 Handle<SharedFunctionInfo> shared_info = |
| 1348 UnwrapSharedFunctionInfoFromJSValue(function_wrapper); | 1347 UnwrapSharedFunctionInfoFromJSValue(function_wrapper); |
| 1349 CHECK(script_handle->IsScript() || script_handle->IsUndefined()); | 1348 CHECK(script_handle->IsScript() || script_handle->IsUndefined()); |
| 1350 shared_info->set_script(*script_handle); | 1349 shared_info->set_script(*script_handle); |
| 1351 | 1350 |
| 1352 Isolate::Current()->compilation_cache()->Remove(shared_info); | 1351 function_wrapper->GetIsolate()->compilation_cache()->Remove(shared_info); |
| 1353 } | 1352 } |
| 1354 | 1353 |
| 1355 | 1354 |
| 1356 // For a script text change (defined as position_change_array), translates | 1355 // For a script text change (defined as position_change_array), translates |
| 1357 // position in unchanged text to position in changed text. | 1356 // position in unchanged text to position in changed text. |
| 1358 // Text change is a set of non-overlapping regions in text, that have changed | 1357 // Text change is a set of non-overlapping regions in text, that have changed |
| 1359 // their contents and length. It is specified as array of groups of 3 numbers: | 1358 // their contents and length. It is specified as array of groups of 3 numbers: |
| 1360 // (change_begin, change_end, change_end_new_position). | 1359 // (change_begin, change_end, change_end_new_position). |
| 1361 // Each group describes a change in text; groups are sorted by change_begin. | 1360 // Each group describes a change in text; groups are sorted by change_begin. |
| 1362 // Only position in text beyond any changes may be successfully translated. | 1361 // Only position in text beyond any changes may be successfully translated. |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1511 // code object. | 1510 // code object. |
| 1512 Handle<Code> result(isolate->factory()->CopyCode(code, buffer)); | 1511 Handle<Code> result(isolate->factory()->CopyCode(code, buffer)); |
| 1513 return result; | 1512 return result; |
| 1514 } | 1513 } |
| 1515 } | 1514 } |
| 1516 | 1515 |
| 1517 | 1516 |
| 1518 MaybeObject* LiveEdit::PatchFunctionPositions( | 1517 MaybeObject* LiveEdit::PatchFunctionPositions( |
| 1519 Handle<JSArray> shared_info_array, Handle<JSArray> position_change_array) { | 1518 Handle<JSArray> shared_info_array, Handle<JSArray> position_change_array) { |
| 1520 if (!SharedInfoWrapper::IsInstance(shared_info_array)) { | 1519 if (!SharedInfoWrapper::IsInstance(shared_info_array)) { |
| 1521 return Isolate::Current()->ThrowIllegalOperation(); | 1520 return shared_info_array->GetIsolate()->ThrowIllegalOperation(); |
| 1522 } | 1521 } |
| 1523 | 1522 |
| 1524 SharedInfoWrapper shared_info_wrapper(shared_info_array); | 1523 SharedInfoWrapper shared_info_wrapper(shared_info_array); |
| 1525 Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo(); | 1524 Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo(); |
| 1526 | 1525 |
| 1527 int old_function_start = info->start_position(); | 1526 int old_function_start = info->start_position(); |
| 1528 int new_function_start = TranslatePosition(old_function_start, | 1527 int new_function_start = TranslatePosition(old_function_start, |
| 1529 position_change_array); | 1528 position_change_array); |
| 1530 int new_function_end = TranslatePosition(info->end_position(), | 1529 int new_function_end = TranslatePosition(info->end_position(), |
| 1531 position_change_array); | 1530 position_change_array); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1655 } | 1654 } |
| 1656 return false; | 1655 return false; |
| 1657 } | 1656 } |
| 1658 | 1657 |
| 1659 | 1658 |
| 1660 // Iterates over handler chain and removes all elements that are inside | 1659 // Iterates over handler chain and removes all elements that are inside |
| 1661 // frames being dropped. | 1660 // frames being dropped. |
| 1662 static bool FixTryCatchHandler(StackFrame* top_frame, | 1661 static bool FixTryCatchHandler(StackFrame* top_frame, |
| 1663 StackFrame* bottom_frame) { | 1662 StackFrame* bottom_frame) { |
| 1664 Address* pointer_address = | 1663 Address* pointer_address = |
| 1665 &Memory::Address_at(Isolate::Current()->get_address_from_id( | 1664 &Memory::Address_at(top_frame->isolate()->get_address_from_id( |
| 1666 Isolate::kHandlerAddress)); | 1665 Isolate::kHandlerAddress)); |
| 1667 | 1666 |
| 1668 while (*pointer_address < top_frame->sp()) { | 1667 while (*pointer_address < top_frame->sp()) { |
| 1669 pointer_address = &Memory::Address_at(*pointer_address); | 1668 pointer_address = &Memory::Address_at(*pointer_address); |
| 1670 } | 1669 } |
| 1671 Address* above_frame_address = pointer_address; | 1670 Address* above_frame_address = pointer_address; |
| 1672 while (*pointer_address < bottom_frame->fp()) { | 1671 while (*pointer_address < bottom_frame->fp()) { |
| 1673 pointer_address = &Memory::Address_at(*pointer_address); | 1672 pointer_address = &Memory::Address_at(*pointer_address); |
| 1674 } | 1673 } |
| 1675 bool change = *above_frame_address != *pointer_address; | 1674 bool change = *above_frame_address != *pointer_address; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1691 return "Stack manipulations are not supported in this architecture."; | 1690 return "Stack manipulations are not supported in this architecture."; |
| 1692 } | 1691 } |
| 1693 | 1692 |
| 1694 StackFrame* pre_top_frame = frames[top_frame_index - 1]; | 1693 StackFrame* pre_top_frame = frames[top_frame_index - 1]; |
| 1695 StackFrame* top_frame = frames[top_frame_index]; | 1694 StackFrame* top_frame = frames[top_frame_index]; |
| 1696 StackFrame* bottom_js_frame = frames[bottom_js_frame_index]; | 1695 StackFrame* bottom_js_frame = frames[bottom_js_frame_index]; |
| 1697 | 1696 |
| 1698 ASSERT(bottom_js_frame->is_java_script()); | 1697 ASSERT(bottom_js_frame->is_java_script()); |
| 1699 | 1698 |
| 1700 // Check the nature of the top frame. | 1699 // Check the nature of the top frame. |
| 1701 Isolate* isolate = Isolate::Current(); | 1700 Isolate* isolate = bottom_js_frame->isolate(); |
| 1702 Code* pre_top_frame_code = pre_top_frame->LookupCode(); | 1701 Code* pre_top_frame_code = pre_top_frame->LookupCode(); |
| 1703 bool frame_has_padding; | 1702 bool frame_has_padding; |
| 1704 if (pre_top_frame_code->is_inline_cache_stub() && | 1703 if (pre_top_frame_code->is_inline_cache_stub() && |
| 1705 pre_top_frame_code->is_debug_stub()) { | 1704 pre_top_frame_code->is_debug_stub()) { |
| 1706 // OK, we can drop inline cache calls. | 1705 // OK, we can drop inline cache calls. |
| 1707 *mode = Debug::FRAME_DROPPED_IN_IC_CALL; | 1706 *mode = Debug::FRAME_DROPPED_IN_IC_CALL; |
| 1708 frame_has_padding = Debug::FramePaddingLayout::kIsSupported; | 1707 frame_has_padding = Debug::FramePaddingLayout::kIsSupported; |
| 1709 } else if (pre_top_frame_code == | 1708 } else if (pre_top_frame_code == |
| 1710 isolate->debug()->debug_break_slot()) { | 1709 isolate->debug()->debug_break_slot()) { |
| 1711 // OK, we can drop debug break slot. | 1710 // OK, we can drop debug break slot. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 return "Not enough space for frame dropper frame"; | 1793 return "Not enough space for frame dropper frame"; |
| 1795 } | 1794 } |
| 1796 } | 1795 } |
| 1797 | 1796 |
| 1798 // Committing now. After this point we should return only NULL value. | 1797 // Committing now. After this point we should return only NULL value. |
| 1799 | 1798 |
| 1800 FixTryCatchHandler(pre_top_frame, bottom_js_frame); | 1799 FixTryCatchHandler(pre_top_frame, bottom_js_frame); |
| 1801 // Make sure FixTryCatchHandler is idempotent. | 1800 // Make sure FixTryCatchHandler is idempotent. |
| 1802 ASSERT(!FixTryCatchHandler(pre_top_frame, bottom_js_frame)); | 1801 ASSERT(!FixTryCatchHandler(pre_top_frame, bottom_js_frame)); |
| 1803 | 1802 |
| 1804 Handle<Code> code = Isolate::Current()->builtins()->FrameDropper_LiveEdit(); | 1803 Handle<Code> code = isolate->builtins()->FrameDropper_LiveEdit(); |
| 1805 *top_frame_pc_address = code->entry(); | 1804 *top_frame_pc_address = code->entry(); |
| 1806 pre_top_frame->SetCallerFp(bottom_js_frame->fp()); | 1805 pre_top_frame->SetCallerFp(bottom_js_frame->fp()); |
| 1807 | 1806 |
| 1808 *restarter_frame_function_pointer = | 1807 *restarter_frame_function_pointer = |
| 1809 Debug::SetUpFrameDropperFrame(bottom_js_frame, code); | 1808 Debug::SetUpFrameDropperFrame(bottom_js_frame, code); |
| 1810 | 1809 |
| 1811 ASSERT((**restarter_frame_function_pointer)->IsJSFunction()); | 1810 ASSERT((**restarter_frame_function_pointer)->IsJSFunction()); |
| 1812 | 1811 |
| 1813 for (Address a = unused_stack_top; | 1812 for (Address a = unused_stack_top; |
| 1814 a < unused_stack_bottom; | 1813 a < unused_stack_bottom; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1842 } | 1841 } |
| 1843 private: | 1842 private: |
| 1844 Handle<JSArray> m_shared_info_array; | 1843 Handle<JSArray> m_shared_info_array; |
| 1845 Handle<JSArray> m_result; | 1844 Handle<JSArray> m_result; |
| 1846 }; | 1845 }; |
| 1847 | 1846 |
| 1848 | 1847 |
| 1849 // Drops all call frame matched by target and all frames above them. | 1848 // Drops all call frame matched by target and all frames above them. |
| 1850 template<typename TARGET> | 1849 template<typename TARGET> |
| 1851 static const char* DropActivationsInActiveThreadImpl( | 1850 static const char* DropActivationsInActiveThreadImpl( |
| 1852 TARGET& target, bool do_drop) { | 1851 Isolate* isolate, TARGET& target, bool do_drop) { |
| 1853 Isolate* isolate = Isolate::Current(); | |
| 1854 Debug* debug = isolate->debug(); | 1852 Debug* debug = isolate->debug(); |
| 1855 Zone zone(isolate); | 1853 Zone zone(isolate); |
| 1856 Vector<StackFrame*> frames = CreateStackMap(isolate, &zone); | 1854 Vector<StackFrame*> frames = CreateStackMap(isolate, &zone); |
| 1857 | 1855 |
| 1858 | 1856 |
| 1859 int top_frame_index = -1; | 1857 int top_frame_index = -1; |
| 1860 int frame_index = 0; | 1858 int frame_index = 0; |
| 1861 for (; frame_index < frames.length(); frame_index++) { | 1859 for (; frame_index < frames.length(); frame_index++) { |
| 1862 StackFrame* frame = frames[frame_index]; | 1860 StackFrame* frame = frames[frame_index]; |
| 1863 if (frame->id() == debug->break_frame_id()) { | 1861 if (frame->id() == debug->break_frame_id()) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1942 return NULL; | 1940 return NULL; |
| 1943 } | 1941 } |
| 1944 | 1942 |
| 1945 | 1943 |
| 1946 // Fills result array with statuses of functions. Modifies the stack | 1944 // Fills result array with statuses of functions. Modifies the stack |
| 1947 // removing all listed function if possible and if do_drop is true. | 1945 // removing all listed function if possible and if do_drop is true. |
| 1948 static const char* DropActivationsInActiveThread( | 1946 static const char* DropActivationsInActiveThread( |
| 1949 Handle<JSArray> shared_info_array, Handle<JSArray> result, bool do_drop) { | 1947 Handle<JSArray> shared_info_array, Handle<JSArray> result, bool do_drop) { |
| 1950 MultipleFunctionTarget target(shared_info_array, result); | 1948 MultipleFunctionTarget target(shared_info_array, result); |
| 1951 | 1949 |
| 1952 const char* message = | 1950 const char* message = DropActivationsInActiveThreadImpl( |
| 1953 DropActivationsInActiveThreadImpl(target, do_drop); | 1951 shared_info_array->GetIsolate(), target, do_drop); |
| 1954 if (message) { | 1952 if (message) { |
| 1955 return message; | 1953 return message; |
| 1956 } | 1954 } |
| 1957 | 1955 |
| 1958 Isolate* isolate = shared_info_array->GetIsolate(); | 1956 Isolate* isolate = shared_info_array->GetIsolate(); |
| 1959 int array_len = GetArrayLength(shared_info_array); | 1957 int array_len = GetArrayLength(shared_info_array); |
| 1960 | 1958 |
| 1961 // Replace "blocked on active" with "replaced on active" status. | 1959 // Replace "blocked on active" with "replaced on active" status. |
| 1962 for (int i = 0; i < array_len; i++) { | 1960 for (int i = 0; i < array_len; i++) { |
| 1963 if (result->GetElement(result->GetIsolate(), i) == | 1961 if (result->GetElement(result->GetIsolate(), i) == |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2008 SetElementNonStrict( | 2006 SetElementNonStrict( |
| 2009 result, | 2007 result, |
| 2010 i, | 2008 i, |
| 2011 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH), isolate)); | 2009 Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH), isolate)); |
| 2012 } | 2010 } |
| 2013 | 2011 |
| 2014 | 2012 |
| 2015 // First check inactive threads. Fail if some functions are blocked there. | 2013 // First check inactive threads. Fail if some functions are blocked there. |
| 2016 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, | 2014 InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array, |
| 2017 result); | 2015 result); |
| 2018 Isolate::Current()->thread_manager()->IterateArchivedThreads( | 2016 isolate->thread_manager()->IterateArchivedThreads( |
| 2019 &inactive_threads_checker); | 2017 &inactive_threads_checker); |
| 2020 if (inactive_threads_checker.HasBlockedFunctions()) { | 2018 if (inactive_threads_checker.HasBlockedFunctions()) { |
| 2021 return result; | 2019 return result; |
| 2022 } | 2020 } |
| 2023 | 2021 |
| 2024 // Try to drop activations from the current stack. | 2022 // Try to drop activations from the current stack. |
| 2025 const char* error_message = | 2023 const char* error_message = |
| 2026 DropActivationsInActiveThread(shared_info_array, result, do_drop); | 2024 DropActivationsInActiveThread(shared_info_array, result, do_drop); |
| 2027 if (error_message != NULL) { | 2025 if (error_message != NULL) { |
| 2028 // Add error message as an array extra element. | 2026 // Add error message as an array extra element. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2060 JavaScriptFrame* m_frame; | 2058 JavaScriptFrame* m_frame; |
| 2061 LiveEdit::FunctionPatchabilityStatus m_saved_status; | 2059 LiveEdit::FunctionPatchabilityStatus m_saved_status; |
| 2062 }; | 2060 }; |
| 2063 | 2061 |
| 2064 | 2062 |
| 2065 // Finds a drops required frame and all frames above. | 2063 // Finds a drops required frame and all frames above. |
| 2066 // Returns error message or NULL. | 2064 // Returns error message or NULL. |
| 2067 const char* LiveEdit::RestartFrame(JavaScriptFrame* frame) { | 2065 const char* LiveEdit::RestartFrame(JavaScriptFrame* frame) { |
| 2068 SingleFrameTarget target(frame); | 2066 SingleFrameTarget target(frame); |
| 2069 | 2067 |
| 2070 const char* result = DropActivationsInActiveThreadImpl(target, true); | 2068 const char* result = DropActivationsInActiveThreadImpl( |
| 2069 frame->isolate(), target, true); |
| 2071 if (result != NULL) { | 2070 if (result != NULL) { |
| 2072 return result; | 2071 return result; |
| 2073 } | 2072 } |
| 2074 if (target.saved_status() == LiveEdit::FUNCTION_BLOCKED_UNDER_NATIVE_CODE) { | 2073 if (target.saved_status() == LiveEdit::FUNCTION_BLOCKED_UNDER_NATIVE_CODE) { |
| 2075 return "Function is blocked under native code"; | 2074 return "Function is blocked under native code"; |
| 2076 } | 2075 } |
| 2077 return NULL; | 2076 return NULL; |
| 2078 } | 2077 } |
| 2079 | 2078 |
| 2080 | 2079 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2139 | 2138 |
| 2140 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { | 2139 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { |
| 2141 return false; | 2140 return false; |
| 2142 } | 2141 } |
| 2143 | 2142 |
| 2144 #endif // ENABLE_DEBUGGER_SUPPORT | 2143 #endif // ENABLE_DEBUGGER_SUPPORT |
| 2145 | 2144 |
| 2146 | 2145 |
| 2147 | 2146 |
| 2148 } } // namespace v8::internal | 2147 } } // namespace v8::internal |
| OLD | NEW |