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_JS_CALL_REDUCER_H_ | 5 #ifndef V8_COMPILER_JS_CALL_REDUCER_H_ |
6 #define V8_COMPILER_JS_CALL_REDUCER_H_ | 6 #define V8_COMPILER_JS_CALL_REDUCER_H_ |
7 | 7 |
8 #include "src/base/flags.h" | 8 #include "src/base/flags.h" |
9 #include "src/compiler/graph-reducer.h" | 9 #include "src/compiler/graph-reducer.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
| 13 |
| 14 // Forward declarations. |
| 15 class CompilationDependencies; |
| 16 class Factory; |
| 17 |
13 namespace compiler { | 18 namespace compiler { |
14 | 19 |
15 // Forward declarations. | 20 // Forward declarations. |
16 class CommonOperatorBuilder; | 21 class CommonOperatorBuilder; |
17 class JSGraph; | 22 class JSGraph; |
18 class JSOperatorBuilder; | 23 class JSOperatorBuilder; |
19 class SimplifiedOperatorBuilder; | 24 class SimplifiedOperatorBuilder; |
20 | 25 |
21 // Performs strength reduction on {JSCallConstruct} and {JSCallFunction} nodes, | 26 // Performs strength reduction on {JSCallConstruct} and {JSCallFunction} nodes, |
22 // which might allow inlining or other optimizations to be performed afterwards. | 27 // which might allow inlining or other optimizations to be performed afterwards. |
23 class JSCallReducer final : public AdvancedReducer { | 28 class JSCallReducer final : public AdvancedReducer { |
24 public: | 29 public: |
25 // Flags that control the mode of operation. | 30 // Flags that control the mode of operation. |
26 enum Flag { | 31 enum Flag { |
27 kNoFlags = 0u, | 32 kNoFlags = 0u, |
28 kDeoptimizationEnabled = 1u << 0, | 33 kDeoptimizationEnabled = 1u << 0, |
29 }; | 34 }; |
30 typedef base::Flags<Flag> Flags; | 35 typedef base::Flags<Flag> Flags; |
31 | 36 |
32 JSCallReducer(Editor* editor, JSGraph* jsgraph, Flags flags, | 37 JSCallReducer(Editor* editor, JSGraph* jsgraph, Flags flags, |
33 Handle<Context> native_context) | 38 Handle<Context> native_context, |
| 39 CompilationDependencies* dependencies) |
34 : AdvancedReducer(editor), | 40 : AdvancedReducer(editor), |
35 jsgraph_(jsgraph), | 41 jsgraph_(jsgraph), |
36 flags_(flags), | 42 flags_(flags), |
37 native_context_(native_context) {} | 43 native_context_(native_context), |
| 44 dependencies_(dependencies) {} |
38 | 45 |
39 Reduction Reduce(Node* node) final; | 46 Reduction Reduce(Node* node) final; |
40 | 47 |
41 private: | 48 private: |
42 Reduction ReduceArrayConstructor(Node* node); | 49 Reduction ReduceArrayConstructor(Node* node); |
43 Reduction ReduceCallApiFunction( | 50 Reduction ReduceCallApiFunction( |
44 Node* node, Node* target, | 51 Node* node, Node* target, |
45 Handle<FunctionTemplateInfo> function_template_info); | 52 Handle<FunctionTemplateInfo> function_template_info); |
46 Reduction ReduceNumberConstructor(Node* node); | 53 Reduction ReduceNumberConstructor(Node* node); |
47 Reduction ReduceFunctionPrototypeApply(Node* node); | 54 Reduction ReduceFunctionPrototypeApply(Node* node); |
48 Reduction ReduceFunctionPrototypeCall(Node* node); | 55 Reduction ReduceFunctionPrototypeCall(Node* node); |
49 Reduction ReduceFunctionPrototypeHasInstance(Node* node); | 56 Reduction ReduceFunctionPrototypeHasInstance(Node* node); |
50 Reduction ReduceObjectPrototypeGetProto(Node* node); | 57 Reduction ReduceObjectPrototypeGetProto(Node* node); |
51 Reduction ReduceJSCallConstruct(Node* node); | 58 Reduction ReduceJSCallConstruct(Node* node); |
| 59 Reduction ReduceJSCallConstructWithSpread(Node* node); |
52 Reduction ReduceJSCallFunction(Node* node); | 60 Reduction ReduceJSCallFunction(Node* node); |
53 | 61 |
54 enum HolderLookup { kHolderNotFound, kHolderIsReceiver, kHolderFound }; | 62 enum HolderLookup { kHolderNotFound, kHolderIsReceiver, kHolderFound }; |
55 | 63 |
56 HolderLookup LookupHolder(Handle<JSObject> object, | 64 HolderLookup LookupHolder(Handle<JSObject> object, |
57 Handle<FunctionTemplateInfo> function_template_info, | 65 Handle<FunctionTemplateInfo> function_template_info, |
58 Handle<JSObject>* holder); | 66 Handle<JSObject>* holder); |
59 | 67 |
60 Graph* graph() const; | 68 Graph* graph() const; |
61 Flags flags() const { return flags_; } | 69 Flags flags() const { return flags_; } |
62 JSGraph* jsgraph() const { return jsgraph_; } | 70 JSGraph* jsgraph() const { return jsgraph_; } |
63 Isolate* isolate() const; | 71 Isolate* isolate() const; |
| 72 Factory* factory() const; |
64 Handle<Context> native_context() const { return native_context_; } | 73 Handle<Context> native_context() const { return native_context_; } |
65 CommonOperatorBuilder* common() const; | 74 CommonOperatorBuilder* common() const; |
66 JSOperatorBuilder* javascript() const; | 75 JSOperatorBuilder* javascript() const; |
67 SimplifiedOperatorBuilder* simplified() const; | 76 SimplifiedOperatorBuilder* simplified() const; |
| 77 CompilationDependencies* dependencies() const { return dependencies_; } |
68 | 78 |
69 JSGraph* const jsgraph_; | 79 JSGraph* const jsgraph_; |
70 Flags const flags_; | 80 Flags const flags_; |
71 Handle<Context> const native_context_; | 81 Handle<Context> const native_context_; |
| 82 CompilationDependencies* const dependencies_; |
72 }; | 83 }; |
73 | 84 |
74 DEFINE_OPERATORS_FOR_FLAGS(JSCallReducer::Flags) | 85 DEFINE_OPERATORS_FOR_FLAGS(JSCallReducer::Flags) |
75 | 86 |
76 } // namespace compiler | 87 } // namespace compiler |
77 } // namespace internal | 88 } // namespace internal |
78 } // namespace v8 | 89 } // namespace v8 |
79 | 90 |
80 #endif // V8_COMPILER_JS_CALL_REDUCER_H_ | 91 #endif // V8_COMPILER_JS_CALL_REDUCER_H_ |
OLD | NEW |