| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
| 9 #include "vm/disassembler.h" | 9 #include "vm/disassembler.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 OS::Print("Code for closure allocation stub '%s': {\n", name); | 150 OS::Print("Code for closure allocation stub '%s': {\n", name); |
| 151 Disassembler::Disassemble(stub.EntryPoint(), | 151 Disassembler::Disassemble(stub.EntryPoint(), |
| 152 stub.EntryPoint() + assembler.CodeSize()); | 152 stub.EntryPoint() + assembler.CodeSize()); |
| 153 OS::Print("}\n"); | 153 OS::Print("}\n"); |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 return stub.raw(); | 156 return stub.raw(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 | 159 |
| 160 RawCode* StubCode::GetAllocationStubForStaticImplicitClosure( | |
| 161 const Function& func) { | |
| 162 ASSERT(func.is_static()); | |
| 163 Code& stub = Code::Handle(func.closure_allocation_stub()); | |
| 164 if (stub.IsNull()) { | |
| 165 Assembler assembler; | |
| 166 const char* name = func.ToCString(); | |
| 167 StubCode::GenerateAllocationStubForStaticImplicitClosure(&assembler, func); | |
| 168 stub ^= Code::FinalizeCode(name, &assembler); | |
| 169 func.set_closure_allocation_stub(stub); | |
| 170 if (FLAG_disassemble_stubs) { | |
| 171 OS::Print("Code for implicit closure allocation stub '%s': {\n", name); | |
| 172 Disassembler::Disassemble(stub.EntryPoint(), | |
| 173 stub.EntryPoint() + assembler.CodeSize()); | |
| 174 OS::Print("}\n"); | |
| 175 } | |
| 176 } | |
| 177 return stub.raw(); | |
| 178 } | |
| 179 | |
| 180 | |
| 181 RawCode* StubCode::Generate(const char* name, | 160 RawCode* StubCode::Generate(const char* name, |
| 182 void (*GenerateStub)(Assembler* assembler)) { | 161 void (*GenerateStub)(Assembler* assembler)) { |
| 183 Assembler assembler; | 162 Assembler assembler; |
| 184 GenerateStub(&assembler); | 163 GenerateStub(&assembler); |
| 185 const Code& code = Code::Handle(Code::FinalizeCode(name, &assembler)); | 164 const Code& code = Code::Handle(Code::FinalizeCode(name, &assembler)); |
| 186 if (FLAG_disassemble_stubs) { | 165 if (FLAG_disassemble_stubs) { |
| 187 OS::Print("Code for stub '%s': {\n", name); | 166 OS::Print("Code for stub '%s': {\n", name); |
| 188 Disassembler::Disassemble(code.EntryPoint(), | 167 Disassembler::Disassemble(code.EntryPoint(), |
| 189 code.EntryPoint() + assembler.CodeSize()); | 168 code.EntryPoint() + assembler.CodeSize()); |
| 190 OS::Print("}\n"); | 169 OS::Print("}\n"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 202 VM_STUB_CODE_LIST(STUB_CODE_TESTER); | 181 VM_STUB_CODE_LIST(STUB_CODE_TESTER); |
| 203 Isolate* isolate = Isolate::Current(); | 182 Isolate* isolate = Isolate::Current(); |
| 204 if ((isolate != NULL) && (isolate->stub_code() != NULL)) { | 183 if ((isolate != NULL) && (isolate->stub_code() != NULL)) { |
| 205 STUB_CODE_LIST(STUB_CODE_TESTER); | 184 STUB_CODE_LIST(STUB_CODE_TESTER); |
| 206 } | 185 } |
| 207 #undef STUB_CODE_TESTER | 186 #undef STUB_CODE_TESTER |
| 208 return NULL; | 187 return NULL; |
| 209 } | 188 } |
| 210 | 189 |
| 211 } // namespace dart | 190 } // namespace dart |
| OLD | NEW |