| 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/stub_code.h" | 9 #include "vm/stub_code.h" |
| 10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 MegamorphicCacheTable::MegamorphicCacheTable() | 14 MegamorphicCacheTable::MegamorphicCacheTable() |
| 15 : miss_handler_(NULL), | 15 : miss_handler_function_(NULL), |
| 16 miss_handler_code_(NULL), |
| 16 capacity_(0), | 17 capacity_(0), |
| 17 length_(0), | 18 length_(0), |
| 18 table_(NULL) { | 19 table_(NULL) { |
| 19 } | 20 } |
| 20 | 21 |
| 21 | 22 |
| 22 MegamorphicCacheTable::~MegamorphicCacheTable() { | 23 MegamorphicCacheTable::~MegamorphicCacheTable() { |
| 23 free(table_); | 24 free(table_); |
| 24 } | 25 } |
| 25 | 26 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 Class::Handle(Type::Handle(Type::Function()).type_class()); | 59 Class::Handle(Type::Handle(Type::Function()).type_class()); |
| 59 const Function& function = | 60 const Function& function = |
| 60 Function::Handle(Function::New(Symbols::MegamorphicMiss(), | 61 Function::Handle(Function::New(Symbols::MegamorphicMiss(), |
| 61 RawFunction::kRegularFunction, | 62 RawFunction::kRegularFunction, |
| 62 false, // Not static. | 63 false, // Not static. |
| 63 false, // Not const. | 64 false, // Not const. |
| 64 false, // Not abstract. | 65 false, // Not abstract. |
| 65 false, // Not external. | 66 false, // Not external. |
| 66 cls, | 67 cls, |
| 67 0)); // No token position. | 68 0)); // No token position. |
| 69 miss_handler_code_ = code.raw(); |
| 70 miss_handler_function_ = function.raw(); |
| 68 function.SetCode(code); | 71 function.SetCode(code); |
| 69 miss_handler_ = function.raw(); | |
| 70 } | 72 } |
| 71 | 73 |
| 72 | 74 |
| 73 void MegamorphicCacheTable::VisitObjectPointers(ObjectPointerVisitor* v) { | 75 void MegamorphicCacheTable::VisitObjectPointers(ObjectPointerVisitor* v) { |
| 74 ASSERT(v != NULL); | 76 ASSERT(v != NULL); |
| 75 v->VisitPointer(reinterpret_cast<RawObject**>(&miss_handler_)); | 77 v->VisitPointer(reinterpret_cast<RawObject**>(&miss_handler_code_)); |
| 78 v->VisitPointer(reinterpret_cast<RawObject**>(&miss_handler_function_)); |
| 76 for (intptr_t i = 0; i < length_; ++i) { | 79 for (intptr_t i = 0; i < length_; ++i) { |
| 77 v->VisitPointer(reinterpret_cast<RawObject**>(&table_[i].name)); | 80 v->VisitPointer(reinterpret_cast<RawObject**>(&table_[i].name)); |
| 78 v->VisitPointer(reinterpret_cast<RawObject**>(&table_[i].descriptor)); | 81 v->VisitPointer(reinterpret_cast<RawObject**>(&table_[i].descriptor)); |
| 79 v->VisitPointer(reinterpret_cast<RawObject**>(&table_[i].cache)); | 82 v->VisitPointer(reinterpret_cast<RawObject**>(&table_[i].cache)); |
| 80 } | 83 } |
| 81 } | 84 } |
| 82 | 85 |
| 83 | 86 |
| 84 void MegamorphicCacheTable::PrintSizes() { | 87 void MegamorphicCacheTable::PrintSizes() { |
| 85 StackZone zone(Isolate::Current()); | 88 StackZone zone(Isolate::Current()); |
| 86 intptr_t size = 0; | 89 intptr_t size = 0; |
| 87 MegamorphicCache& cache = MegamorphicCache::Handle(); | 90 MegamorphicCache& cache = MegamorphicCache::Handle(); |
| 88 Array& buckets = Array::Handle(); | 91 Array& buckets = Array::Handle(); |
| 89 for (intptr_t i = 0; i < length_; ++i) { | 92 for (intptr_t i = 0; i < length_; ++i) { |
| 90 cache = table_[i].cache; | 93 cache = table_[i].cache; |
| 91 buckets = cache.buckets(); | 94 buckets = cache.buckets(); |
| 92 size += MegamorphicCache::InstanceSize(); | 95 size += MegamorphicCache::InstanceSize(); |
| 93 size += Array::InstanceSize(buckets.Length()); | 96 size += Array::InstanceSize(buckets.Length()); |
| 94 } | 97 } |
| 95 OS::Print("%" Pd " megamorphic caches using %" Pd "KB.\n", | 98 OS::Print("%" Pd " megamorphic caches using %" Pd "KB.\n", |
| 96 length_, size / 1024); | 99 length_, size / 1024); |
| 97 } | 100 } |
| 98 | 101 |
| 99 } // namespace dart | 102 } // namespace dart |
| OLD | NEW |