Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Side by Side Diff: runtime/vm/object.cc

Issue 1339363002: Reapply "Move megamorphic cache table into the Dart heap." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/megamorphic_cache_table.cc ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
13799 const Function& handler = Function::Handle( 13798 const Function& handler = Function::Handle(
13800 Isolate::Current()->megamorphic_cache_table()->miss_handler()); 13799 MegamorphicCacheTable::miss_handler(Isolate::Current()));
13801 for (intptr_t i = 0; i < capacity; ++i) { 13800 for (intptr_t i = 0; i < capacity; ++i) {
13802 SetEntry(buckets, i, smi_illegal_cid(), handler); 13801 SetEntry(buckets, i, smi_illegal_cid(), handler);
13803 } 13802 }
13804 result.set_buckets(buckets); 13803 result.set_buckets(buckets);
13805 result.set_mask(capacity - 1); 13804 result.set_mask(capacity - 1);
13806 result.set_filled_entry_count(0); 13805 result.set_filled_entry_count(0);
13807 return result.raw(); 13806 return result.raw();
13808 } 13807 }
13809 13808
13810 13809
13811 void MegamorphicCache::EnsureCapacity() const { 13810 void MegamorphicCache::EnsureCapacity() const {
13812 intptr_t old_capacity = mask() + 1; 13811 intptr_t old_capacity = mask() + 1;
13813 double load_limit = kLoadFactor * static_cast<double>(old_capacity); 13812 double load_limit = kLoadFactor * static_cast<double>(old_capacity);
13814 if (static_cast<double>(filled_entry_count() + 1) > load_limit) { 13813 if (static_cast<double>(filled_entry_count() + 1) > load_limit) {
13815 const Array& old_buckets = Array::Handle(buckets()); 13814 const Array& old_buckets = Array::Handle(buckets());
13816 intptr_t new_capacity = old_capacity * 2; 13815 intptr_t new_capacity = old_capacity * 2;
13817 const Array& new_buckets = 13816 const Array& new_buckets =
13818 Array::Handle(Array::New(kEntryLength * new_capacity)); 13817 Array::Handle(Array::New(kEntryLength * new_capacity));
13819 13818
13820 Function& target = Function::Handle( 13819 Function& target = Function::Handle(
13821 Isolate::Current()->megamorphic_cache_table()->miss_handler()); 13820 MegamorphicCacheTable::miss_handler(Isolate::Current()));
13822 for (intptr_t i = 0; i < new_capacity; ++i) { 13821 for (intptr_t i = 0; i < new_capacity; ++i) {
13823 SetEntry(new_buckets, i, smi_illegal_cid(), target); 13822 SetEntry(new_buckets, i, smi_illegal_cid(), target);
13824 } 13823 }
13825 set_buckets(new_buckets); 13824 set_buckets(new_buckets);
13826 set_mask(new_capacity - 1); 13825 set_mask(new_capacity - 1);
13827 set_filled_entry_count(0); 13826 set_filled_entry_count(0);
13828 13827
13829 // Rehash the valid entries. 13828 // Rehash the valid entries.
13830 Smi& class_id = Smi::Handle(); 13829 Smi& class_id = Smi::Handle();
13831 for (intptr_t i = 0; i < old_capacity; ++i) { 13830 for (intptr_t i = 0; i < old_capacity; ++i) {
(...skipping 7603 matching lines...) Expand 10 before | Expand all | Expand 10 after
21435 return tag_label.ToCString(); 21434 return tag_label.ToCString();
21436 } 21435 }
21437 21436
21438 21437
21439 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21438 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21440 Instance::PrintJSONImpl(stream, ref); 21439 Instance::PrintJSONImpl(stream, ref);
21441 } 21440 }
21442 21441
21443 21442
21444 } // namespace dart 21443 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/megamorphic_cache_table.cc ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698