V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
operation-typer.h
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_COMPILER_OPERATION_TYPER_H_
6 #define V8_COMPILER_OPERATION_TYPER_H_
7 
8 #include "src/base/flags.h"
9 #include "src/compiler/opcodes.h"
10 #include "src/compiler/types.h"
11 #include "src/objects.h"
12 
13 namespace v8 {
14 namespace internal {
15 
16 // Forward declarations.
17 class Isolate;
18 class RangeType;
19 class Zone;
20 
21 namespace compiler {
22 
23 // Forward declarations.
24 class Operator;
25 class Type;
26 class TypeCache;
27 
28 class V8_EXPORT_PRIVATE OperationTyper {
29  public:
30  OperationTyper(JSHeapBroker* broker, Zone* zone);
31 
32  // Typing Phi.
33  Type Merge(Type left, Type right);
34 
35  Type ToPrimitive(Type type);
36  Type ToNumber(Type type);
37  Type ToNumberConvertBigInt(Type type);
38  Type ToNumeric(Type type);
39  Type ToBoolean(Type type);
40 
41  Type WeakenRange(Type current_range, Type previous_range);
42 
43 // Unary operators.
44 #define DECLARE_METHOD(Name) Type Name(Type type);
45  SIMPLIFIED_NUMBER_UNOP_LIST(DECLARE_METHOD)
46  SIMPLIFIED_SPECULATIVE_NUMBER_UNOP_LIST(DECLARE_METHOD)
47  DECLARE_METHOD(ConvertReceiver)
48 #undef DECLARE_METHOD
49 
50 // Number binary operators.
51 #define DECLARE_METHOD(Name) Type Name(Type lhs, Type rhs);
52  SIMPLIFIED_NUMBER_BINOP_LIST(DECLARE_METHOD)
53  SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(DECLARE_METHOD)
54 #undef DECLARE_METHOD
55 
56  // Comparison operators.
57  Type SameValue(Type lhs, Type rhs);
58  Type StrictEqual(Type lhs, Type rhs);
59 
60  // Check operators.
61  Type CheckBounds(Type index, Type length);
62  Type CheckFloat64Hole(Type type);
63  Type CheckNumber(Type type);
64  Type ConvertTaggedHoleToUndefined(Type type);
65 
66  Type TypeTypeGuard(const Operator* sigma_op, Type input);
67 
68  enum ComparisonOutcomeFlags {
69  kComparisonTrue = 1,
70  kComparisonFalse = 2,
71  kComparisonUndefined = 4
72  };
73 
74  Type singleton_false() const { return singleton_false_; }
75  Type singleton_true() const { return singleton_true_; }
76  Type singleton_the_hole() const { return singleton_the_hole_; }
77 
78  private:
80 
82  Type Invert(Type);
83  Type FalsifyUndefined(ComparisonOutcome);
84 
85  Type Rangify(Type);
86  Type AddRanger(double lhs_min, double lhs_max, double rhs_min,
87  double rhs_max);
88  Type SubtractRanger(double lhs_min, double lhs_max, double rhs_min,
89  double rhs_max);
90  Type MultiplyRanger(double lhs_min, double lhs_max, double rhs_min,
91  double rhs_max);
92 
93  Zone* zone() const { return zone_; }
94 
95  Zone* const zone_;
96  TypeCache const& cache_;
97 
98  Type infinity_;
99  Type minus_infinity_;
100  Type singleton_NaN_string_;
101  Type singleton_zero_string_;
102  Type singleton_false_;
103  Type singleton_true_;
104  Type singleton_the_hole_;
105  Type signed32ish_;
106  Type unsigned32ish_;
107  Type singleton_empty_string_;
108  Type truish_;
109  Type falsish_;
110 };
111 
112 } // namespace compiler
113 } // namespace internal
114 } // namespace v8
115 
116 #endif // V8_COMPILER_OPERATION_TYPER_H_
Definition: libplatform.h:13