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 namespace compiler { | 13 namespace compiler { |
14 | 14 |
15 // Forward declarations. | 15 // Forward declarations. |
16 class CommonOperatorBuilder; | 16 class CommonOperatorBuilder; |
17 class JSGraph; | 17 class JSGraph; |
18 class JSOperatorBuilder; | 18 class JSOperatorBuilder; |
19 class SimplifiedOperatorBuilder; | |
20 | 19 |
21 | 20 |
22 // Performs strength reduction on {JSCallFunction} nodes, which might allow | 21 // Performs strength reduction on {JSCallConstruct} and {JSCallFunction} nodes, |
23 // inlining or other optimizations to be performed afterwards. | 22 // which might allow inlining or other optimizations to be performed afterwards. |
24 class JSCallReducer final : public Reducer { | 23 class JSCallReducer final : public Reducer { |
25 public: | 24 public: |
26 // Flags that control the mode of operation. | 25 // Flags that control the mode of operation. |
27 enum Flag { | 26 enum Flag { |
28 kNoFlags = 0u, | 27 kNoFlags = 0u, |
29 kDeoptimizationEnabled = 1u << 0, | 28 kDeoptimizationEnabled = 1u << 0, |
30 }; | 29 }; |
31 typedef base::Flags<Flag> Flags; | 30 typedef base::Flags<Flag> Flags; |
32 | 31 |
33 JSCallReducer(JSGraph* jsgraph, Flags flags) | 32 JSCallReducer(JSGraph* jsgraph, Flags flags, |
34 : jsgraph_(jsgraph), flags_(flags) {} | 33 MaybeHandle<Context> native_context) |
| 34 : jsgraph_(jsgraph), flags_(flags), native_context_(native_context) {} |
35 | 35 |
36 Reduction Reduce(Node* node) final; | 36 Reduction Reduce(Node* node) final; |
37 | 37 |
38 private: | 38 private: |
| 39 Reduction ReduceArrayConstructor(Node* node); |
39 Reduction ReduceFunctionPrototypeApply(Node* node); | 40 Reduction ReduceFunctionPrototypeApply(Node* node); |
40 Reduction ReduceFunctionPrototypeCall(Node* node); | 41 Reduction ReduceFunctionPrototypeCall(Node* node); |
| 42 Reduction ReduceJSCallConstruct(Node* node); |
41 Reduction ReduceJSCallFunction(Node* node); | 43 Reduction ReduceJSCallFunction(Node* node); |
42 | 44 |
| 45 MaybeHandle<Context> GetNativeContext(Node* node); |
| 46 |
43 Graph* graph() const; | 47 Graph* graph() const; |
44 Flags flags() const { return flags_; } | 48 Flags flags() const { return flags_; } |
45 JSGraph* jsgraph() const { return jsgraph_; } | 49 JSGraph* jsgraph() const { return jsgraph_; } |
46 Isolate* isolate() const; | 50 Isolate* isolate() const; |
| 51 MaybeHandle<Context> native_context() const { return native_context_; } |
47 CommonOperatorBuilder* common() const; | 52 CommonOperatorBuilder* common() const; |
48 JSOperatorBuilder* javascript() const; | 53 JSOperatorBuilder* javascript() const; |
49 SimplifiedOperatorBuilder* simplified() const; | |
50 | 54 |
51 JSGraph* const jsgraph_; | 55 JSGraph* const jsgraph_; |
52 Flags const flags_; | 56 Flags const flags_; |
| 57 MaybeHandle<Context> const native_context_; |
53 }; | 58 }; |
54 | 59 |
55 DEFINE_OPERATORS_FOR_FLAGS(JSCallReducer::Flags) | 60 DEFINE_OPERATORS_FOR_FLAGS(JSCallReducer::Flags) |
56 | 61 |
57 } // namespace compiler | 62 } // namespace compiler |
58 } // namespace internal | 63 } // namespace internal |
59 } // namespace v8 | 64 } // namespace v8 |
60 | 65 |
61 #endif // V8_COMPILER_JS_CALL_REDUCER_H_ | 66 #endif // V8_COMPILER_JS_CALL_REDUCER_H_ |
OLD | NEW |