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