OLD | NEW |
(Empty) | |
| 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 |
| 11 namespace v8 { |
| 12 namespace internal { |
| 13 |
| 14 class Isolate; |
| 15 class RangeType; |
| 16 class Type; |
| 17 class TypeCache; |
| 18 class Zone; |
| 19 |
| 20 namespace compiler { |
| 21 |
| 22 class OperationTyper { |
| 23 public: |
| 24 OperationTyper(Isolate* isolate, Zone* zone); |
| 25 |
| 26 // Typing Phi. |
| 27 Type* Merge(Type* left, Type* right); |
| 28 |
| 29 Type* ToPrimitive(Type* type); |
| 30 |
| 31 // Helpers for number operation typing. |
| 32 Type* ToNumber(Type* type); |
| 33 Type* WeakenRange(Type* current_range, Type* previous_range); |
| 34 |
| 35 Type* NumericAdd(Type* lhs, Type* rhs); |
| 36 Type* NumericSubtract(Type* lhs, Type* rhs); |
| 37 |
| 38 enum ComparisonOutcomeFlags { |
| 39 kComparisonTrue = 1, |
| 40 kComparisonFalse = 2, |
| 41 kComparisonUndefined = 4 |
| 42 }; |
| 43 |
| 44 // Javascript binop typers. |
| 45 #define DECLARE_CASE(x) Type* Type##x(Type* lhs, Type* rhs); |
| 46 JS_SIMPLE_BINOP_LIST(DECLARE_CASE) |
| 47 #undef DECLARE_CASE |
| 48 |
| 49 Type* singleton_false() { return singleton_false_; } |
| 50 Type* singleton_true() { return singleton_true_; } |
| 51 Type* singleton_the_hole() { return singleton_the_hole_; } |
| 52 |
| 53 private: |
| 54 typedef base::Flags<ComparisonOutcomeFlags> ComparisonOutcome; |
| 55 |
| 56 ComparisonOutcome Invert(ComparisonOutcome); |
| 57 Type* Invert(Type*); |
| 58 Type* FalsifyUndefined(ComparisonOutcome); |
| 59 |
| 60 Type* Rangify(Type*); |
| 61 Type* AddRanger(RangeType* lhs, RangeType* rhs); |
| 62 Type* SubtractRanger(RangeType* lhs, RangeType* rhs); |
| 63 Type* ModulusRanger(RangeType* lhs, RangeType* rhs); |
| 64 |
| 65 Zone* zone() { return zone_; } |
| 66 |
| 67 Zone* zone_; |
| 68 TypeCache const& cache_; |
| 69 |
| 70 Type* singleton_false_; |
| 71 Type* singleton_true_; |
| 72 Type* singleton_the_hole_; |
| 73 }; |
| 74 |
| 75 } // namespace compiler |
| 76 } // namespace internal |
| 77 } // namespace v8 |
| 78 |
| 79 #endif // V8_COMPILER_OPERATION_TYPER_H_ |
OLD | NEW |