LCOV - code coverage report
Current view: top level - src/objects - literal-objects.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 15 16 93.8 %
Date: 2017-04-26 Functions: 5 6 83.3 %

          Line data    Source code
       1             : // Copyright 2017 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/objects/literal-objects.h"
       6             : 
       7             : #include "src/factory.h"
       8             : #include "src/isolate.h"
       9             : #include "src/objects-inl.h"
      10             : 
      11             : namespace v8 {
      12             : namespace internal {
      13             : 
      14     2817142 : Object* BoilerplateDescription::name(int index) const {
      15             :   // get() already checks for out of bounds access, but we do not want to allow
      16             :   // access to the last element, if it is the number of properties.
      17             :   DCHECK_NE(size(), index);
      18     5634284 :   return get(2 * index);
      19             : }
      20             : 
      21     2817142 : Object* BoilerplateDescription::value(int index) const {
      22     5634284 :   return get(2 * index + 1);
      23             : }
      24             : 
      25      880827 : int BoilerplateDescription::size() const {
      26             :   DCHECK_EQ(0, (length() - (this->has_number_of_properties() ? 1 : 0)) % 2);
      27             :   // Rounding is intended.
      28     1706711 :   return length() / 2;
      29             : }
      30             : 
      31      831886 : int BoilerplateDescription::backing_store_size() const {
      32      831886 :   if (has_number_of_properties()) {
      33             :     // If present, the last entry contains the number of properties.
      34       12004 :     return Smi::cast(this->get(length() - 1))->value();
      35             :   }
      36             :   // If the number is not given explicitly, we assume there are no
      37             :   // properties with computed names.
      38      825884 :   return size();
      39             : }
      40             : 
      41        3343 : void BoilerplateDescription::set_backing_store_size(Isolate* isolate,
      42             :                                                     int backing_store_size) {
      43             :   DCHECK(has_number_of_properties());
      44             :   DCHECK_NE(size(), backing_store_size);
      45             :   Handle<Object> backing_store_size_obj =
      46        3343 :       isolate->factory()->NewNumberFromInt(backing_store_size);
      47        3343 :   set(length() - 1, *backing_store_size_obj);
      48        3343 : }
      49             : 
      50           0 : bool BoilerplateDescription::has_number_of_properties() const {
      51      831886 :   return length() % 2 != 0;
      52             : }
      53             : 
      54             : }  // namespace internal
      55             : }  // namespace v8

Generated by: LCOV version 1.10