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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 | 79 |
80 void StubCode::Init(Isolate* isolate) { } | 80 void StubCode::Init(Isolate* isolate) { } |
81 | 81 |
82 | 82 |
83 void StubCode::VisitObjectPointers(ObjectPointerVisitor* visitor) { | 83 void StubCode::VisitObjectPointers(ObjectPointerVisitor* visitor) { |
84 } | 84 } |
85 | 85 |
86 | 86 |
87 bool StubCode::HasBeenInitialized() { | 87 bool StubCode::HasBeenInitialized() { |
| 88 #if !defined(TARGET_ARCH_DBC) |
88 // Use JumpToExceptionHandler and InvokeDart as canaries. | 89 // Use JumpToExceptionHandler and InvokeDart as canaries. |
89 const StubEntry* entry_1 = StubCode::JumpToExceptionHandler_entry(); | 90 const StubEntry* entry_1 = StubCode::JumpToExceptionHandler_entry(); |
90 const StubEntry* entry_2 = StubCode::InvokeDartCode_entry(); | 91 const StubEntry* entry_2 = StubCode::InvokeDartCode_entry(); |
91 return (entry_1 != NULL) && (entry_2 != NULL); | 92 return (entry_1 != NULL) && (entry_2 != NULL); |
| 93 #else |
| 94 return true; |
| 95 #endif |
92 } | 96 } |
93 | 97 |
94 | 98 |
95 bool StubCode::InInvocationStub(uword pc) { | 99 bool StubCode::InInvocationStub(uword pc) { |
| 100 #if !defined(TARGET_ARCH_DBC) |
96 ASSERT(HasBeenInitialized()); | 101 ASSERT(HasBeenInitialized()); |
97 uword entry = StubCode::InvokeDartCode_entry()->EntryPoint(); | 102 uword entry = StubCode::InvokeDartCode_entry()->EntryPoint(); |
98 uword size = StubCode::InvokeDartCodeSize(); | 103 uword size = StubCode::InvokeDartCodeSize(); |
99 return (pc >= entry) && (pc < (entry + size)); | 104 return (pc >= entry) && (pc < (entry + size)); |
| 105 #else |
| 106 // On DBC we use a special marker PC to signify entry frame because there is |
| 107 // no such thing as invocation stub. |
| 108 return (pc & 2) != 0; |
| 109 #endif |
100 } | 110 } |
101 | 111 |
102 | 112 |
103 bool StubCode::InJumpToExceptionHandlerStub(uword pc) { | 113 bool StubCode::InJumpToExceptionHandlerStub(uword pc) { |
| 114 #if !defined(TARGET_ARCH_DBC) |
104 ASSERT(HasBeenInitialized()); | 115 ASSERT(HasBeenInitialized()); |
105 uword entry = StubCode::JumpToExceptionHandler_entry()->EntryPoint(); | 116 uword entry = StubCode::JumpToExceptionHandler_entry()->EntryPoint(); |
106 uword size = StubCode::JumpToExceptionHandlerSize(); | 117 uword size = StubCode::JumpToExceptionHandlerSize(); |
107 return (pc >= entry) && (pc < (entry + size)); | 118 return (pc >= entry) && (pc < (entry + size)); |
| 119 #else |
| 120 // This stub does not exist on DBC. |
| 121 return false; |
| 122 #endif |
108 } | 123 } |
109 | 124 |
110 | 125 |
111 RawCode* StubCode::GetAllocationStubForClass(const Class& cls) { | 126 RawCode* StubCode::GetAllocationStubForClass(const Class& cls) { |
| 127 // These stubs are not used by DBC. |
| 128 #if !defined(TARGET_ARCH_DBC) |
112 Thread* thread = Thread::Current(); | 129 Thread* thread = Thread::Current(); |
113 Zone* zone = thread->zone(); | 130 Zone* zone = thread->zone(); |
114 const Error& error = Error::Handle(zone, cls.EnsureIsFinalized(thread)); | 131 const Error& error = Error::Handle(zone, cls.EnsureIsFinalized(thread)); |
115 ASSERT(error.IsNull()); | 132 ASSERT(error.IsNull()); |
116 if (cls.id() == kArrayCid) { | 133 if (cls.id() == kArrayCid) { |
117 return AllocateArray_entry()->code(); | 134 return AllocateArray_entry()->code(); |
118 } | 135 } |
119 Code& stub = Code::Handle(zone, cls.allocation_stub()); | 136 Code& stub = Code::Handle(zone, cls.allocation_stub()); |
120 if (stub.IsNull()) { | 137 if (stub.IsNull()) { |
121 Assembler assembler; | 138 Assembler assembler; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 #ifndef PRODUCT | 179 #ifndef PRODUCT |
163 DisassembleToStdout formatter; | 180 DisassembleToStdout formatter; |
164 stub.Disassemble(&formatter); | 181 stub.Disassemble(&formatter); |
165 #endif | 182 #endif |
166 THR_Print("}\n"); | 183 THR_Print("}\n"); |
167 const ObjectPool& object_pool = ObjectPool::Handle(stub.object_pool()); | 184 const ObjectPool& object_pool = ObjectPool::Handle(stub.object_pool()); |
168 object_pool.DebugPrint(); | 185 object_pool.DebugPrint(); |
169 } | 186 } |
170 } | 187 } |
171 return stub.raw(); | 188 return stub.raw(); |
| 189 #endif |
| 190 UNIMPLEMENTED(); |
| 191 return Code::null(); |
172 } | 192 } |
173 | 193 |
174 | 194 |
175 const StubEntry* StubCode::UnoptimizedStaticCallEntry( | 195 const StubEntry* StubCode::UnoptimizedStaticCallEntry( |
176 intptr_t num_args_tested) { | 196 intptr_t num_args_tested) { |
| 197 // These stubs are not used by DBC. |
| 198 #if !defined(TARGET_ARCH_DBC) |
177 switch (num_args_tested) { | 199 switch (num_args_tested) { |
178 case 0: | 200 case 0: |
179 return ZeroArgsUnoptimizedStaticCall_entry(); | 201 return ZeroArgsUnoptimizedStaticCall_entry(); |
180 case 1: | 202 case 1: |
181 return OneArgUnoptimizedStaticCall_entry(); | 203 return OneArgUnoptimizedStaticCall_entry(); |
182 case 2: | 204 case 2: |
183 return TwoArgsUnoptimizedStaticCall_entry(); | 205 return TwoArgsUnoptimizedStaticCall_entry(); |
184 default: | 206 default: |
185 UNIMPLEMENTED(); | 207 UNIMPLEMENTED(); |
186 return NULL; | 208 return NULL; |
187 } | 209 } |
| 210 #else |
| 211 return NULL; |
| 212 #endif |
188 } | 213 } |
189 | 214 |
190 | 215 |
191 RawCode* StubCode::Generate(const char* name, | 216 RawCode* StubCode::Generate(const char* name, |
192 void (*GenerateStub)(Assembler* assembler)) { | 217 void (*GenerateStub)(Assembler* assembler)) { |
193 Assembler assembler; | 218 Assembler assembler; |
194 GenerateStub(&assembler); | 219 GenerateStub(&assembler); |
195 const Code& code = Code::Handle( | 220 const Code& code = Code::Handle( |
196 Code::FinalizeCode(name, &assembler, false /* optimized */)); | 221 Code::FinalizeCode(name, &assembler, false /* optimized */)); |
197 if (FLAG_support_disassembler && FLAG_disassemble_stubs) { | 222 if (FLAG_support_disassembler && FLAG_disassemble_stubs) { |
(...skipping 14 matching lines...) Expand all Loading... |
212 if ((name##_entry() != NULL) && \ | 237 if ((name##_entry() != NULL) && \ |
213 (entry_point == name##_entry()->EntryPoint())) { \ | 238 (entry_point == name##_entry()->EntryPoint())) { \ |
214 return ""#name; \ | 239 return ""#name; \ |
215 } | 240 } |
216 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); | 241 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); |
217 #undef VM_STUB_CODE_TESTER | 242 #undef VM_STUB_CODE_TESTER |
218 return NULL; | 243 return NULL; |
219 } | 244 } |
220 | 245 |
221 } // namespace dart | 246 } // namespace dart |
OLD | NEW |