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_COMPILER_FAST_ACCESSOR_ASSEMBLER_H_ | 5 #ifndef V8_FAST_ACCESSOR_ASSEMBLER_H_ |
6 #define V8_COMPILER_FAST_ACCESSOR_ASSEMBLER_H_ | 6 #define V8_FAST_ACCESSOR_ASSEMBLER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 // Clients of this interface shouldn't depend on lots of compiler internals. | |
12 // Do not include anything from src/compiler here! | |
13 #include "include/v8-experimental.h" | 11 #include "include/v8-experimental.h" |
14 #include "src/base/macros.h" | 12 #include "src/base/macros.h" |
15 #include "src/base/smart-pointers.h" | 13 #include "src/base/smart-pointers.h" |
16 #include "src/handles.h" | 14 #include "src/handles.h" |
17 | 15 |
| 16 // For CodeStubAssembler::Label. (We cannot forward-declare inner classes.) |
| 17 #include "src/compiler/code-stub-assembler.h" |
18 | 18 |
19 namespace v8 { | 19 namespace v8 { |
20 namespace internal { | 20 namespace internal { |
21 | 21 |
22 class Code; | 22 class Code; |
23 class Isolate; | 23 class Isolate; |
24 class Zone; | 24 class Zone; |
25 | 25 |
26 namespace compiler { | 26 namespace compiler { |
27 | |
28 class Node; | 27 class Node; |
29 class RawMachineAssembler; | 28 } |
30 class RawMachineLabel; | |
31 | |
32 | 29 |
33 // This interface "exports" an aggregated subset of RawMachineAssembler, for | 30 // This interface "exports" an aggregated subset of RawMachineAssembler, for |
34 // use by the API to implement Fast Dom Accessors. | 31 // use by the API to implement Fast Dom Accessors. |
35 // | 32 // |
36 // This interface is made for this single purpose only and does not attempt | 33 // This interface is made for this single purpose only and does not attempt |
37 // to implement a general purpose solution. If you need one, please look at | 34 // to implement a general purpose solution. If you need one, please look at |
38 // RawMachineAssembler instead. | 35 // RawMachineAssembler instead. |
39 // | 36 // |
40 // The life cycle of a FastAccessorAssembler has two phases: | 37 // The life cycle of a FastAccessorAssembler has two phases: |
41 // - After creating the instance, you can call an arbitrary sequence of | 38 // - After creating the instance, you can call an arbitrary sequence of |
(...skipping 26 matching lines...) Expand all Loading... |
68 void SetLabel(LabelId label_id); | 65 void SetLabel(LabelId label_id); |
69 void CheckNotZeroOrJump(ValueId value_id, LabelId label_id); | 66 void CheckNotZeroOrJump(ValueId value_id, LabelId label_id); |
70 | 67 |
71 // C++ callback. | 68 // C++ callback. |
72 ValueId Call(FunctionCallback callback, ValueId arg); | 69 ValueId Call(FunctionCallback callback, ValueId arg); |
73 | 70 |
74 // Assemble the code. | 71 // Assemble the code. |
75 MaybeHandle<Code> Build(); | 72 MaybeHandle<Code> Build(); |
76 | 73 |
77 private: | 74 private: |
78 ValueId FromRaw(Node* node); | 75 ValueId FromRaw(compiler::Node* node); |
79 LabelId FromRaw(RawMachineLabel* label); | 76 LabelId FromRaw(compiler::CodeStubAssembler::Label* label); |
80 Node* FromId(ValueId value) const; | 77 compiler::Node* FromId(ValueId value) const; |
81 RawMachineLabel* FromId(LabelId value) const; | 78 compiler::CodeStubAssembler::Label* FromId(LabelId value) const; |
82 | 79 |
| 80 void Clear(); |
83 Zone* zone() { return &zone_; } | 81 Zone* zone() { return &zone_; } |
| 82 Isolate* isolate() const { return isolate_; } |
84 | 83 |
85 Zone zone_; | 84 Zone zone_; |
86 base::SmartPointer<RawMachineAssembler> assembler_; | 85 Isolate* isolate_; |
| 86 base::SmartPointer<compiler::CodeStubAssembler> assembler_; |
87 | 87 |
88 // To prevent exposing the RMA internals to the outside world, we'll map | 88 // To prevent exposing the RMA internals to the outside world, we'll map |
89 // Node + Label pointers integers wrapped in ValueId and LabelId instances. | 89 // Node + Label pointers integers wrapped in ValueId and LabelId instances. |
90 // These vectors maintain this mapping. | 90 // These vectors maintain this mapping. |
91 std::vector<Node*> nodes_; | 91 std::vector<compiler::Node*> nodes_; |
92 std::vector<RawMachineLabel*> labels_; | 92 std::vector<compiler::CodeStubAssembler::Label*> labels_; |
93 | 93 |
94 // Remember the current state for easy error checking. (We prefer to be | 94 // Remember the current state for easy error checking. (We prefer to be |
95 // strict as this class will be exposed at the API.) | 95 // strict as this class will be exposed at the API.) |
96 enum { kBuilding, kBuilt, kError } state_; | 96 enum { kBuilding, kBuilt, kError } state_; |
97 | 97 |
98 DISALLOW_COPY_AND_ASSIGN(FastAccessorAssembler); | 98 DISALLOW_COPY_AND_ASSIGN(FastAccessorAssembler); |
99 }; | 99 }; |
100 | 100 |
101 } // namespace compiler | |
102 } // namespace internal | 101 } // namespace internal |
103 } // namespace v8 | 102 } // namespace v8 |
104 | 103 |
105 #endif // V8_COMPILER_FAST_ACCESSOR_ASSEMBLER_H_ | 104 #endif // V8_FAST_ACCESSOR_ASSEMBLER_H_ |
OLD | NEW |