js-typed-lowering.h 3.75 KB
Newer Older
1 2 3 4
// Copyright 2014 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.

5 6
#ifndef V8_COMPILER_JS_TYPED_LOWERING_H_
#define V8_COMPILER_JS_TYPED_LOWERING_H_
7

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

namespace v8 {
namespace internal {
15 16 17 18

// Forward declarations.
class Factory;

19 20
namespace compiler {

21 22 23 24
// Forward declarations.
class CommonOperatorBuilder;
class JSGraph;
class JSOperatorBuilder;
25
class SimplifiedOperatorBuilder;
26
class TypeCache;
27

28 29
enum Signedness { kSigned, kUnsigned };

30
// Lowers JS-level operators to simplified operators based on types.
31 32
class V8_EXPORT_PRIVATE JSTypedLowering final
    : public NON_EXPORTED_BASE(AdvancedReducer) {
33
 public:
34 35
  JSTypedLowering(Editor* editor, JSGraph* jsgraph, JSHeapBroker* broker,
                  Zone* zone);
36
  ~JSTypedLowering() final = default;
37

38 39
  const char* reducer_name() const override { return "JSTypedLowering"; }

40
  Reduction Reduce(Node* node) final;
41 42 43 44 45

 private:
  friend class JSBinopReduction;

  Reduction ReduceJSAdd(Node* node);
46
  Reduction ReduceJSBitwiseNot(Node* node);
47 48
  Reduction ReduceJSDecrement(Node* node);
  Reduction ReduceJSIncrement(Node* node);
49
  Reduction ReduceJSNegate(Node* node);
50
  Reduction ReduceJSComparison(Node* node);
51
  Reduction ReduceJSLoadNamed(Node* node);
52
  Reduction ReduceJSHasInPrototypeChain(Node* node);
53
  Reduction ReduceJSOrdinaryHasInstance(Node* node);
54
  Reduction ReduceJSHasContextExtension(Node* node);
55 56
  Reduction ReduceJSLoadContext(Node* node);
  Reduction ReduceJSStoreContext(Node* node);
57 58
  Reduction ReduceJSLoadModule(Node* node);
  Reduction ReduceJSStoreModule(Node* node);
59
  Reduction ReduceJSEqual(Node* node);
60
  Reduction ReduceJSStrictEqual(Node* node);
61
  Reduction ReduceJSToLength(Node* node);
62
  Reduction ReduceJSToName(Node* node);
63 64 65
  Reduction ReduceJSToNumberInput(Node* input);
  Reduction ReduceJSToNumber(Node* node);
  Reduction ReduceJSToNumeric(Node* node);
66
  Reduction ReduceJSToStringInput(Node* input);
67
  Reduction ReduceJSToString(Node* node);
68
  Reduction ReduceJSToObject(Node* node);
69
  Reduction ReduceJSConstructForwardVarargs(Node* node);
70
  Reduction ReduceJSConstruct(Node* node);
71
  Reduction ReduceJSCallForwardVarargs(Node* node);
72
  Reduction ReduceJSCall(Node* node);
73
  Reduction ReduceJSForInNext(Node* node);
74
  Reduction ReduceJSForInPrepare(Node* node);
75 76
  Reduction ReduceJSLoadMessage(Node* node);
  Reduction ReduceJSStoreMessage(Node* node);
77 78
  Reduction ReduceJSGeneratorStore(Node* node);
  Reduction ReduceJSGeneratorRestoreContinuation(Node* node);
79
  Reduction ReduceJSGeneratorRestoreContext(Node* node);
80
  Reduction ReduceJSGeneratorRestoreRegister(Node* node);
81
  Reduction ReduceJSGeneratorRestoreInputOrDebugPos(Node* node);
82 83 84
  Reduction ReduceNumberBinop(Node* node);
  Reduction ReduceInt32Binop(Node* node);
  Reduction ReduceUI32Shift(Node* node, Signedness signedness);
85
  Reduction ReduceObjectIsArray(Node* node);
86
  Reduction ReduceJSParseInt(Node* node);
87
  Reduction ReduceJSResolvePromise(Node* node);
88

89 90 91
  // Helper for ReduceJSLoadModule and ReduceJSStoreModule.
  Node* BuildGetModuleCell(Node* node);

92 93 94
  Factory* factory() const;
  Graph* graph() const;
  JSGraph* jsgraph() const { return jsgraph_; }
95
  JSHeapBroker* broker() const { return broker_; }
96
  Isolate* isolate() const;
97 98
  JSOperatorBuilder* javascript() const;
  CommonOperatorBuilder* common() const;
99
  SimplifiedOperatorBuilder* simplified() const;
100 101

  JSGraph* jsgraph_;
102
  JSHeapBroker* broker_;
103
  Type empty_string_type_;
104
  Type pointer_comparable_type_;
105
  TypeCache const* type_cache_;
106
};
107 108 109 110

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

112
#endif  // V8_COMPILER_JS_TYPED_LOWERING_H_