blob: 52e7ec254ad2301e6eb10b42be7ca9cc6c690e86 [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);
48 Reduction ReduceJSCreateIterResultObject(Node* node);
49 Reduction ReduceJSCreateLiteral(Node* node);
50 Reduction ReduceJSCreateFunctionContext(Node* node);
51 Reduction ReduceJSCreateWithContext(Node* node);
52 Reduction ReduceJSCreateCatchContext(Node* node);
53 Reduction ReduceJSCreateBlockContext(Node* node);
54 Reduction ReduceNewArray(Node* node, Node* length, int capacity,
55 Handle<AllocationSite> site);
56
57 Node* AllocateArguments(Node* effect, Node* control, Node* frame_state);
58 Node* AllocateRestArguments(Node* effect, Node* control, Node* frame_state,
59 int start_index);
60 Node* AllocateAliasedArguments(Node* effect, Node* control, Node* frame_state,
61 Node* context, Handle<SharedFunctionInfo>,
62 bool* has_aliased_arguments);
63 Node* AllocateElements(Node* effect, Node* control,
64 ElementsKind elements_kind, int capacity,
65 PretenureFlag pretenure);
66 Node* AllocateFastLiteral(Node* effect, Node* control,
67 Handle<JSObject> boilerplate,
68 AllocationSiteUsageContext* site_context);
69 Node* AllocateFastLiteralElements(Node* effect, Node* control,
70 Handle<JSObject> boilerplate,
71 PretenureFlag pretenure,
72 AllocationSiteUsageContext* site_context);
Ben Murdoch097c5b22016-05-18 11:27:45 +010073
74 // Infers the LiteralsArray to use for a given {node}.
75 MaybeHandle<LiteralsArray> GetSpecializationLiterals(Node* node);
76
77 Factory* factory() const;
78 Graph* graph() const;
79 JSGraph* jsgraph() const { return jsgraph_; }
80 Isolate* isolate() const;
81 JSOperatorBuilder* javascript() const;
82 CommonOperatorBuilder* common() const;
83 SimplifiedOperatorBuilder* simplified() const;
84 MachineOperatorBuilder* machine() const;
85 CompilationDependencies* dependencies() const { return dependencies_; }
86 Zone* zone() const { return zone_; }
87
88 CompilationDependencies* const dependencies_;
89 JSGraph* const jsgraph_;
90 MaybeHandle<LiteralsArray> const literals_array_;
91 Zone* const zone_;
92};
93
94} // namespace compiler
95} // namespace internal
96} // namespace v8
97
98#endif // V8_COMPILER_JS_CREATE_LOWERING_H_