| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 149 } |
| 150 stub ^= Code::FinalizeCode(name, &assembler); | 150 stub ^= Code::FinalizeCode(name, &assembler); |
| 151 stub.set_owner(cls); | 151 stub.set_owner(cls); |
| 152 cls.set_allocation_stub(stub); | 152 cls.set_allocation_stub(stub); |
| 153 if (FLAG_disassemble_stubs) { | 153 if (FLAG_disassemble_stubs) { |
| 154 LogBlock lb(Isolate::Current()); | 154 LogBlock lb(Isolate::Current()); |
| 155 ISL_Print("Code for allocation stub '%s': {\n", name); | 155 ISL_Print("Code for allocation stub '%s': {\n", name); |
| 156 DisassembleToStdout formatter; | 156 DisassembleToStdout formatter; |
| 157 stub.Disassemble(&formatter); | 157 stub.Disassemble(&formatter); |
| 158 ISL_Print("}\n"); | 158 ISL_Print("}\n"); |
| 159 const ObjectPool& object_pool = ObjectPool::Handle( | 159 const ObjectPool& object_pool = ObjectPool::Handle(stub.object_pool()); |
| 160 Instructions::Handle(stub.instructions()).object_pool()); | |
| 161 object_pool.DebugPrint(); | 160 object_pool.DebugPrint(); |
| 162 } | 161 } |
| 163 stub.set_entry_patch_pc_offset(entry_patch_offset); | 162 stub.set_entry_patch_pc_offset(entry_patch_offset); |
| 164 stub.set_patch_code_pc_offset(patch_code_offset); | 163 stub.set_patch_code_pc_offset(patch_code_offset); |
| 165 } | 164 } |
| 166 return stub.raw(); | 165 return stub.raw(); |
| 167 } | 166 } |
| 168 | 167 |
| 169 | 168 |
| 170 uword StubCode::UnoptimizedStaticCallEntryPoint(intptr_t num_args_tested) { | 169 uword StubCode::UnoptimizedStaticCallEntryPoint(intptr_t num_args_tested) { |
| 171 switch (num_args_tested) { | 170 switch (num_args_tested) { |
| 172 case 0: | 171 case 0: |
| 173 return ZeroArgsUnoptimizedStaticCallEntryPoint(); | 172 return ZeroArgsUnoptimizedStaticCallEntryPoint(); |
| 174 case 1: | 173 case 1: |
| 175 return OneArgUnoptimizedStaticCallEntryPoint(); | 174 return OneArgUnoptimizedStaticCallEntryPoint(); |
| 176 case 2: | 175 case 2: |
| 177 return TwoArgsUnoptimizedStaticCallEntryPoint(); | 176 return TwoArgsUnoptimizedStaticCallEntryPoint(); |
| 178 default: | 177 default: |
| 179 UNIMPLEMENTED(); | 178 UNIMPLEMENTED(); |
| 180 return 0; | 179 return 0; |
| 181 } | 180 } |
| 182 } | 181 } |
| 183 | 182 |
| 184 | 183 |
| 184 RawCode* StubCode::UnoptimizedStaticCallCode(intptr_t num_args_tested) { |
| 185 switch (num_args_tested) { |
| 186 case 0: |
| 187 return ZeroArgsUnoptimizedStaticCallCode(); |
| 188 case 1: |
| 189 return OneArgUnoptimizedStaticCallCode(); |
| 190 case 2: |
| 191 return TwoArgsUnoptimizedStaticCallCode(); |
| 192 default: |
| 193 UNIMPLEMENTED(); |
| 194 return 0; |
| 195 } |
| 196 } |
| 197 |
| 198 |
| 185 RawCode* StubCode::Generate(const char* name, | 199 RawCode* StubCode::Generate(const char* name, |
| 186 void (*GenerateStub)(Assembler* assembler)) { | 200 void (*GenerateStub)(Assembler* assembler)) { |
| 187 Assembler assembler; | 201 Assembler assembler; |
| 188 GenerateStub(&assembler); | 202 GenerateStub(&assembler); |
| 189 const Code& code = Code::Handle(Code::FinalizeCode(name, &assembler)); | 203 const Code& code = Code::Handle(Code::FinalizeCode(name, &assembler)); |
| 190 if (FLAG_disassemble_stubs) { | 204 if (FLAG_disassemble_stubs) { |
| 191 LogBlock lb(Isolate::Current()); | 205 LogBlock lb(Isolate::Current()); |
| 192 ISL_Print("Code for stub '%s': {\n", name); | 206 ISL_Print("Code for stub '%s': {\n", name); |
| 193 DisassembleToStdout formatter; | 207 DisassembleToStdout formatter; |
| 194 code.Disassemble(&formatter); | 208 code.Disassemble(&formatter); |
| 195 ISL_Print("}\n"); | 209 ISL_Print("}\n"); |
| 196 const ObjectPool& object_pool = ObjectPool::Handle( | 210 const ObjectPool& object_pool = ObjectPool::Handle(code.object_pool()); |
| 197 Instructions::Handle(code.instructions()).object_pool()); | |
| 198 object_pool.DebugPrint(); | 211 object_pool.DebugPrint(); |
| 199 } | 212 } |
| 200 return code.raw(); | 213 return code.raw(); |
| 201 } | 214 } |
| 202 | 215 |
| 203 | 216 |
| 204 const char* StubCode::NameOfStub(uword entry_point) { | 217 const char* StubCode::NameOfStub(uword entry_point) { |
| 205 #define VM_STUB_CODE_TESTER(name) \ | 218 #define VM_STUB_CODE_TESTER(name) \ |
| 206 if ((name##_entry() != NULL) && (entry_point == name##EntryPoint())) { \ | 219 if ((name##_entry() != NULL) && (entry_point == name##EntryPoint())) { \ |
| 207 return ""#name; \ | 220 return ""#name; \ |
| 208 } | 221 } |
| 209 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); | 222 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); |
| 210 | 223 |
| 211 #define STUB_CODE_TESTER(name) \ | 224 #define STUB_CODE_TESTER(name) \ |
| 212 if ((isolate->stub_code()->name##_entry() != NULL) && \ | 225 if ((isolate->stub_code()->name##_entry() != NULL) && \ |
| 213 (entry_point == isolate->stub_code()->name##EntryPoint())) { \ | 226 (entry_point == isolate->stub_code()->name##EntryPoint())) { \ |
| 214 return ""#name; \ | 227 return ""#name; \ |
| 215 } | 228 } |
| 216 Isolate* isolate = Isolate::Current(); | 229 Isolate* isolate = Isolate::Current(); |
| 217 if ((isolate != NULL) && (isolate->stub_code() != NULL)) { | 230 if ((isolate != NULL) && (isolate->stub_code() != NULL)) { |
| 218 STUB_CODE_LIST(STUB_CODE_TESTER); | 231 STUB_CODE_LIST(STUB_CODE_TESTER); |
| 219 } | 232 } |
| 220 #undef VM_STUB_CODE_TESTER | 233 #undef VM_STUB_CODE_TESTER |
| 221 #undef STUB_CODE_TESTER | 234 #undef STUB_CODE_TESTER |
| 222 return NULL; | 235 return NULL; |
| 223 } | 236 } |
| 224 | 237 |
| 225 } // namespace dart | 238 } // namespace dart |
| OLD | NEW |