| 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/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/object_store.h" | 9 #include "vm/object_store.h" |
| 10 #include "vm/stub_code.h" | 10 #include "vm/stub_code.h" |
| 11 #include "vm/symbols.h" | 11 #include "vm/symbols.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 RawMegamorphicCache* MegamorphicCacheTable::Lookup(Isolate* isolate, | 15 RawMegamorphicCache* MegamorphicCacheTable::Lookup(Isolate* isolate, |
| 16 const String& name, | 16 const String& name, |
| 17 const Array& descriptor) { | 17 const Array& descriptor) { |
| 18 // Multiple compilation threads could access this lookup. |
| 19 MutexLocker ml(isolate->mutex()); |
| 18 ASSERT(name.IsSymbol()); | 20 ASSERT(name.IsSymbol()); |
| 19 // TODO(rmacnak): ASSERT(descriptor.IsCanonical()); | 21 // TODO(rmacnak): ASSERT(descriptor.IsCanonical()); |
| 20 | 22 |
| 21 // TODO(rmacnak): Make a proper hashtable a la symbol table. | 23 // TODO(rmacnak): Make a proper hashtable a la symbol table. |
| 22 GrowableObjectArray& table = GrowableObjectArray::Handle( | 24 GrowableObjectArray& table = GrowableObjectArray::Handle( |
| 23 isolate->object_store()->megamorphic_cache_table()); | 25 isolate->object_store()->megamorphic_cache_table()); |
| 24 MegamorphicCache& cache = MegamorphicCache::Handle(); | 26 MegamorphicCache& cache = MegamorphicCache::Handle(); |
| 25 if (table.IsNull()) { | 27 if (table.IsNull()) { |
| 26 table = GrowableObjectArray::New(Heap::kOld); | 28 table = GrowableObjectArray::New(Heap::kOld); |
| 27 isolate->object_store()->set_megamorphic_cache_table(table); | 29 isolate->object_store()->set_megamorphic_cache_table(table); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 cache ^= table.At(i); | 92 cache ^= table.At(i); |
| 91 buckets = cache.buckets(); | 93 buckets = cache.buckets(); |
| 92 size += MegamorphicCache::InstanceSize(); | 94 size += MegamorphicCache::InstanceSize(); |
| 93 size += Array::InstanceSize(buckets.Length()); | 95 size += Array::InstanceSize(buckets.Length()); |
| 94 } | 96 } |
| 95 OS::Print("%" Pd " megamorphic caches using %" Pd "KB.\n", | 97 OS::Print("%" Pd " megamorphic caches using %" Pd "KB.\n", |
| 96 table.Length(), size / 1024); | 98 table.Length(), size / 1024); |
| 97 } | 99 } |
| 98 | 100 |
| 99 } // namespace dart | 101 } // namespace dart |
| OLD | NEW |