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 "src/debug/liveedit.h" | 5 #include "src/debug/liveedit.h" |
6 | 6 |
7 #include "src/ast/scopeinfo.h" | 7 #include "src/ast/scopeinfo.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 int parent_index) { | 614 int parent_index) { |
615 HandleScope scope(isolate()); | 615 HandleScope scope(isolate()); |
616 this->SetField(kFunctionNameOffset_, name); | 616 this->SetField(kFunctionNameOffset_, name); |
617 this->SetSmiValueField(kStartPositionOffset_, start_position); | 617 this->SetSmiValueField(kStartPositionOffset_, start_position); |
618 this->SetSmiValueField(kEndPositionOffset_, end_position); | 618 this->SetSmiValueField(kEndPositionOffset_, end_position); |
619 this->SetSmiValueField(kParamNumOffset_, param_num); | 619 this->SetSmiValueField(kParamNumOffset_, param_num); |
620 this->SetSmiValueField(kLiteralNumOffset_, literal_count); | 620 this->SetSmiValueField(kLiteralNumOffset_, literal_count); |
621 this->SetSmiValueField(kParentIndexOffset_, parent_index); | 621 this->SetSmiValueField(kParentIndexOffset_, parent_index); |
622 } | 622 } |
623 | 623 |
624 | 624 void FunctionInfoWrapper::SetFunctionCode(Handle<AbstractCode> function_code, |
625 void FunctionInfoWrapper::SetFunctionCode(Handle<Code> function_code, | |
626 Handle<HeapObject> code_scope_info) { | 625 Handle<HeapObject> code_scope_info) { |
627 // CompileForLiveEdit must deliver full-codegen code. | 626 // CompileForLiveEdit must deliver full-codegen code. |
628 DCHECK(function_code->kind() == Code::FUNCTION); | |
629 Handle<JSValue> code_wrapper = WrapInJSValue(function_code); | 627 Handle<JSValue> code_wrapper = WrapInJSValue(function_code); |
630 this->SetField(kCodeOffset_, code_wrapper); | 628 this->SetField(kCodeOffset_, code_wrapper); |
631 | 629 |
632 Handle<JSValue> scope_wrapper = WrapInJSValue(code_scope_info); | 630 Handle<JSValue> scope_wrapper = WrapInJSValue(code_scope_info); |
633 this->SetField(kCodeScopeInfoOffset_, scope_wrapper); | 631 this->SetField(kCodeScopeInfoOffset_, scope_wrapper); |
634 } | 632 } |
635 | 633 |
636 | 634 |
637 void FunctionInfoWrapper::SetSharedFunctionInfo( | 635 void FunctionInfoWrapper::SetSharedFunctionInfo( |
638 Handle<SharedFunctionInfo> info) { | 636 Handle<SharedFunctionInfo> info) { |
639 Handle<JSValue> info_holder = WrapInJSValue(info); | 637 Handle<JSValue> info_holder = WrapInJSValue(info); |
640 this->SetField(kSharedFunctionInfoOffset_, info_holder); | 638 this->SetField(kSharedFunctionInfoOffset_, info_holder); |
641 } | 639 } |
642 | 640 |
643 | 641 Handle<AbstractCode> FunctionInfoWrapper::GetFunctionCode() { |
644 Handle<Code> FunctionInfoWrapper::GetFunctionCode() { | |
645 Handle<Object> element = this->GetField(kCodeOffset_); | 642 Handle<Object> element = this->GetField(kCodeOffset_); |
646 Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element); | 643 Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element); |
647 Handle<Object> raw_result = UnwrapJSValue(value_wrapper); | 644 Handle<Object> raw_result = UnwrapJSValue(value_wrapper); |
648 CHECK(raw_result->IsCode()); | 645 CHECK(raw_result->IsAbstractCode()); |
649 return Handle<Code>::cast(raw_result); | 646 return Handle<AbstractCode>::cast(raw_result); |
650 } | 647 } |
651 | 648 |
652 MaybeHandle<TypeFeedbackMetadata> FunctionInfoWrapper::GetFeedbackMetadata() { | 649 MaybeHandle<TypeFeedbackMetadata> FunctionInfoWrapper::GetFeedbackMetadata() { |
653 Handle<Object> element = this->GetField(kSharedFunctionInfoOffset_); | 650 Handle<Object> element = this->GetField(kSharedFunctionInfoOffset_); |
654 if (element->IsJSValue()) { | 651 if (element->IsJSValue()) { |
655 Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element); | 652 Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element); |
656 Handle<Object> raw_result = UnwrapJSValue(value_wrapper); | 653 Handle<Object> raw_result = UnwrapJSValue(value_wrapper); |
657 Handle<SharedFunctionInfo> shared = | 654 Handle<SharedFunctionInfo> shared = |
658 Handle<SharedFunctionInfo>::cast(raw_result); | 655 Handle<SharedFunctionInfo>::cast(raw_result); |
659 return Handle<TypeFeedbackMetadata>(shared->feedback_metadata(), isolate()); | 656 return Handle<TypeFeedbackMetadata>(shared->feedback_metadata(), isolate()); |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 Handle<JSArray> shared_info_array) { | 1002 Handle<JSArray> shared_info_array) { |
1006 Isolate* isolate = new_compile_info_array->GetIsolate(); | 1003 Isolate* isolate = new_compile_info_array->GetIsolate(); |
1007 | 1004 |
1008 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); | 1005 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); |
1009 SharedInfoWrapper shared_info_wrapper(shared_info_array); | 1006 SharedInfoWrapper shared_info_wrapper(shared_info_array); |
1010 | 1007 |
1011 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); | 1008 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); |
1012 bool feedback_metadata_changed = false; | 1009 bool feedback_metadata_changed = false; |
1013 | 1010 |
1014 if (shared_info->is_compiled()) { | 1011 if (shared_info->is_compiled()) { |
1015 Handle<Code> new_code = compile_info_wrapper.GetFunctionCode(); | 1012 Handle<AbstractCode> new_code = compile_info_wrapper.GetFunctionCode(); |
1016 Handle<Code> old_code(shared_info->code()); | |
1017 if (shared_info->HasBytecodeArray()) { | 1013 if (shared_info->HasBytecodeArray()) { |
1018 // The old code is interpreted. If we clear the bytecode array, the | 1014 DCHECK(new_code->IsBytecodeArray()); |
1019 // interpreter entry trampoline will self-heal and go to compiled code. | 1015 // The old code is interpreted, the new code must be interpreted as well. |
1020 shared_info->ClearBytecodeArray(); | 1016 shared_info->ClearBytecodeArray(); |
1021 shared_info->ReplaceCode(*new_code); | 1017 shared_info->set_bytecode_array(BytecodeArray::cast(*new_code)); |
1022 } else { | 1018 } else { |
| 1019 Handle<Code> old_code(shared_info->code()); |
1023 DCHECK(old_code->kind() == Code::FUNCTION); | 1020 DCHECK(old_code->kind() == Code::FUNCTION); |
1024 ReplaceCodeObject(old_code, new_code); | 1021 DCHECK(new_code->kind() == AbstractCode::FUNCTION); |
| 1022 ReplaceCodeObject(old_code, Handle<Code>::cast(new_code)); |
1025 } | 1023 } |
1026 if (shared_info->HasDebugInfo()) { | 1024 if (shared_info->HasDebugInfo()) { |
1027 // Existing break points will be re-applied. Reset the debug info here. | 1025 // Existing break points will be re-applied. Reset the debug info here. |
1028 isolate->debug()->RemoveDebugInfoAndClearFromShared( | 1026 isolate->debug()->RemoveDebugInfoAndClearFromShared( |
1029 handle(shared_info->GetDebugInfo())); | 1027 handle(shared_info->GetDebugInfo())); |
1030 } | 1028 } |
1031 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); | 1029 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); |
1032 if (code_scope_info->IsFixedArray()) { | 1030 if (code_scope_info->IsFixedArray()) { |
1033 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info)); | 1031 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info)); |
1034 } | 1032 } |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1995 } | 1993 } |
1996 | 1994 |
1997 // Saves full information about a function: its code, its scope info | 1995 // Saves full information about a function: its code, its scope info |
1998 // and a SharedFunctionInfo object. | 1996 // and a SharedFunctionInfo object. |
1999 void LiveEditFunctionTracker::FunctionDone(Handle<SharedFunctionInfo> shared, | 1997 void LiveEditFunctionTracker::FunctionDone(Handle<SharedFunctionInfo> shared, |
2000 Scope* scope) { | 1998 Scope* scope) { |
2001 HandleScope handle_scope(isolate_); | 1999 HandleScope handle_scope(isolate_); |
2002 FunctionInfoWrapper info = FunctionInfoWrapper::cast( | 2000 FunctionInfoWrapper info = FunctionInfoWrapper::cast( |
2003 *JSReceiver::GetElement(isolate_, result_, current_parent_index_) | 2001 *JSReceiver::GetElement(isolate_, result_, current_parent_index_) |
2004 .ToHandleChecked()); | 2002 .ToHandleChecked()); |
2005 info.SetFunctionCode(Handle<Code>(shared->code()), | 2003 info.SetFunctionCode(Handle<AbstractCode>(shared->abstract_code()), |
2006 Handle<HeapObject>(shared->scope_info())); | 2004 Handle<HeapObject>(shared->scope_info())); |
2007 info.SetSharedFunctionInfo(shared); | 2005 info.SetSharedFunctionInfo(shared); |
2008 | 2006 |
2009 Handle<Object> scope_info_list = SerializeFunctionScope(scope); | 2007 Handle<Object> scope_info_list = SerializeFunctionScope(scope); |
2010 info.SetFunctionScopeInfo(scope_info_list); | 2008 info.SetFunctionScopeInfo(scope_info_list); |
2011 | 2009 |
2012 current_parent_index_ = info.GetParentIndex(); | 2010 current_parent_index_ = info.GetParentIndex(); |
2013 } | 2011 } |
2014 | 2012 |
2015 Handle<Object> LiveEditFunctionTracker::SerializeFunctionScope(Scope* scope) { | 2013 Handle<Object> LiveEditFunctionTracker::SerializeFunctionScope(Scope* scope) { |
(...skipping 28 matching lines...) Expand all Loading... |
2044 scope_info_length++; | 2042 scope_info_length++; |
2045 | 2043 |
2046 current_scope = current_scope->outer_scope(); | 2044 current_scope = current_scope->outer_scope(); |
2047 } | 2045 } |
2048 | 2046 |
2049 return scope_info_list; | 2047 return scope_info_list; |
2050 } | 2048 } |
2051 | 2049 |
2052 } // namespace internal | 2050 } // namespace internal |
2053 } // namespace v8 | 2051 } // namespace v8 |
OLD | NEW |