OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_JS_GENERIC_LOWERING_H_ | 5 #ifndef V8_COMPILER_JS_GENERIC_LOWERING_H_ |
6 #define V8_COMPILER_JS_GENERIC_LOWERING_H_ | 6 #define V8_COMPILER_JS_GENERIC_LOWERING_H_ |
7 | 7 |
8 #include "src/allocation.h" | |
9 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
10 #include "src/compiler/graph.h" | |
11 #include "src/compiler/graph-reducer.h" | 9 #include "src/compiler/graph-reducer.h" |
12 #include "src/compiler/js-graph.h" | |
13 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
14 #include "src/compiler/opcodes.h" | 11 #include "src/compiler/opcodes.h" |
15 | 12 |
16 namespace v8 { | 13 namespace v8 { |
17 namespace internal { | 14 namespace internal { |
18 namespace compiler { | 15 namespace compiler { |
19 | 16 |
20 // Forward declarations. | 17 // Forward declarations. |
21 class CommonOperatorBuilder; | 18 class CommonOperatorBuilder; |
| 19 class JSGraph; |
22 class MachineOperatorBuilder; | 20 class MachineOperatorBuilder; |
23 class Linkage; | 21 class Linkage; |
24 | 22 |
25 | 23 |
26 // Lowers JS-level operators to runtime and IC calls in the "generic" case. | 24 // Lowers JS-level operators to runtime and IC calls in the "generic" case. |
27 class JSGenericLowering FINAL : public Reducer { | 25 class JSGenericLowering FINAL : public Reducer { |
28 public: | 26 public: |
29 JSGenericLowering(bool is_typing_enabled, JSGraph* graph); | 27 JSGenericLowering(bool is_typing_enabled, JSGraph* jsgraph); |
30 ~JSGenericLowering() FINAL {} | 28 ~JSGenericLowering() FINAL; |
31 | 29 |
32 Reduction Reduce(Node* node) FINAL; | 30 Reduction Reduce(Node* node) FINAL; |
33 | 31 |
34 protected: | 32 protected: |
35 #define DECLARE_LOWER(x) void Lower##x(Node* node); | 33 #define DECLARE_LOWER(x) void Lower##x(Node* node); |
36 // Dispatched depending on opcode. | 34 // Dispatched depending on opcode. |
37 JS_OP_LIST(DECLARE_LOWER) | 35 JS_OP_LIST(DECLARE_LOWER) |
38 #undef DECLARE_LOWER | 36 #undef DECLARE_LOWER |
39 | 37 |
40 // Helpers to replace existing nodes with a generic call. | 38 // Helpers to replace existing nodes with a generic call. |
41 void ReplaceWithCompareIC(Node* node, Token::Value token); | 39 void ReplaceWithCompareIC(Node* node, Token::Value token); |
42 void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags); | 40 void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags); |
43 void ReplaceWithBuiltinCall(Node* node, Builtins::JavaScript id, int args); | 41 void ReplaceWithBuiltinCall(Node* node, Builtins::JavaScript id, int args); |
44 void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1); | 42 void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1); |
45 | 43 |
46 // Helper for optimization of JSCallFunction. | 44 // Helper for optimization of JSCallFunction. |
47 bool TryLowerDirectJSCall(Node* node); | 45 bool TryLowerDirectJSCall(Node* node); |
48 | 46 |
49 Zone* zone() const { return graph()->zone(); } | 47 Zone* zone() const; |
50 Isolate* isolate() const { return jsgraph()->isolate(); } | 48 Isolate* isolate() const; |
51 JSGraph* jsgraph() const { return jsgraph_; } | 49 JSGraph* jsgraph() const { return jsgraph_; } |
52 Graph* graph() const { return jsgraph()->graph(); } | 50 Graph* graph() const; |
53 CommonOperatorBuilder* common() const { return jsgraph()->common(); } | 51 CommonOperatorBuilder* common() const; |
54 MachineOperatorBuilder* machine() const { return jsgraph()->machine(); } | 52 MachineOperatorBuilder* machine() const; |
55 | 53 |
56 private: | 54 private: |
57 bool is_typing_enabled_; | 55 bool const is_typing_enabled_; |
58 JSGraph* jsgraph_; | 56 JSGraph* const jsgraph_; |
59 }; | 57 }; |
60 | 58 |
61 } // namespace compiler | 59 } // namespace compiler |
62 } // namespace internal | 60 } // namespace internal |
63 } // namespace v8 | 61 } // namespace v8 |
64 | 62 |
65 #endif // V8_COMPILER_JS_GENERIC_LOWERING_H_ | 63 #endif // V8_COMPILER_JS_GENERIC_LOWERING_H_ |
OLD | NEW |