| 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 "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/disassembler.h" | 9 #include "vm/disassembler.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 (pc < (InvokeDartCodeEntryPoint() + InvokeDartCodeSize()))); | 100 (pc < (InvokeDartCodeEntryPoint() + InvokeDartCodeSize()))); |
| 101 } | 101 } |
| 102 | 102 |
| 103 | 103 |
| 104 RawCode* StubCode::GetAllocationStubForClass(const Class& cls) { | 104 RawCode* StubCode::GetAllocationStubForClass(const Class& cls) { |
| 105 Code& stub = Code::Handle(cls.allocation_stub()); | 105 Code& stub = Code::Handle(cls.allocation_stub()); |
| 106 if (stub.IsNull()) { | 106 if (stub.IsNull()) { |
| 107 Assembler assembler; | 107 Assembler assembler; |
| 108 const char* name = cls.ToCString(); | 108 const char* name = cls.ToCString(); |
| 109 StubCode::GenerateAllocationStubForClass(&assembler, cls); | 109 StubCode::GenerateAllocationStubForClass(&assembler, cls); |
| 110 stub ^= Code::FinalizeCode(name, &assembler); | 110 stub ^= Code::FinalizeStubCode(name, &assembler); |
| 111 cls.set_allocation_stub(stub); | 111 cls.set_allocation_stub(stub); |
| 112 if (FLAG_disassemble_stubs) { | 112 if (FLAG_disassemble_stubs) { |
| 113 OS::Print("Code for allocation stub '%s': {\n", name); | 113 OS::Print("Code for allocation stub '%s': {\n", name); |
| 114 Disassembler::Disassemble(stub.EntryPoint(), | 114 Disassembler::Disassemble(stub.EntryPoint(), |
| 115 stub.EntryPoint() + assembler.CodeSize()); | 115 stub.EntryPoint() + assembler.CodeSize()); |
| 116 OS::Print("}\n"); | 116 OS::Print("}\n"); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 return stub.raw(); | 119 return stub.raw(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 | 122 |
| 123 RawCode* StubCode::GetAllocationStubForClosure(const Function& func) { | 123 RawCode* StubCode::GetAllocationStubForClosure(const Function& func) { |
| 124 Code& stub = Code::Handle(func.closure_allocation_stub()); | 124 Code& stub = Code::Handle(func.closure_allocation_stub()); |
| 125 if (stub.IsNull()) { | 125 if (stub.IsNull()) { |
| 126 Assembler assembler; | 126 Assembler assembler; |
| 127 const char* name = func.ToCString(); | 127 const char* name = func.ToCString(); |
| 128 StubCode::GenerateAllocationStubForClosure(&assembler, func); | 128 StubCode::GenerateAllocationStubForClosure(&assembler, func); |
| 129 stub ^= Code::FinalizeCode(name, &assembler); | 129 stub ^= Code::FinalizeStubCode(name, &assembler); |
| 130 func.set_closure_allocation_stub(stub); | 130 func.set_closure_allocation_stub(stub); |
| 131 if (FLAG_disassemble_stubs) { | 131 if (FLAG_disassemble_stubs) { |
| 132 OS::Print("Code for closure allocation stub '%s': {\n", name); | 132 OS::Print("Code for closure allocation stub '%s': {\n", name); |
| 133 Disassembler::Disassemble(stub.EntryPoint(), | 133 Disassembler::Disassemble(stub.EntryPoint(), |
| 134 stub.EntryPoint() + assembler.CodeSize()); | 134 stub.EntryPoint() + assembler.CodeSize()); |
| 135 OS::Print("}\n"); | 135 OS::Print("}\n"); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 return stub.raw(); | 138 return stub.raw(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 | 141 |
| 142 RawCode* StubCode::Generate(const char* name, | 142 RawCode* StubCode::Generate(const char* name, |
| 143 void (*GenerateStub)(Assembler* assembler)) { | 143 void (*GenerateStub)(Assembler* assembler)) { |
| 144 Assembler assembler; | 144 Assembler assembler; |
| 145 GenerateStub(&assembler); | 145 GenerateStub(&assembler); |
| 146 const Code& code = Code::Handle(Code::FinalizeCode(name, &assembler)); | 146 const Code& code = Code::Handle(Code::FinalizeStubCode(name, &assembler)); |
| 147 if (FLAG_disassemble_stubs) { | 147 if (FLAG_disassemble_stubs) { |
| 148 OS::Print("Code for stub '%s': {\n", name); | 148 OS::Print("Code for stub '%s': {\n", name); |
| 149 Disassembler::Disassemble(code.EntryPoint(), | 149 Disassembler::Disassemble(code.EntryPoint(), |
| 150 code.EntryPoint() + assembler.CodeSize()); | 150 code.EntryPoint() + assembler.CodeSize()); |
| 151 OS::Print("}\n"); | 151 OS::Print("}\n"); |
| 152 } | 152 } |
| 153 return code.raw(); | 153 return code.raw(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 | 156 |
| 157 const char* StubCode::NameOfStub(uword entry_point) { | 157 const char* StubCode::NameOfStub(uword entry_point) { |
| 158 #define STUB_CODE_TESTER(name) \ | 158 #define STUB_CODE_TESTER(name) \ |
| 159 if ((name##_entry() != NULL) && (entry_point == name##EntryPoint())) { \ | 159 if ((name##_entry() != NULL) && (entry_point == name##EntryPoint())) { \ |
| 160 return ""#name; \ | 160 return ""#name; \ |
| 161 } | 161 } |
| 162 | 162 |
| 163 VM_STUB_CODE_LIST(STUB_CODE_TESTER); | 163 VM_STUB_CODE_LIST(STUB_CODE_TESTER); |
| 164 Isolate* isolate = Isolate::Current(); | 164 Isolate* isolate = Isolate::Current(); |
| 165 if ((isolate != NULL) && (isolate->stub_code() != NULL)) { | 165 if ((isolate != NULL) && (isolate->stub_code() != NULL)) { |
| 166 STUB_CODE_LIST(STUB_CODE_TESTER); | 166 STUB_CODE_LIST(STUB_CODE_TESTER); |
| 167 } | 167 } |
| 168 #undef STUB_CODE_TESTER | 168 #undef STUB_CODE_TESTER |
| 169 return NULL; | 169 return NULL; |
| 170 } | 170 } |
| 171 | 171 |
| 172 } // namespace dart | 172 } // namespace dart |
| OLD | NEW |