js-typed-lowering.h 3.69 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/compiler/graph-reducer.h"
10
#include "src/compiler/opcodes.h"
11
#include "src/globals.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 55
  Reduction ReduceJSLoadContext(Node* node);
  Reduction ReduceJSStoreContext(Node* node);
56 57
  Reduction ReduceJSLoadModule(Node* node);
  Reduction ReduceJSStoreModule(Node* node);
58
  Reduction ReduceJSEqual(Node* node);
59
  Reduction ReduceJSStrictEqual(Node* node);
60
  Reduction ReduceJSToLength(Node* node);
61
  Reduction ReduceJSToName(Node* node);
62 63 64
  Reduction ReduceJSToNumberInput(Node* input);
  Reduction ReduceJSToNumber(Node* node);
  Reduction ReduceJSToNumeric(Node* node);
65
  Reduction ReduceJSToStringInput(Node* input);
66
  Reduction ReduceJSToString(Node* node);
67
  Reduction ReduceJSToObject(Node* node);
68
  Reduction ReduceJSConstructForwardVarargs(Node* node);
69
  Reduction ReduceJSConstruct(Node* node);
70
  Reduction ReduceJSCallForwardVarargs(Node* node);
71
  Reduction ReduceJSCall(Node* node);
72
  Reduction ReduceJSForInNext(Node* node);
73
  Reduction ReduceJSForInPrepare(Node* node);
74 75
  Reduction ReduceJSLoadMessage(Node* node);
  Reduction ReduceJSStoreMessage(Node* node);
76 77
  Reduction ReduceJSGeneratorStore(Node* node);
  Reduction ReduceJSGeneratorRestoreContinuation(Node* node);
78
  Reduction ReduceJSGeneratorRestoreContext(Node* node);
79
  Reduction ReduceJSGeneratorRestoreRegister(Node* node);
80
  Reduction ReduceJSGeneratorRestoreInputOrDebugPos(Node* node);
81 82 83
  Reduction ReduceNumberBinop(Node* node);
  Reduction ReduceInt32Binop(Node* node);
  Reduction ReduceUI32Shift(Node* node, Signedness signedness);
84
  Reduction ReduceObjectIsArray(Node* node);
85
  Reduction ReduceJSParseInt(Node* node);
86
  Reduction ReduceJSResolvePromise(Node* node);
87

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

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

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

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

111
#endif  // V8_COMPILER_JS_TYPED_LOWERING_H_