| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 StubCode::GeneratePatchableAllocateArrayStub( | 144 StubCode::GeneratePatchableAllocateArrayStub( |
| 145 &assembler, &entry_patch_offset, &patch_code_offset); | 145 &assembler, &entry_patch_offset, &patch_code_offset); |
| 146 } else { | 146 } else { |
| 147 StubCode::GenerateAllocationStubForClass( | 147 StubCode::GenerateAllocationStubForClass( |
| 148 &assembler, cls, &entry_patch_offset, &patch_code_offset); | 148 &assembler, cls, &entry_patch_offset, &patch_code_offset); |
| 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 OS::Print("Code for allocation stub '%s': {\n", name); | 154 ISL_Print("Code for allocation stub '%s': {\n", name); |
| 155 DisassembleToStdout formatter; | 155 DisassembleToStdout formatter; |
| 156 stub.Disassemble(&formatter); | 156 stub.Disassemble(&formatter); |
| 157 OS::Print("}\n"); | 157 ISL_Print("}\n"); |
| 158 } | 158 } |
| 159 stub.set_entry_patch_pc_offset(entry_patch_offset); | 159 stub.set_entry_patch_pc_offset(entry_patch_offset); |
| 160 stub.set_patch_code_pc_offset(patch_code_offset); | 160 stub.set_patch_code_pc_offset(patch_code_offset); |
| 161 } | 161 } |
| 162 return stub.raw(); | 162 return stub.raw(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 | 165 |
| 166 uword StubCode::UnoptimizedStaticCallEntryPoint(intptr_t num_args_tested) { | 166 uword StubCode::UnoptimizedStaticCallEntryPoint(intptr_t num_args_tested) { |
| 167 switch (num_args_tested) { | 167 switch (num_args_tested) { |
| 168 case 0: | 168 case 0: |
| 169 return ZeroArgsUnoptimizedStaticCallEntryPoint(); | 169 return ZeroArgsUnoptimizedStaticCallEntryPoint(); |
| 170 case 1: | 170 case 1: |
| 171 return OneArgUnoptimizedStaticCallEntryPoint(); | 171 return OneArgUnoptimizedStaticCallEntryPoint(); |
| 172 case 2: | 172 case 2: |
| 173 return TwoArgsUnoptimizedStaticCallEntryPoint(); | 173 return TwoArgsUnoptimizedStaticCallEntryPoint(); |
| 174 default: | 174 default: |
| 175 UNIMPLEMENTED(); | 175 UNIMPLEMENTED(); |
| 176 return 0; | 176 return 0; |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 | 180 |
| 181 RawCode* StubCode::Generate(const char* name, | 181 RawCode* StubCode::Generate(const char* name, |
| 182 void (*GenerateStub)(Assembler* assembler)) { | 182 void (*GenerateStub)(Assembler* assembler)) { |
| 183 Assembler assembler; | 183 Assembler assembler; |
| 184 GenerateStub(&assembler); | 184 GenerateStub(&assembler); |
| 185 const Code& code = Code::Handle(Code::FinalizeCode(name, &assembler)); | 185 const Code& code = Code::Handle(Code::FinalizeCode(name, &assembler)); |
| 186 if (FLAG_disassemble_stubs) { | 186 if (FLAG_disassemble_stubs) { |
| 187 OS::Print("Code for stub '%s': {\n", name); | 187 ISL_Print("Code for stub '%s': {\n", name); |
| 188 DisassembleToStdout formatter; | 188 DisassembleToStdout formatter; |
| 189 code.Disassemble(&formatter); | 189 code.Disassemble(&formatter); |
| 190 OS::Print("}\n"); | 190 ISL_Print("}\n"); |
| 191 } | 191 } |
| 192 return code.raw(); | 192 return code.raw(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 | 195 |
| 196 const char* StubCode::NameOfStub(uword entry_point) { | 196 const char* StubCode::NameOfStub(uword entry_point) { |
| 197 #define VM_STUB_CODE_TESTER(name) \ | 197 #define VM_STUB_CODE_TESTER(name) \ |
| 198 if ((name##_entry() != NULL) && (entry_point == name##EntryPoint())) { \ | 198 if ((name##_entry() != NULL) && (entry_point == name##EntryPoint())) { \ |
| 199 return ""#name; \ | 199 return ""#name; \ |
| 200 } | 200 } |
| 201 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); | 201 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); |
| 202 | 202 |
| 203 #define STUB_CODE_TESTER(name) \ | 203 #define STUB_CODE_TESTER(name) \ |
| 204 if ((isolate->stub_code()->name##_entry() != NULL) && \ | 204 if ((isolate->stub_code()->name##_entry() != NULL) && \ |
| 205 (entry_point == isolate->stub_code()->name##EntryPoint())) { \ | 205 (entry_point == isolate->stub_code()->name##EntryPoint())) { \ |
| 206 return ""#name; \ | 206 return ""#name; \ |
| 207 } | 207 } |
| 208 Isolate* isolate = Isolate::Current(); | 208 Isolate* isolate = Isolate::Current(); |
| 209 if ((isolate != NULL) && (isolate->stub_code() != NULL)) { | 209 if ((isolate != NULL) && (isolate->stub_code() != NULL)) { |
| 210 STUB_CODE_LIST(STUB_CODE_TESTER); | 210 STUB_CODE_LIST(STUB_CODE_TESTER); |
| 211 } | 211 } |
| 212 #undef VM_STUB_CODE_TESTER | 212 #undef VM_STUB_CODE_TESTER |
| 213 #undef STUB_CODE_TESTER | 213 #undef STUB_CODE_TESTER |
| 214 return NULL; | 214 return NULL; |
| 215 } | 215 } |
| 216 | 216 |
| 217 } // namespace dart | 217 } // namespace dart |
| OLD | NEW |