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