| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 OS::Print("Code for allocation stub '%s': {\n", name); | 110 OS::Print("Code for allocation stub '%s': {\n", name); |
| 111 Disassembler::Disassemble(stub.EntryPoint(), | 111 Disassembler::Disassemble(stub.EntryPoint(), |
| 112 stub.EntryPoint() + assembler.CodeSize()); | 112 stub.EntryPoint() + assembler.CodeSize()); |
| 113 OS::Print("}\n"); | 113 OS::Print("}\n"); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 return stub.raw(); | 116 return stub.raw(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 | 119 |
| 120 RawCode* StubCode::GetAllocationStubForClosure(const Function& func) { | |
| 121 Code& stub = Code::Handle(func.closure_allocation_stub()); | |
| 122 if (stub.IsNull()) { | |
| 123 Assembler assembler; | |
| 124 const char* name = func.ToCString(); | |
| 125 StubCode::GenerateAllocationStubForClosure(&assembler, func); | |
| 126 stub ^= Code::FinalizeCode(name, &assembler); | |
| 127 func.set_closure_allocation_stub(stub); | |
| 128 if (FLAG_disassemble_stubs) { | |
| 129 OS::Print("Code for closure allocation stub '%s': {\n", name); | |
| 130 Disassembler::Disassemble(stub.EntryPoint(), | |
| 131 stub.EntryPoint() + assembler.CodeSize()); | |
| 132 OS::Print("}\n"); | |
| 133 } | |
| 134 } | |
| 135 return stub.raw(); | |
| 136 } | |
| 137 | |
| 138 | |
| 139 RawCode* StubCode::Generate(const char* name, | 120 RawCode* StubCode::Generate(const char* name, |
| 140 void (*GenerateStub)(Assembler* assembler)) { | 121 void (*GenerateStub)(Assembler* assembler)) { |
| 141 Assembler assembler; | 122 Assembler assembler; |
| 142 GenerateStub(&assembler); | 123 GenerateStub(&assembler); |
| 143 const Code& code = Code::Handle(Code::FinalizeCode(name, &assembler)); | 124 const Code& code = Code::Handle(Code::FinalizeCode(name, &assembler)); |
| 144 if (FLAG_disassemble_stubs) { | 125 if (FLAG_disassemble_stubs) { |
| 145 OS::Print("Code for stub '%s': {\n", name); | 126 OS::Print("Code for stub '%s': {\n", name); |
| 146 Disassembler::Disassemble(code.EntryPoint(), | 127 Disassembler::Disassemble(code.EntryPoint(), |
| 147 code.EntryPoint() + assembler.CodeSize()); | 128 code.EntryPoint() + assembler.CodeSize()); |
| 148 OS::Print("}\n"); | 129 OS::Print("}\n"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 160 VM_STUB_CODE_LIST(STUB_CODE_TESTER); | 141 VM_STUB_CODE_LIST(STUB_CODE_TESTER); |
| 161 Isolate* isolate = Isolate::Current(); | 142 Isolate* isolate = Isolate::Current(); |
| 162 if ((isolate != NULL) && (isolate->stub_code() != NULL)) { | 143 if ((isolate != NULL) && (isolate->stub_code() != NULL)) { |
| 163 STUB_CODE_LIST(STUB_CODE_TESTER); | 144 STUB_CODE_LIST(STUB_CODE_TESTER); |
| 164 } | 145 } |
| 165 #undef STUB_CODE_TESTER | 146 #undef STUB_CODE_TESTER |
| 166 return NULL; | 147 return NULL; |
| 167 } | 148 } |
| 168 | 149 |
| 169 } // namespace dart | 150 } // namespace dart |
| OLD | NEW |