Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: runtime/vm/stub_code.h

Issue 1229283002: VM: Share some stub code between isolates. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comments Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/stub_code.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 18
19 19
20 // List of stubs created in the VM isolate, these stubs are shared by different 20 // List of stubs created in the VM isolate, these stubs are shared by different
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(GetStackPointer) \ 23 V(GetStackPointer) \
24 V(JumpToExceptionHandler) \ 24 V(JumpToExceptionHandler) \
25 V(UpdateStoreBuffer) \ 25 V(UpdateStoreBuffer) \
26
27 // Is it permitted for the stubs above to refer to Object::null(), which is
28 // allocated in the VM isolate and shared across all isolates.
29 // However, in cases where a simple GC-safe placeholder is needed on the stack,
30 // using Smi 0 instead of Object::null() is slightly more efficient, since a Smi
31 // does not require relocation.
32
33 // List of stubs created per isolate, these stubs could potentially contain
34 // embedded objects and hence cannot be shared across isolates.
35 // The initial stubs are needed for loading bootstrapping scripts and have to
36 // be generated before Object::Init is called.
37 #define BOOTSTRAP_STUB_CODE_LIST(V) \
38 V(PrintStopMessage) \ 26 V(PrintStopMessage) \
39 V(CallToRuntime) \ 27 V(CallToRuntime) \
40 V(LazyCompile) \ 28 V(LazyCompile) \
41
42 #define REST_STUB_CODE_LIST(V) \
43 V(CallBootstrapCFunction) \ 29 V(CallBootstrapCFunction) \
44 V(CallNativeCFunction) \ 30 V(CallNativeCFunction) \
45 V(FixCallersTarget) \ 31 V(FixCallersTarget) \
46 V(CallStaticFunction) \ 32 V(CallStaticFunction) \
33 V(OptimizeFunction) \
34 V(InvokeDartCode) \
35 V(DebugStepCheck) \
36 V(MegamorphicLookup) \
47 V(FixAllocationStubTarget) \ 37 V(FixAllocationStubTarget) \
48 V(FixAllocateArrayStubTarget) \ 38 V(FixAllocateArrayStubTarget) \
49 V(CallClosureNoSuchMethod) \ 39 V(Deoptimize) \
50 V(AllocateContext) \ 40 V(DeoptimizeLazy) \
41 V(UnoptimizedIdenticalWithNumberCheck) \
42 V(OptimizedIdenticalWithNumberCheck) \
43 V(ICCallBreakpoint) \
44 V(RuntimeCallBreakpoint) \
51 V(OneArgCheckInlineCache) \ 45 V(OneArgCheckInlineCache) \
52 V(TwoArgsCheckInlineCache) \ 46 V(TwoArgsCheckInlineCache) \
53 V(SmiAddInlineCache) \ 47 V(SmiAddInlineCache) \
54 V(SmiSubInlineCache) \ 48 V(SmiSubInlineCache) \
55 V(SmiEqualInlineCache) \ 49 V(SmiEqualInlineCache) \
56 V(UnaryRangeCollectingInlineCache) \ 50 V(UnaryRangeCollectingInlineCache) \
57 V(BinaryRangeCollectingInlineCache) \ 51 V(BinaryRangeCollectingInlineCache) \
58 V(OneArgOptimizedCheckInlineCache) \ 52 V(OneArgOptimizedCheckInlineCache) \
59 V(TwoArgsOptimizedCheckInlineCache) \ 53 V(TwoArgsOptimizedCheckInlineCache) \
60 V(ZeroArgsUnoptimizedStaticCall) \ 54 V(ZeroArgsUnoptimizedStaticCall) \
61 V(OneArgUnoptimizedStaticCall) \ 55 V(OneArgUnoptimizedStaticCall) \
62 V(TwoArgsUnoptimizedStaticCall) \ 56 V(TwoArgsUnoptimizedStaticCall) \
63 V(OptimizeFunction) \ 57
64 V(InvokeDartCode) \ 58 // Is it permitted for the stubs above to refer to Object::null(), which is
59 // allocated in the VM isolate and shared across all isolates.
60 // However, in cases where a simple GC-safe placeholder is needed on the stack,
61 // using Smi 0 instead of Object::null() is slightly more efficient, since a Smi
62 // does not require relocation.
63
64 // List of stubs created per isolate, these stubs could potentially contain
65 // embedded objects and hence cannot be shared across isolates.
66 #define STUB_CODE_LIST(V) \
67 V(CallClosureNoSuchMethod) \
68 V(AllocateContext) \
65 V(Subtype1TestCache) \ 69 V(Subtype1TestCache) \
66 V(Subtype2TestCache) \ 70 V(Subtype2TestCache) \
67 V(Subtype3TestCache) \ 71 V(Subtype3TestCache) \
68 V(Deoptimize) \
69 V(DeoptimizeLazy) \
70 V(ICCallBreakpoint) \
71 V(RuntimeCallBreakpoint) \
72 V(UnoptimizedIdenticalWithNumberCheck) \
73 V(OptimizedIdenticalWithNumberCheck) \
74 V(DebugStepCheck) \
75 V(MegamorphicLookup) \
76 72
77 #define STUB_CODE_LIST(V) \
78 BOOTSTRAP_STUB_CODE_LIST(V) \
79 REST_STUB_CODE_LIST(V)
80 73
81 // class StubEntry is used to describe stub methods generated in dart to 74 // class StubEntry is used to describe stub methods generated in dart to
82 // abstract out common code executed from generated dart code. 75 // abstract out common code executed from generated dart code.
83 class StubEntry { 76 class StubEntry {
84 public: 77 public:
85 explicit StubEntry(const Code& code); 78 explicit StubEntry(const Code& code);
86 ~StubEntry() {} 79 ~StubEntry() {}
87 80
88 const ExternalLabel& label() const { return label_; } 81 const ExternalLabel& label() const { return label_; }
89 uword EntryPoint() const { return entry_point_; } 82 uword EntryPoint() const { return entry_point_; }
(...skipping 24 matching lines...) Expand all
114 isolate_(isolate) {} 107 isolate_(isolate) {}
115 ~StubCode(); 108 ~StubCode();
116 109
117 110
118 // 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
119 // 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.
120 static void InitOnce(); 113 static void InitOnce();
121 114
122 // 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
123 // have embedded objects which are isolate specific. 116 // have embedded objects which are isolate specific.
124 // Bootstrap stubs are needed before Object::Init to compile the bootstrap
125 // scripts.
126 static void InitBootstrapStubs(Isolate* isolate);
127 static void Init(Isolate* isolate); 117 static void Init(Isolate* isolate);
128 118
129 static void VisitObjectPointers(ObjectPointerVisitor* visitor); 119 static void VisitObjectPointers(ObjectPointerVisitor* visitor);
130 120
131 // Check if specified pc is in the dart invocation stub used for 121 // Check if specified pc is in the dart invocation stub used for
132 // transitioning into dart code. 122 // transitioning into dart code.
133 static bool InInvocationStub(uword pc); 123 static bool InInvocationStub(uword pc);
134 124
135 static bool InInvocationStubForIsolate(Isolate* isolate, uword pc); 125 static bool InInvocationStubForIsolate(Isolate* isolate, uword pc);
136 126
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 RawCode* GetAllocateArrayStub(); 168 RawCode* GetAllocateArrayStub();
179 169
180 uword UnoptimizedStaticCallEntryPoint(intptr_t num_args_tested); 170 uword UnoptimizedStaticCallEntryPoint(intptr_t num_args_tested);
181 171
182 static const intptr_t kNoInstantiator = 0; 172 static const intptr_t kNoInstantiator = 0;
183 173
184 static void EmitMegamorphicLookup( 174 static void EmitMegamorphicLookup(
185 Assembler*, Register recv, Register cache, Register target); 175 Assembler*, Register recv, Register cache, Register target);
186 176
187 private: 177 private:
188 void GenerateBootstrapStubsFor(Isolate* isolate);
189 void GenerateStubsFor(Isolate* isolate); 178 void GenerateStubsFor(Isolate* isolate);
190 179
191 friend class MegamorphicCacheTable; 180 friend class MegamorphicCacheTable;
192 181
193 static const intptr_t kStubCodeSize = 4 * KB; 182 static const intptr_t kStubCodeSize = 4 * KB;
194 183
195 #define STUB_CODE_GENERATE(name) \ 184 #define STUB_CODE_GENERATE(name) \
196 static void Generate##name##Stub(Assembler* assembler); 185 static void Generate##name##Stub(Assembler* assembler);
197 VM_STUB_CODE_LIST(STUB_CODE_GENERATE); 186 VM_STUB_CODE_LIST(STUB_CODE_GENERATE);
198 STUB_CODE_LIST(STUB_CODE_GENERATE); 187 STUB_CODE_LIST(STUB_CODE_GENERATE);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 Assembler* assembler, 229 Assembler* assembler,
241 const Register left, 230 const Register left,
242 const Register right, 231 const Register right,
243 const Register temp1 = kNoRegister, 232 const Register temp1 = kNoRegister,
244 const Register temp2 = kNoRegister); 233 const Register temp2 = kNoRegister);
245 }; 234 };
246 235
247 } // namespace dart 236 } // namespace dart
248 237
249 #endif // VM_STUB_CODE_H_ 238 #endif // VM_STUB_CODE_H_
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/stub_code.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698