| 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 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 // Forward declarations. | 13 // Forward declarations. |
| 14 class Code; | 14 class Code; |
| 15 class Isolate; | 15 class Isolate; |
| 16 class ObjectPointerVisitor; | 16 class ObjectPointerVisitor; |
| 17 class RawCode; | 17 class RawCode; |
| 18 class SnapshotReader; | 18 class SnapshotReader; |
| 19 class SnapshotWriter; | 19 class SnapshotWriter; |
| 20 class Serializer; | |
| 21 class Deserializer; | |
| 22 | 20 |
| 23 // List of stubs created in the VM isolate, these stubs are shared by different | 21 // List of stubs created in the VM isolate, these stubs are shared by different |
| 24 // isolates running in this dart process. | 22 // isolates running in this dart process. |
| 25 #if !defined(TARGET_ARCH_DBC) | 23 #if !defined(TARGET_ARCH_DBC) |
| 26 #define VM_STUB_CODE_LIST(V) \ | 24 #define VM_STUB_CODE_LIST(V) \ |
| 27 V(GetStackPointer) \ | 25 V(GetStackPointer) \ |
| 28 V(JumpToFrame) \ | 26 V(JumpToFrame) \ |
| 29 V(RunExceptionHandler) \ | 27 V(RunExceptionHandler) \ |
| 30 V(DeoptForRewind) \ | 28 V(DeoptForRewind) \ |
| 31 V(UpdateStoreBuffer) \ | 29 V(UpdateStoreBuffer) \ |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 }; | 116 }; |
| 119 | 117 |
| 120 | 118 |
| 121 // class StubCode is used to maintain the lifecycle of stubs. | 119 // class StubCode is used to maintain the lifecycle of stubs. |
| 122 class StubCode : public AllStatic { | 120 class StubCode : public AllStatic { |
| 123 public: | 121 public: |
| 124 // Generate all stubs which are shared across all isolates, this is done | 122 // Generate all stubs which are shared across all isolates, this is done |
| 125 // only once and the stub code resides in the vm_isolate heap. | 123 // only once and the stub code resides in the vm_isolate heap. |
| 126 static void InitOnce(); | 124 static void InitOnce(); |
| 127 | 125 |
| 128 static void Push(Serializer* serializer); | |
| 129 static void WriteRef(Serializer* serializer); | |
| 130 static void ReadRef(Deserializer* deserializer); | |
| 131 | |
| 132 // Generate all stubs which are generated on a per isolate basis as they | 126 // Generate all stubs which are generated on a per isolate basis as they |
| 133 // have embedded objects which are isolate specific. | 127 // have embedded objects which are isolate specific. |
| 134 static void Init(Isolate* isolate); | 128 static void Init(Isolate* isolate); |
| 135 | 129 |
| 136 static void VisitObjectPointers(ObjectPointerVisitor* visitor); | 130 static void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 137 | 131 |
| 138 // Returns true if stub code has been initialized. | 132 // Returns true if stub code has been initialized. |
| 139 static bool HasBeenInitialized(); | 133 static bool HasBeenInitialized(); |
| 140 | 134 |
| 141 // Check if specified pc is in the dart invocation stub used for | 135 // Check if specified pc is in the dart invocation stub used for |
| 142 // transitioning into dart code. | 136 // transitioning into dart code. |
| 143 static bool InInvocationStub(uword pc); | 137 static bool InInvocationStub(uword pc); |
| 144 | 138 |
| 145 // Check if the specified pc is in the jump to frame stub. | 139 // Check if the specified pc is in the jump to frame stub. |
| 146 static bool InJumpToFrameStub(uword pc); | 140 static bool InJumpToFrameStub(uword pc); |
| 147 | 141 |
| 148 // Returns NULL if no stub found. | 142 // Returns NULL if no stub found. |
| 149 static const char* NameOfStub(uword entry_point); | 143 static const char* NameOfStub(uword entry_point); |
| 150 | 144 |
| 151 // Define the shared stub code accessors. | 145 // Define the shared stub code accessors. |
| 152 #define STUB_CODE_ACCESSOR(name) \ | 146 #define STUB_CODE_ACCESSOR(name) \ |
| 153 static const StubEntry* name##_entry() { return name##_entry_; } \ | 147 static const StubEntry* name##_entry() { return entries_[k##name##Index]; } \ |
| 154 static intptr_t name##Size() { return name##_entry()->Size(); } | 148 static intptr_t name##Size() { return name##_entry()->Size(); } |
| 155 VM_STUB_CODE_LIST(STUB_CODE_ACCESSOR); | 149 VM_STUB_CODE_LIST(STUB_CODE_ACCESSOR); |
| 156 #undef STUB_CODE_ACCESSOR | 150 #undef STUB_CODE_ACCESSOR |
| 157 | 151 |
| 158 static RawCode* GetAllocationStubForClass(const Class& cls); | 152 static RawCode* GetAllocationStubForClass(const Class& cls); |
| 159 | 153 |
| 160 static const StubEntry* UnoptimizedStaticCallEntry(intptr_t num_args_tested); | 154 static const StubEntry* UnoptimizedStaticCallEntry(intptr_t num_args_tested); |
| 161 | 155 |
| 162 static const intptr_t kNoInstantiator = 0; | 156 static const intptr_t kNoInstantiator = 0; |
| 163 | 157 |
| 158 static StubEntry* EntryAt(intptr_t index) { return entries_[index]; } |
| 159 static void EntryAtPut(intptr_t index, StubEntry* entry) { |
| 160 entries_[index] = entry; |
| 161 } |
| 162 static intptr_t NumEntries() { return kNumStubEntries; } |
| 163 |
| 164 private: | 164 private: |
| 165 friend class MegamorphicCacheTable; | 165 friend class MegamorphicCacheTable; |
| 166 | 166 |
| 167 static const intptr_t kStubCodeSize = 4 * KB; | 167 static const intptr_t kStubCodeSize = 4 * KB; |
| 168 | 168 |
| 169 #define STUB_CODE_GENERATE(name) \ | 169 #define STUB_CODE_GENERATE(name) \ |
| 170 static void Generate##name##Stub(Assembler* assembler); | 170 static void Generate##name##Stub(Assembler* assembler); |
| 171 VM_STUB_CODE_LIST(STUB_CODE_GENERATE); | 171 VM_STUB_CODE_LIST(STUB_CODE_GENERATE) |
| 172 #undef STUB_CODE_GENERATE | 172 #undef STUB_CODE_GENERATE |
| 173 | 173 |
| 174 #define STUB_CODE_ENTRY(name) static StubEntry* name##_entry_; | 174 enum { |
| 175 VM_STUB_CODE_LIST(STUB_CODE_ENTRY); | 175 #define STUB_CODE_ENTRY(name) k##name##Index, |
| 176 VM_STUB_CODE_LIST(STUB_CODE_ENTRY) |
| 176 #undef STUB_CODE_ENTRY | 177 #undef STUB_CODE_ENTRY |
| 178 kNumStubEntries |
| 179 }; |
| 180 |
| 181 static StubEntry* entries_[kNumStubEntries]; |
| 177 | 182 |
| 178 // Generate the stub and finalize the generated code into the stub | 183 // Generate the stub and finalize the generated code into the stub |
| 179 // code executable area. | 184 // code executable area. |
| 180 static RawCode* Generate(const char* name, | 185 static RawCode* Generate(const char* name, |
| 181 void (*GenerateStub)(Assembler* assembler)); | 186 void (*GenerateStub)(Assembler* assembler)); |
| 182 | 187 |
| 183 static void GenerateMegamorphicMissStub(Assembler* assembler); | 188 static void GenerateMegamorphicMissStub(Assembler* assembler); |
| 184 static void GenerateAllocationStubForClass(Assembler* assembler, | 189 static void GenerateAllocationStubForClass(Assembler* assembler, |
| 185 const Class& cls); | 190 const Class& cls); |
| 186 static void GenerateNArgsCheckInlineCacheStub( | 191 static void GenerateNArgsCheckInlineCacheStub( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 199 | 204 |
| 200 // Zap value used to indicate unused CODE_REG in deopt. | 205 // Zap value used to indicate unused CODE_REG in deopt. |
| 201 static const uword kZapCodeReg = 0xf1f1f1f1; | 206 static const uword kZapCodeReg = 0xf1f1f1f1; |
| 202 | 207 |
| 203 // Zap value used to indicate unused return address in deopt. | 208 // Zap value used to indicate unused return address in deopt. |
| 204 static const uword kZapReturnAddress = 0xe1e1e1e1; | 209 static const uword kZapReturnAddress = 0xe1e1e1e1; |
| 205 | 210 |
| 206 } // namespace dart | 211 } // namespace dart |
| 207 | 212 |
| 208 #endif // RUNTIME_VM_STUB_CODE_H_ | 213 #endif // RUNTIME_VM_STUB_CODE_H_ |
| OLD | NEW |