Chromium Code Reviews| 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" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 return cache.raw(); | 48 return cache.raw(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 | 51 |
| 52 void MegamorphicCacheTable::InitMissHandler() { | 52 void MegamorphicCacheTable::InitMissHandler() { |
| 53 // 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 |
| 54 // normal Dart function. | 54 // normal Dart function. |
| 55 const Code& code = | 55 const Code& code = |
| 56 Code::Handle(StubCode::Generate("_stub_MegamorphicMiss", | 56 Code::Handle(StubCode::Generate("_stub_MegamorphicMiss", |
| 57 StubCode::GenerateMegamorphicMissStub)); | 57 StubCode::GenerateMegamorphicMissStub)); |
| 58 // When FLAG_lazy_dispatcher=false, this stub can be on the stack during | |
| 59 // exceptions, but it has a corresponding function so IsStubCode is false and | |
| 60 // it is considered in the search for an exception handler. | |
| 61 code.set_exception_handlers(Object::empty_exception_handlers()); | |
| 62 | |
| 58 const Class& cls = | 63 const Class& cls = |
| 59 Class::Handle(Type::Handle(Type::Function()).type_class()); | 64 Class::Handle(Type::Handle(Type::Function()).type_class()); |
| 60 const Function& function = | 65 const Function& function = |
| 61 Function::Handle(Function::New(Symbols::MegamorphicMiss(), | 66 Function::Handle(Function::New(Symbols::MegamorphicMiss(), |
| 62 RawFunction::kRegularFunction, | 67 RawFunction::kRegularFunction, |
| 63 false, // Not static. | 68 false, // Not static. |
| 64 false, // Not const. | 69 false, // Not const. |
| 65 false, // Not abstract. | 70 false, // Not abstract. |
| 66 false, // Not external. | 71 false, // Not external. |
| 67 false, // Not native. | 72 false, // Not native. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 95 for (intptr_t i = 0; i < length_; ++i) { | 100 for (intptr_t i = 0; i < length_; ++i) { |
| 96 cache = table_[i].cache; | 101 cache = table_[i].cache; |
| 97 buckets = cache.buckets(); | 102 buckets = cache.buckets(); |
| 98 size += MegamorphicCache::InstanceSize(); | 103 size += MegamorphicCache::InstanceSize(); |
| 99 size += Array::InstanceSize(buckets.Length()); | 104 size += Array::InstanceSize(buckets.Length()); |
| 100 } | 105 } |
| 101 OS::Print("%" Pd " megamorphic caches using %" Pd "KB.\n", | 106 OS::Print("%" Pd " megamorphic caches using %" Pd "KB.\n", |
| 102 length_, size / 1024); | 107 length_, size / 1024); |
| 103 } | 108 } |
| 104 | 109 |
| 110 | |
| 111 void MegamorphicCacheTable::ReadFrom(SnapshotReader* reader) { | |
| 112 ASSERT(reader->snapshot_code()); | |
| 113 | |
| 114 *reader->FunctionHandle() ^= reader->ReadObject(); | |
| 115 miss_handler_function_ = reader->FunctionHandle()->raw(); | |
| 116 miss_handler_code_ = reader->FunctionHandle()->CurrentCode(); | |
| 117 | |
| 118 capacity_ = reader->Read<intptr_t>(); | |
| 119 length_ = capacity_; | |
| 120 | |
| 121 table_ = reinterpret_cast<Entry*>(malloc(length_ * sizeof(*table_))); | |
| 122 for (intptr_t i = 0; i < length_; ++i) { | |
| 123 *reader->StringHandle() ^= reader->ReadObject(); | |
| 124 table_[i].name = reader->StringHandle()->raw(); | |
| 125 *reader->ArrayHandle() ^= reader->ReadObject(); | |
| 126 table_[i].descriptor = reader->ArrayHandle()->raw(); | |
| 127 *reader->MegamorphicCacheHandle() ^= reader->ReadObject(); | |
| 128 table_[i].cache = reader->MegamorphicCacheHandle()->raw(); | |
| 129 } | |
| 130 } | |
| 131 | |
| 132 | |
| 133 void MegamorphicCacheTable::WriteTo(SnapshotWriter* writer) { | |
| 134 ASSERT(writer->snapshot_code()); | |
| 135 | |
| 136 writer->WriteObject(miss_handler_function_); | |
| 137 writer->Write<intptr_t>(length_); | |
| 138 for (intptr_t i = 0; i < length_; i++) { | |
| 139 writer->WriteObject(table_[i].name); | |
| 140 writer->WriteObject(table_[i].descriptor); | |
| 141 writer->WriteObject(table_[i].cache); | |
| 142 } | |
| 143 } | |
|
siva
2015/09/14 21:29:34
This code is another CL and as discussed offline m
rmacnak
2015/09/15 20:07:45
Dropped.
| |
| 144 | |
| 145 | |
| 105 } // namespace dart | 146 } // namespace dart |
| OLD | NEW |