js-create-lowering.h 3.57 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
// 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_

#include "src/compiler/graph-reducer.h"

namespace v8 {
namespace internal {

// Forward declarations.
14
class AllocationSiteUsageContext;
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
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.
class JSCreateLowering final : public AdvancedReducer {
 public:
  JSCreateLowering(Editor* editor, CompilationDependencies* dependencies,
33 34
                   JSGraph* jsgraph, MaybeHandle<LiteralsArray> literals_array,
                   Zone* zone)
35 36
      : AdvancedReducer(editor),
        dependencies_(dependencies),
37 38 39
        jsgraph_(jsgraph),
        literals_array_(literals_array),
        zone_(zone) {}
40 41 42 43 44 45 46 47
  ~JSCreateLowering() final {}

  Reduction Reduce(Node* node) final;

 private:
  Reduction ReduceJSCreate(Node* node);
  Reduction ReduceJSCreateArguments(Node* node);
  Reduction ReduceJSCreateArray(Node* node);
48
  Reduction ReduceJSCreateClosure(Node* node);
49
  Reduction ReduceJSCreateIterResultObject(Node* node);
50
  Reduction ReduceJSCreateLiteral(Node* node);
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
  Reduction ReduceJSCreateFunctionContext(Node* node);
  Reduction ReduceJSCreateWithContext(Node* node);
  Reduction ReduceJSCreateCatchContext(Node* node);
  Reduction ReduceJSCreateBlockContext(Node* node);
  Reduction ReduceNewArray(Node* node, Node* length, int capacity,
                           Handle<AllocationSite> site);

  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);
67 68 69 70 71 72 73 74 75 76
  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);

  // Infers the LiteralsArray to use for a given {node}.
  MaybeHandle<LiteralsArray> GetSpecializationLiterals(Node* node);
77 78 79 80 81 82 83 84 85 86

  Factory* factory() const;
  Graph* graph() const;
  JSGraph* jsgraph() const { return jsgraph_; }
  Isolate* isolate() const;
  JSOperatorBuilder* javascript() const;
  CommonOperatorBuilder* common() const;
  SimplifiedOperatorBuilder* simplified() const;
  MachineOperatorBuilder* machine() const;
  CompilationDependencies* dependencies() const { return dependencies_; }
87
  Zone* zone() const { return zone_; }
88 89 90

  CompilationDependencies* const dependencies_;
  JSGraph* const jsgraph_;
91 92
  MaybeHandle<LiteralsArray> const literals_array_;
  Zone* const zone_;
93 94 95 96 97 98 99
};

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

#endif  // V8_COMPILER_JS_CREATE_LOWERING_H_