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 return (pc & 2) != 0; |
| 107 #endif |
100 } | 108 } |
101 | 109 |
102 | 110 |
103 bool StubCode::InJumpToExceptionHandlerStub(uword pc) { | 111 bool StubCode::InJumpToExceptionHandlerStub(uword pc) { |
| 112 #if !defined(TARGET_ARCH_DBC) |
104 ASSERT(HasBeenInitialized()); | 113 ASSERT(HasBeenInitialized()); |
105 uword entry = StubCode::JumpToExceptionHandler_entry()->EntryPoint(); | 114 uword entry = StubCode::JumpToExceptionHandler_entry()->EntryPoint(); |
106 uword size = StubCode::JumpToExceptionHandlerSize(); | 115 uword size = StubCode::JumpToExceptionHandlerSize(); |
107 return (pc >= entry) && (pc < (entry + size)); | 116 return (pc >= entry) && (pc < (entry + size)); |
| 117 #else |
| 118 return false; |
| 119 #endif |
108 } | 120 } |
109 | 121 |
110 | 122 |
111 RawCode* StubCode::GetAllocationStubForClass(const Class& cls) { | 123 RawCode* StubCode::GetAllocationStubForClass(const Class& cls) { |
| 124 #if !defined(TARGET_ARCH_DBC) |
112 Thread* thread = Thread::Current(); | 125 Thread* thread = Thread::Current(); |
113 Zone* zone = thread->zone(); | 126 Zone* zone = thread->zone(); |
114 const Error& error = Error::Handle(zone, cls.EnsureIsFinalized(thread)); | 127 const Error& error = Error::Handle(zone, cls.EnsureIsFinalized(thread)); |
115 ASSERT(error.IsNull()); | 128 ASSERT(error.IsNull()); |
116 if (cls.id() == kArrayCid) { | 129 if (cls.id() == kArrayCid) { |
117 return AllocateArray_entry()->code(); | 130 return AllocateArray_entry()->code(); |
118 } | 131 } |
119 Code& stub = Code::Handle(zone, cls.allocation_stub()); | 132 Code& stub = Code::Handle(zone, cls.allocation_stub()); |
120 if (stub.IsNull()) { | 133 if (stub.IsNull()) { |
121 Assembler assembler; | 134 Assembler assembler; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 #ifndef PRODUCT | 175 #ifndef PRODUCT |
163 DisassembleToStdout formatter; | 176 DisassembleToStdout formatter; |
164 stub.Disassemble(&formatter); | 177 stub.Disassemble(&formatter); |
165 #endif | 178 #endif |
166 THR_Print("}\n"); | 179 THR_Print("}\n"); |
167 const ObjectPool& object_pool = ObjectPool::Handle(stub.object_pool()); | 180 const ObjectPool& object_pool = ObjectPool::Handle(stub.object_pool()); |
168 object_pool.DebugPrint(); | 181 object_pool.DebugPrint(); |
169 } | 182 } |
170 } | 183 } |
171 return stub.raw(); | 184 return stub.raw(); |
| 185 #endif |
| 186 UNIMPLEMENTED(); |
| 187 return Code::null(); |
172 } | 188 } |
173 | 189 |
174 | 190 |
175 const StubEntry* StubCode::UnoptimizedStaticCallEntry( | 191 const StubEntry* StubCode::UnoptimizedStaticCallEntry( |
176 intptr_t num_args_tested) { | 192 intptr_t num_args_tested) { |
| 193 #if !defined(TARGET_ARCH_DBC) |
177 switch (num_args_tested) { | 194 switch (num_args_tested) { |
178 case 0: | 195 case 0: |
179 return ZeroArgsUnoptimizedStaticCall_entry(); | 196 return ZeroArgsUnoptimizedStaticCall_entry(); |
180 case 1: | 197 case 1: |
181 return OneArgUnoptimizedStaticCall_entry(); | 198 return OneArgUnoptimizedStaticCall_entry(); |
182 case 2: | 199 case 2: |
183 return TwoArgsUnoptimizedStaticCall_entry(); | 200 return TwoArgsUnoptimizedStaticCall_entry(); |
184 default: | 201 default: |
185 UNIMPLEMENTED(); | 202 UNIMPLEMENTED(); |
186 return NULL; | 203 return NULL; |
187 } | 204 } |
| 205 #else |
| 206 return NULL; |
| 207 #endif |
188 } | 208 } |
189 | 209 |
190 | 210 |
191 RawCode* StubCode::Generate(const char* name, | 211 RawCode* StubCode::Generate(const char* name, |
192 void (*GenerateStub)(Assembler* assembler)) { | 212 void (*GenerateStub)(Assembler* assembler)) { |
193 Assembler assembler; | 213 Assembler assembler; |
194 GenerateStub(&assembler); | 214 GenerateStub(&assembler); |
195 const Code& code = Code::Handle( | 215 const Code& code = Code::Handle( |
196 Code::FinalizeCode(name, &assembler, false /* optimized */)); | 216 Code::FinalizeCode(name, &assembler, false /* optimized */)); |
197 if (FLAG_support_disassembler && FLAG_disassemble_stubs) { | 217 if (FLAG_support_disassembler && FLAG_disassemble_stubs) { |
(...skipping 14 matching lines...) Expand all Loading... |
212 if ((name##_entry() != NULL) && \ | 232 if ((name##_entry() != NULL) && \ |
213 (entry_point == name##_entry()->EntryPoint())) { \ | 233 (entry_point == name##_entry()->EntryPoint())) { \ |
214 return ""#name; \ | 234 return ""#name; \ |
215 } | 235 } |
216 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); | 236 VM_STUB_CODE_LIST(VM_STUB_CODE_TESTER); |
217 #undef VM_STUB_CODE_TESTER | 237 #undef VM_STUB_CODE_TESTER |
218 return NULL; | 238 return NULL; |
219 } | 239 } |
220 | 240 |
221 } // namespace dart | 241 } // namespace dart |
OLD | NEW |