| 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 VM_STUB_CODE_H_ | 5 #ifndef VM_STUB_CODE_H_ |
| 6 #define VM_STUB_CODE_H_ | 6 #define 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 10 matching lines...) Expand all Loading... |
| 21 // isolates running in this dart process. | 21 // isolates running in this dart process. |
| 22 #define VM_STUB_CODE_LIST(V) \ | 22 #define VM_STUB_CODE_LIST(V) \ |
| 23 V(PrintStopMessage) \ | 23 V(PrintStopMessage) \ |
| 24 V(CallToRuntime) \ | 24 V(CallToRuntime) \ |
| 25 V(LazyCompile) \ | 25 V(LazyCompile) \ |
| 26 V(CallBootstrapCFunction) \ | 26 V(CallBootstrapCFunction) \ |
| 27 V(CallNativeCFunction) \ | 27 V(CallNativeCFunction) \ |
| 28 V(CallStaticFunction) \ | 28 V(CallStaticFunction) \ |
| 29 V(FixCallersTarget) \ | 29 V(FixCallersTarget) \ |
| 30 V(FixAllocationStubTarget) \ | 30 V(FixAllocationStubTarget) \ |
| 31 V(FixAllocateArrayStubTarget) \ |
| 31 V(Deoptimize) \ | 32 V(Deoptimize) \ |
| 32 V(DeoptimizeLazy) \ | 33 V(DeoptimizeLazy) \ |
| 33 V(ICCallBreakpoint) \ | 34 V(ICCallBreakpoint) \ |
| 34 V(ClosureCallBreakpoint) \ | 35 V(ClosureCallBreakpoint) \ |
| 35 V(RuntimeCallBreakpoint) \ | 36 V(RuntimeCallBreakpoint) \ |
| 36 V(DebugStepCheck) \ | 37 V(DebugStepCheck) \ |
| 37 V(Subtype1TestCache) \ | 38 V(Subtype1TestCache) \ |
| 38 V(Subtype2TestCache) \ | 39 V(Subtype2TestCache) \ |
| 39 V(Subtype3TestCache) \ | 40 V(Subtype3TestCache) \ |
| 40 V(GetStackPointer) \ | 41 V(GetStackPointer) \ |
| 41 V(JumpToExceptionHandler) \ | 42 V(JumpToExceptionHandler) \ |
| 42 V(UnoptimizedIdenticalWithNumberCheck) \ | 43 V(UnoptimizedIdenticalWithNumberCheck) \ |
| 43 V(OptimizedIdenticalWithNumberCheck) \ | 44 V(OptimizedIdenticalWithNumberCheck) \ |
| 44 | 45 |
| 45 // Is it permitted for the stubs above to refer to Object::null(), which is | 46 // Is it permitted for the stubs above to refer to Object::null(), which is |
| 46 // allocated in the VM isolate and shared across all isolates. | 47 // allocated in the VM isolate and shared across all isolates. |
| 47 // However, in cases where a simple GC-safe placeholder is needed on the stack, | 48 // However, in cases where a simple GC-safe placeholder is needed on the stack, |
| 48 // using Smi 0 instead of Object::null() is slightly more efficient, since a Smi | 49 // using Smi 0 instead of Object::null() is slightly more efficient, since a Smi |
| 49 // does not require relocation. | 50 // does not require relocation. |
| 50 | 51 |
| 51 // List of stubs created per isolate, these stubs could potentially contain | 52 // List of stubs created per isolate, these stubs could potentially contain |
| 52 // embedded objects and hence cannot be shared across isolates. | 53 // embedded objects and hence cannot be shared across isolates. |
| 53 #define STUB_CODE_LIST(V) \ | 54 #define STUB_CODE_LIST(V) \ |
| 54 V(AllocateArray) \ | |
| 55 V(CallClosureNoSuchMethod) \ | 55 V(CallClosureNoSuchMethod) \ |
| 56 V(AllocateContext) \ | 56 V(AllocateContext) \ |
| 57 V(UpdateStoreBuffer) \ | 57 V(UpdateStoreBuffer) \ |
| 58 V(OneArgCheckInlineCache) \ | 58 V(OneArgCheckInlineCache) \ |
| 59 V(TwoArgsCheckInlineCache) \ | 59 V(TwoArgsCheckInlineCache) \ |
| 60 V(ThreeArgsCheckInlineCache) \ | 60 V(ThreeArgsCheckInlineCache) \ |
| 61 V(SmiAddInlineCache) \ | 61 V(SmiAddInlineCache) \ |
| 62 V(SmiSubInlineCache) \ | 62 V(SmiSubInlineCache) \ |
| 63 V(SmiEqualInlineCache) \ | 63 V(SmiEqualInlineCache) \ |
| 64 V(OneArgOptimizedCheckInlineCache) \ | 64 V(OneArgOptimizedCheckInlineCache) \ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 91 intptr_t size_; | 91 intptr_t size_; |
| 92 ExternalLabel label_; | 92 ExternalLabel label_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(StubEntry); | 94 DISALLOW_COPY_AND_ASSIGN(StubEntry); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 | 97 |
| 98 // class StubCode is used to maintain the lifecycle of stubs. | 98 // class StubCode is used to maintain the lifecycle of stubs. |
| 99 class StubCode { | 99 class StubCode { |
| 100 public: | 100 public: |
| 101 StubCode() | 101 explicit StubCode(Isolate* isolate) |
| 102 : | 102 : |
| 103 #define STUB_CODE_INITIALIZER(name) \ | 103 #define STUB_CODE_INITIALIZER(name) \ |
| 104 name##_entry_(NULL), | 104 name##_entry_(NULL), |
| 105 STUB_CODE_LIST(STUB_CODE_INITIALIZER) | 105 STUB_CODE_LIST(STUB_CODE_INITIALIZER) |
| 106 dummy_(NULL) {} | 106 isolate_(isolate) {} |
| 107 ~StubCode(); | 107 ~StubCode(); |
| 108 | 108 |
| 109 void GenerateFor(Isolate* isolate); | 109 void GenerateFor(Isolate* isolate); |
| 110 | 110 |
| 111 // Generate all stubs which are shared across all isolates, this is done | 111 // Generate all stubs which are shared across all isolates, this is done |
| 112 // only once and the stub code resides in the vm_isolate heap. | 112 // only once and the stub code resides in the vm_isolate heap. |
| 113 static void InitOnce(); | 113 static void InitOnce(); |
| 114 | 114 |
| 115 // Generate all stubs which are generated on a per isolate basis as they | 115 // Generate all stubs which are generated on a per isolate basis as they |
| 116 // have embedded objects which are isolate specific. | 116 // have embedded objects which are isolate specific. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 uword name##EntryPoint() { \ | 158 uword name##EntryPoint() { \ |
| 159 return name##_entry()->EntryPoint(); \ | 159 return name##_entry()->EntryPoint(); \ |
| 160 } \ | 160 } \ |
| 161 intptr_t name##Size() { \ | 161 intptr_t name##Size() { \ |
| 162 return name##_entry()->Size(); \ | 162 return name##_entry()->Size(); \ |
| 163 } | 163 } |
| 164 STUB_CODE_LIST(STUB_CODE_ACCESSOR); | 164 STUB_CODE_LIST(STUB_CODE_ACCESSOR); |
| 165 #undef STUB_CODE_ACCESSOR | 165 #undef STUB_CODE_ACCESSOR |
| 166 | 166 |
| 167 static RawCode* GetAllocationStubForClass(const Class& cls); | 167 static RawCode* GetAllocationStubForClass(const Class& cls); |
| 168 RawCode* GetAllocateArrayStub(); |
| 168 | 169 |
| 169 uword UnoptimizedStaticCallEntryPoint(intptr_t num_args_tested); | 170 uword UnoptimizedStaticCallEntryPoint(intptr_t num_args_tested); |
| 170 | 171 |
| 171 static const intptr_t kNoInstantiator = 0; | 172 static const intptr_t kNoInstantiator = 0; |
| 172 | 173 |
| 173 private: | 174 private: |
| 174 friend class MegamorphicCacheTable; | 175 friend class MegamorphicCacheTable; |
| 175 | 176 |
| 176 static const intptr_t kStubCodeSize = 4 * KB; | 177 static const intptr_t kStubCodeSize = 4 * KB; |
| 177 | 178 |
| 178 #define STUB_CODE_GENERATE(name) \ | 179 #define STUB_CODE_GENERATE(name) \ |
| 179 static void Generate##name##Stub(Assembler* assembler); | 180 static void Generate##name##Stub(Assembler* assembler); |
| 180 VM_STUB_CODE_LIST(STUB_CODE_GENERATE); | 181 VM_STUB_CODE_LIST(STUB_CODE_GENERATE); |
| 181 STUB_CODE_LIST(STUB_CODE_GENERATE); | 182 STUB_CODE_LIST(STUB_CODE_GENERATE); |
| 182 #undef STUB_CODE_GENERATE | 183 #undef STUB_CODE_GENERATE |
| 183 | 184 |
| 184 #define STUB_CODE_ENTRY(name) \ | 185 #define STUB_CODE_ENTRY(name) \ |
| 185 static StubEntry* name##_entry_; | 186 static StubEntry* name##_entry_; |
| 186 VM_STUB_CODE_LIST(STUB_CODE_ENTRY); | 187 VM_STUB_CODE_LIST(STUB_CODE_ENTRY); |
| 187 #undef STUB_CODE_ENTRY | 188 #undef STUB_CODE_ENTRY |
| 188 | 189 |
| 189 #define STUB_CODE_ENTRY(name) \ | 190 #define STUB_CODE_ENTRY(name) \ |
| 190 StubEntry* name##_entry_; | 191 StubEntry* name##_entry_; |
| 191 STUB_CODE_LIST(STUB_CODE_ENTRY); | 192 STUB_CODE_LIST(STUB_CODE_ENTRY); |
| 192 #undef STUB_CODE_ENTRY | 193 #undef STUB_CODE_ENTRY |
| 193 // This dummy field is needed so that we can initialize | 194 Isolate* isolate_; |
| 194 // the stubs from a macro. | |
| 195 void* dummy_; | |
| 196 | 195 |
| 197 // Generate the stub and finalize the generated code into the stub | 196 // Generate the stub and finalize the generated code into the stub |
| 198 // code executable area. | 197 // code executable area. |
| 199 static RawCode* Generate(const char* name, | 198 static RawCode* Generate(const char* name, |
| 200 void (*GenerateStub)(Assembler* assembler)); | 199 void (*GenerateStub)(Assembler* assembler)); |
| 201 | 200 |
| 202 static void GenerateMegamorphicMissStub(Assembler* assembler); | 201 static void GenerateMegamorphicMissStub(Assembler* assembler); |
| 203 static void GenerateAllocationStubForClass( | 202 static void GenerateAllocationStubForClass( |
| 204 Assembler* assembler, const Class& cls, | 203 Assembler* assembler, const Class& cls, |
| 205 uword* entry_patch_offset, uword* patch_code_pc_offset); | 204 uword* entry_patch_offset, uword* patch_code_pc_offset); |
| 205 static void GeneratePatchableAllocateArrayStub(Assembler* assembler, |
| 206 uword* entry_patch_offset, uword* patch_code_pc_offset); |
| 206 static void GenerateNArgsCheckInlineCacheStub( | 207 static void GenerateNArgsCheckInlineCacheStub( |
| 207 Assembler* assembler, | 208 Assembler* assembler, |
| 208 intptr_t num_args, | 209 intptr_t num_args, |
| 209 const RuntimeEntry& handle_ic_miss, | 210 const RuntimeEntry& handle_ic_miss, |
| 210 Token::Kind kind); | 211 Token::Kind kind); |
| 211 static void GenerateUsageCounterIncrement(Assembler* assembler, | 212 static void GenerateUsageCounterIncrement(Assembler* assembler, |
| 212 Register temp_reg); | 213 Register temp_reg); |
| 213 static void GenerateOptimizedUsageCounterIncrement(Assembler* assembler); | 214 static void GenerateOptimizedUsageCounterIncrement(Assembler* assembler); |
| 214 | 215 |
| 215 static void GenerateIdenticalWithNumberCheckStub( | 216 static void GenerateIdenticalWithNumberCheckStub( |
| 216 Assembler* assembler, | 217 Assembler* assembler, |
| 217 const Register left, | 218 const Register left, |
| 218 const Register right, | 219 const Register right, |
| 219 const Register temp1 = kNoRegister, | 220 const Register temp1 = kNoRegister, |
| 220 const Register temp2 = kNoRegister); | 221 const Register temp2 = kNoRegister); |
| 221 }; | 222 }; |
| 222 | 223 |
| 223 } // namespace dart | 224 } // namespace dart |
| 224 | 225 |
| 225 #endif // VM_STUB_CODE_H_ | 226 #endif // VM_STUB_CODE_H_ |
| OLD | NEW |