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