OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_FAST_ACCESSOR_ASSEMBLER_H_ | 5 #ifndef V8_FAST_ACCESSOR_ASSEMBLER_H_ |
6 #define V8_FAST_ACCESSOR_ASSEMBLER_H_ | 6 #define V8_FAST_ACCESSOR_ASSEMBLER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "include/v8-experimental.h" | 12 #include "include/v8-experimental.h" |
13 #include "src/base/macros.h" | 13 #include "src/base/macros.h" |
14 #include "src/handles.h" | 14 #include "src/handles.h" |
15 | 15 |
16 // For CodeStubAssembler::Label. (We cannot forward-declare inner classes.) | |
17 #include "src/code-stub-assembler.h" | |
18 | |
19 namespace v8 { | 16 namespace v8 { |
20 namespace internal { | 17 namespace internal { |
21 | 18 |
22 class Code; | 19 class Code; |
| 20 class CodeStubAssembler; |
23 class Isolate; | 21 class Isolate; |
24 class Zone; | 22 class Zone; |
25 | 23 |
26 namespace compiler { | 24 namespace compiler { |
27 class Node; | 25 class Node; |
| 26 class CodeAssemblerLabel; |
| 27 class CodeAssemblerState; |
| 28 class CodeAssemblerVariable; |
28 } | 29 } |
29 | 30 |
30 // This interface "exports" an aggregated subset of RawMachineAssembler, for | 31 // This interface "exports" an aggregated subset of RawMachineAssembler, for |
31 // use by the API to implement Fast Dom Accessors. | 32 // use by the API to implement Fast Dom Accessors. |
32 // | 33 // |
33 // This interface is made for this single purpose only and does not attempt | 34 // This interface is made for this single purpose only and does not attempt |
34 // to implement a general purpose solution. If you need one, please look at | 35 // to implement a general purpose solution. If you need one, please look at |
35 // RawMachineAssembler instead. | 36 // RawMachineAssembler instead. |
36 // | 37 // |
37 // The life cycle of a FastAccessorAssembler has two phases: | 38 // The life cycle of a FastAccessorAssembler has two phases: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 void CheckNotZeroOrJump(ValueId value_id, LabelId label_id); | 80 void CheckNotZeroOrJump(ValueId value_id, LabelId label_id); |
80 | 81 |
81 // C++ callback. | 82 // C++ callback. |
82 ValueId Call(FunctionCallback callback, ValueId arg); | 83 ValueId Call(FunctionCallback callback, ValueId arg); |
83 | 84 |
84 // Assemble the code. | 85 // Assemble the code. |
85 MaybeHandle<Code> Build(); | 86 MaybeHandle<Code> Build(); |
86 | 87 |
87 private: | 88 private: |
88 ValueId FromRaw(compiler::Node* node); | 89 ValueId FromRaw(compiler::Node* node); |
89 LabelId FromRaw(CodeStubAssembler::Label* label); | 90 LabelId FromRaw(compiler::CodeAssemblerLabel* label); |
90 compiler::Node* FromId(ValueId value) const; | 91 compiler::Node* FromId(ValueId value) const; |
91 CodeStubAssembler::Label* FromId(LabelId value) const; | 92 compiler::CodeAssemblerLabel* FromId(LabelId value) const; |
92 | 93 |
93 void CheckIsJSObjectOrJump(ValueId value, LabelId label_id); | 94 void CheckIsJSObjectOrJump(ValueId value, LabelId label_id); |
94 | 95 |
95 void Clear(); | 96 void Clear(); |
96 Zone* zone() { return &zone_; } | 97 Zone* zone() { return &zone_; } |
97 Isolate* isolate() const { return isolate_; } | 98 Isolate* isolate() const { return isolate_; } |
98 | 99 |
99 Zone zone_; | 100 Zone zone_; |
100 Isolate* isolate_; | 101 Isolate* isolate_; |
101 compiler::CodeAssemblerState assembler_state_; | 102 std::unique_ptr<compiler::CodeAssemblerState> assembler_state_; |
102 std::unique_ptr<CodeStubAssembler> assembler_; | 103 std::unique_ptr<CodeStubAssembler> assembler_; |
103 | 104 |
104 // To prevent exposing the RMA internals to the outside world, we'll map | 105 // To prevent exposing the RMA internals to the outside world, we'll map |
105 // Node + Label pointers integers wrapped in ValueId and LabelId instances. | 106 // Node + Label pointers integers wrapped in ValueId and LabelId instances. |
106 // These vectors maintain this mapping. | 107 // These vectors maintain this mapping. |
107 std::vector<compiler::Node*> nodes_; | 108 std::vector<compiler::Node*> nodes_; |
108 std::vector<CodeStubAssembler::Label*> labels_; | 109 std::vector<compiler::CodeAssemblerLabel*> labels_; |
109 | 110 |
110 // Remember the current state for easy error checking. (We prefer to be | 111 // Remember the current state for easy error checking. (We prefer to be |
111 // strict as this class will be exposed at the API.) | 112 // strict as this class will be exposed at the API.) |
112 enum { kBuilding, kBuilt, kError } state_; | 113 enum { kBuilding, kBuilt, kError } state_; |
113 | 114 |
114 DISALLOW_COPY_AND_ASSIGN(FastAccessorAssembler); | 115 DISALLOW_COPY_AND_ASSIGN(FastAccessorAssembler); |
115 }; | 116 }; |
116 | 117 |
117 } // namespace internal | 118 } // namespace internal |
118 } // namespace v8 | 119 } // namespace v8 |
119 | 120 |
120 #endif // V8_FAST_ACCESSOR_ASSEMBLER_H_ | 121 #endif // V8_FAST_ACCESSOR_ASSEMBLER_H_ |
OLD | NEW |