| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 for (intptr_t i = 0; i < length_; ++i) { | 95 for (intptr_t i = 0; i < length_; ++i) { |
| 96 cache = table_[i].cache; | 96 cache = table_[i].cache; |
| 97 buckets = cache.buckets(); | 97 buckets = cache.buckets(); |
| 98 size += MegamorphicCache::InstanceSize(); | 98 size += MegamorphicCache::InstanceSize(); |
| 99 size += Array::InstanceSize(buckets.Length()); | 99 size += Array::InstanceSize(buckets.Length()); |
| 100 } | 100 } |
| 101 OS::Print("%" Pd " megamorphic caches using %" Pd "KB.\n", | 101 OS::Print("%" Pd " megamorphic caches using %" Pd "KB.\n", |
| 102 length_, size / 1024); | 102 length_, size / 1024); |
| 103 } | 103 } |
| 104 | 104 |
| 105 |
| 106 void MegamorphicCacheTable::ReadFrom(SnapshotReader* reader) { |
| 107 ASSERT(reader->snapshot_code()); |
| 108 |
| 109 *reader->FunctionHandle() ^= reader->ReadObject(); |
| 110 miss_handler_function_ = reader->FunctionHandle()->raw(); |
| 111 miss_handler_code_ = reader->FunctionHandle()->CurrentCode(); |
| 112 |
| 113 capacity_ = reader->Read<intptr_t>(); |
| 114 length_ = capacity_; |
| 115 |
| 116 table_ = reinterpret_cast<Entry*>(malloc(length_ * sizeof(*table_))); |
| 117 for (intptr_t i = 0; i < length_; ++i) { |
| 118 *reader->StringHandle() ^= reader->ReadObject(); |
| 119 table_[i].name = reader->StringHandle()->raw(); |
| 120 *reader->ArrayHandle() ^= reader->ReadObject(); |
| 121 table_[i].descriptor = reader->ArrayHandle()->raw(); |
| 122 *reader->MegamorphicCacheHandle() ^= reader->ReadObject(); |
| 123 table_[i].cache = reader->MegamorphicCacheHandle()->raw(); |
| 124 } |
| 125 } |
| 126 |
| 127 |
| 128 void MegamorphicCacheTable::WriteTo(SnapshotWriter* writer) { |
| 129 ASSERT(writer->snapshot_code()); |
| 130 |
| 131 writer->WriteObject(miss_handler_function_); |
| 132 writer->Write<intptr_t>(length_); |
| 133 for (intptr_t i = 0; i < length_; i++) { |
| 134 writer->WriteObject(table_[i].name); |
| 135 writer->WriteObject(table_[i].descriptor); |
| 136 writer->WriteObject(table_[i].cache); |
| 137 } |
| 138 } |
| 139 |
| 140 |
| 105 } // namespace dart | 141 } // namespace dart |
| OLD | NEW |