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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 Isolate* isolate = Isolate::Current(); | 97 Isolate* isolate = Isolate::Current(); |
98 const Error& error = Error::Handle(isolate, cls.EnsureIsFinalized(isolate)); | 98 const Error& error = Error::Handle(isolate, cls.EnsureIsFinalized(isolate)); |
99 ASSERT(error.IsNull()); | 99 ASSERT(error.IsNull()); |
100 if (cls.id() == kArrayCid) { | 100 if (cls.id() == kArrayCid) { |
101 return AllocateArray_entry()->code(); | 101 return AllocateArray_entry()->code(); |
102 } | 102 } |
103 Code& stub = Code::Handle(isolate, cls.allocation_stub()); | 103 Code& stub = Code::Handle(isolate, cls.allocation_stub()); |
104 if (stub.IsNull()) { | 104 if (stub.IsNull()) { |
105 Assembler assembler; | 105 Assembler assembler; |
106 const char* name = cls.ToCString(); | 106 const char* name = cls.ToCString(); |
107 uword patch_code_offset = 0; | 107 StubCode::GenerateAllocationStubForClass(&assembler, cls); |
108 uword entry_patch_offset = 0; | |
109 StubCode::GenerateAllocationStubForClass( | |
110 &assembler, cls, &entry_patch_offset, &patch_code_offset); | |
111 stub ^= Code::FinalizeCode(name, &assembler); | 108 stub ^= Code::FinalizeCode(name, &assembler); |
112 stub.set_owner(cls); | 109 stub.set_owner(cls); |
113 cls.set_allocation_stub(stub); | 110 cls.set_allocation_stub(stub); |
114 if (FLAG_disassemble_stubs) { | 111 if (FLAG_disassemble_stubs) { |
115 LogBlock lb; | 112 LogBlock lb; |
116 THR_Print("Code for allocation stub '%s': {\n", name); | 113 THR_Print("Code for allocation stub '%s': {\n", name); |
117 DisassembleToStdout formatter; | 114 DisassembleToStdout formatter; |
118 stub.Disassemble(&formatter); | 115 stub.Disassemble(&formatter); |
119 THR_Print("}\n"); | 116 THR_Print("}\n"); |
120 const ObjectPool& object_pool = ObjectPool::Handle( | 117 const ObjectPool& object_pool = ObjectPool::Handle(stub.object_pool()); |
121 Instructions::Handle(stub.instructions()).object_pool()); | |
122 object_pool.DebugPrint(); | 118 object_pool.DebugPrint(); |
123 } | 119 } |
124 stub.set_entry_patch_pc_offset(entry_patch_offset); | |
125 stub.set_patch_code_pc_offset(patch_code_offset); | |
126 } | 120 } |
127 return stub.raw(); | 121 return stub.raw(); |
128 } | 122 } |
129 | 123 |
130 | 124 |
131 const StubEntry* StubCode::UnoptimizedStaticCallEntry( | 125 const StubEntry* StubCode::UnoptimizedStaticCallEntry( |
132 intptr_t num_args_tested) { | 126 intptr_t num_args_tested) { |
133 switch (num_args_tested) { | 127 switch (num_args_tested) { |
134 case 0: | 128 case 0: |
135 return ZeroArgsUnoptimizedStaticCall_entry(); | 129 return ZeroArgsUnoptimizedStaticCall_entry(); |
(...skipping 12 matching lines...) Expand all Loading... |
148 void (*GenerateStub)(Assembler* assembler)) { | 142 void (*GenerateStub)(Assembler* assembler)) { |
149 Assembler assembler; | 143 Assembler assembler; |
150 GenerateStub(&assembler); | 144 GenerateStub(&assembler); |
151 const Code& code = Code::Handle(Code::FinalizeCode(name, &assembler)); | 145 const Code& code = Code::Handle(Code::FinalizeCode(name, &assembler)); |
152 if (FLAG_disassemble_stubs) { | 146 if (FLAG_disassemble_stubs) { |
153 LogBlock lb; | 147 LogBlock lb; |
154 THR_Print("Code for stub '%s': {\n", name); | 148 THR_Print("Code for stub '%s': {\n", name); |
155 DisassembleToStdout formatter; | 149 DisassembleToStdout formatter; |
156 code.Disassemble(&formatter); | 150 code.Disassemble(&formatter); |
157 THR_Print("}\n"); | 151 THR_Print("}\n"); |
158 const ObjectPool& object_pool = ObjectPool::Handle( | 152 const ObjectPool& object_pool = ObjectPool::Handle(code.object_pool()); |
159 Instructions::Handle(code.instructions()).object_pool()); | |
160 object_pool.DebugPrint(); | 153 object_pool.DebugPrint(); |
161 } | 154 } |
162 return code.raw(); | 155 return code.raw(); |
163 } | 156 } |
164 | 157 |
165 | 158 |
166 const char* StubCode::NameOfStub(uword entry_point) { | 159 const char* StubCode::NameOfStub(uword entry_point) { |
167 #define VM_STUB_CODE_TESTER(name) \ | 160 #define VM_STUB_CODE_TESTER(name) \ |
168 if ((name##_entry() != NULL) && \ | 161 if ((name##_entry() != NULL) && \ |
169 (entry_point == name##_entry()->EntryPoint())) { \ | 162 (entry_point == name##_entry()->EntryPoint())) { \ |
170 return ""#name; \ | 163 return ""#name; \ |
171 } | 164 } |
172 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); | 165 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); |
173 #undef VM_STUB_CODE_TESTER | 166 #undef VM_STUB_CODE_TESTER |
174 return NULL; | 167 return NULL; |
175 } | 168 } |
176 | 169 |
177 } // namespace dart | 170 } // namespace dart |
OLD | NEW |