Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1 | // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef V8_COMPILER_JS_CREATE_LOWERING_H_ |
| 6 | #define V8_COMPILER_JS_CREATE_LOWERING_H_ |
| 7 | |
| 8 | #include "src/compiler/graph-reducer.h" |
| 9 | |
| 10 | namespace v8 { |
| 11 | namespace internal { |
| 12 | |
| 13 | // Forward declarations. |
| 14 | class AllocationSiteUsageContext; |
| 15 | class CompilationDependencies; |
| 16 | class Factory; |
| 17 | |
| 18 | |
| 19 | namespace compiler { |
| 20 | |
| 21 | // Forward declarations. |
| 22 | class CommonOperatorBuilder; |
| 23 | class JSGraph; |
| 24 | class JSOperatorBuilder; |
| 25 | class MachineOperatorBuilder; |
| 26 | class SimplifiedOperatorBuilder; |
| 27 | |
| 28 | |
| 29 | // Lowers JSCreate-level operators to fast (inline) allocations. |
| 30 | class JSCreateLowering final : public AdvancedReducer { |
| 31 | public: |
| 32 | JSCreateLowering(Editor* editor, CompilationDependencies* dependencies, |
| 33 | JSGraph* jsgraph, MaybeHandle<LiteralsArray> literals_array, |
| 34 | Zone* zone) |
| 35 | : AdvancedReducer(editor), |
| 36 | dependencies_(dependencies), |
| 37 | jsgraph_(jsgraph), |
| 38 | literals_array_(literals_array), |
| 39 | zone_(zone) {} |
| 40 | ~JSCreateLowering() final {} |
| 41 | |
| 42 | Reduction Reduce(Node* node) final; |
| 43 | |
| 44 | private: |
| 45 | Reduction ReduceJSCreate(Node* node); |
| 46 | Reduction ReduceJSCreateArguments(Node* node); |
| 47 | Reduction ReduceJSCreateArray(Node* node); |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 48 | Reduction ReduceJSCreateClosure(Node* node); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 49 | Reduction ReduceJSCreateIterResultObject(Node* node); |
| 50 | Reduction ReduceJSCreateLiteral(Node* node); |
| 51 | Reduction ReduceJSCreateFunctionContext(Node* node); |
| 52 | Reduction ReduceJSCreateWithContext(Node* node); |
| 53 | Reduction ReduceJSCreateCatchContext(Node* node); |
| 54 | Reduction ReduceJSCreateBlockContext(Node* node); |
| 55 | Reduction ReduceNewArray(Node* node, Node* length, int capacity, |
| 56 | Handle<AllocationSite> site); |
| 57 | |
| 58 | Node* AllocateArguments(Node* effect, Node* control, Node* frame_state); |
| 59 | Node* AllocateRestArguments(Node* effect, Node* control, Node* frame_state, |
| 60 | int start_index); |
| 61 | Node* AllocateAliasedArguments(Node* effect, Node* control, Node* frame_state, |
| 62 | Node* context, Handle<SharedFunctionInfo>, |
| 63 | bool* has_aliased_arguments); |
| 64 | Node* AllocateElements(Node* effect, Node* control, |
| 65 | ElementsKind elements_kind, int capacity, |
| 66 | PretenureFlag pretenure); |
| 67 | Node* AllocateFastLiteral(Node* effect, Node* control, |
| 68 | Handle<JSObject> boilerplate, |
| 69 | AllocationSiteUsageContext* site_context); |
| 70 | Node* AllocateFastLiteralElements(Node* effect, Node* control, |
| 71 | Handle<JSObject> boilerplate, |
| 72 | PretenureFlag pretenure, |
| 73 | AllocationSiteUsageContext* site_context); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 74 | |
| 75 | // Infers the LiteralsArray to use for a given {node}. |
| 76 | MaybeHandle<LiteralsArray> GetSpecializationLiterals(Node* node); |
| 77 | |
| 78 | Factory* factory() const; |
| 79 | Graph* graph() const; |
| 80 | JSGraph* jsgraph() const { return jsgraph_; } |
| 81 | Isolate* isolate() const; |
| 82 | JSOperatorBuilder* javascript() const; |
| 83 | CommonOperatorBuilder* common() const; |
| 84 | SimplifiedOperatorBuilder* simplified() const; |
| 85 | MachineOperatorBuilder* machine() const; |
| 86 | CompilationDependencies* dependencies() const { return dependencies_; } |
| 87 | Zone* zone() const { return zone_; } |
| 88 | |
| 89 | CompilationDependencies* const dependencies_; |
| 90 | JSGraph* const jsgraph_; |
| 91 | MaybeHandle<LiteralsArray> const literals_array_; |
| 92 | Zone* const zone_; |
| 93 | }; |
| 94 | |
| 95 | } // namespace compiler |
| 96 | } // namespace internal |
| 97 | } // namespace v8 |
| 98 | |
| 99 | #endif // V8_COMPILER_JS_CREATE_LOWERING_H_ |