js-typed-lowering.h 4.03 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
  JSTypedLowering(Editor* editor, JSGraph* jsgraph,
35
                  JSHeapBroker* js_heap_broker, Zone* zone);
36
  ~JSTypedLowering() final {}
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 61
  Reduction ReduceJSToInteger(Node* node);
  Reduction ReduceJSToLength(Node* node);
62
  Reduction ReduceJSToName(Node* node);
63 64
  Reduction ReduceJSToNumberOrNumericInput(Node* input);
  Reduction ReduceJSToNumberOrNumeric(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 ReduceCreateConsString(Node* node);
85
  Reduction ReduceSpeculativeNumberAdd(Node* node);
86
  Reduction ReduceSpeculativeNumberMultiply(Node* node);
87
  Reduction ReduceSpeculativeNumberBinop(Node* node);
88
  Reduction ReduceSpeculativeNumberComparison(Node* node);
89
  Reduction ReduceObjectIsArray(Node* node);
90
  Reduction ReduceJSParseInt(Node* node);
91

92 93 94
  // Helper for ReduceJSLoadModule and ReduceJSStoreModule.
  Node* BuildGetModuleCell(Node* node);

95 96
  // Helpers for ReduceJSCreateConsString.
  Node* BuildGetStringLength(Node* value);
97

98 99 100
  Factory* factory() const;
  Graph* graph() const;
  JSGraph* jsgraph() const { return jsgraph_; }
101
  JSHeapBroker* js_heap_broker() const { return js_heap_broker_; }
102
  Isolate* isolate() const;
103 104
  JSOperatorBuilder* javascript() const;
  CommonOperatorBuilder* common() const;
105
  SimplifiedOperatorBuilder* simplified() const;
106 107

  JSGraph* jsgraph_;
108
  JSHeapBroker* js_heap_broker_;
109 110
  Type empty_string_type_;
  Type pointer_comparable_type_;
111
  TypeCache const& type_cache_;
112
};
113 114 115 116

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

118
#endif  // V8_COMPILER_JS_TYPED_LOWERING_H_