| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 return AllocateArray_entry()->code(); | 116 return AllocateArray_entry()->code(); |
| 117 } | 117 } |
| 118 Code& stub = Code::Handle(zone, cls.allocation_stub()); | 118 Code& stub = Code::Handle(zone, cls.allocation_stub()); |
| 119 if (stub.IsNull()) { | 119 if (stub.IsNull()) { |
| 120 Assembler assembler; | 120 Assembler assembler; |
| 121 const char* name = cls.ToCString(); | 121 const char* name = cls.ToCString(); |
| 122 StubCode::GenerateAllocationStubForClass(&assembler, cls); | 122 StubCode::GenerateAllocationStubForClass(&assembler, cls); |
| 123 stub ^= Code::FinalizeCode(name, &assembler, false /* optimized */); | 123 stub ^= Code::FinalizeCode(name, &assembler, false /* optimized */); |
| 124 stub.set_owner(cls); | 124 stub.set_owner(cls); |
| 125 cls.set_allocation_stub(stub); | 125 cls.set_allocation_stub(stub); |
| 126 if (FLAG_disassemble_stubs) { | 126 if (FLAG_support_disassembler && FLAG_disassemble_stubs) { |
| 127 LogBlock lb; | 127 LogBlock lb; |
| 128 THR_Print("Code for allocation stub '%s': {\n", name); | 128 THR_Print("Code for allocation stub '%s': {\n", name); |
| 129 #ifndef PRODUCT |
| 129 DisassembleToStdout formatter; | 130 DisassembleToStdout formatter; |
| 130 stub.Disassemble(&formatter); | 131 stub.Disassemble(&formatter); |
| 132 #endif |
| 131 THR_Print("}\n"); | 133 THR_Print("}\n"); |
| 132 const ObjectPool& object_pool = ObjectPool::Handle(stub.object_pool()); | 134 const ObjectPool& object_pool = ObjectPool::Handle(stub.object_pool()); |
| 133 object_pool.DebugPrint(); | 135 object_pool.DebugPrint(); |
| 134 } | 136 } |
| 135 } | 137 } |
| 136 return stub.raw(); | 138 return stub.raw(); |
| 137 } | 139 } |
| 138 | 140 |
| 139 | 141 |
| 140 const StubEntry* StubCode::UnoptimizedStaticCallEntry( | 142 const StubEntry* StubCode::UnoptimizedStaticCallEntry( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 152 } | 154 } |
| 153 } | 155 } |
| 154 | 156 |
| 155 | 157 |
| 156 RawCode* StubCode::Generate(const char* name, | 158 RawCode* StubCode::Generate(const char* name, |
| 157 void (*GenerateStub)(Assembler* assembler)) { | 159 void (*GenerateStub)(Assembler* assembler)) { |
| 158 Assembler assembler; | 160 Assembler assembler; |
| 159 GenerateStub(&assembler); | 161 GenerateStub(&assembler); |
| 160 const Code& code = Code::Handle( | 162 const Code& code = Code::Handle( |
| 161 Code::FinalizeCode(name, &assembler, false /* optimized */)); | 163 Code::FinalizeCode(name, &assembler, false /* optimized */)); |
| 162 if (FLAG_disassemble_stubs) { | 164 if (FLAG_support_disassembler && FLAG_disassemble_stubs) { |
| 163 LogBlock lb; | 165 LogBlock lb; |
| 164 THR_Print("Code for stub '%s': {\n", name); | 166 THR_Print("Code for stub '%s': {\n", name); |
| 165 DisassembleToStdout formatter; | 167 DisassembleToStdout formatter; |
| 166 code.Disassemble(&formatter); | 168 code.Disassemble(&formatter); |
| 167 THR_Print("}\n"); | 169 THR_Print("}\n"); |
| 168 const ObjectPool& object_pool = ObjectPool::Handle(code.object_pool()); | 170 const ObjectPool& object_pool = ObjectPool::Handle(code.object_pool()); |
| 169 object_pool.DebugPrint(); | 171 object_pool.DebugPrint(); |
| 170 } | 172 } |
| 171 return code.raw(); | 173 return code.raw(); |
| 172 } | 174 } |
| 173 | 175 |
| 174 | 176 |
| 175 const char* StubCode::NameOfStub(uword entry_point) { | 177 const char* StubCode::NameOfStub(uword entry_point) { |
| 176 #define VM_STUB_CODE_TESTER(name) \ | 178 #define VM_STUB_CODE_TESTER(name) \ |
| 177 if ((name##_entry() != NULL) && \ | 179 if ((name##_entry() != NULL) && \ |
| 178 (entry_point == name##_entry()->EntryPoint())) { \ | 180 (entry_point == name##_entry()->EntryPoint())) { \ |
| 179 return ""#name; \ | 181 return ""#name; \ |
| 180 } | 182 } |
| 181 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); | 183 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); |
| 182 #undef VM_STUB_CODE_TESTER | 184 #undef VM_STUB_CODE_TESTER |
| 183 return NULL; | 185 return NULL; |
| 184 } | 186 } |
| 185 | 187 |
| 186 } // namespace dart | 188 } // namespace dart |
| OLD | NEW |