v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-create-lowering.h
Go to the documentation of this file.
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 <optional>
9
11#include "src/common/globals.h"
13
14namespace v8 {
15namespace internal {
16
17// Forward declarations.
18class AllocationSiteUsageContext;
19class Factory;
20class JSRegExp;
21
22namespace compiler {
23
24// Forward declarations.
25class CommonOperatorBuilder;
26class CompilationDependencies;
27class FrameState;
28class JSGraph;
29class JSOperatorBuilder;
30class MachineOperatorBuilder;
31class SimplifiedOperatorBuilder;
32class SlackTrackingPrediction;
33
34// Lowers JSCreate-level operators to fast (inline) allocations.
36 : public NON_EXPORTED_BASE(AdvancedReducer) {
37 public:
39 Zone* zone)
40 : AdvancedReducer(editor),
41 jsgraph_(jsgraph),
43 zone_(zone) {}
44 ~JSCreateLowering() final = default;
45
46 const char* reducer_name() const override { return "JSCreateLowering"; }
47
48 Reduction Reduce(Node* node) final;
49
50 private:
51 Reduction ReduceJSCreate(Node* node);
52 Reduction ReduceJSCreateArguments(Node* node);
53 Reduction ReduceJSCreateArray(Node* node);
54 Reduction ReduceJSCreateArrayIterator(Node* node);
55 Reduction ReduceJSCreateAsyncFunctionObject(Node* node);
56 Reduction ReduceJSCreateCollectionIterator(Node* node);
57 Reduction ReduceJSCreateBoundFunction(Node* node);
58 Reduction ReduceJSCreateClosure(Node* node);
59 Reduction ReduceJSCreateIterResultObject(Node* node);
60 Reduction ReduceJSCreateStringIterator(Node* node);
61 Reduction ReduceJSCreateKeyValueArray(Node* node);
62 Reduction ReduceJSCreatePromise(Node* node);
63 Reduction ReduceJSCreateLiteralArrayOrObject(Node* node);
64 Reduction ReduceJSCreateEmptyLiteralObject(Node* node);
65 Reduction ReduceJSCreateEmptyLiteralArray(Node* node);
66 Reduction ReduceJSCreateLiteralRegExp(Node* node);
67 Reduction ReduceJSCreateFunctionContext(Node* node);
68 Reduction ReduceJSCreateWithContext(Node* node);
69 Reduction ReduceJSCreateCatchContext(Node* node);
70 Reduction ReduceJSCreateBlockContext(Node* node);
71 Reduction ReduceJSCreateGeneratorObject(Node* node);
72 Reduction ReduceJSGetTemplateObject(Node* node);
73 Reduction ReduceNewArray(
74 Node* node, Node* length, MapRef initial_map, ElementsKind elements_kind,
75 AllocationType allocation,
76 const SlackTrackingPrediction& slack_tracking_prediction);
77 Reduction ReduceNewArray(
78 Node* node, Node* length, int capacity, MapRef initial_map,
79 ElementsKind elements_kind, AllocationType allocation,
80 const SlackTrackingPrediction& slack_tracking_prediction);
81 Reduction ReduceNewArray(
82 Node* node, std::vector<Node*> values, MapRef initial_map,
83 ElementsKind elements_kind, AllocationType allocation,
84 const SlackTrackingPrediction& slack_tracking_prediction);
85 Reduction ReduceJSCreateObject(Node* node);
86 Reduction ReduceJSCreateStringWrapper(Node* node);
87
88 // The following functions all return nullptr iff there are too many arguments
89 // for inline allocation.
90 Node* TryAllocateArguments(Node* effect, Node* control,
91 FrameState frame_state);
92 Node* TryAllocateRestArguments(Node* effect, Node* control,
93 FrameState frame_state, int start_index);
94 Node* TryAllocateAliasedArguments(Node* effect, Node* control,
95 FrameState frame_state, Node* context,
97 bool* has_aliased_arguments);
98 Node* TryAllocateAliasedArguments(Node* effect, Node* control, Node* context,
99 Node* arguments_length,
101 bool* has_aliased_arguments);
102 std::optional<Node*> TryAllocateFastLiteral(Node* effect, Node* control,
103 JSObjectRef boilerplate,
104 AllocationType allocation,
105 int max_depth,
106 int* max_properties);
107 std::optional<Node*> TryAllocateFastLiteralElements(
108 Node* effect, Node* control, JSObjectRef boilerplate,
109 AllocationType allocation, int max_depth, int* max_properties);
110
111 Node* AllocateElements(Node* effect, Node* control,
112 ElementsKind elements_kind, int capacity,
113 AllocationType allocation);
114 Node* AllocateElements(Node* effect, Node* control,
115 ElementsKind elements_kind, Node* capacity_and_length);
116 Node* AllocateElements(Node* effect, Node* control,
117 ElementsKind elements_kind,
118 std::vector<Node*> const& values,
119 AllocationType allocation);
120 Node* AllocateLiteralRegExp(Node* effect, Node* control,
122
123 Factory* factory() const;
124 TFGraph* graph() const;
125 JSGraph* jsgraph() const { return jsgraph_; }
127 CommonOperatorBuilder* common() const;
129 CompilationDependencies* dependencies() const;
130 JSHeapBroker* broker() const { return broker_; }
131 Zone* zone() const { return zone_; }
132
135 Zone* const zone_;
136};
137
138} // namespace compiler
139} // namespace internal
140} // namespace v8
141
142#endif // V8_COMPILER_JS_CREATE_LOWERING_H_
TFGraph * graph
JSGraph * jsgraph
SimplifiedOperatorBuilder * simplified
Node * AllocateElements(Node *effect, Node *control, ElementsKind elements_kind, Node *capacity_and_length)
JSCreateLowering(Editor *editor, JSGraph *jsgraph, JSHeapBroker *broker, Zone *zone)
Zone * zone_
JSHeapBroker *const broker_
JSHeapBroker * broker
!IsContextMap !IsContextMap native_context
Definition map-inl.h:877
#define NON_EXPORTED_BASE(code)
#define V8_EXPORT_PRIVATE
Definition macros.h:460