OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 ASSERT(!value->IsPropertyCell() && !value->IsCell()); | 634 ASSERT(!value->IsPropertyCell() && !value->IsCell()); |
635 return value; | 635 return value; |
636 } | 636 } |
637 | 637 |
638 | 638 |
639 Object* JSObject::SetNormalizedProperty(LookupResult* result, Object* value) { | 639 Object* JSObject::SetNormalizedProperty(LookupResult* result, Object* value) { |
640 ASSERT(!HasFastProperties()); | 640 ASSERT(!HasFastProperties()); |
641 if (IsGlobalObject()) { | 641 if (IsGlobalObject()) { |
642 PropertyCell* cell = PropertyCell::cast( | 642 PropertyCell* cell = PropertyCell::cast( |
643 property_dictionary()->ValueAt(result->GetDictionaryEntry())); | 643 property_dictionary()->ValueAt(result->GetDictionaryEntry())); |
644 cell->set_value(value); | 644 cell->set_value_infer_type(value); |
645 } else { | 645 } else { |
646 property_dictionary()->ValueAtPut(result->GetDictionaryEntry(), value); | 646 property_dictionary()->ValueAtPut(result->GetDictionaryEntry(), value); |
647 } | 647 } |
648 return value; | 648 return value; |
649 } | 649 } |
650 | 650 |
651 | 651 |
652 Handle<Object> JSObject::SetNormalizedProperty(Handle<JSObject> object, | 652 Handle<Object> JSObject::SetNormalizedProperty(Handle<JSObject> object, |
653 Handle<Name> key, | 653 Handle<Name> key, |
654 Handle<Object> value, | 654 Handle<Object> value, |
655 PropertyDetails details) { | 655 PropertyDetails details) { |
656 CALL_HEAP_FUNCTION(object->GetIsolate(), | 656 CALL_HEAP_FUNCTION(object->GetIsolate(), |
657 object->SetNormalizedProperty(*key, *value, details), | 657 object->SetNormalizedProperty(*key, *value, details), |
658 Object); | 658 Object); |
659 } | 659 } |
660 | 660 |
661 | 661 |
662 MaybeObject* JSObject::SetNormalizedProperty(Name* name, | 662 MaybeObject* JSObject::SetNormalizedProperty(Name* name, |
663 Object* value, | 663 Object* value, |
664 PropertyDetails details) { | 664 PropertyDetails details) { |
665 ASSERT(!HasFastProperties()); | 665 ASSERT(!HasFastProperties()); |
666 int entry = property_dictionary()->FindEntry(name); | 666 int entry = property_dictionary()->FindEntry(name); |
667 if (entry == NameDictionary::kNotFound) { | 667 if (entry == NameDictionary::kNotFound) { |
668 Object* store_value = value; | 668 Object* store_value = value; |
669 if (IsGlobalObject()) { | 669 if (IsGlobalObject()) { |
670 Heap* heap = name->GetHeap(); | 670 Heap* heap = name->GetHeap(); |
671 MaybeObject* maybe_store_value = | 671 MaybeObject* maybe_store_value = heap->AllocatePropertyCell(value); |
672 heap->AllocatePropertyCell(value); | |
673 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; | 672 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; |
674 } | 673 } |
675 Object* dict; | 674 Object* dict; |
676 { MaybeObject* maybe_dict = | 675 { MaybeObject* maybe_dict = |
677 property_dictionary()->Add(name, store_value, details); | 676 property_dictionary()->Add(name, store_value, details); |
678 if (!maybe_dict->ToObject(&dict)) return maybe_dict; | 677 if (!maybe_dict->ToObject(&dict)) return maybe_dict; |
679 } | 678 } |
680 set_properties(NameDictionary::cast(dict)); | 679 set_properties(NameDictionary::cast(dict)); |
681 return value; | 680 return value; |
682 } | 681 } |
683 | 682 |
684 PropertyDetails original_details = property_dictionary()->DetailsAt(entry); | 683 PropertyDetails original_details = property_dictionary()->DetailsAt(entry); |
685 int enumeration_index; | 684 int enumeration_index; |
686 // Preserve the enumeration index unless the property was deleted. | 685 // Preserve the enumeration index unless the property was deleted. |
687 if (original_details.IsDeleted()) { | 686 if (original_details.IsDeleted()) { |
688 enumeration_index = property_dictionary()->NextEnumerationIndex(); | 687 enumeration_index = property_dictionary()->NextEnumerationIndex(); |
689 property_dictionary()->SetNextEnumerationIndex(enumeration_index + 1); | 688 property_dictionary()->SetNextEnumerationIndex(enumeration_index + 1); |
690 } else { | 689 } else { |
691 enumeration_index = original_details.dictionary_index(); | 690 enumeration_index = original_details.dictionary_index(); |
692 ASSERT(enumeration_index > 0); | 691 ASSERT(enumeration_index > 0); |
693 } | 692 } |
694 | 693 |
695 details = PropertyDetails( | 694 details = PropertyDetails( |
696 details.attributes(), details.type(), enumeration_index); | 695 details.attributes(), details.type(), enumeration_index); |
697 | 696 |
698 if (IsGlobalObject()) { | 697 if (IsGlobalObject()) { |
699 PropertyCell* cell = | 698 PropertyCell* cell = |
700 PropertyCell::cast(property_dictionary()->ValueAt(entry)); | 699 PropertyCell::cast(property_dictionary()->ValueAt(entry)); |
701 cell->set_value(value); | 700 cell->set_value_infer_type(value); |
702 // Please note we have to update the property details. | 701 // Please note we have to update the property details. |
703 property_dictionary()->DetailsAtPut(entry, details); | 702 property_dictionary()->DetailsAtPut(entry, details); |
704 } else { | 703 } else { |
705 property_dictionary()->SetEntry(entry, name, value, details); | 704 property_dictionary()->SetEntry(entry, name, value, details); |
706 } | 705 } |
707 return value; | 706 return value; |
708 } | 707 } |
709 | 708 |
710 | 709 |
711 MaybeObject* JSObject::DeleteNormalizedProperty(Name* name, DeleteMode mode) { | 710 MaybeObject* JSObject::DeleteNormalizedProperty(Name* name, DeleteMode mode) { |
(...skipping 11 matching lines...) Expand all Loading... |
723 // from the DontDelete cell without checking if it contains | 722 // from the DontDelete cell without checking if it contains |
724 // the hole value. | 723 // the hole value. |
725 Map* new_map; | 724 Map* new_map; |
726 MaybeObject* maybe_new_map = map()->CopyDropDescriptors(); | 725 MaybeObject* maybe_new_map = map()->CopyDropDescriptors(); |
727 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 726 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
728 | 727 |
729 ASSERT(new_map->is_dictionary_map()); | 728 ASSERT(new_map->is_dictionary_map()); |
730 set_map(new_map); | 729 set_map(new_map); |
731 } | 730 } |
732 PropertyCell* cell = PropertyCell::cast(dictionary->ValueAt(entry)); | 731 PropertyCell* cell = PropertyCell::cast(dictionary->ValueAt(entry)); |
733 cell->set_value(cell->GetHeap()->the_hole_value()); | 732 cell->set_value_infer_type(cell->GetHeap()->the_hole_value()); |
734 dictionary->DetailsAtPut(entry, details.AsDeleted()); | 733 dictionary->DetailsAtPut(entry, details.AsDeleted()); |
735 } else { | 734 } else { |
736 Object* deleted = dictionary->DeleteProperty(entry, mode); | 735 Object* deleted = dictionary->DeleteProperty(entry, mode); |
737 if (deleted == GetHeap()->true_value()) { | 736 if (deleted == GetHeap()->true_value()) { |
738 FixedArray* new_properties = NULL; | 737 FixedArray* new_properties = NULL; |
739 MaybeObject* maybe_properties = dictionary->Shrink(name); | 738 MaybeObject* maybe_properties = dictionary->Shrink(name); |
740 if (!maybe_properties->To(&new_properties)) { | 739 if (!maybe_properties->To(&new_properties)) { |
741 return maybe_properties; | 740 return maybe_properties; |
742 } | 741 } |
743 set_properties(new_properties); | 742 set_properties(new_properties); |
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1929 Object* value, | 1928 Object* value, |
1930 PropertyAttributes attributes) { | 1929 PropertyAttributes attributes) { |
1931 ASSERT(!HasFastProperties()); | 1930 ASSERT(!HasFastProperties()); |
1932 NameDictionary* dict = property_dictionary(); | 1931 NameDictionary* dict = property_dictionary(); |
1933 Object* store_value = value; | 1932 Object* store_value = value; |
1934 if (IsGlobalObject()) { | 1933 if (IsGlobalObject()) { |
1935 // In case name is an orphaned property reuse the cell. | 1934 // In case name is an orphaned property reuse the cell. |
1936 int entry = dict->FindEntry(name); | 1935 int entry = dict->FindEntry(name); |
1937 if (entry != NameDictionary::kNotFound) { | 1936 if (entry != NameDictionary::kNotFound) { |
1938 store_value = dict->ValueAt(entry); | 1937 store_value = dict->ValueAt(entry); |
1939 PropertyCell::cast(store_value)->set_value(value); | 1938 PropertyCell::cast(store_value)->set_value_infer_type(value); |
1940 // Assign an enumeration index to the property and update | 1939 // Assign an enumeration index to the property and update |
1941 // SetNextEnumerationIndex. | 1940 // SetNextEnumerationIndex. |
1942 int index = dict->NextEnumerationIndex(); | 1941 int index = dict->NextEnumerationIndex(); |
1943 PropertyDetails details = PropertyDetails(attributes, NORMAL, index); | 1942 PropertyDetails details = PropertyDetails(attributes, NORMAL, index); |
1944 dict->SetNextEnumerationIndex(index + 1); | 1943 dict->SetNextEnumerationIndex(index + 1); |
1945 dict->SetEntry(entry, name, store_value, details); | 1944 dict->SetEntry(entry, name, store_value, details); |
1946 return value; | 1945 return value; |
1947 } | 1946 } |
1948 Heap* heap = GetHeap(); | 1947 Heap* heap = GetHeap(); |
1949 { MaybeObject* maybe_store_value = | 1948 { MaybeObject* maybe_store_value = |
1950 heap->AllocatePropertyCell(value); | 1949 heap->AllocatePropertyCell(value); |
1951 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; | 1950 if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value; |
1952 } | 1951 } |
1953 PropertyCell::cast(store_value)->set_value(value); | 1952 PropertyCell::cast(store_value)->set_value_infer_type(value); |
1954 } | 1953 } |
1955 PropertyDetails details = PropertyDetails(attributes, NORMAL, 0); | 1954 PropertyDetails details = PropertyDetails(attributes, NORMAL, 0); |
1956 Object* result; | 1955 Object* result; |
1957 { MaybeObject* maybe_result = dict->Add(name, store_value, details); | 1956 { MaybeObject* maybe_result = dict->Add(name, store_value, details); |
1958 if (!maybe_result->ToObject(&result)) return maybe_result; | 1957 if (!maybe_result->ToObject(&result)) return maybe_result; |
1959 } | 1958 } |
1960 if (dict != result) set_properties(NameDictionary::cast(result)); | 1959 if (dict != result) set_properties(NameDictionary::cast(result)); |
1961 return value; | 1960 return value; |
1962 } | 1961 } |
1963 | 1962 |
(...skipping 8176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10140 return statement_position; | 10139 return statement_position; |
10141 } | 10140 } |
10142 | 10141 |
10143 | 10142 |
10144 SafepointEntry Code::GetSafepointEntry(Address pc) { | 10143 SafepointEntry Code::GetSafepointEntry(Address pc) { |
10145 SafepointTable table(this); | 10144 SafepointTable table(this); |
10146 return table.FindEntry(pc); | 10145 return table.FindEntry(pc); |
10147 } | 10146 } |
10148 | 10147 |
10149 | 10148 |
10150 Map* Code::FindFirstMap() { | 10149 Object* Code::FindNthObject(int n, Map* match_map) { |
10151 ASSERT(is_inline_cache_stub()); | 10150 ASSERT(is_inline_cache_stub()); |
10152 DisallowHeapAllocation no_allocation; | 10151 DisallowHeapAllocation no_allocation; |
10153 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 10152 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
10154 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10153 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10155 RelocInfo* info = it.rinfo(); | 10154 RelocInfo* info = it.rinfo(); |
10156 Object* object = info->target_object(); | 10155 Object* object = info->target_object(); |
10157 if (object->IsMap()) return Map::cast(object); | 10156 if (object->IsHeapObject()) { |
| 10157 if (HeapObject::cast(object)->map() == match_map) { |
| 10158 if (--n == 0) return object; |
| 10159 } |
| 10160 } |
10158 } | 10161 } |
10159 return NULL; | 10162 return NULL; |
10160 } | 10163 } |
10161 | 10164 |
10162 | 10165 |
10163 void Code::ReplaceFirstMap(Map* replace_with) { | 10166 Map* Code::FindFirstMap() { |
| 10167 Object* result = FindNthObject(1, GetHeap()->meta_map()); |
| 10168 if (result == NULL) return NULL; |
| 10169 return Map::cast(result); |
| 10170 } |
| 10171 |
| 10172 |
| 10173 void Code::ReplaceNthObject(int n, |
| 10174 Map* match_map, |
| 10175 Object* replace_with) { |
10164 ASSERT(is_inline_cache_stub()); | 10176 ASSERT(is_inline_cache_stub()); |
10165 DisallowHeapAllocation no_allocation; | 10177 DisallowHeapAllocation no_allocation; |
10166 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 10178 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
10167 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10179 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10168 RelocInfo* info = it.rinfo(); | 10180 RelocInfo* info = it.rinfo(); |
10169 Object* object = info->target_object(); | 10181 Object* object = info->target_object(); |
10170 if (object->IsMap()) { | 10182 if (object->IsHeapObject()) { |
10171 info->set_target_object(replace_with); | 10183 if (HeapObject::cast(object)->map() == match_map) { |
10172 return; | 10184 if (--n == 0) { |
| 10185 info->set_target_object(replace_with); |
| 10186 return; |
| 10187 } |
| 10188 } |
10173 } | 10189 } |
10174 } | 10190 } |
10175 UNREACHABLE(); | 10191 UNREACHABLE(); |
10176 } | 10192 } |
10177 | 10193 |
10178 | 10194 |
10179 void Code::FindAllMaps(MapHandleList* maps) { | 10195 void Code::FindAllMaps(MapHandleList* maps) { |
10180 ASSERT(is_inline_cache_stub()); | 10196 ASSERT(is_inline_cache_stub()); |
10181 DisallowHeapAllocation no_allocation; | 10197 DisallowHeapAllocation no_allocation; |
10182 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 10198 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
10183 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10199 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10184 RelocInfo* info = it.rinfo(); | 10200 RelocInfo* info = it.rinfo(); |
10185 Object* object = info->target_object(); | 10201 Object* object = info->target_object(); |
10186 if (object->IsMap()) maps->Add(Handle<Map>(Map::cast(object))); | 10202 if (object->IsMap()) maps->Add(Handle<Map>(Map::cast(object))); |
10187 } | 10203 } |
10188 } | 10204 } |
10189 | 10205 |
10190 | 10206 |
| 10207 void Code::ReplaceFirstMap(Map* replace_with) { |
| 10208 ReplaceNthObject(1, GetHeap()->meta_map(), replace_with); |
| 10209 } |
| 10210 |
| 10211 |
10191 Code* Code::FindFirstCode() { | 10212 Code* Code::FindFirstCode() { |
10192 ASSERT(is_inline_cache_stub()); | 10213 ASSERT(is_inline_cache_stub()); |
10193 DisallowHeapAllocation no_allocation; | 10214 DisallowHeapAllocation no_allocation; |
10194 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); | 10215 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); |
10195 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10216 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10196 RelocInfo* info = it.rinfo(); | 10217 RelocInfo* info = it.rinfo(); |
10197 return Code::GetCodeFromTargetAddress(info->target_address()); | 10218 return Code::GetCodeFromTargetAddress(info->target_address()); |
10198 } | 10219 } |
10199 return NULL; | 10220 return NULL; |
10200 } | 10221 } |
10201 | 10222 |
10202 | 10223 |
10203 void Code::FindAllCode(CodeHandleList* code_list, int length) { | 10224 void Code::FindAllCode(CodeHandleList* code_list, int length) { |
10204 ASSERT(is_inline_cache_stub()); | 10225 ASSERT(is_inline_cache_stub()); |
10205 DisallowHeapAllocation no_allocation; | 10226 DisallowHeapAllocation no_allocation; |
10206 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); | 10227 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET); |
10207 int i = 0; | 10228 int i = 0; |
10208 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10229 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10209 if (i++ == length) return; | 10230 if (i++ == length) return; |
10210 RelocInfo* info = it.rinfo(); | 10231 RelocInfo* info = it.rinfo(); |
10211 Code* code = Code::GetCodeFromTargetAddress(info->target_address()); | 10232 Code* code = Code::GetCodeFromTargetAddress(info->target_address()); |
10212 ASSERT(code->kind() == Code::STUB); | 10233 ASSERT(code->kind() == Code::STUB); |
10213 code_list->Add(Handle<Code>(code)); | 10234 code_list->Add(Handle<Code>(code)); |
10214 } | 10235 } |
10215 UNREACHABLE(); | 10236 UNREACHABLE(); |
10216 } | 10237 } |
10217 | 10238 |
10218 | 10239 |
10219 Name* Code::FindFirstName() { | 10240 Name* Code::FindFirstName() { |
| 10241 #if 0 |
| 10242 Object* result = FindNthObject(1, GetHeap()->symbol_map()); |
| 10243 if (result == NULL) return NULL; |
| 10244 return Name::cast(result); |
| 10245 #else |
10220 ASSERT(is_inline_cache_stub()); | 10246 ASSERT(is_inline_cache_stub()); |
10221 DisallowHeapAllocation no_allocation; | 10247 DisallowHeapAllocation no_allocation; |
10222 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | 10248 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); |
10223 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10249 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10224 RelocInfo* info = it.rinfo(); | 10250 RelocInfo* info = it.rinfo(); |
10225 Object* object = info->target_object(); | 10251 Object* object = info->target_object(); |
10226 if (object->IsName()) return Name::cast(object); | 10252 if (object->IsName()) return Name::cast(object); |
10227 } | 10253 } |
10228 return NULL; | 10254 return NULL; |
| 10255 #endif |
10229 } | 10256 } |
10230 | 10257 |
10231 | 10258 |
| 10259 void Code::ReplaceNthCell(int n, |
| 10260 Cell* replace_with) { |
| 10261 ASSERT(is_inline_cache_stub()); |
| 10262 DisallowHeapAllocation no_allocation; |
| 10263 int mask = RelocInfo::ModeMask(RelocInfo::CELL); |
| 10264 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
| 10265 RelocInfo* info = it.rinfo(); |
| 10266 if (--n == 0) { |
| 10267 info->set_target_cell(replace_with); |
| 10268 return; |
| 10269 } |
| 10270 } |
| 10271 UNREACHABLE(); |
| 10272 } |
| 10273 |
| 10274 |
10232 void Code::ClearInlineCaches() { | 10275 void Code::ClearInlineCaches() { |
10233 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | | 10276 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | |
10234 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | | 10277 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | |
10235 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID) | | 10278 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID) | |
10236 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_CONTEXT); | 10279 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_CONTEXT); |
10237 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 10280 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
10238 RelocInfo* info = it.rinfo(); | 10281 RelocInfo* info = it.rinfo(); |
10239 Code* target(Code::GetCodeFromTargetAddress(info->target_address())); | 10282 Code* target(Code::GetCodeFromTargetAddress(info->target_address())); |
10240 if (target->is_inline_cache_stub()) { | 10283 if (target->is_inline_cache_stub()) { |
10241 IC::Clear(info->pc()); | 10284 IC::Clear(info->pc()); |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11104 proto_transitions->length()); | 11147 proto_transitions->length()); |
11105 } | 11148 } |
11106 | 11149 |
11107 | 11150 |
11108 void Map::AddDependentCompilationInfo(DependentCode::DependencyGroup group, | 11151 void Map::AddDependentCompilationInfo(DependentCode::DependencyGroup group, |
11109 CompilationInfo* info) { | 11152 CompilationInfo* info) { |
11110 Handle<DependentCode> dep(dependent_code()); | 11153 Handle<DependentCode> dep(dependent_code()); |
11111 Handle<DependentCode> codes = | 11154 Handle<DependentCode> codes = |
11112 DependentCode::Insert(dep, group, info->object_wrapper()); | 11155 DependentCode::Insert(dep, group, info->object_wrapper()); |
11113 if (*codes != dependent_code()) set_dependent_code(*codes); | 11156 if (*codes != dependent_code()) set_dependent_code(*codes); |
11114 info->dependent_maps(group)->Add(Handle<Map>(this), info->zone()); | 11157 info->dependencies(group)->Add(Handle<HeapObject>(this), info->zone()); |
11115 } | 11158 } |
11116 | 11159 |
11117 | 11160 |
11118 void Map::AddDependentCode(DependentCode::DependencyGroup group, | 11161 void Map::AddDependentCode(DependentCode::DependencyGroup group, |
11119 Handle<Code> code) { | 11162 Handle<Code> code) { |
11120 Handle<DependentCode> codes = DependentCode::Insert( | 11163 Handle<DependentCode> codes = DependentCode::Insert( |
11121 Handle<DependentCode>(dependent_code()), group, code); | 11164 Handle<DependentCode>(dependent_code()), group, code); |
11122 if (*codes != dependent_code()) set_dependent_code(*codes); | 11165 if (*codes != dependent_code()) set_dependent_code(*codes); |
11123 } | 11166 } |
11124 | 11167 |
11125 | 11168 |
11126 DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* entries) { | 11169 DependentCode::GroupStartIndexes::GroupStartIndexes(DependentCode* entries) { |
11127 Recompute(entries); | 11170 Recompute(entries); |
11128 } | 11171 } |
11129 | 11172 |
11130 | 11173 |
11131 void DependentCode::GroupStartIndexes::Recompute(DependentCode* entries) { | 11174 void DependentCode::GroupStartIndexes::Recompute(DependentCode* entries) { |
11132 start_indexes_[0] = 0; | 11175 start_indexes_[0] = 0; |
11133 for (int g = 1; g <= kGroupCount; g++) { | 11176 for (int g = 1; g <= kGroupCount; g++) { |
11134 int count = entries->number_of_entries(static_cast<DependencyGroup>(g - 1)); | 11177 int count = entries->number_of_entries(static_cast<DependencyGroup>(g - 1)); |
11135 start_indexes_[g] = start_indexes_[g - 1] + count; | 11178 start_indexes_[g] = start_indexes_[g - 1] + count; |
11136 } | 11179 } |
11137 } | 11180 } |
11138 | 11181 |
11139 | 11182 |
| 11183 DependentCode* DependentCode::ForObject(Handle<HeapObject> object, |
| 11184 DependencyGroup group) { |
| 11185 if (group == DependentCode::kPropertyCellChangedGroup) { |
| 11186 return Handle<PropertyCell>::cast(object)->dependent_code(); |
| 11187 } |
| 11188 return Handle<Map>::cast(object)->dependent_code(); |
| 11189 } |
| 11190 |
| 11191 |
11140 Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries, | 11192 Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries, |
11141 DependencyGroup group, | 11193 DependencyGroup group, |
11142 Handle<Object> object) { | 11194 Handle<Object> object) { |
11143 GroupStartIndexes starts(*entries); | 11195 GroupStartIndexes starts(*entries); |
11144 int start = starts.at(group); | 11196 int start = starts.at(group); |
11145 int end = starts.at(group + 1); | 11197 int end = starts.at(group + 1); |
11146 int number_of_entries = starts.number_of_entries(); | 11198 int number_of_entries = starts.number_of_entries(); |
11147 if (start < end && entries->object_at(end - 1) == *object) { | 11199 if (start < end && entries->object_at(end - 1) == *object) { |
11148 // Do not append the compilation info if it is already in the array. | 11200 // Do not append the compilation info if it is already in the array. |
11149 // It is sufficient to just check only the last element because | 11201 // It is sufficient to just check only the last element because |
(...skipping 4663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15813 Type* PropertyCell::type() { | 15865 Type* PropertyCell::type() { |
15814 return static_cast<Type*>(type_raw()); | 15866 return static_cast<Type*>(type_raw()); |
15815 } | 15867 } |
15816 | 15868 |
15817 | 15869 |
15818 void PropertyCell::set_type(Type* type, WriteBarrierMode ignored) { | 15870 void PropertyCell::set_type(Type* type, WriteBarrierMode ignored) { |
15819 set_type_raw(type, ignored); | 15871 set_type_raw(type, ignored); |
15820 } | 15872 } |
15821 | 15873 |
15822 | 15874 |
| 15875 Type* PropertyCell::union_type(Object* value) { |
| 15876 Isolate* isolate = GetIsolate(); |
| 15877 Handle<Object> value_handle(value, isolate); |
| 15878 Handle<Type> old_type(type(), isolate); |
| 15879 Handle<Type> new_type(Type::Constant(value_handle, isolate), isolate); |
| 15880 |
| 15881 if (new_type->Is(old_type)) { |
| 15882 return *new_type; |
| 15883 } |
| 15884 |
| 15885 dependent_code()->DeoptimizeDependentCodeGroup( |
| 15886 isolate, DependentCode::kPropertyCellChangedGroup); |
| 15887 |
| 15888 if (old_type->IsConstant()) { |
| 15889 Handle<Object> undefined(isolate->heap()->undefined_value(), isolate); |
| 15890 Type* const_undefined = Type::Constant(undefined, isolate); |
| 15891 if (old_type->Is(const_undefined)) { |
| 15892 return *new_type; |
| 15893 } |
| 15894 } |
| 15895 |
| 15896 return Type::Union(old_type, new_type); |
| 15897 } |
| 15898 |
| 15899 |
| 15900 void PropertyCell::set_value_infer_type(Object* value, |
| 15901 WriteBarrierMode ignored) { |
| 15902 set_value(value, ignored); |
| 15903 set_type(union_type(value)); |
| 15904 } |
| 15905 |
| 15906 |
| 15907 void PropertyCell::AddDependentCompilationInfo(CompilationInfo* info) { |
| 15908 Handle<DependentCode> dep(dependent_code()); |
| 15909 Handle<DependentCode> codes = |
| 15910 DependentCode::Insert(dep, DependentCode::kPropertyCellChangedGroup, |
| 15911 info->object_wrapper()); |
| 15912 if (*codes != dependent_code()) set_dependent_code(*codes); |
| 15913 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
| 15914 Handle<HeapObject>(this), info->zone()); |
| 15915 } |
| 15916 |
| 15917 |
| 15918 void PropertyCell::AddDependentCode(Handle<Code> code) { |
| 15919 Handle<DependentCode> codes = DependentCode::Insert( |
| 15920 Handle<DependentCode>(dependent_code()), |
| 15921 DependentCode::kPropertyCellChangedGroup, code); |
| 15922 if (*codes != dependent_code()) set_dependent_code(*codes); |
| 15923 } |
| 15924 |
| 15925 |
15823 } } // namespace v8::internal | 15926 } } // namespace v8::internal |
OLD | NEW |