| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #ifndef RUNTIME_VM_STUB_CODE_H_ | 5 #ifndef RUNTIME_VM_STUB_CODE_H_ |
| 6 #define RUNTIME_VM_STUB_CODE_H_ | 6 #define RUNTIME_VM_STUB_CODE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 | 10 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 static void EntryAtPut(intptr_t index, StubEntry* entry) { | 163 static void EntryAtPut(intptr_t index, StubEntry* entry) { |
| 164 entries_[index] = entry; | 164 entries_[index] = entry; |
| 165 } | 165 } |
| 166 static intptr_t NumEntries() { return kNumStubEntries; } | 166 static intptr_t NumEntries() { return kNumStubEntries; } |
| 167 | 167 |
| 168 private: | 168 private: |
| 169 friend class MegamorphicCacheTable; | 169 friend class MegamorphicCacheTable; |
| 170 | 170 |
| 171 static const intptr_t kStubCodeSize = 4 * KB; | 171 static const intptr_t kStubCodeSize = 4 * KB; |
| 172 | 172 |
| 173 #define STUB_CODE_GENERATE(name) \ | |
| 174 static void Generate##name##Stub(Assembler* assembler); | |
| 175 VM_STUB_CODE_LIST(STUB_CODE_GENERATE) | |
| 176 #undef STUB_CODE_GENERATE | |
| 177 | |
| 178 enum { | 173 enum { |
| 179 #define STUB_CODE_ENTRY(name) k##name##Index, | 174 #define STUB_CODE_ENTRY(name) k##name##Index, |
| 180 VM_STUB_CODE_LIST(STUB_CODE_ENTRY) | 175 VM_STUB_CODE_LIST(STUB_CODE_ENTRY) |
| 181 #undef STUB_CODE_ENTRY | 176 #undef STUB_CODE_ENTRY |
| 182 kNumStubEntries | 177 kNumStubEntries |
| 183 }; | 178 }; |
| 184 | 179 |
| 185 static StubEntry* entries_[kNumStubEntries]; | 180 static StubEntry* entries_[kNumStubEntries]; |
| 186 | 181 |
| 182 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 183 #define STUB_CODE_GENERATE(name) \ |
| 184 static void Generate##name##Stub(Assembler* assembler); |
| 185 VM_STUB_CODE_LIST(STUB_CODE_GENERATE) |
| 186 #undef STUB_CODE_GENERATE |
| 187 |
| 187 // Generate the stub and finalize the generated code into the stub | 188 // Generate the stub and finalize the generated code into the stub |
| 188 // code executable area. | 189 // code executable area. |
| 189 static RawCode* Generate(const char* name, | 190 static RawCode* Generate(const char* name, |
| 190 void (*GenerateStub)(Assembler* assembler)); | 191 void (*GenerateStub)(Assembler* assembler)); |
| 191 | 192 |
| 192 static void GenerateMegamorphicMissStub(Assembler* assembler); | 193 static void GenerateMegamorphicMissStub(Assembler* assembler); |
| 193 static void GenerateAllocationStubForClass(Assembler* assembler, | 194 static void GenerateAllocationStubForClass(Assembler* assembler, |
| 194 const Class& cls); | 195 const Class& cls); |
| 195 static void GenerateNArgsCheckInlineCacheStub( | 196 static void GenerateNArgsCheckInlineCacheStub( |
| 196 Assembler* assembler, | 197 Assembler* assembler, |
| 197 intptr_t num_args, | 198 intptr_t num_args, |
| 198 const RuntimeEntry& handle_ic_miss, | 199 const RuntimeEntry& handle_ic_miss, |
| 199 Token::Kind kind, | 200 Token::Kind kind, |
| 200 bool optimized = false); | 201 bool optimized = false); |
| 201 static void GenerateUsageCounterIncrement(Assembler* assembler, | 202 static void GenerateUsageCounterIncrement(Assembler* assembler, |
| 202 Register temp_reg); | 203 Register temp_reg); |
| 203 static void GenerateOptimizedUsageCounterIncrement(Assembler* assembler); | 204 static void GenerateOptimizedUsageCounterIncrement(Assembler* assembler); |
| 205 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 204 }; | 206 }; |
| 205 | 207 |
| 206 | 208 |
| 207 enum DeoptStubKind { kLazyDeoptFromReturn, kLazyDeoptFromThrow, kEagerDeopt }; | 209 enum DeoptStubKind { kLazyDeoptFromReturn, kLazyDeoptFromThrow, kEagerDeopt }; |
| 208 | 210 |
| 209 // Zap value used to indicate unused CODE_REG in deopt. | 211 // Zap value used to indicate unused CODE_REG in deopt. |
| 210 static const uword kZapCodeReg = 0xf1f1f1f1; | 212 static const uword kZapCodeReg = 0xf1f1f1f1; |
| 211 | 213 |
| 212 // Zap value used to indicate unused return address in deopt. | 214 // Zap value used to indicate unused return address in deopt. |
| 213 static const uword kZapReturnAddress = 0xe1e1e1e1; | 215 static const uword kZapReturnAddress = 0xe1e1e1e1; |
| 214 | 216 |
| 215 } // namespace dart | 217 } // namespace dart |
| 216 | 218 |
| 217 #endif // RUNTIME_VM_STUB_CODE_H_ | 219 #endif // RUNTIME_VM_STUB_CODE_H_ |
| OLD | NEW |