LCOV - code coverage report
Current view: top level - src/compiler - type-cache.h (source / functions) Hit Total Coverage
Test: app.info Lines: 22 22 100.0 %
Date: 2017-04-26 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright 2014 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_TYPE_CACHE_H_
       6             : #define V8_COMPILER_TYPE_CACHE_H_
       7             : 
       8             : #include "src/compiler/types.h"
       9             : #include "src/date.h"
      10             : 
      11             : namespace v8 {
      12             : namespace internal {
      13             : namespace compiler {
      14             : 
      15             : class TypeCache final {
      16             :  private:
      17             :   // This has to be first for the initialization magic to work.
      18             :   AccountingAllocator allocator;
      19             :   Zone zone_;
      20             : 
      21             :  public:
      22             :   static TypeCache const& Get();
      23             : 
      24      698265 :   TypeCache() : zone_(&allocator, ZONE_NAME) {}
      25             : 
      26             :   Type* const kInt8 = CreateRange<int8_t>();
      27             :   Type* const kUint8 = CreateRange<uint8_t>();
      28             :   Type* const kUint8Clamped = kUint8;
      29             :   Type* const kUint8OrMinusZeroOrNaN =
      30       15517 :       Type::Union(kUint8, Type::MinusZeroOrNaN(), zone());
      31             :   Type* const kInt16 = CreateRange<int16_t>();
      32             :   Type* const kUint16 = CreateRange<uint16_t>();
      33             :   Type* const kInt32 = Type::Signed32();
      34             :   Type* const kUint32 = Type::Unsigned32();
      35             :   Type* const kFloat32 = Type::Number();
      36             :   Type* const kFloat64 = Type::Number();
      37             : 
      38             :   Type* const kHoleySmi =
      39       15517 :       Type::Union(Type::SignedSmall(), Type::Hole(), zone());
      40             : 
      41             :   Type* const kSingletonZero = CreateRange(0.0, 0.0);
      42             :   Type* const kSingletonOne = CreateRange(1.0, 1.0);
      43             :   Type* const kSingletonTen = CreateRange(10.0, 10.0);
      44             :   Type* const kSingletonMinusOne = CreateRange(-1.0, -1.0);
      45             :   Type* const kZeroOrUndefined =
      46       15517 :       Type::Union(kSingletonZero, Type::Undefined(), zone());
      47             :   Type* const kTenOrUndefined =
      48       15517 :       Type::Union(kSingletonTen, Type::Undefined(), zone());
      49             :   Type* const kMinusOneOrZero = CreateRange(-1.0, 0.0);
      50             :   Type* const kMinusOneToOneOrMinusZeroOrNaN = Type::Union(
      51             :       Type::Union(CreateRange(-1.0, 1.0), Type::MinusZero(), zone()),
      52       15517 :       Type::NaN(), zone());
      53             :   Type* const kZeroOrOne = CreateRange(0.0, 1.0);
      54       15517 :   Type* const kZeroOrOneOrNaN = Type::Union(kZeroOrOne, Type::NaN(), zone());
      55             :   Type* const kZeroToThirtyOne = CreateRange(0.0, 31.0);
      56             :   Type* const kZeroToThirtyTwo = CreateRange(0.0, 32.0);
      57             :   Type* const kZeroish =
      58       15517 :       Type::Union(kSingletonZero, Type::MinusZeroOrNaN(), zone());
      59             :   Type* const kInteger = CreateRange(-V8_INFINITY, V8_INFINITY);
      60             :   Type* const kIntegerOrMinusZero =
      61       15517 :       Type::Union(kInteger, Type::MinusZero(), zone());
      62             :   Type* const kIntegerOrMinusZeroOrNaN =
      63       15517 :       Type::Union(kIntegerOrMinusZero, Type::NaN(), zone());
      64             :   Type* const kPositiveInteger = CreateRange(0.0, V8_INFINITY);
      65             :   Type* const kPositiveIntegerOrMinusZero =
      66       15517 :       Type::Union(kPositiveInteger, Type::MinusZero(), zone());
      67             :   Type* const kPositiveIntegerOrNaN =
      68       15517 :       Type::Union(kPositiveInteger, Type::NaN(), zone());
      69             :   Type* const kPositiveIntegerOrMinusZeroOrNaN =
      70       15517 :       Type::Union(kPositiveIntegerOrMinusZero, Type::NaN(), zone());
      71             : 
      72             :   Type* const kAdditiveSafeInteger =
      73             :       CreateRange(-4503599627370496.0, 4503599627370496.0);
      74             :   Type* const kSafeInteger = CreateRange(-kMaxSafeInteger, kMaxSafeInteger);
      75             :   Type* const kAdditiveSafeIntegerOrMinusZero =
      76       15517 :       Type::Union(kAdditiveSafeInteger, Type::MinusZero(), zone());
      77             :   Type* const kSafeIntegerOrMinusZero =
      78       15517 :       Type::Union(kSafeInteger, Type::MinusZero(), zone());
      79             :   Type* const kPositiveSafeInteger = CreateRange(0.0, kMaxSafeInteger);
      80             : 
      81             :   // The FixedArray::length property always containts a smi in the range
      82             :   // [0, FixedArray::kMaxLength].
      83             :   Type* const kFixedArrayLengthType = CreateRange(0.0, FixedArray::kMaxLength);
      84             : 
      85             :   // The FixedDoubleArray::length property always containts a smi in the range
      86             :   // [0, FixedDoubleArray::kMaxLength].
      87             :   Type* const kFixedDoubleArrayLengthType =
      88             :       CreateRange(0.0, FixedDoubleArray::kMaxLength);
      89             : 
      90             :   // The JSArray::length property always contains a tagged number in the range
      91             :   // [0, kMaxUInt32].
      92             :   Type* const kJSArrayLengthType = Type::Unsigned32();
      93             : 
      94             :   // The JSTyped::length property always contains a tagged number in the range
      95             :   // [0, kMaxSmiValue].
      96             :   Type* const kJSTypedArrayLengthType = Type::UnsignedSmall();
      97             : 
      98             :   // The String::length property always contains a smi in the range
      99             :   // [0, String::kMaxLength].
     100             :   Type* const kStringLengthType = CreateRange(0.0, String::kMaxLength);
     101             : 
     102             :   // A time value always contains a tagged number in the range
     103             :   // [-kMaxTimeInMs, kMaxTimeInMs].
     104             :   Type* const kTimeValueType =
     105             :       CreateRange(-DateCache::kMaxTimeInMs, DateCache::kMaxTimeInMs);
     106             : 
     107             :   // The JSDate::day property always contains a tagged number in the range
     108             :   // [1, 31] or NaN.
     109             :   Type* const kJSDateDayType =
     110       15517 :       Type::Union(CreateRange(1, 31.0), Type::NaN(), zone());
     111             : 
     112             :   // The JSDate::hour property always contains a tagged number in the range
     113             :   // [0, 23] or NaN.
     114             :   Type* const kJSDateHourType =
     115       15517 :       Type::Union(CreateRange(0, 23.0), Type::NaN(), zone());
     116             : 
     117             :   // The JSDate::minute property always contains a tagged number in the range
     118             :   // [0, 59] or NaN.
     119             :   Type* const kJSDateMinuteType =
     120       15517 :       Type::Union(CreateRange(0, 59.0), Type::NaN(), zone());
     121             : 
     122             :   // The JSDate::month property always contains a tagged number in the range
     123             :   // [0, 11] or NaN.
     124             :   Type* const kJSDateMonthType =
     125       15517 :       Type::Union(CreateRange(0, 11.0), Type::NaN(), zone());
     126             : 
     127             :   // The JSDate::second property always contains a tagged number in the range
     128             :   // [0, 59] or NaN.
     129             :   Type* const kJSDateSecondType = kJSDateMinuteType;
     130             : 
     131             :   // The JSDate::value property always contains a tagged number in the range
     132             :   // [-kMaxTimeInMs, kMaxTimeInMs] or NaN.
     133             :   Type* const kJSDateValueType =
     134       15517 :       Type::Union(kTimeValueType, Type::NaN(), zone());
     135             : 
     136             :   // The JSDate::weekday property always contains a tagged number in the range
     137             :   // [0, 6] or NaN.
     138             :   Type* const kJSDateWeekdayType =
     139       15517 :       Type::Union(CreateRange(0, 6.0), Type::NaN(), zone());
     140             : 
     141             :   // The JSDate::year property always contains a tagged number in the signed
     142             :   // small range or NaN.
     143             :   Type* const kJSDateYearType =
     144       15517 :       Type::Union(Type::SignedSmall(), Type::NaN(), zone());
     145             : 
     146             :   // The valid number of arguments for JavaScript functions.
     147             :   Type* const kArgumentsLengthType =
     148             :       Type::Range(0.0, Code::kMaxArguments, zone());
     149             : 
     150             :  private:
     151             :   template <typename T>
     152             :   Type* CreateRange() {
     153             :     return CreateRange(std::numeric_limits<T>::min(),
     154             :                        std::numeric_limits<T>::max());
     155             :   }
     156             : 
     157             :   Type* CreateRange(double min, double max) {
     158             :     return Type::Range(min, max, zone());
     159             :   }
     160             : 
     161             :   Zone* zone() { return &zone_; }
     162             : };
     163             : 
     164             : }  // namespace compiler
     165             : }  // namespace internal
     166             : }  // namespace v8
     167             : 
     168             : #endif  // V8_COMPILER_TYPE_CACHE_H_

Generated by: LCOV version 1.10