| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 1791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1803 } else { | 1803 } else { |
| 1804 result->NotFound(); | 1804 result->NotFound(); |
| 1805 } | 1805 } |
| 1806 } | 1806 } |
| 1807 | 1807 |
| 1808 | 1808 |
| 1809 void Map::LookupInDescriptors(JSObject* holder, | 1809 void Map::LookupInDescriptors(JSObject* holder, |
| 1810 String* name, | 1810 String* name, |
| 1811 LookupResult* result) { | 1811 LookupResult* result) { |
| 1812 DescriptorArray* descriptors = instance_descriptors(); | 1812 DescriptorArray* descriptors = instance_descriptors(); |
| 1813 DescriptorLookupCache* cache = heap()->isolate()->descriptor_lookup_cache(); | 1813 DescriptorLookupCache* cache = |
| 1814 GetHeap()->isolate()->descriptor_lookup_cache(); |
| 1814 int number = cache->Lookup(descriptors, name); | 1815 int number = cache->Lookup(descriptors, name); |
| 1815 if (number == DescriptorLookupCache::kAbsent) { | 1816 if (number == DescriptorLookupCache::kAbsent) { |
| 1816 number = descriptors->Search(name); | 1817 number = descriptors->Search(name); |
| 1817 cache->Update(descriptors, name, number); | 1818 cache->Update(descriptors, name, number); |
| 1818 } | 1819 } |
| 1819 if (number != DescriptorArray::kNotFound) { | 1820 if (number != DescriptorArray::kNotFound) { |
| 1820 result->DescriptorResult(holder, descriptors->GetDetails(number), number); | 1821 result->DescriptorResult(holder, descriptors->GetDetails(number), number); |
| 1821 } else { | 1822 } else { |
| 1822 result->NotFound(); | 1823 result->NotFound(); |
| 1823 } | 1824 } |
| (...skipping 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3570 void Map::RemoveFromCodeCache(String* name, Code* code, int index) { | 3571 void Map::RemoveFromCodeCache(String* name, Code* code, int index) { |
| 3571 // No GC is supposed to happen between a call to IndexInCodeCache and | 3572 // No GC is supposed to happen between a call to IndexInCodeCache and |
| 3572 // RemoveFromCodeCache so the code cache must be there. | 3573 // RemoveFromCodeCache so the code cache must be there. |
| 3573 ASSERT(!code_cache()->IsFixedArray()); | 3574 ASSERT(!code_cache()->IsFixedArray()); |
| 3574 CodeCache::cast(code_cache())->RemoveByIndex(name, code, index); | 3575 CodeCache::cast(code_cache())->RemoveByIndex(name, code, index); |
| 3575 } | 3576 } |
| 3576 | 3577 |
| 3577 | 3578 |
| 3578 void Map::TraverseTransitionTree(TraverseCallback callback, void* data) { | 3579 void Map::TraverseTransitionTree(TraverseCallback callback, void* data) { |
| 3579 Map* current = this; | 3580 Map* current = this; |
| 3580 Map* meta_map = heap()->meta_map(); | 3581 Map* meta_map = GetHeap()->meta_map(); |
| 3581 while (current != meta_map) { | 3582 while (current != meta_map) { |
| 3582 DescriptorArray* d = reinterpret_cast<DescriptorArray*>( | 3583 DescriptorArray* d = reinterpret_cast<DescriptorArray*>( |
| 3583 *RawField(current, Map::kInstanceDescriptorsOffset)); | 3584 *RawField(current, Map::kInstanceDescriptorsOffset)); |
| 3584 if (d == heap()->empty_descriptor_array()) { | 3585 if (d == GetHeap()->empty_descriptor_array()) { |
| 3585 Map* prev = current->map(); | 3586 Map* prev = current->map(); |
| 3586 current->set_map(meta_map); | 3587 current->set_map(meta_map); |
| 3587 callback(current, data); | 3588 callback(current, data); |
| 3588 current = prev; | 3589 current = prev; |
| 3589 continue; | 3590 continue; |
| 3590 } | 3591 } |
| 3591 | 3592 |
| 3592 FixedArray* contents = reinterpret_cast<FixedArray*>( | 3593 FixedArray* contents = reinterpret_cast<FixedArray*>( |
| 3593 d->get(DescriptorArray::kContentArrayIndex)); | 3594 d->get(DescriptorArray::kContentArrayIndex)); |
| 3594 Object** map_or_index_field = RawField(contents, HeapObject::kMapOffset); | 3595 Object** map_or_index_field = RawField(contents, HeapObject::kMapOffset); |
| 3595 Object* map_or_index = *map_or_index_field; | 3596 Object* map_or_index = *map_or_index_field; |
| 3596 bool map_done = true; | 3597 bool map_done = true; |
| 3597 for (int i = map_or_index->IsSmi() ? Smi::cast(map_or_index)->value() : 0; | 3598 for (int i = map_or_index->IsSmi() ? Smi::cast(map_or_index)->value() : 0; |
| 3598 i < contents->length(); | 3599 i < contents->length(); |
| 3599 i += 2) { | 3600 i += 2) { |
| 3600 PropertyDetails details(Smi::cast(contents->get(i + 1))); | 3601 PropertyDetails details(Smi::cast(contents->get(i + 1))); |
| 3601 if (details.IsTransition()) { | 3602 if (details.IsTransition()) { |
| 3602 Map* next = reinterpret_cast<Map*>(contents->get(i)); | 3603 Map* next = reinterpret_cast<Map*>(contents->get(i)); |
| 3603 next->set_map(current); | 3604 next->set_map(current); |
| 3604 *map_or_index_field = Smi::FromInt(i + 2); | 3605 *map_or_index_field = Smi::FromInt(i + 2); |
| 3605 current = next; | 3606 current = next; |
| 3606 map_done = false; | 3607 map_done = false; |
| 3607 break; | 3608 break; |
| 3608 } | 3609 } |
| 3609 } | 3610 } |
| 3610 if (!map_done) continue; | 3611 if (!map_done) continue; |
| 3611 *map_or_index_field = heap()->fixed_array_map(); | 3612 *map_or_index_field = GetHeap()->fixed_array_map(); |
| 3612 Map* prev = current->map(); | 3613 Map* prev = current->map(); |
| 3613 current->set_map(meta_map); | 3614 current->set_map(meta_map); |
| 3614 callback(current, data); | 3615 callback(current, data); |
| 3615 current = prev; | 3616 current = prev; |
| 3616 } | 3617 } |
| 3617 } | 3618 } |
| 3618 | 3619 |
| 3619 | 3620 |
| 3620 MaybeObject* CodeCache::Update(String* name, Code* code) { | 3621 MaybeObject* CodeCache::Update(String* name, Code* code) { |
| 3621 ASSERT(code->ic_state() == MONOMORPHIC); | 3622 ASSERT(code->ic_state() == MONOMORPHIC); |
| (...skipping 2315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5937 if (Serializer::enabled()) return; | 5938 if (Serializer::enabled()) return; |
| 5938 | 5939 |
| 5939 if (map->unused_property_fields() == 0) return; | 5940 if (map->unused_property_fields() == 0) return; |
| 5940 | 5941 |
| 5941 // Nonzero counter is a leftover from the previous attempt interrupted | 5942 // Nonzero counter is a leftover from the previous attempt interrupted |
| 5942 // by GC, keep it. | 5943 // by GC, keep it. |
| 5943 if (construction_count() == 0) { | 5944 if (construction_count() == 0) { |
| 5944 set_construction_count(kGenerousAllocationCount); | 5945 set_construction_count(kGenerousAllocationCount); |
| 5945 } | 5946 } |
| 5946 set_initial_map(map); | 5947 set_initial_map(map); |
| 5947 Builtins* builtins = map->heap()->isolate()->builtins(); | 5948 Builtins* builtins = map->GetHeap()->isolate()->builtins(); |
| 5948 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubGeneric), | 5949 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubGeneric), |
| 5949 construct_stub()); | 5950 construct_stub()); |
| 5950 set_construct_stub(builtins->builtin(Builtins::JSConstructStubCountdown)); | 5951 set_construct_stub(builtins->builtin(Builtins::JSConstructStubCountdown)); |
| 5951 } | 5952 } |
| 5952 | 5953 |
| 5953 | 5954 |
| 5954 // Called from GC, hence reinterpret_cast and unchecked accessors. | 5955 // Called from GC, hence reinterpret_cast and unchecked accessors. |
| 5955 void SharedFunctionInfo::DetachInitialMap() { | 5956 void SharedFunctionInfo::DetachInitialMap() { |
| 5956 Map* map = reinterpret_cast<Map*>(initial_map()); | 5957 Map* map = reinterpret_cast<Map*>(initial_map()); |
| 5957 | 5958 |
| 5958 // Make the map remember to restore the link if it survives the GC. | 5959 // Make the map remember to restore the link if it survives the GC. |
| 5959 map->set_bit_field2( | 5960 map->set_bit_field2( |
| 5960 map->bit_field2() | (1 << Map::kAttachedToSharedFunctionInfo)); | 5961 map->bit_field2() | (1 << Map::kAttachedToSharedFunctionInfo)); |
| 5961 | 5962 |
| 5962 // Undo state changes made by StartInobjectTracking (except the | 5963 // Undo state changes made by StartInobjectTracking (except the |
| 5963 // construction_count). This way if the initial map does not survive the GC | 5964 // construction_count). This way if the initial map does not survive the GC |
| 5964 // then StartInobjectTracking will be called again the next time the | 5965 // then StartInobjectTracking will be called again the next time the |
| 5965 // constructor is called. The countdown will continue and (possibly after | 5966 // constructor is called. The countdown will continue and (possibly after |
| 5966 // several more GCs) CompleteInobjectSlackTracking will eventually be called. | 5967 // several more GCs) CompleteInobjectSlackTracking will eventually be called. |
| 5967 set_initial_map(map->heap()->raw_unchecked_undefined_value()); | 5968 Heap* heap = map->GetHeap(); |
| 5968 Builtins* builtins = map->heap()->isolate()->builtins(); | 5969 set_initial_map(heap->raw_unchecked_undefined_value()); |
| 5970 Builtins* builtins = heap->isolate()->builtins(); |
| 5969 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubCountdown), | 5971 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubCountdown), |
| 5970 *RawField(this, kConstructStubOffset)); | 5972 *RawField(this, kConstructStubOffset)); |
| 5971 set_construct_stub(builtins->builtin(Builtins::JSConstructStubGeneric)); | 5973 set_construct_stub(builtins->builtin(Builtins::JSConstructStubGeneric)); |
| 5972 // It is safe to clear the flag: it will be set again if the map is live. | 5974 // It is safe to clear the flag: it will be set again if the map is live. |
| 5973 set_live_objects_may_exist(false); | 5975 set_live_objects_may_exist(false); |
| 5974 } | 5976 } |
| 5975 | 5977 |
| 5976 | 5978 |
| 5977 // Called from GC, hence reinterpret_cast and unchecked accessors. | 5979 // Called from GC, hence reinterpret_cast and unchecked accessors. |
| 5978 void SharedFunctionInfo::AttachInitialMap(Map* map) { | 5980 void SharedFunctionInfo::AttachInitialMap(Map* map) { |
| 5979 map->set_bit_field2( | 5981 map->set_bit_field2( |
| 5980 map->bit_field2() & ~(1 << Map::kAttachedToSharedFunctionInfo)); | 5982 map->bit_field2() & ~(1 << Map::kAttachedToSharedFunctionInfo)); |
| 5981 | 5983 |
| 5982 // Resume inobject slack tracking. | 5984 // Resume inobject slack tracking. |
| 5983 set_initial_map(map); | 5985 set_initial_map(map); |
| 5984 Builtins* builtins = map->heap()->isolate()->builtins(); | 5986 Builtins* builtins = map->GetHeap()->isolate()->builtins(); |
| 5985 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubGeneric), | 5987 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubGeneric), |
| 5986 *RawField(this, kConstructStubOffset)); | 5988 *RawField(this, kConstructStubOffset)); |
| 5987 set_construct_stub(builtins->builtin(Builtins::JSConstructStubCountdown)); | 5989 set_construct_stub(builtins->builtin(Builtins::JSConstructStubCountdown)); |
| 5988 // The map survived the gc, so there may be objects referencing it. | 5990 // The map survived the gc, so there may be objects referencing it. |
| 5989 set_live_objects_may_exist(true); | 5991 set_live_objects_may_exist(true); |
| 5990 } | 5992 } |
| 5991 | 5993 |
| 5992 | 5994 |
| 5993 static void GetMinInobjectSlack(Map* map, void* data) { | 5995 static void GetMinInobjectSlack(Map* map, void* data) { |
| 5994 int slack = map->unused_property_fields(); | 5996 int slack = map->unused_property_fields(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 6006 | 6008 |
| 6007 // Visitor id might depend on the instance size, recalculate it. | 6009 // Visitor id might depend on the instance size, recalculate it. |
| 6008 map->set_visitor_id(StaticVisitorBase::GetVisitorId(map)); | 6010 map->set_visitor_id(StaticVisitorBase::GetVisitorId(map)); |
| 6009 } | 6011 } |
| 6010 | 6012 |
| 6011 | 6013 |
| 6012 void SharedFunctionInfo::CompleteInobjectSlackTracking() { | 6014 void SharedFunctionInfo::CompleteInobjectSlackTracking() { |
| 6013 ASSERT(live_objects_may_exist() && IsInobjectSlackTrackingInProgress()); | 6015 ASSERT(live_objects_may_exist() && IsInobjectSlackTrackingInProgress()); |
| 6014 Map* map = Map::cast(initial_map()); | 6016 Map* map = Map::cast(initial_map()); |
| 6015 | 6017 |
| 6016 Heap* heap = map->heap(); | 6018 Heap* heap = map->GetHeap(); |
| 6017 set_initial_map(heap->undefined_value()); | 6019 set_initial_map(heap->undefined_value()); |
| 6018 Builtins* builtins = heap->isolate()->builtins(); | 6020 Builtins* builtins = heap->isolate()->builtins(); |
| 6019 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubCountdown), | 6021 ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubCountdown), |
| 6020 construct_stub()); | 6022 construct_stub()); |
| 6021 set_construct_stub(builtins->builtin(Builtins::JSConstructStubGeneric)); | 6023 set_construct_stub(builtins->builtin(Builtins::JSConstructStubGeneric)); |
| 6022 | 6024 |
| 6023 int slack = map->unused_property_fields(); | 6025 int slack = map->unused_property_fields(); |
| 6024 map->TraverseTransitionTree(&GetMinInobjectSlack, &slack); | 6026 map->TraverseTransitionTree(&GetMinInobjectSlack, &slack); |
| 6025 if (slack != 0) { | 6027 if (slack != 0) { |
| 6026 // Resize the initial map and all maps in its transition tree. | 6028 // Resize the initial map and all maps in its transition tree. |
| (...skipping 4141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10168 if (break_point_objects()->IsUndefined()) return 0; | 10170 if (break_point_objects()->IsUndefined()) return 0; |
| 10169 // Single beak point. | 10171 // Single beak point. |
| 10170 if (!break_point_objects()->IsFixedArray()) return 1; | 10172 if (!break_point_objects()->IsFixedArray()) return 1; |
| 10171 // Multiple break points. | 10173 // Multiple break points. |
| 10172 return FixedArray::cast(break_point_objects())->length(); | 10174 return FixedArray::cast(break_point_objects())->length(); |
| 10173 } | 10175 } |
| 10174 #endif | 10176 #endif |
| 10175 | 10177 |
| 10176 | 10178 |
| 10177 } } // namespace v8::internal | 10179 } } // namespace v8::internal |
| OLD | NEW |