LCOV - code coverage report
Current view: top level - src - field-type.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 22 32 68.8 %
Date: 2017-10-20 Functions: 10 13 76.9 %

          Line data    Source code
       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             : #include "src/field-type.h"
       6             : 
       7             : #include "src/handles-inl.h"
       8             : #include "src/objects-inl.h"
       9             : #include "src/ostreams.h"
      10             : 
      11             : namespace v8 {
      12             : namespace internal {
      13             : 
      14             : // static
      15     3011132 : FieldType* FieldType::None() {
      16             :   // Do not Smi::kZero here or for Any(), as that may translate
      17             :   // as `nullptr` which is not a valid value for `this`.
      18     3011132 :   return reinterpret_cast<FieldType*>(Smi::FromInt(2));
      19             : }
      20             : 
      21             : // static
      22    39509305 : FieldType* FieldType::Any() {
      23    39509305 :   return reinterpret_cast<FieldType*>(Smi::FromInt(1));
      24             : }
      25             : 
      26             : // static
      27      317550 : Handle<FieldType> FieldType::None(Isolate* isolate) {
      28      317550 :   return handle(None(), isolate);
      29             : }
      30             : 
      31             : // static
      32     6751004 : Handle<FieldType> FieldType::Any(Isolate* isolate) {
      33     6751003 :   return handle(Any(), isolate);
      34             : }
      35             : 
      36             : // static
      37           0 : FieldType* FieldType::Class(i::Map* map) { return FieldType::cast(map); }
      38             : 
      39             : // static
      40      986464 : Handle<FieldType> FieldType::Class(i::Handle<i::Map> map, Isolate* isolate) {
      41      986464 :   return handle(Class(*map), isolate);
      42             : }
      43             : 
      44             : // static
      45    40103380 : FieldType* FieldType::cast(Object* object) {
      46             :   DCHECK(object == None() || object == Any() || object->IsMap());
      47    40103380 :   return reinterpret_cast<FieldType*>(object);
      48             : }
      49             : 
      50    14343564 : bool FieldType::IsClass() { return this->IsMap(); }
      51             : 
      52      568078 : Handle<i::Map> FieldType::AsClass() {
      53             :   DCHECK(IsClass());
      54             :   i::Map* map = Map::cast(this);
      55      568078 :   return handle(map, map->GetIsolate());
      56             : }
      57             : 
      58           0 : bool FieldType::NowStable() {
      59           0 :   return !this->IsClass() || this->AsClass()->is_stable();
      60             : }
      61             : 
      62       56187 : bool FieldType::NowIs(FieldType* other) {
      63     1052967 :   if (other->IsAny()) return true;
      64      194895 :   if (IsNone()) return true;
      65      116480 :   if (other->IsNone()) return false;
      66       97944 :   if (IsAny()) return false;
      67             :   DCHECK(IsClass());
      68             :   DCHECK(other->IsClass());
      69       64783 :   return this == other;
      70             : }
      71             : 
      72     1993560 : bool FieldType::NowIs(Handle<FieldType> other) { return NowIs(*other); }
      73             : 
      74           0 : void FieldType::PrintTo(std::ostream& os) {
      75           0 :   if (IsAny()) {
      76           0 :     os << "Any";
      77           0 :   } else if (IsNone()) {
      78           0 :     os << "None";
      79             :   } else {
      80             :     DCHECK(IsClass());
      81           0 :     os << "Class(" << static_cast<void*>(*AsClass()) << ")";
      82             :   }
      83           0 : }
      84             : 
      85             : }  // namespace internal
      86             : }  // namespace v8

Generated by: LCOV version 1.10