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" | 8 #include "src/allocation.h" |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 virtual ~JSGenericLowering() {} | 29 virtual ~JSGenericLowering() {} |
30 | 30 |
31 virtual Reduction Reduce(Node* node); | 31 virtual Reduction Reduce(Node* node); |
32 | 32 |
33 protected: | 33 protected: |
34 #define DECLARE_LOWER(x) void Lower##x(Node* node); | 34 #define DECLARE_LOWER(x) void Lower##x(Node* node); |
35 // Dispatched depending on opcode. | 35 // Dispatched depending on opcode. |
36 ALL_OP_LIST(DECLARE_LOWER) | 36 ALL_OP_LIST(DECLARE_LOWER) |
37 #undef DECLARE_LOWER | 37 #undef DECLARE_LOWER |
38 | 38 |
39 // Helpers to create new constant nodes. | |
40 Node* SmiConstant(int immediate); | |
41 Node* Int32Constant(int immediate); | |
42 Node* CodeConstant(Handle<Code> code); | |
43 Node* FunctionConstant(Handle<JSFunction> function); | |
44 Node* ExternalConstant(ExternalReference ref); | |
45 | |
46 // Helpers to patch existing nodes in the graph. | 39 // Helpers to patch existing nodes in the graph. |
47 void PatchOperator(Node* node, const Operator* new_op); | 40 void PatchOperator(Node* node, const Operator* new_op); |
48 void PatchInsertInput(Node* node, int index, Node* input); | 41 void PatchInsertInput(Node* node, int index, Node* input); |
49 | 42 |
50 // Helpers to replace existing nodes with a generic call. | 43 // Helpers to replace existing nodes with a generic call. |
51 void ReplaceWithCompareIC(Node* node, Token::Value token, bool pure); | 44 void ReplaceWithCompareIC(Node* node, Token::Value token, bool pure); |
52 void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags); | 45 void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags); |
53 void ReplaceWithBuiltinCall(Node* node, Builtins::JavaScript id, int args); | 46 void ReplaceWithBuiltinCall(Node* node, Builtins::JavaScript id, int args); |
54 void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1); | 47 void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1); |
55 | 48 |
| 49 // Helper for optimization of JSCallFunction. |
| 50 bool TryLowerDirectJSCall(Node* node); |
| 51 |
56 Zone* zone() const { return graph()->zone(); } | 52 Zone* zone() const { return graph()->zone(); } |
57 Isolate* isolate() const { return zone()->isolate(); } | 53 Isolate* isolate() const { return zone()->isolate(); } |
58 JSGraph* jsgraph() const { return jsgraph_; } | 54 JSGraph* jsgraph() const { return jsgraph_; } |
59 Graph* graph() const { return jsgraph()->graph(); } | 55 Graph* graph() const { return jsgraph()->graph(); } |
60 Linkage* linkage() const { return linkage_; } | 56 Linkage* linkage() const { return linkage_; } |
61 CompilationInfo* info() const { return info_; } | 57 CompilationInfo* info() const { return info_; } |
62 CommonOperatorBuilder* common() const { return jsgraph()->common(); } | 58 CommonOperatorBuilder* common() const { return jsgraph()->common(); } |
63 MachineOperatorBuilder* machine() const { return jsgraph()->machine(); } | 59 MachineOperatorBuilder* machine() const { return jsgraph()->machine(); } |
64 | 60 |
65 private: | 61 private: |
66 CompilationInfo* info_; | 62 CompilationInfo* info_; |
67 JSGraph* jsgraph_; | 63 JSGraph* jsgraph_; |
68 Linkage* linkage_; | 64 Linkage* linkage_; |
69 | |
70 bool TryLowerDirectJSCall(Node* node); | |
71 }; | 65 }; |
72 | 66 |
73 } // namespace compiler | 67 } // namespace compiler |
74 } // namespace internal | 68 } // namespace internal |
75 } // namespace v8 | 69 } // namespace v8 |
76 | 70 |
77 #endif // V8_COMPILER_JS_GENERIC_LOWERING_H_ | 71 #endif // V8_COMPILER_JS_GENERIC_LOWERING_H_ |
OLD | NEW |