blob: 57b28af603f30f6cab920cd2fc24ed488bec15ee [file] [log] [blame]
Ben Murdoch097c5b22016-05-18 11:27:45 +01001// 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
10namespace v8 {
11namespace internal {
12
13// Forward declarations.
14class AllocationSiteUsageContext;
15class CompilationDependencies;
16class Factory;
17
18
19namespace compiler {
20
21// Forward declarations.
22class CommonOperatorBuilder;
23class JSGraph;
24class JSOperatorBuilder;
25class MachineOperatorBuilder;
26class SimplifiedOperatorBuilder;
27
28
29// Lowers JSCreate-level operators to fast (inline) allocations.
30class 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 Murdochc5610432016-08-08 18:44:38 +010048 Reduction ReduceJSCreateClosure(Node* node);
Ben Murdoch097c5b22016-05-18 11:27:45 +010049 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 Murdoch097c5b22016-05-18 11:27:45 +010074
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_