| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 V(SmiEqualInlineCache) \ | 60 V(SmiEqualInlineCache) \ |
| 61 V(OneArgOptimizedCheckInlineCache) \ | 61 V(OneArgOptimizedCheckInlineCache) \ |
| 62 V(TwoArgsOptimizedCheckInlineCache) \ | 62 V(TwoArgsOptimizedCheckInlineCache) \ |
| 63 V(ZeroArgsUnoptimizedStaticCall) \ | 63 V(ZeroArgsUnoptimizedStaticCall) \ |
| 64 V(OneArgUnoptimizedStaticCall) \ | 64 V(OneArgUnoptimizedStaticCall) \ |
| 65 V(TwoArgsUnoptimizedStaticCall) \ | 65 V(TwoArgsUnoptimizedStaticCall) \ |
| 66 V(Subtype1TestCache) \ | 66 V(Subtype1TestCache) \ |
| 67 V(Subtype2TestCache) \ | 67 V(Subtype2TestCache) \ |
| 68 V(Subtype3TestCache) \ | 68 V(Subtype3TestCache) \ |
| 69 V(CallClosureNoSuchMethod) \ | 69 V(CallClosureNoSuchMethod) \ |
| 70 V(FrameAwaitingMaterialization) \ | 70 V(FrameAwaitingMaterialization) |
| 71 | 71 |
| 72 #else | 72 #else |
| 73 #define VM_STUB_CODE_LIST(V) \ | 73 #define VM_STUB_CODE_LIST(V) \ |
| 74 V(LazyCompile) \ | 74 V(LazyCompile) \ |
| 75 V(OptimizeFunction) \ | 75 V(OptimizeFunction) \ |
| 76 V(FixCallersTarget) \ | 76 V(FixCallersTarget) \ |
| 77 V(Deoptimize) \ | 77 V(Deoptimize) \ |
| 78 V(DeoptimizeLazyFromReturn) \ | 78 V(DeoptimizeLazyFromReturn) \ |
| 79 V(DeoptimizeLazyFromThrow) \ | 79 V(DeoptimizeLazyFromThrow) \ |
| 80 V(FrameAwaitingMaterialization) \ | 80 V(FrameAwaitingMaterialization) |
| 81 | 81 |
| 82 #endif // !defined(TARGET_ARCH_DBC) | 82 #endif // !defined(TARGET_ARCH_DBC) |
| 83 | 83 |
| 84 // Is it permitted for the stubs above to refer to Object::null(), which is | 84 // Is it permitted for the stubs above to refer to Object::null(), which is |
| 85 // allocated in the VM isolate and shared across all isolates. | 85 // allocated in the VM isolate and shared across all isolates. |
| 86 // However, in cases where a simple GC-safe placeholder is needed on the stack, | 86 // However, in cases where a simple GC-safe placeholder is needed on the stack, |
| 87 // using Smi 0 instead of Object::null() is slightly more efficient, since a Smi | 87 // using Smi 0 instead of Object::null() is slightly more efficient, since a Smi |
| 88 // does not require relocation. | 88 // does not require relocation. |
| 89 | 89 |
| 90 // class StubEntry is used to describe stub methods generated in dart to | 90 // class StubEntry is used to describe stub methods generated in dart to |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // Check if specified pc is in the dart invocation stub used for | 137 // Check if specified pc is in the dart invocation stub used for |
| 138 // transitioning into dart code. | 138 // transitioning into dart code. |
| 139 static bool InInvocationStub(uword pc); | 139 static bool InInvocationStub(uword pc); |
| 140 | 140 |
| 141 // Check if the specified pc is in the jump to exception handler stub. | 141 // Check if the specified pc is in the jump to exception handler stub. |
| 142 static bool InJumpToExceptionHandlerStub(uword pc); | 142 static bool InJumpToExceptionHandlerStub(uword pc); |
| 143 | 143 |
| 144 // Returns NULL if no stub found. | 144 // Returns NULL if no stub found. |
| 145 static const char* NameOfStub(uword entry_point); | 145 static const char* NameOfStub(uword entry_point); |
| 146 | 146 |
| 147 // Define the shared stub code accessors. | 147 // Define the shared stub code accessors. |
| 148 #define STUB_CODE_ACCESSOR(name) \ | 148 #define STUB_CODE_ACCESSOR(name) \ |
| 149 static const StubEntry* name##_entry() { \ | 149 static const StubEntry* name##_entry() { return name##_entry_; } \ |
| 150 return name##_entry_; \ | 150 static intptr_t name##Size() { return name##_entry()->Size(); } |
| 151 } \ | |
| 152 static intptr_t name##Size() { \ | |
| 153 return name##_entry()->Size(); \ | |
| 154 } | |
| 155 VM_STUB_CODE_LIST(STUB_CODE_ACCESSOR); | 151 VM_STUB_CODE_LIST(STUB_CODE_ACCESSOR); |
| 156 #undef STUB_CODE_ACCESSOR | 152 #undef STUB_CODE_ACCESSOR |
| 157 | 153 |
| 158 static RawCode* GetAllocationStubForClass(const Class& cls); | 154 static RawCode* GetAllocationStubForClass(const Class& cls); |
| 159 | 155 |
| 160 static const StubEntry* UnoptimizedStaticCallEntry(intptr_t num_args_tested); | 156 static const StubEntry* UnoptimizedStaticCallEntry(intptr_t num_args_tested); |
| 161 | 157 |
| 162 static const intptr_t kNoInstantiator = 0; | 158 static const intptr_t kNoInstantiator = 0; |
| 163 | 159 |
| 164 private: | 160 private: |
| 165 friend class MegamorphicCacheTable; | 161 friend class MegamorphicCacheTable; |
| 166 | 162 |
| 167 static const intptr_t kStubCodeSize = 4 * KB; | 163 static const intptr_t kStubCodeSize = 4 * KB; |
| 168 | 164 |
| 169 #define STUB_CODE_GENERATE(name) \ | 165 #define STUB_CODE_GENERATE(name) \ |
| 170 static void Generate##name##Stub(Assembler* assembler); | 166 static void Generate##name##Stub(Assembler* assembler); |
| 171 VM_STUB_CODE_LIST(STUB_CODE_GENERATE); | 167 VM_STUB_CODE_LIST(STUB_CODE_GENERATE); |
| 172 #undef STUB_CODE_GENERATE | 168 #undef STUB_CODE_GENERATE |
| 173 | 169 |
| 174 #define STUB_CODE_ENTRY(name) \ | 170 #define STUB_CODE_ENTRY(name) static StubEntry* name##_entry_; |
| 175 static StubEntry* name##_entry_; | |
| 176 VM_STUB_CODE_LIST(STUB_CODE_ENTRY); | 171 VM_STUB_CODE_LIST(STUB_CODE_ENTRY); |
| 177 #undef STUB_CODE_ENTRY | 172 #undef STUB_CODE_ENTRY |
| 178 | 173 |
| 179 // Generate the stub and finalize the generated code into the stub | 174 // Generate the stub and finalize the generated code into the stub |
| 180 // code executable area. | 175 // code executable area. |
| 181 static RawCode* Generate(const char* name, | 176 static RawCode* Generate(const char* name, |
| 182 void (*GenerateStub)(Assembler* assembler)); | 177 void (*GenerateStub)(Assembler* assembler)); |
| 183 | 178 |
| 184 static void GenerateMegamorphicMissStub(Assembler* assembler); | 179 static void GenerateMegamorphicMissStub(Assembler* assembler); |
| 185 static void GenerateAllocationStubForClass(Assembler* assembler, | 180 static void GenerateAllocationStubForClass(Assembler* assembler, |
| 186 const Class& cls); | 181 const Class& cls); |
| 187 static void GenerateNArgsCheckInlineCacheStub( | 182 static void GenerateNArgsCheckInlineCacheStub( |
| 188 Assembler* assembler, | 183 Assembler* assembler, |
| 189 intptr_t num_args, | 184 intptr_t num_args, |
| 190 const RuntimeEntry& handle_ic_miss, | 185 const RuntimeEntry& handle_ic_miss, |
| 191 Token::Kind kind, | 186 Token::Kind kind, |
| 192 bool optimized = false); | 187 bool optimized = false); |
| 193 static void GenerateUsageCounterIncrement(Assembler* assembler, | 188 static void GenerateUsageCounterIncrement(Assembler* assembler, |
| 194 Register temp_reg); | 189 Register temp_reg); |
| 195 static void GenerateOptimizedUsageCounterIncrement(Assembler* assembler); | 190 static void GenerateOptimizedUsageCounterIncrement(Assembler* assembler); |
| 196 }; | 191 }; |
| 197 | 192 |
| 198 | 193 |
| 199 enum DeoptStubKind { | 194 enum DeoptStubKind { kLazyDeoptFromReturn, kLazyDeoptFromThrow, kEagerDeopt }; |
| 200 kLazyDeoptFromReturn, | |
| 201 kLazyDeoptFromThrow, | |
| 202 kEagerDeopt | |
| 203 }; | |
| 204 | 195 |
| 205 } // namespace dart | 196 } // namespace dart |
| 206 | 197 |
| 207 #endif // RUNTIME_VM_STUB_CODE_H_ | 198 #endif // RUNTIME_VM_STUB_CODE_H_ |
| OLD | NEW |