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