LCOV - code coverage report
Current view: top level - src - field-type.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 33 35 94.3 %
Date: 2019-02-19 Functions: 15 16 93.8 %

          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/objects/smi.h"
      10             : #include "src/ostreams.h"
      11             : 
      12             : namespace v8 {
      13             : namespace internal {
      14             : 
      15             : // static
      16     1774589 : FieldType FieldType::None() { return FieldType(Smi::FromInt(2).ptr()); }
      17             : 
      18             : // static
      19     4288138 : FieldType FieldType::Any() { return FieldType(Smi::FromInt(1).ptr()); }
      20             : 
      21             : // static
      22      231505 : Handle<FieldType> FieldType::None(Isolate* isolate) {
      23      231505 :   return handle(None(), isolate);
      24             : }
      25             : 
      26             : // static
      27    11291221 : Handle<FieldType> FieldType::Any(Isolate* isolate) {
      28    11291220 :   return handle(Any(), isolate);
      29             : }
      30             : 
      31             : // static
      32          50 : FieldType FieldType::Class(Map map) { return FieldType::cast(map); }
      33             : 
      34             : // static
      35     6123597 : Handle<FieldType> FieldType::Class(Handle<Map> map, Isolate* isolate) {
      36     6123600 :   return handle(Class(*map), isolate);
      37             : }
      38             : 
      39             : // static
      40    41017941 : FieldType FieldType::cast(Object object) {
      41             :   DCHECK(object == None() || object == Any() || object->IsMap());
      42    41017941 :   return FieldType(object->ptr());
      43             : }
      44             : 
      45    32615408 : bool FieldType::IsClass() const { return this->IsMap(); }
      46             : 
      47     6097455 : Map FieldType::AsClass() const {
      48             :   DCHECK(IsClass());
      49     6097455 :   return Map::cast(*this);
      50             : }
      51             : 
      52           0 : bool FieldType::NowStable() const {
      53           0 :   return !this->IsClass() || AsClass()->is_stable();
      54             : }
      55             : 
      56       50613 : bool FieldType::NowIs(FieldType other) const {
      57     1180904 :   if (other->IsAny()) return true;
      58      198496 :   if (IsNone()) return true;
      59      144536 :   if (other->IsNone()) return false;
      60      119410 :   if (IsAny()) return false;
      61             :   DCHECK(IsClass());
      62             :   DCHECK(other->IsClass());
      63         325 :   return *this == other;
      64             : }
      65             : 
      66     2260582 : bool FieldType::NowIs(Handle<FieldType> other) const { return NowIs(*other); }
      67             : 
      68       30301 : void FieldType::PrintTo(std::ostream& os) const {
      69       30301 :   if (IsAny()) {
      70       29184 :     os << "Any";
      71        1117 :   } else if (IsNone()) {
      72          25 :     os << "None";
      73             :   } else {
      74             :     DCHECK(IsClass());
      75        3276 :     os << "Class(" << reinterpret_cast<void*>(AsClass()->ptr()) << ")";
      76             :   }
      77       30301 : }
      78             : 
      79    37802417 : bool FieldType::NowContains(Object value) const {
      80    37802417 :   if (*this == Any()) return true;
      81     2499163 :   if (*this == None()) return false;
      82     2499159 :   if (!value->IsHeapObject()) return false;
      83             :   return HeapObject::cast(value)->map() == Map::cast(*this);
      84             : }
      85             : 
      86             : }  // namespace internal
      87      178779 : }  // namespace v8

Generated by: LCOV version 1.10