js-create-lowering.h 4.71 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 18 19 20 21 22 23 24 25 26 27 28 29 30 31
class CompilationDependencies;
class Factory;


namespace compiler {

// Forward declarations.
class CommonOperatorBuilder;
class JSGraph;
class JSOperatorBuilder;
class MachineOperatorBuilder;
class SimplifiedOperatorBuilder;


// 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,
37
                   MaybeHandle<FeedbackVector> feedback_vector,
38
                   Handle<Context> native_context, Zone* zone)
39 40
      : AdvancedReducer(editor),
        dependencies_(dependencies),
41
        jsgraph_(jsgraph),
42
        feedback_vector_(feedback_vector),
43
        native_context_(native_context),
44
        zone_(zone) {}
45 46
  ~JSCreateLowering() final {}

47 48
  const char* reducer_name() const override { return "JSCreateLowering"; }

49 50 51 52 53 54 55
  Reduction Reduce(Node* node) final;

 private:
  Reduction ReduceJSCreate(Node* node);
  Reduction ReduceJSCreateArguments(Node* node);
  Reduction ReduceJSCreateArray(Node* node);
  Reduction ReduceJSCreateIterResultObject(Node* node);
56
  Reduction ReduceJSCreateKeyValueArray(Node* node);
57
  Reduction ReduceJSCreateEmptyLiteralArray(Node* node);
58 59
  Reduction ReduceJSCreateLiteralArrayOrObject(Node* node);
  Reduction ReduceJSCreateLiteralRegExp(Node* node);
60 61 62 63
  Reduction ReduceJSCreateFunctionContext(Node* node);
  Reduction ReduceJSCreateWithContext(Node* node);
  Reduction ReduceJSCreateCatchContext(Node* node);
  Reduction ReduceJSCreateBlockContext(Node* node);
64
  Reduction ReduceJSCreateGeneratorObject(Node* node);
65 66
  Reduction ReduceNewArray(Node* node, Node* length, int capacity,
                           Handle<AllocationSite> site);
67 68
  Reduction ReduceNewArray(Node* node, std::vector<Node*> values,
                           Handle<AllocationSite> site);
69 70 71 72 73 74 75 76 77 78

  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,
                                 Node* context, Handle<SharedFunctionInfo>,
                                 bool* has_aliased_arguments);
  Node* AllocateElements(Node* effect, Node* control,
                         ElementsKind elements_kind, int capacity,
                         PretenureFlag pretenure);
79 80
  Node* AllocateElements(Node* effect, Node* control,
                         ElementsKind elements_kind, Node* capacity_and_length);
81 82 83 84
  Node* AllocateElements(Node* effect, Node* control,
                         ElementsKind elements_kind,
                         std::vector<Node*> const& values,
                         PretenureFlag pretenure);
85 86 87 88 89 90 91
  Node* AllocateFastLiteral(Node* effect, Node* control,
                            Handle<JSObject> boilerplate,
                            AllocationSiteUsageContext* site_context);
  Node* AllocateFastLiteralElements(Node* effect, Node* control,
                                    Handle<JSObject> boilerplate,
                                    PretenureFlag pretenure,
                                    AllocationSiteUsageContext* site_context);
92 93
  Node* AllocateLiteralRegExp(Node* effect, Node* control,
                              Handle<JSRegExp> boilerplate);
94

95 96
  Reduction ReduceNewArrayToStubCall(Node* node, Handle<AllocationSite> site);

97 98
  // Infers the FeedbackVector to use for a given {node}.
  MaybeHandle<FeedbackVector> GetSpecializationFeedbackVector(Node* node);
99 100 101 102 103

  Factory* factory() const;
  Graph* graph() const;
  JSGraph* jsgraph() const { return jsgraph_; }
  Isolate* isolate() const;
104
  Handle<Context> native_context() const { return native_context_; }
105 106 107
  CommonOperatorBuilder* common() const;
  SimplifiedOperatorBuilder* simplified() const;
  CompilationDependencies* dependencies() const { return dependencies_; }
108
  Zone* zone() const { return zone_; }
109 110 111

  CompilationDependencies* const dependencies_;
  JSGraph* const jsgraph_;
112
  MaybeHandle<FeedbackVector> const feedback_vector_;
113
  Handle<Context> const native_context_;
114
  Zone* const zone_;
115 116 117 118 119 120 121
};

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

#endif  // V8_COMPILER_JS_CREATE_LOWERING_H_