OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 13777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13788 MegamorphicCache& result = MegamorphicCache::Handle(); | 13788 MegamorphicCache& result = MegamorphicCache::Handle(); |
13789 { RawObject* raw = Object::Allocate(MegamorphicCache::kClassId, | 13789 { RawObject* raw = Object::Allocate(MegamorphicCache::kClassId, |
13790 MegamorphicCache::InstanceSize(), | 13790 MegamorphicCache::InstanceSize(), |
13791 Heap::kOld); | 13791 Heap::kOld); |
13792 NoSafepointScope no_safepoint; | 13792 NoSafepointScope no_safepoint; |
13793 result ^= raw; | 13793 result ^= raw; |
13794 } | 13794 } |
13795 const intptr_t capacity = kInitialCapacity; | 13795 const intptr_t capacity = kInitialCapacity; |
13796 const Array& buckets = Array::Handle( | 13796 const Array& buckets = Array::Handle( |
13797 Array::New(kEntryLength * capacity, Heap::kOld)); | 13797 Array::New(kEntryLength * capacity, Heap::kOld)); |
| 13798 ASSERT(Isolate::Current()->megamorphic_cache_table()->miss_handler() != NULL); |
13798 const Function& handler = Function::Handle( | 13799 const Function& handler = Function::Handle( |
13799 MegamorphicCacheTable::miss_handler(Isolate::Current())); | 13800 Isolate::Current()->megamorphic_cache_table()->miss_handler()); |
13800 for (intptr_t i = 0; i < capacity; ++i) { | 13801 for (intptr_t i = 0; i < capacity; ++i) { |
13801 SetEntry(buckets, i, smi_illegal_cid(), handler); | 13802 SetEntry(buckets, i, smi_illegal_cid(), handler); |
13802 } | 13803 } |
13803 result.set_buckets(buckets); | 13804 result.set_buckets(buckets); |
13804 result.set_mask(capacity - 1); | 13805 result.set_mask(capacity - 1); |
13805 result.set_filled_entry_count(0); | 13806 result.set_filled_entry_count(0); |
13806 return result.raw(); | 13807 return result.raw(); |
13807 } | 13808 } |
13808 | 13809 |
13809 | 13810 |
13810 void MegamorphicCache::EnsureCapacity() const { | 13811 void MegamorphicCache::EnsureCapacity() const { |
13811 intptr_t old_capacity = mask() + 1; | 13812 intptr_t old_capacity = mask() + 1; |
13812 double load_limit = kLoadFactor * static_cast<double>(old_capacity); | 13813 double load_limit = kLoadFactor * static_cast<double>(old_capacity); |
13813 if (static_cast<double>(filled_entry_count() + 1) > load_limit) { | 13814 if (static_cast<double>(filled_entry_count() + 1) > load_limit) { |
13814 const Array& old_buckets = Array::Handle(buckets()); | 13815 const Array& old_buckets = Array::Handle(buckets()); |
13815 intptr_t new_capacity = old_capacity * 2; | 13816 intptr_t new_capacity = old_capacity * 2; |
13816 const Array& new_buckets = | 13817 const Array& new_buckets = |
13817 Array::Handle(Array::New(kEntryLength * new_capacity)); | 13818 Array::Handle(Array::New(kEntryLength * new_capacity)); |
13818 | 13819 |
13819 Function& target = Function::Handle( | 13820 Function& target = Function::Handle( |
13820 MegamorphicCacheTable::miss_handler(Isolate::Current())); | 13821 Isolate::Current()->megamorphic_cache_table()->miss_handler()); |
13821 for (intptr_t i = 0; i < new_capacity; ++i) { | 13822 for (intptr_t i = 0; i < new_capacity; ++i) { |
13822 SetEntry(new_buckets, i, smi_illegal_cid(), target); | 13823 SetEntry(new_buckets, i, smi_illegal_cid(), target); |
13823 } | 13824 } |
13824 set_buckets(new_buckets); | 13825 set_buckets(new_buckets); |
13825 set_mask(new_capacity - 1); | 13826 set_mask(new_capacity - 1); |
13826 set_filled_entry_count(0); | 13827 set_filled_entry_count(0); |
13827 | 13828 |
13828 // Rehash the valid entries. | 13829 // Rehash the valid entries. |
13829 Smi& class_id = Smi::Handle(); | 13830 Smi& class_id = Smi::Handle(); |
13830 for (intptr_t i = 0; i < old_capacity; ++i) { | 13831 for (intptr_t i = 0; i < old_capacity; ++i) { |
(...skipping 7603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21434 return tag_label.ToCString(); | 21435 return tag_label.ToCString(); |
21435 } | 21436 } |
21436 | 21437 |
21437 | 21438 |
21438 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21439 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21439 Instance::PrintJSONImpl(stream, ref); | 21440 Instance::PrintJSONImpl(stream, ref); |
21440 } | 21441 } |
21441 | 21442 |
21442 | 21443 |
21443 } // namespace dart | 21444 } // namespace dart |
OLD | NEW |