| 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/stub_code.h" | 5 #include "vm/stub_code.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/disassembler.h" | 10 #include "vm/disassembler.h" |
| 11 #include "vm/flags.h" | 11 #include "vm/flags.h" |
| 12 #include "vm/object_store.h" | 12 #include "vm/object_store.h" |
| 13 #include "vm/snapshot.h" |
| 13 #include "vm/virtual_memory.h" | 14 #include "vm/virtual_memory.h" |
| 14 #include "vm/visitor.h" | 15 #include "vm/visitor.h" |
| 15 | 16 |
| 16 namespace dart { | 17 namespace dart { |
| 17 | 18 |
| 18 DEFINE_FLAG(bool, disassemble_stubs, false, "Disassemble generated stubs."); | 19 DEFINE_FLAG(bool, disassemble_stubs, false, "Disassemble generated stubs."); |
| 19 | 20 |
| 20 #define STUB_CODE_DECLARE(name) \ | 21 #define STUB_CODE_DECLARE(name) \ |
| 21 StubEntry* StubCode::name##_entry_ = NULL; | 22 StubEntry* StubCode::name##_entry_ = NULL; |
| 22 VM_STUB_CODE_LIST(STUB_CODE_DECLARE); | 23 VM_STUB_CODE_LIST(STUB_CODE_DECLARE); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 46 void StubCode::InitOnce() { | 47 void StubCode::InitOnce() { |
| 47 // Generate all the stubs. | 48 // Generate all the stubs. |
| 48 Code& code = Code::Handle(); | 49 Code& code = Code::Handle(); |
| 49 VM_STUB_CODE_LIST(STUB_CODE_GENERATE); | 50 VM_STUB_CODE_LIST(STUB_CODE_GENERATE); |
| 50 } | 51 } |
| 51 | 52 |
| 52 | 53 |
| 53 #undef STUB_CODE_GENERATE | 54 #undef STUB_CODE_GENERATE |
| 54 | 55 |
| 55 | 56 |
| 57 void StubCode::ReadFrom(SnapshotReader* reader) { |
| 58 #define READ_STUB(name) \ |
| 59 *(reader->CodeHandle()) ^= reader->ReadObject(); \ |
| 60 name##_entry_ = new StubEntry(*(reader->CodeHandle())); |
| 61 VM_STUB_CODE_LIST(READ_STUB); |
| 62 #undef READ_STUB |
| 63 } |
| 64 |
| 65 void StubCode::WriteTo(SnapshotWriter* writer) { |
| 66 // TODO(rmacnak): Consider writing only the instructions to avoid |
| 67 // vm_isolate_is_symbolic. |
| 68 #define WRITE_STUB(name) \ |
| 69 writer->WriteObject(StubCode::name##_entry()->code()); |
| 70 VM_STUB_CODE_LIST(WRITE_STUB); |
| 71 #undef WRITE_STUB |
| 72 } |
| 73 |
| 74 |
| 56 void StubCode::Init(Isolate* isolate) { } | 75 void StubCode::Init(Isolate* isolate) { } |
| 57 | 76 |
| 58 | 77 |
| 59 void StubCode::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 78 void StubCode::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
| 60 } | 79 } |
| 61 | 80 |
| 62 | 81 |
| 63 bool StubCode::InInvocationStub(uword pc) { | 82 bool StubCode::InInvocationStub(uword pc) { |
| 64 uword entry = StubCode::InvokeDartCode_entry()->EntryPoint(); | 83 uword entry = StubCode::InvokeDartCode_entry()->EntryPoint(); |
| 65 uword size = StubCode::InvokeDartCodeSize(); | 84 uword size = StubCode::InvokeDartCodeSize(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if ((name##_entry() != NULL) && \ | 168 if ((name##_entry() != NULL) && \ |
| 150 (entry_point == name##_entry()->EntryPoint())) { \ | 169 (entry_point == name##_entry()->EntryPoint())) { \ |
| 151 return ""#name; \ | 170 return ""#name; \ |
| 152 } | 171 } |
| 153 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); | 172 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); |
| 154 #undef VM_STUB_CODE_TESTER | 173 #undef VM_STUB_CODE_TESTER |
| 155 return NULL; | 174 return NULL; |
| 156 } | 175 } |
| 157 | 176 |
| 158 } // namespace dart | 177 } // namespace dart |
| OLD | NEW |