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