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

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

Issue 16271010: Use 'new' in all the snapshot reallocation functions instead of realloc. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/debuginfo.h ('k') | runtime/vm/object.cc » ('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/megamorphic_cache_table.h" 5 #include "vm/megamorphic_cache_table.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include "vm/object.h" 8 #include "vm/object.h"
9 #include "vm/stub_code.h" 9 #include "vm/stub_code.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
(...skipping 16 matching lines...) Expand all
27 RawMegamorphicCache* MegamorphicCacheTable::Lookup(const String& name, 27 RawMegamorphicCache* MegamorphicCacheTable::Lookup(const String& name,
28 const Array& descriptor) { 28 const Array& descriptor) {
29 for (intptr_t i = 0; i < length_; ++i) { 29 for (intptr_t i = 0; i < length_; ++i) {
30 if ((table_[i].name == name.raw()) && 30 if ((table_[i].name == name.raw()) &&
31 (table_[i].descriptor == descriptor.raw())) { 31 (table_[i].descriptor == descriptor.raw())) {
32 return table_[i].cache; 32 return table_[i].cache;
33 } 33 }
34 } 34 }
35 35
36 if (length_ == capacity_) { 36 if (length_ == capacity_) {
37 capacity_ += kCapacityIncrement; 37 intptr_t new_capacity = capacity_ + kCapacityIncrement;
38 table_ = 38 table_ = Utils::Realloc(table_, capacity_, new_capacity);
39 reinterpret_cast<Entry*>(realloc(table_, capacity_ * sizeof(*table_))); 39 capacity_ = new_capacity;
40 } 40 }
41 41
42 ASSERT(length_ < capacity_); 42 ASSERT(length_ < capacity_);
43 const MegamorphicCache& cache = 43 const MegamorphicCache& cache =
44 MegamorphicCache::Handle(MegamorphicCache::New()); 44 MegamorphicCache::Handle(MegamorphicCache::New());
45 Entry entry = { name.raw(), descriptor.raw(), cache.raw() }; 45 Entry entry = { name.raw(), descriptor.raw(), cache.raw() };
46 table_[length_++] = entry; 46 table_[length_++] = entry;
47 return cache.raw(); 47 return cache.raw();
48 } 48 }
49 49
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 for (intptr_t i = 0; i < length_; ++i) { 89 for (intptr_t i = 0; i < length_; ++i) {
90 cache = table_[i].cache; 90 cache = table_[i].cache;
91 buckets = cache.buckets(); 91 buckets = cache.buckets();
92 size += MegamorphicCache::InstanceSize(); 92 size += MegamorphicCache::InstanceSize();
93 size += Array::InstanceSize(buckets.Length()); 93 size += Array::InstanceSize(buckets.Length());
94 } 94 }
95 OS::Print("%"Pd" megamorphic caches using %"Pd"KB.\n", length_, size / 1024); 95 OS::Print("%"Pd" megamorphic caches using %"Pd"KB.\n", length_, size / 1024);
96 } 96 }
97 97
98 } // namespace dart 98 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debuginfo.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698