| 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 | 5 |
| 6 #include "v8.h" | 6 #include "v8.h" |
| 7 | 7 |
| 8 #include "liveedit.h" | 8 #include "liveedit.h" |
| 9 | 9 |
| 10 #include "code-stubs.h" | 10 #include "code-stubs.h" |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 CHECK(length->IsSmi()); | 603 CHECK(length->IsSmi()); |
| 604 return Smi::cast(length)->value(); | 604 return Smi::cast(length)->value(); |
| 605 } | 605 } |
| 606 | 606 |
| 607 | 607 |
| 608 void FunctionInfoWrapper::SetInitialProperties(Handle<String> name, | 608 void FunctionInfoWrapper::SetInitialProperties(Handle<String> name, |
| 609 int start_position, | 609 int start_position, |
| 610 int end_position, | 610 int end_position, |
| 611 int param_num, | 611 int param_num, |
| 612 int literal_count, | 612 int literal_count, |
| 613 int slot_count, |
| 613 int parent_index) { | 614 int parent_index) { |
| 614 HandleScope scope(isolate()); | 615 HandleScope scope(isolate()); |
| 615 this->SetField(kFunctionNameOffset_, name); | 616 this->SetField(kFunctionNameOffset_, name); |
| 616 this->SetSmiValueField(kStartPositionOffset_, start_position); | 617 this->SetSmiValueField(kStartPositionOffset_, start_position); |
| 617 this->SetSmiValueField(kEndPositionOffset_, end_position); | 618 this->SetSmiValueField(kEndPositionOffset_, end_position); |
| 618 this->SetSmiValueField(kParamNumOffset_, param_num); | 619 this->SetSmiValueField(kParamNumOffset_, param_num); |
| 619 this->SetSmiValueField(kLiteralNumOffset_, literal_count); | 620 this->SetSmiValueField(kLiteralNumOffset_, literal_count); |
| 621 this->SetSmiValueField(kSlotNumOffset_, slot_count); |
| 620 this->SetSmiValueField(kParentIndexOffset_, parent_index); | 622 this->SetSmiValueField(kParentIndexOffset_, parent_index); |
| 621 } | 623 } |
| 622 | 624 |
| 623 | 625 |
| 624 void FunctionInfoWrapper::SetFunctionCode(Handle<Code> function_code, | 626 void FunctionInfoWrapper::SetFunctionCode(Handle<Code> function_code, |
| 625 Handle<HeapObject> code_scope_info) { | 627 Handle<HeapObject> code_scope_info) { |
| 626 Handle<JSValue> code_wrapper = WrapInJSValue(function_code); | 628 Handle<JSValue> code_wrapper = WrapInJSValue(function_code); |
| 627 this->SetField(kCodeOffset_, code_wrapper); | 629 this->SetField(kCodeOffset_, code_wrapper); |
| 628 | 630 |
| 629 Handle<JSValue> scope_wrapper = WrapInJSValue(code_scope_info); | 631 Handle<JSValue> scope_wrapper = WrapInJSValue(code_scope_info); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 640 | 642 |
| 641 Handle<Code> FunctionInfoWrapper::GetFunctionCode() { | 643 Handle<Code> FunctionInfoWrapper::GetFunctionCode() { |
| 642 Handle<Object> element = this->GetField(kCodeOffset_); | 644 Handle<Object> element = this->GetField(kCodeOffset_); |
| 643 Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element); | 645 Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element); |
| 644 Handle<Object> raw_result = UnwrapJSValue(value_wrapper); | 646 Handle<Object> raw_result = UnwrapJSValue(value_wrapper); |
| 645 CHECK(raw_result->IsCode()); | 647 CHECK(raw_result->IsCode()); |
| 646 return Handle<Code>::cast(raw_result); | 648 return Handle<Code>::cast(raw_result); |
| 647 } | 649 } |
| 648 | 650 |
| 649 | 651 |
| 652 Handle<FixedArray> FunctionInfoWrapper::GetFeedbackVector() { |
| 653 Handle<Object> element = this->GetField(kSharedFunctionInfoOffset_); |
| 654 Handle<FixedArray> result; |
| 655 if (element->IsJSValue()) { |
| 656 Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element); |
| 657 Handle<Object> raw_result = UnwrapJSValue(value_wrapper); |
| 658 Handle<SharedFunctionInfo> shared = |
| 659 Handle<SharedFunctionInfo>::cast(raw_result); |
| 660 result = Handle<FixedArray>(shared->feedback_vector(), isolate()); |
| 661 CHECK_EQ(result->length(), GetSlotCount()); |
| 662 } else { |
| 663 // Scripts may never have a SharedFunctionInfo created, so |
| 664 // create a type feedback vector here. |
| 665 int slot_count = GetSlotCount(); |
| 666 result = isolate()->factory()->NewTypeFeedbackVector(slot_count); |
| 667 } |
| 668 return result; |
| 669 } |
| 670 |
| 671 |
| 650 Handle<Object> FunctionInfoWrapper::GetCodeScopeInfo() { | 672 Handle<Object> FunctionInfoWrapper::GetCodeScopeInfo() { |
| 651 Handle<Object> element = this->GetField(kCodeScopeInfoOffset_); | 673 Handle<Object> element = this->GetField(kCodeScopeInfoOffset_); |
| 652 return UnwrapJSValue(Handle<JSValue>::cast(element)); | 674 return UnwrapJSValue(Handle<JSValue>::cast(element)); |
| 653 } | 675 } |
| 654 | 676 |
| 655 | 677 |
| 656 void SharedInfoWrapper::SetProperties(Handle<String> name, | 678 void SharedInfoWrapper::SetProperties(Handle<String> name, |
| 657 int start_position, | 679 int start_position, |
| 658 int end_position, | 680 int end_position, |
| 659 Handle<SharedFunctionInfo> info) { | 681 Handle<SharedFunctionInfo> info) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 680 len_ = 0; | 702 len_ = 0; |
| 681 result_ = isolate->factory()->NewJSArray(10); | 703 result_ = isolate->factory()->NewJSArray(10); |
| 682 } | 704 } |
| 683 | 705 |
| 684 void FunctionStarted(FunctionLiteral* fun) { | 706 void FunctionStarted(FunctionLiteral* fun) { |
| 685 HandleScope scope(isolate()); | 707 HandleScope scope(isolate()); |
| 686 FunctionInfoWrapper info = FunctionInfoWrapper::Create(isolate()); | 708 FunctionInfoWrapper info = FunctionInfoWrapper::Create(isolate()); |
| 687 info.SetInitialProperties(fun->name(), fun->start_position(), | 709 info.SetInitialProperties(fun->name(), fun->start_position(), |
| 688 fun->end_position(), fun->parameter_count(), | 710 fun->end_position(), fun->parameter_count(), |
| 689 fun->materialized_literal_count(), | 711 fun->materialized_literal_count(), |
| 712 fun->slot_count(), |
| 690 current_parent_index_); | 713 current_parent_index_); |
| 691 current_parent_index_ = len_; | 714 current_parent_index_ = len_; |
| 692 SetElementSloppy(result_, len_, info.GetJSArray()); | 715 SetElementSloppy(result_, len_, info.GetJSArray()); |
| 693 len_++; | 716 len_++; |
| 694 } | 717 } |
| 695 | 718 |
| 696 void FunctionDone() { | 719 void FunctionDone() { |
| 697 HandleScope scope(isolate()); | 720 HandleScope scope(isolate()); |
| 698 FunctionInfoWrapper info = | 721 FunctionInfoWrapper info = |
| 699 FunctionInfoWrapper::cast( | 722 FunctionInfoWrapper::cast( |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 isolate->heap()->EnsureHeapIsIterable(); | 1168 isolate->heap()->EnsureHeapIsIterable(); |
| 1146 | 1169 |
| 1147 if (IsJSFunctionCode(shared_info->code())) { | 1170 if (IsJSFunctionCode(shared_info->code())) { |
| 1148 Handle<Code> code = compile_info_wrapper.GetFunctionCode(); | 1171 Handle<Code> code = compile_info_wrapper.GetFunctionCode(); |
| 1149 ReplaceCodeObject(Handle<Code>(shared_info->code()), code); | 1172 ReplaceCodeObject(Handle<Code>(shared_info->code()), code); |
| 1150 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); | 1173 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); |
| 1151 if (code_scope_info->IsFixedArray()) { | 1174 if (code_scope_info->IsFixedArray()) { |
| 1152 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info)); | 1175 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info)); |
| 1153 } | 1176 } |
| 1154 shared_info->DisableOptimization(kLiveEdit); | 1177 shared_info->DisableOptimization(kLiveEdit); |
| 1178 // Update the type feedback vector |
| 1179 Handle<FixedArray> feedback_vector = |
| 1180 compile_info_wrapper.GetFeedbackVector(); |
| 1181 shared_info->set_feedback_vector(*feedback_vector); |
| 1155 } | 1182 } |
| 1156 | 1183 |
| 1157 if (shared_info->debug_info()->IsDebugInfo()) { | 1184 if (shared_info->debug_info()->IsDebugInfo()) { |
| 1158 Handle<DebugInfo> debug_info(DebugInfo::cast(shared_info->debug_info())); | 1185 Handle<DebugInfo> debug_info(DebugInfo::cast(shared_info->debug_info())); |
| 1159 Handle<Code> new_original_code = | 1186 Handle<Code> new_original_code = |
| 1160 isolate->factory()->CopyCode(compile_info_wrapper.GetFunctionCode()); | 1187 isolate->factory()->CopyCode(compile_info_wrapper.GetFunctionCode()); |
| 1161 debug_info->set_original_code(*new_original_code); | 1188 debug_info->set_original_code(*new_original_code); |
| 1162 } | 1189 } |
| 1163 | 1190 |
| 1164 int start_position = compile_info_wrapper.GetStartPosition(); | 1191 int start_position = compile_info_wrapper.GetStartPosition(); |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1943 void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) { | 1970 void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) { |
| 1944 isolate_->active_function_info_listener()->FunctionCode(code); | 1971 isolate_->active_function_info_listener()->FunctionCode(code); |
| 1945 } | 1972 } |
| 1946 | 1973 |
| 1947 | 1974 |
| 1948 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { | 1975 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { |
| 1949 return isolate->active_function_info_listener() != NULL; | 1976 return isolate->active_function_info_listener() != NULL; |
| 1950 } | 1977 } |
| 1951 | 1978 |
| 1952 } } // namespace v8::internal | 1979 } } // namespace v8::internal |
| OLD | NEW |