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" |
(...skipping 24 matching lines...) Expand all Loading... |
35 return cache.raw(); | 35 return cache.raw(); |
36 } | 36 } |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 cache = MegamorphicCache::New(name, descriptor); | 40 cache = MegamorphicCache::New(name, descriptor); |
41 table.Add(cache, Heap::kOld); | 41 table.Add(cache, Heap::kOld); |
42 return cache.raw(); | 42 return cache.raw(); |
43 } | 43 } |
44 | 44 |
45 | |
46 RawFunction* MegamorphicCacheTable::miss_handler(Isolate* isolate) { | 45 RawFunction* MegamorphicCacheTable::miss_handler(Isolate* isolate) { |
47 ASSERT(isolate->object_store()->megamorphic_miss_function() != | 46 ASSERT(isolate->object_store()->megamorphic_miss_function() != |
48 Function::null()); | 47 Function::null()); |
49 return isolate->object_store()->megamorphic_miss_function(); | 48 return isolate->object_store()->megamorphic_miss_function(); |
50 } | 49 } |
51 | 50 |
52 | |
53 void MegamorphicCacheTable::InitMissHandler(Isolate* isolate) { | 51 void MegamorphicCacheTable::InitMissHandler(Isolate* isolate) { |
54 // The miss handler for a class ID not found in the table is invoked as a | 52 // The miss handler for a class ID not found in the table is invoked as a |
55 // normal Dart function. | 53 // normal Dart function. |
56 const Code& code = Code::Handle(StubCode::Generate( | 54 const Code& code = Code::Handle(StubCode::Generate( |
57 "_stub_MegamorphicMiss", StubCode::GenerateMegamorphicMissStub)); | 55 "_stub_MegamorphicMiss", StubCode::GenerateMegamorphicMissStub)); |
58 // When FLAG_lazy_dispatchers=false, this stub can be on the stack during | 56 // When FLAG_lazy_dispatchers=false, this stub can be on the stack during |
59 // exceptions, but it has a corresponding function so IsStubCode is false and | 57 // exceptions, but it has a corresponding function so IsStubCode is false and |
60 // it is considered in the search for an exception handler. | 58 // it is considered in the search for an exception handler. |
61 code.set_exception_handlers(Object::empty_exception_handlers()); | 59 code.set_exception_handlers(Object::empty_exception_handlers()); |
62 const Class& cls = | 60 const Class& cls = |
(...skipping 11 matching lines...) Expand all Loading... |
74 function.set_is_visible(false); | 72 function.set_is_visible(false); |
75 function.AttachCode(code); // Has a single entry point, as a static function. | 73 function.AttachCode(code); // Has a single entry point, as a static function. |
76 // For inclusion in Snapshot::kFullJIT. | 74 // For inclusion in Snapshot::kFullJIT. |
77 function.set_unoptimized_code(code); | 75 function.set_unoptimized_code(code); |
78 | 76 |
79 ASSERT(isolate->object_store()->megamorphic_miss_function() == | 77 ASSERT(isolate->object_store()->megamorphic_miss_function() == |
80 Function::null()); | 78 Function::null()); |
81 isolate->object_store()->SetMegamorphicMissHandler(code, function); | 79 isolate->object_store()->SetMegamorphicMissHandler(code, function); |
82 } | 80 } |
83 | 81 |
84 | |
85 void MegamorphicCacheTable::PrintSizes(Isolate* isolate) { | 82 void MegamorphicCacheTable::PrintSizes(Isolate* isolate) { |
86 StackZone zone(Thread::Current()); | 83 StackZone zone(Thread::Current()); |
87 intptr_t size = 0; | 84 intptr_t size = 0; |
88 MegamorphicCache& cache = MegamorphicCache::Handle(); | 85 MegamorphicCache& cache = MegamorphicCache::Handle(); |
89 Array& buckets = Array::Handle(); | 86 Array& buckets = Array::Handle(); |
90 const GrowableObjectArray& table = GrowableObjectArray::Handle( | 87 const GrowableObjectArray& table = GrowableObjectArray::Handle( |
91 isolate->object_store()->megamorphic_cache_table()); | 88 isolate->object_store()->megamorphic_cache_table()); |
92 if (table.IsNull()) return; | 89 if (table.IsNull()) return; |
93 intptr_t max_size = 0; | 90 intptr_t max_size = 0; |
94 for (intptr_t i = 0; i < table.Length(); i++) { | 91 for (intptr_t i = 0; i < table.Length(); i++) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 for (intptr_t i = 0; i <= max_probe_count; i++) { | 140 for (intptr_t i = 0; i <= max_probe_count; i++) { |
144 cumulative_entries += probe_counts[i]; | 141 cumulative_entries += probe_counts[i]; |
145 OS::Print("Megamorphic probe %" Pd ": %" Pd " (%lf)\n", i, probe_counts[i], | 142 OS::Print("Megamorphic probe %" Pd ": %" Pd " (%lf)\n", i, probe_counts[i], |
146 static_cast<double>(cumulative_entries) / | 143 static_cast<double>(cumulative_entries) / |
147 static_cast<double>(entry_count)); | 144 static_cast<double>(entry_count)); |
148 } | 145 } |
149 delete[] probe_counts; | 146 delete[] probe_counts; |
150 } | 147 } |
151 | 148 |
152 } // namespace dart | 149 } // namespace dart |
OLD | NEW |