js-create-lowering.h 5.39 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMPILER_JS_CREATE_LOWERING_H_
#define V8_COMPILER_JS_CREATE_LOWERING_H_

8
#include "src/base/compiler-specific.h"
9
#include "src/compiler/graph-reducer.h"
10
#include "src/globals.h"
11 12 13 14 15

namespace v8 {
namespace internal {

// Forward declarations.
16
class AllocationSiteUsageContext;
17
class Factory;
18
class JSRegExp;
19 20 21 22 23

namespace compiler {

// Forward declarations.
class CommonOperatorBuilder;
24
class CompilationDependencies;
25 26 27 28
class JSGraph;
class JSOperatorBuilder;
class MachineOperatorBuilder;
class SimplifiedOperatorBuilder;
29
class SlackTrackingPrediction;
30 31

// Lowers JSCreate-level operators to fast (inline) allocations.
32 33
class V8_EXPORT_PRIVATE JSCreateLowering final
    : public NON_EXPORTED_BASE(AdvancedReducer) {
34 35
 public:
  JSCreateLowering(Editor* editor, CompilationDependencies* dependencies,
36
                   JSGraph* jsgraph, JSHeapBroker* broker, Zone* zone)
37 38
      : AdvancedReducer(editor),
        dependencies_(dependencies),
39
        jsgraph_(jsgraph),
40
        broker_(broker),
41
        zone_(zone) {}
42
  ~JSCreateLowering() final = default;
43

44 45
  const char* reducer_name() const override { return "JSCreateLowering"; }

46 47 48 49 50 51
  Reduction Reduce(Node* node) final;

 private:
  Reduction ReduceJSCreate(Node* node);
  Reduction ReduceJSCreateArguments(Node* node);
  Reduction ReduceJSCreateArray(Node* node);
52
  Reduction ReduceJSCreateArrayIterator(Node* node);
53
  Reduction ReduceJSCreateAsyncFunctionObject(Node* node);
54
  Reduction ReduceJSCreateCollectionIterator(Node* node);
55
  Reduction ReduceJSCreateBoundFunction(Node* node);
56
  Reduction ReduceJSCreateClosure(Node* node);
57
  Reduction ReduceJSCreateIterResultObject(Node* node);
58
  Reduction ReduceJSCreateStringIterator(Node* node);
59
  Reduction ReduceJSCreateKeyValueArray(Node* node);
60
  Reduction ReduceJSCreatePromise(Node* node);
61
  Reduction ReduceJSCreateLiteralArrayOrObject(Node* node);
62 63
  Reduction ReduceJSCreateEmptyLiteralObject(Node* node);
  Reduction ReduceJSCreateEmptyLiteralArray(Node* node);
64
  Reduction ReduceJSCreateLiteralRegExp(Node* node);
65 66 67 68
  Reduction ReduceJSCreateFunctionContext(Node* node);
  Reduction ReduceJSCreateWithContext(Node* node);
  Reduction ReduceJSCreateCatchContext(Node* node);
  Reduction ReduceJSCreateBlockContext(Node* node);
69
  Reduction ReduceJSCreateGeneratorObject(Node* node);
70
  Reduction ReduceNewArray(
71
      Node* node, Node* length, MapRef initial_map, ElementsKind elements_kind,
72
      AllocationType allocation,
73 74 75
      const SlackTrackingPrediction& slack_tracking_prediction);
  Reduction ReduceNewArray(
      Node* node, Node* length, int capacity, MapRef initial_map,
76
      ElementsKind elements_kind, AllocationType allocation,
77 78 79
      const SlackTrackingPrediction& slack_tracking_prediction);
  Reduction ReduceNewArray(
      Node* node, std::vector<Node*> values, MapRef initial_map,
80
      ElementsKind elements_kind, AllocationType allocation,
81
      const SlackTrackingPrediction& slack_tracking_prediction);
82
  Reduction ReduceJSCreateObject(Node* node);
83 84 85 86 87

  Node* AllocateArguments(Node* effect, Node* control, Node* frame_state);
  Node* AllocateRestArguments(Node* effect, Node* control, Node* frame_state,
                              int start_index);
  Node* AllocateAliasedArguments(Node* effect, Node* control, Node* frame_state,
88 89
                                 Node* context,
                                 const SharedFunctionInfoRef& shared,
90
                                 bool* has_aliased_arguments);
91 92
  Node* AllocateAliasedArguments(Node* effect, Node* control, Node* context,
                                 Node* arguments_frame, Node* arguments_length,
93
                                 const SharedFunctionInfoRef& shared,
94
                                 bool* has_aliased_arguments);
95 96
  Node* AllocateElements(Node* effect, Node* control,
                         ElementsKind elements_kind, int capacity,
97
                         AllocationType allocation);
98 99
  Node* AllocateElements(Node* effect, Node* control,
                         ElementsKind elements_kind, Node* capacity_and_length);
100 101 102
  Node* AllocateElements(Node* effect, Node* control,
                         ElementsKind elements_kind,
                         std::vector<Node*> const& values,
103
                         AllocationType allocation);
104
  Node* AllocateFastLiteral(Node* effect, Node* control,
105
                            JSObjectRef boilerplate, AllocationType allocation);
106
  Node* AllocateFastLiteralElements(Node* effect, Node* control,
107
                                    JSObjectRef boilerplate,
108
                                    AllocationType allocation);
109
  Node* AllocateLiteralRegExp(Node* effect, Node* control,
110
                              JSRegExpRef boilerplate);
111

112 113 114
  Factory* factory() const;
  Graph* graph() const;
  JSGraph* jsgraph() const { return jsgraph_; }
115
  NativeContextRef native_context() const;
116 117 118
  CommonOperatorBuilder* common() const;
  SimplifiedOperatorBuilder* simplified() const;
  CompilationDependencies* dependencies() const { return dependencies_; }
119
  JSHeapBroker* broker() const { return broker_; }
120
  Zone* zone() const { return zone_; }
121 122 123

  CompilationDependencies* const dependencies_;
  JSGraph* const jsgraph_;
124
  JSHeapBroker* const broker_;
125
  Zone* const zone_;
126 127 128 129 130 131 132
};

}  // namespace compiler
}  // namespace internal
}  // namespace v8

#endif  // V8_COMPILER_JS_CREATE_LOWERING_H_