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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 CHECK(length->IsSmi()); | 630 CHECK(length->IsSmi()); |
631 return Smi::cast(length)->value(); | 631 return Smi::cast(length)->value(); |
632 } | 632 } |
633 | 633 |
634 | 634 |
635 void FunctionInfoWrapper::SetInitialProperties(Handle<String> name, | 635 void FunctionInfoWrapper::SetInitialProperties(Handle<String> name, |
636 int start_position, | 636 int start_position, |
637 int end_position, | 637 int end_position, |
638 int param_num, | 638 int param_num, |
639 int literal_count, | 639 int literal_count, |
| 640 int slot_count, |
640 int parent_index) { | 641 int parent_index) { |
641 HandleScope scope(isolate()); | 642 HandleScope scope(isolate()); |
642 this->SetField(kFunctionNameOffset_, name); | 643 this->SetField(kFunctionNameOffset_, name); |
643 this->SetSmiValueField(kStartPositionOffset_, start_position); | 644 this->SetSmiValueField(kStartPositionOffset_, start_position); |
644 this->SetSmiValueField(kEndPositionOffset_, end_position); | 645 this->SetSmiValueField(kEndPositionOffset_, end_position); |
645 this->SetSmiValueField(kParamNumOffset_, param_num); | 646 this->SetSmiValueField(kParamNumOffset_, param_num); |
646 this->SetSmiValueField(kLiteralNumOffset_, literal_count); | 647 this->SetSmiValueField(kLiteralNumOffset_, literal_count); |
| 648 this->SetSmiValueField(kSlotNumOffset_, slot_count); |
647 this->SetSmiValueField(kParentIndexOffset_, parent_index); | 649 this->SetSmiValueField(kParentIndexOffset_, parent_index); |
648 } | 650 } |
649 | 651 |
650 | 652 |
651 void FunctionInfoWrapper::SetFunctionCode(Handle<Code> function_code, | 653 void FunctionInfoWrapper::SetFunctionCode(Handle<Code> function_code, |
652 Handle<HeapObject> code_scope_info) { | 654 Handle<HeapObject> code_scope_info) { |
653 Handle<JSValue> code_wrapper = WrapInJSValue(function_code); | 655 Handle<JSValue> code_wrapper = WrapInJSValue(function_code); |
654 this->SetField(kCodeOffset_, code_wrapper); | 656 this->SetField(kCodeOffset_, code_wrapper); |
655 | 657 |
656 Handle<JSValue> scope_wrapper = WrapInJSValue(code_scope_info); | 658 Handle<JSValue> scope_wrapper = WrapInJSValue(code_scope_info); |
(...skipping 10 matching lines...) Expand all Loading... |
667 | 669 |
668 Handle<Code> FunctionInfoWrapper::GetFunctionCode() { | 670 Handle<Code> FunctionInfoWrapper::GetFunctionCode() { |
669 Handle<Object> element = this->GetField(kCodeOffset_); | 671 Handle<Object> element = this->GetField(kCodeOffset_); |
670 Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element); | 672 Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element); |
671 Handle<Object> raw_result = UnwrapJSValue(value_wrapper); | 673 Handle<Object> raw_result = UnwrapJSValue(value_wrapper); |
672 CHECK(raw_result->IsCode()); | 674 CHECK(raw_result->IsCode()); |
673 return Handle<Code>::cast(raw_result); | 675 return Handle<Code>::cast(raw_result); |
674 } | 676 } |
675 | 677 |
676 | 678 |
| 679 Handle<FixedArray> FunctionInfoWrapper::GetFeedbackVector() { |
| 680 Handle<Object> element = this->GetField(kSharedFunctionInfoOffset_); |
| 681 Handle<FixedArray> result; |
| 682 if (element->IsJSValue()) { |
| 683 Handle<JSValue> value_wrapper = Handle<JSValue>::cast(element); |
| 684 Handle<Object> raw_result = UnwrapJSValue(value_wrapper); |
| 685 Handle<SharedFunctionInfo> shared = |
| 686 Handle<SharedFunctionInfo>::cast(raw_result); |
| 687 result = Handle<FixedArray>(shared->feedback_vector(), isolate()); |
| 688 CHECK_EQ(result->length(), GetSlotCount()); |
| 689 } else { |
| 690 // Scripts may never have a SharedFunctionInfo created, so |
| 691 // create a type feedback vector here. |
| 692 int slot_count = GetSlotCount(); |
| 693 result = isolate()->factory()->NewTypeFeedbackVector(slot_count); |
| 694 } |
| 695 return result; |
| 696 } |
| 697 |
| 698 |
677 Handle<Object> FunctionInfoWrapper::GetCodeScopeInfo() { | 699 Handle<Object> FunctionInfoWrapper::GetCodeScopeInfo() { |
678 Handle<Object> element = this->GetField(kCodeScopeInfoOffset_); | 700 Handle<Object> element = this->GetField(kCodeScopeInfoOffset_); |
679 return UnwrapJSValue(Handle<JSValue>::cast(element)); | 701 return UnwrapJSValue(Handle<JSValue>::cast(element)); |
680 } | 702 } |
681 | 703 |
682 | 704 |
683 void SharedInfoWrapper::SetProperties(Handle<String> name, | 705 void SharedInfoWrapper::SetProperties(Handle<String> name, |
684 int start_position, | 706 int start_position, |
685 int end_position, | 707 int end_position, |
686 Handle<SharedFunctionInfo> info) { | 708 Handle<SharedFunctionInfo> info) { |
(...skipping 20 matching lines...) Expand all Loading... |
707 len_ = 0; | 729 len_ = 0; |
708 result_ = isolate->factory()->NewJSArray(10); | 730 result_ = isolate->factory()->NewJSArray(10); |
709 } | 731 } |
710 | 732 |
711 void FunctionStarted(FunctionLiteral* fun) { | 733 void FunctionStarted(FunctionLiteral* fun) { |
712 HandleScope scope(isolate()); | 734 HandleScope scope(isolate()); |
713 FunctionInfoWrapper info = FunctionInfoWrapper::Create(isolate()); | 735 FunctionInfoWrapper info = FunctionInfoWrapper::Create(isolate()); |
714 info.SetInitialProperties(fun->name(), fun->start_position(), | 736 info.SetInitialProperties(fun->name(), fun->start_position(), |
715 fun->end_position(), fun->parameter_count(), | 737 fun->end_position(), fun->parameter_count(), |
716 fun->materialized_literal_count(), | 738 fun->materialized_literal_count(), |
| 739 fun->slot_count(), |
717 current_parent_index_); | 740 current_parent_index_); |
718 current_parent_index_ = len_; | 741 current_parent_index_ = len_; |
719 SetElementSloppy(result_, len_, info.GetJSArray()); | 742 SetElementSloppy(result_, len_, info.GetJSArray()); |
720 len_++; | 743 len_++; |
721 } | 744 } |
722 | 745 |
723 void FunctionDone() { | 746 void FunctionDone() { |
724 HandleScope scope(isolate()); | 747 HandleScope scope(isolate()); |
725 FunctionInfoWrapper info = | 748 FunctionInfoWrapper info = |
726 FunctionInfoWrapper::cast( | 749 FunctionInfoWrapper::cast( |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 isolate->heap()->EnsureHeapIsIterable(); | 1195 isolate->heap()->EnsureHeapIsIterable(); |
1173 | 1196 |
1174 if (IsJSFunctionCode(shared_info->code())) { | 1197 if (IsJSFunctionCode(shared_info->code())) { |
1175 Handle<Code> code = compile_info_wrapper.GetFunctionCode(); | 1198 Handle<Code> code = compile_info_wrapper.GetFunctionCode(); |
1176 ReplaceCodeObject(Handle<Code>(shared_info->code()), code); | 1199 ReplaceCodeObject(Handle<Code>(shared_info->code()), code); |
1177 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); | 1200 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); |
1178 if (code_scope_info->IsFixedArray()) { | 1201 if (code_scope_info->IsFixedArray()) { |
1179 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info)); | 1202 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info)); |
1180 } | 1203 } |
1181 shared_info->DisableOptimization(kLiveEdit); | 1204 shared_info->DisableOptimization(kLiveEdit); |
| 1205 // Update the type feedback vector |
| 1206 Handle<FixedArray> feedback_vector = |
| 1207 compile_info_wrapper.GetFeedbackVector(); |
| 1208 shared_info->set_feedback_vector(*feedback_vector); |
1182 } | 1209 } |
1183 | 1210 |
1184 if (shared_info->debug_info()->IsDebugInfo()) { | 1211 if (shared_info->debug_info()->IsDebugInfo()) { |
1185 Handle<DebugInfo> debug_info(DebugInfo::cast(shared_info->debug_info())); | 1212 Handle<DebugInfo> debug_info(DebugInfo::cast(shared_info->debug_info())); |
1186 Handle<Code> new_original_code = | 1213 Handle<Code> new_original_code = |
1187 isolate->factory()->CopyCode(compile_info_wrapper.GetFunctionCode()); | 1214 isolate->factory()->CopyCode(compile_info_wrapper.GetFunctionCode()); |
1188 debug_info->set_original_code(*new_original_code); | 1215 debug_info->set_original_code(*new_original_code); |
1189 } | 1216 } |
1190 | 1217 |
1191 int start_position = compile_info_wrapper.GetStartPosition(); | 1218 int start_position = compile_info_wrapper.GetStartPosition(); |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2002 | 2029 |
2003 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { | 2030 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { |
2004 return false; | 2031 return false; |
2005 } | 2032 } |
2006 | 2033 |
2007 #endif // ENABLE_DEBUGGER_SUPPORT | 2034 #endif // ENABLE_DEBUGGER_SUPPORT |
2008 | 2035 |
2009 | 2036 |
2010 | 2037 |
2011 } } // namespace v8::internal | 2038 } } // namespace v8::internal |
OLD | NEW |