LCOV - code coverage report
Current view: top level - src - roots-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 15 15 100.0 %
Date: 2019-01-20 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2018 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_ROOTS_INL_H_
       6             : #define V8_ROOTS_INL_H_
       7             : 
       8             : #include "src/roots.h"
       9             : 
      10             : #include "src/feedback-vector.h"
      11             : #include "src/handles.h"
      12             : #include "src/heap/heap-inl.h"
      13             : #include "src/objects/api-callbacks.h"
      14             : #include "src/objects/descriptor-array.h"
      15             : #include "src/objects/literal-objects.h"
      16             : #include "src/objects/map.h"
      17             : #include "src/objects/scope-info.h"
      18             : #include "src/objects/slots.h"
      19             : 
      20             : namespace v8 {
      21             : namespace internal {
      22             : 
      23             : V8_INLINE constexpr bool operator<(RootIndex lhs, RootIndex rhs) {
      24             :   typedef typename std::underlying_type<RootIndex>::type type;
      25             :   return static_cast<type>(lhs) < static_cast<type>(rhs);
      26             : }
      27             : 
      28             : V8_INLINE RootIndex operator++(RootIndex& index) {
      29             :   typedef typename std::underlying_type<RootIndex>::type type;
      30     9964126 :   index = static_cast<RootIndex>(static_cast<type>(index) + 1);
      31             :   return index;
      32             : }
      33             : 
      34             : bool RootsTable::IsRootHandleLocation(Address* handle_location,
      35             :                                       RootIndex* index) const {
      36             :   FullObjectSlot location(handle_location);
      37    15203055 :   FullObjectSlot first_root(&roots_[0]);
      38    15203055 :   FullObjectSlot last_root(&roots_[kEntriesCount]);
      39    15203055 :   if (location >= last_root) return false;
      40     4486750 :   if (location < first_root) return false;
      41     4453705 :   *index = static_cast<RootIndex>(location - first_root);
      42             :   return true;
      43             : }
      44             : 
      45             : template <typename T>
      46             : bool RootsTable::IsRootHandle(Handle<T> handle, RootIndex* index) const {
      47             :   // This can't use handle.location() because it is called from places
      48             :   // where handle dereferencing is disallowed. Comparing the handle's
      49             :   // location against the root handle list is safe though.
      50             :   Address* handle_location = reinterpret_cast<Address*>(handle.address());
      51             :   return IsRootHandleLocation(handle_location, index);
      52             : }
      53             : 
      54             : ReadOnlyRoots::ReadOnlyRoots(Heap* heap)
      55  3513141149 :     : roots_table_(heap->isolate()->roots_table()) {}
      56             : 
      57             : ReadOnlyRoots::ReadOnlyRoots(Isolate* isolate)
      58   548558397 :     : roots_table_(isolate->roots_table()) {}
      59             : 
      60             : #define ROOT_ACCESSOR(Type, name, CamelName)                          \
      61             :   Type ReadOnlyRoots::name() const {                                  \
      62             :     return Type::cast(Object(roots_table_[RootIndex::k##CamelName])); \
      63             :   }                                                                   \
      64             :   Handle<Type> ReadOnlyRoots::name##_handle() const {                 \
      65             :     return Handle<Type>(&roots_table_[RootIndex::k##CamelName]);      \
      66             :   }
      67             : 
      68 15151824337 : READ_ONLY_ROOT_LIST(ROOT_ACCESSOR)
      69             : #undef ROOT_ACCESSOR
      70             : 
      71             : Map ReadOnlyRoots::MapForFixedTypedArray(ExternalArrayType array_type) {
      72       13882 :   RootIndex root_index = RootsTable::RootIndexForFixedTypedArray(array_type);
      73       27764 :   return Map::cast(Object(roots_table_[root_index]));
      74             : }
      75             : 
      76             : Map ReadOnlyRoots::MapForFixedTypedArray(ElementsKind elements_kind) {
      77        1232 :   RootIndex root_index = RootsTable::RootIndexForFixedTypedArray(elements_kind);
      78        2464 :   return Map::cast(Object(roots_table_[root_index]));
      79             : }
      80             : 
      81             : FixedTypedArrayBase ReadOnlyRoots::EmptyFixedTypedArrayForMap(const Map map) {
      82             :   RootIndex root_index =
      83        4182 :       RootsTable::RootIndexForEmptyFixedTypedArray(map->elements_kind());
      84        8364 :   return FixedTypedArrayBase::cast(Object(roots_table_[root_index]));
      85             : }
      86             : 
      87             : }  // namespace internal
      88             : }  // namespace v8
      89             : 
      90             : #endif  // V8_ROOTS_INL_H_

Generated by: LCOV version 1.10