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 |
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(DartCallToRuntime) \ | 23 V(DartCallToRuntime) \ |
24 V(StubCallToRuntime) \ | 24 V(StubCallToRuntime) \ |
25 V(CallNativeCFunction) \ | 25 V(CallNativeCFunction) \ |
26 V(AllocateArray) \ | 26 V(AllocateArray) \ |
27 V(CallNoSuchMethodFunction) \ | 27 V(CallNoSuchMethodFunction) \ |
28 V(MegamorphicLookup) \ | 28 V(MegamorphicLookup) \ |
29 V(CallInstanceFunction) \ | |
30 V(CallStaticFunction) \ | 29 V(CallStaticFunction) \ |
31 V(CallClosureFunction) \ | 30 V(CallClosureFunction) \ |
32 V(StackOverflow) \ | 31 V(StackOverflow) \ |
33 V(OptimizeInvokedFunction) \ | 32 V(OptimizeInvokedFunction) \ |
34 V(FixCallersTarget) \ | 33 V(FixCallersTarget) \ |
35 V(Deoptimize) \ | 34 V(Deoptimize) \ |
36 | 35 |
37 // TODO(regis): Is it OK for the stubs above to refer to Object::null()? | 36 // TODO(regis): Is it OK for the stubs above to refer to Object::null()? |
38 | 37 |
39 // List of stubs created per isolate, these stubs could potentially contain | 38 // List of stubs created per isolate, these stubs could potentially contain |
40 // embedded objects and hence cannot be shared across isolates. | 39 // embedded objects and hence cannot be shared across isolates. |
41 #define STUB_CODE_LIST(V) \ | 40 #define STUB_CODE_LIST(V) \ |
42 V(InvokeDartCode) \ | 41 V(InvokeDartCode) \ |
43 V(AllocateContext) \ | 42 V(AllocateContext) \ |
| 43 V(InlineCache) \ |
44 | 44 |
45 | 45 |
46 // class StubEntry is used to describe stub methods generated in dart to | 46 // class StubEntry is used to describe stub methods generated in dart to |
47 // abstract out common code executed from generated dart code. | 47 // abstract out common code executed from generated dart code. |
48 class StubEntry { | 48 class StubEntry { |
49 public: | 49 public: |
50 StubEntry(const char* name, const Code& code); | 50 StubEntry(const char* name, const Code& code); |
51 ~StubEntry() {} | 51 ~StubEntry() {} |
52 | 52 |
53 const ExternalLabel& label() const { return label_; } | 53 const ExternalLabel& label() const { return label_; } |
(...skipping 11 matching lines...) Expand all Loading... |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(StubEntry); | 66 DISALLOW_COPY_AND_ASSIGN(StubEntry); |
67 }; | 67 }; |
68 | 68 |
69 | 69 |
70 // class StubCode is used to maintain the lifecycle of stubs. | 70 // class StubCode is used to maintain the lifecycle of stubs. |
71 class StubCode { | 71 class StubCode { |
72 public: | 72 public: |
73 StubCode() | 73 StubCode() |
74 : | 74 : |
75 #define STUB_CODE_INITIALIZER(name) \ | 75 #define STUB_CODE_INITIALIZER(name) \ |
76 name##_entry_(NULL), | 76 name##_entry_(NULL), \ |
77 STUB_CODE_LIST(STUB_CODE_INITIALIZER) | 77 STUB_CODE_LIST(STUB_CODE_INITIALIZER) |
78 dummy_(NULL) {} | 78 dummy_(NULL) {} |
79 ~StubCode(); | 79 ~StubCode(); |
80 | 80 |
81 void GenerateFor(Isolate* isolate); | 81 void GenerateFor(Isolate* isolate); |
82 | 82 |
83 // Generate all stubs which are shared across all isolates, this is done | 83 // Generate all stubs which are shared across all isolates, this is done |
84 // only once and the stub code resides in the vm_isolate heap. | 84 // only once and the stub code resides in the vm_isolate heap. |
85 static void InitOnce(); | 85 static void InitOnce(); |
86 | 86 |
87 // Generate all stubs which are generated on a per isolate basis as they | 87 // Generate all stubs which are generated on a per isolate basis as they |
88 // have embedded objects which are isolate specific. | 88 // have embedded objects which are isolate specific. |
89 static void Init(Isolate* isolate); | 89 static void Init(Isolate* isolate); |
90 | 90 |
91 static void VisitObjectPointers(ObjectPointerVisitor* visitor); | 91 static void VisitObjectPointers(ObjectPointerVisitor* visitor); |
92 | 92 |
93 // Check if specified pc is in the dart invocation stub used for | 93 // Check if specified pc is in the dart invocation stub used for |
94 // transitioning into dart code. | 94 // transitioning into dart code. |
95 static bool InInvocationStub(uword pc); | 95 static bool InInvocationStub(uword pc); |
96 // Check if specified pc is in CallInstanceFunction stub. | |
97 static bool InCallInstanceFunctionStubCode(uword pc); | |
98 // Check if specified pc is in StubCallToRuntime stub. | 96 // Check if specified pc is in StubCallToRuntime stub. |
99 static bool InStubCallToRuntimeStubCode(uword pc); | 97 static bool InStubCallToRuntimeStubCode(uword pc); |
100 | 98 |
101 // Returns NULL if no stub found. | 99 // Returns NULL if no stub found. |
102 static const char* NameOfStub(uword entry_point); | 100 static const char* NameOfStub(uword entry_point); |
103 | 101 |
104 // Define the shared stub code accessors. | 102 // Define the shared stub code accessors. |
105 #define STUB_CODE_ACCESSOR(name) \ | 103 #define STUB_CODE_ACCESSOR(name) \ |
106 static StubEntry* name##_entry() { \ | 104 static StubEntry* name##_entry() { \ |
107 return name##_entry_; \ | 105 return name##_entry_; \ |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 161 |
164 static void GenerateAllocationStubForClass(Assembler* assembler, | 162 static void GenerateAllocationStubForClass(Assembler* assembler, |
165 const Class& cls); | 163 const Class& cls); |
166 static void GenerateAllocationStubForClosure(Assembler* assembler, | 164 static void GenerateAllocationStubForClosure(Assembler* assembler, |
167 const Function& func); | 165 const Function& func); |
168 }; | 166 }; |
169 | 167 |
170 } // namespace dart | 168 } // namespace dart |
171 | 169 |
172 #endif // VM_STUB_CODE_H_ | 170 #endif // VM_STUB_CODE_H_ |
OLD | NEW |