| 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" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 Assembler assembler; | 86 Assembler assembler; |
| 87 const char* name = cls.ToCString(); | 87 const char* name = cls.ToCString(); |
| 88 uword patch_code_offset = 0; | 88 uword patch_code_offset = 0; |
| 89 uword entry_patch_offset = 0; | 89 uword entry_patch_offset = 0; |
| 90 StubCode::GenerateAllocationStubForClass( | 90 StubCode::GenerateAllocationStubForClass( |
| 91 &assembler, cls, &entry_patch_offset, &patch_code_offset); | 91 &assembler, cls, &entry_patch_offset, &patch_code_offset); |
| 92 stub ^= Code::FinalizeCode(name, &assembler); | 92 stub ^= Code::FinalizeCode(name, &assembler); |
| 93 stub.set_owner(cls); | 93 stub.set_owner(cls); |
| 94 cls.set_allocation_stub(stub); | 94 cls.set_allocation_stub(stub); |
| 95 if (FLAG_disassemble_stubs) { | 95 if (FLAG_disassemble_stubs) { |
| 96 LogBlock lb(Isolate::Current()); | 96 LogBlock lb; |
| 97 ISL_Print("Code for allocation stub '%s': {\n", name); | 97 THR_Print("Code for allocation stub '%s': {\n", name); |
| 98 DisassembleToStdout formatter; | 98 DisassembleToStdout formatter; |
| 99 stub.Disassemble(&formatter); | 99 stub.Disassemble(&formatter); |
| 100 ISL_Print("}\n"); | 100 THR_Print("}\n"); |
| 101 const ObjectPool& object_pool = ObjectPool::Handle( | 101 const ObjectPool& object_pool = ObjectPool::Handle( |
| 102 Instructions::Handle(stub.instructions()).object_pool()); | 102 Instructions::Handle(stub.instructions()).object_pool()); |
| 103 object_pool.DebugPrint(); | 103 object_pool.DebugPrint(); |
| 104 } | 104 } |
| 105 stub.set_entry_patch_pc_offset(entry_patch_offset); | 105 stub.set_entry_patch_pc_offset(entry_patch_offset); |
| 106 stub.set_patch_code_pc_offset(patch_code_offset); | 106 stub.set_patch_code_pc_offset(patch_code_offset); |
| 107 } | 107 } |
| 108 return stub.raw(); | 108 return stub.raw(); |
| 109 } | 109 } |
| 110 | 110 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 | 127 |
| 128 RawCode* StubCode::Generate(const char* name, | 128 RawCode* StubCode::Generate(const char* name, |
| 129 void (*GenerateStub)(Assembler* assembler)) { | 129 void (*GenerateStub)(Assembler* assembler)) { |
| 130 Assembler assembler; | 130 Assembler assembler; |
| 131 GenerateStub(&assembler); | 131 GenerateStub(&assembler); |
| 132 const Code& code = Code::Handle(Code::FinalizeCode(name, &assembler)); | 132 const Code& code = Code::Handle(Code::FinalizeCode(name, &assembler)); |
| 133 if (FLAG_disassemble_stubs) { | 133 if (FLAG_disassemble_stubs) { |
| 134 LogBlock lb(Isolate::Current()); | 134 LogBlock lb; |
| 135 ISL_Print("Code for stub '%s': {\n", name); | 135 THR_Print("Code for stub '%s': {\n", name); |
| 136 DisassembleToStdout formatter; | 136 DisassembleToStdout formatter; |
| 137 code.Disassemble(&formatter); | 137 code.Disassemble(&formatter); |
| 138 ISL_Print("}\n"); | 138 THR_Print("}\n"); |
| 139 const ObjectPool& object_pool = ObjectPool::Handle( | 139 const ObjectPool& object_pool = ObjectPool::Handle( |
| 140 Instructions::Handle(code.instructions()).object_pool()); | 140 Instructions::Handle(code.instructions()).object_pool()); |
| 141 object_pool.DebugPrint(); | 141 object_pool.DebugPrint(); |
| 142 } | 142 } |
| 143 return code.raw(); | 143 return code.raw(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 | 146 |
| 147 const char* StubCode::NameOfStub(uword entry_point) { | 147 const char* StubCode::NameOfStub(uword entry_point) { |
| 148 #define VM_STUB_CODE_TESTER(name) \ | 148 #define VM_STUB_CODE_TESTER(name) \ |
| 149 if ((name##_entry() != NULL) && \ | 149 if ((name##_entry() != NULL) && \ |
| 150 (entry_point == name##_entry()->EntryPoint())) { \ | 150 (entry_point == name##_entry()->EntryPoint())) { \ |
| 151 return ""#name; \ | 151 return ""#name; \ |
| 152 } | 152 } |
| 153 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); | 153 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); |
| 154 #undef VM_STUB_CODE_TESTER | 154 #undef VM_STUB_CODE_TESTER |
| 155 return NULL; | 155 return NULL; |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace dart | 158 } // namespace dart |
| OLD | NEW |