LCOV - code coverage report
Current view: top level - src/ic - handler-configuration-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 76 78 97.4 %
Date: 2017-10-20 Functions: 21 21 100.0 %

          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             : #ifndef V8_IC_HANDLER_CONFIGURATION_INL_H_
       6             : #define V8_IC_HANDLER_CONFIGURATION_INL_H_
       7             : 
       8             : #include "src/ic/handler-configuration.h"
       9             : 
      10             : #include "src/field-index-inl.h"
      11             : #include "src/objects-inl.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16             : // Decodes kind from Smi-handler.
      17             : LoadHandler::Kind LoadHandler::GetHandlerKind(Smi* smi_handler) {
      18      385661 :   return KindBits::decode(smi_handler->value());
      19             : }
      20             : 
      21       32843 : Handle<Smi> LoadHandler::LoadNormal(Isolate* isolate) {
      22             :   int config = KindBits::encode(kNormal);
      23       32843 :   return handle(Smi::FromInt(config), isolate);
      24             : }
      25             : 
      26       12253 : Handle<Smi> LoadHandler::LoadGlobal(Isolate* isolate) {
      27             :   int config = KindBits::encode(kGlobal);
      28       12253 :   return handle(Smi::FromInt(config), isolate);
      29             : }
      30             : 
      31         990 : Handle<Smi> LoadHandler::LoadInterceptor(Isolate* isolate) {
      32             :   int config = KindBits::encode(kInterceptor);
      33         990 :   return handle(Smi::FromInt(config), isolate);
      34             : }
      35             : 
      36      780821 : Handle<Smi> LoadHandler::LoadField(Isolate* isolate, FieldIndex field_index) {
      37      780821 :   int config = KindBits::encode(kField) |
      38      780821 :                IsInobjectBits::encode(field_index.is_inobject()) |
      39      780821 :                IsDoubleBits::encode(field_index.is_double()) |
      40     1561642 :                FieldOffsetBits::encode(field_index.offset());
      41      780823 :   return handle(Smi::FromInt(config), isolate);
      42             : }
      43             : 
      44      472420 : Handle<Smi> LoadHandler::LoadConstant(Isolate* isolate, int descriptor) {
      45      472420 :   int config = KindBits::encode(kConstant) | IsAccessorInfoBits::encode(false) |
      46      944840 :                DescriptorBits::encode(descriptor);
      47      472420 :   return handle(Smi::FromInt(config), isolate);
      48             : }
      49             : 
      50       64208 : Handle<Smi> LoadHandler::LoadAccessor(Isolate* isolate, int descriptor) {
      51       64208 :   int config = KindBits::encode(kAccessor) | IsAccessorInfoBits::encode(false) |
      52      128416 :                DescriptorBits::encode(descriptor);
      53       64208 :   return handle(Smi::FromInt(config), isolate);
      54             : }
      55             : 
      56        4244 : Handle<Smi> LoadHandler::LoadProxy(Isolate* isolate) {
      57             :   int config = KindBits::encode(kProxy);
      58        4244 :   return handle(Smi::FromInt(config), isolate);
      59             : }
      60             : 
      61        6899 : Handle<Smi> LoadHandler::LoadApiGetter(Isolate* isolate, int descriptor) {
      62        6899 :   int config = KindBits::encode(kConstant) | IsAccessorInfoBits::encode(true) |
      63       13798 :                DescriptorBits::encode(descriptor);
      64        6899 :   return handle(Smi::FromInt(config), isolate);
      65             : }
      66             : 
      67       19804 : Handle<Smi> LoadHandler::LoadModuleExport(Isolate* isolate, int index) {
      68             :   int config =
      69       39608 :       KindBits::encode(kModuleExport) | ExportsIndexBits::encode(index);
      70       19804 :   return handle(Smi::FromInt(config), isolate);
      71             : }
      72             : 
      73       38077 : Handle<Smi> LoadHandler::EnableAccessCheckOnReceiver(Isolate* isolate,
      74             :                                                      Handle<Smi> smi_handler) {
      75             :   int config = smi_handler->value();
      76             : #ifdef DEBUG
      77             :   Kind kind = KindBits::decode(config);
      78             :   DCHECK_NE(kElement, kind);
      79             : #endif
      80       76154 :   config = DoAccessCheckOnReceiverBits::update(config, true);
      81       38077 :   return handle(Smi::FromInt(config), isolate);
      82             : }
      83             : 
      84        5641 : Handle<Smi> LoadHandler::EnableLookupOnReceiver(Isolate* isolate,
      85             :                                                 Handle<Smi> smi_handler) {
      86             :   int config = smi_handler->value();
      87             : #ifdef DEBUG
      88             :   Kind kind = KindBits::decode(config);
      89             :   DCHECK_NE(kElement, kind);
      90             : #endif
      91       11282 :   config = LookupOnReceiverBits::update(config, true);
      92        5641 :   return handle(Smi::FromInt(config), isolate);
      93             : }
      94             : 
      95       81535 : Handle<Smi> LoadHandler::LoadNonExistent(Isolate* isolate) {
      96             :   int config = KindBits::encode(kNonExistent);
      97       81535 :   return handle(Smi::FromInt(config), isolate);
      98             : }
      99             : 
     100      185819 : Handle<Smi> LoadHandler::LoadElement(Isolate* isolate,
     101             :                                      ElementsKind elements_kind,
     102             :                                      bool convert_hole_to_undefined,
     103             :                                      bool is_js_array) {
     104             :   int config = KindBits::encode(kElement) |
     105      185819 :                ElementsKindBits::encode(elements_kind) |
     106      185819 :                ConvertHoleBits::encode(convert_hole_to_undefined) |
     107      185819 :                IsJsArrayBits::encode(is_js_array);
     108      185819 :   return handle(Smi::FromInt(config), isolate);
     109             : }
     110             : 
     111        1264 : Handle<Smi> StoreHandler::StoreGlobalProxy(Isolate* isolate) {
     112             :   int config = KindBits::encode(kStoreGlobalProxy);
     113        1264 :   return handle(Smi::FromInt(config), isolate);
     114             : }
     115             : 
     116       17577 : Handle<Smi> StoreHandler::StoreNormal(Isolate* isolate) {
     117             :   int config = KindBits::encode(kStoreNormal);
     118       17577 :   return handle(Smi::FromInt(config), isolate);
     119             : }
     120             : 
     121         417 : Handle<Smi> StoreHandler::StoreProxy(Isolate* isolate) {
     122             :   int config = KindBits::encode(kProxy);
     123         417 :   return handle(Smi::FromInt(config), isolate);
     124             : }
     125             : 
     126        1284 : Handle<Smi> StoreHandler::EnableAccessCheckOnReceiver(Isolate* isolate,
     127             :                                                       Handle<Smi> smi_handler) {
     128             :   int config = smi_handler->value();
     129        2568 :   config = DoAccessCheckOnReceiverBits::update(config, true);
     130        1284 :   return handle(Smi::FromInt(config), isolate);
     131             : }
     132             : 
     133      375913 : Handle<Smi> StoreHandler::StoreField(Isolate* isolate, Kind kind,
     134             :                                      int descriptor, FieldIndex field_index,
     135             :                                      Representation representation,
     136             :                                      bool extend_storage) {
     137             :   StoreHandler::FieldRepresentation field_rep;
     138      375913 :   switch (representation.kind()) {
     139             :     case Representation::kSmi:
     140             :       field_rep = StoreHandler::kSmi;
     141             :       break;
     142             :     case Representation::kDouble:
     143             :       field_rep = StoreHandler::kDouble;
     144        3512 :       break;
     145             :     case Representation::kHeapObject:
     146             :       field_rep = StoreHandler::kHeapObject;
     147      237002 :       break;
     148             :     case Representation::kTagged:
     149             :       field_rep = StoreHandler::kTagged;
     150       15669 :       break;
     151             :     default:
     152           0 :       UNREACHABLE();
     153             :   }
     154             : 
     155             :   DCHECK(kind == kStoreField || kind == kTransitionToField ||
     156             :          (kind == kStoreConstField && FLAG_track_constant_fields));
     157             :   DCHECK_IMPLIES(extend_storage, kind == kTransitionToField);
     158             :   DCHECK_IMPLIES(field_index.is_inobject(), !extend_storage);
     159             : 
     160      375913 :   int config = StoreHandler::KindBits::encode(kind) |
     161      375913 :                StoreHandler::ExtendStorageBits::encode(extend_storage) |
     162      375913 :                StoreHandler::IsInobjectBits::encode(field_index.is_inobject()) |
     163      375913 :                StoreHandler::FieldRepresentationBits::encode(field_rep) |
     164      751826 :                StoreHandler::DescriptorBits::encode(descriptor) |
     165      751826 :                StoreHandler::FieldOffsetBits::encode(field_index.offset());
     166      375913 :   return handle(Smi::FromInt(config), isolate);
     167             : }
     168             : 
     169             : Handle<Smi> StoreHandler::StoreField(Isolate* isolate, int descriptor,
     170             :                                      FieldIndex field_index,
     171             :                                      PropertyConstness constness,
     172             :                                      Representation representation) {
     173             :   DCHECK_IMPLIES(!FLAG_track_constant_fields, constness == kMutable);
     174      166208 :   Kind kind = constness == kMutable ? kStoreField : kStoreConstField;
     175             :   return StoreField(isolate, kind, descriptor, field_index, representation,
     176      166208 :                     false);
     177             : }
     178             : 
     179             : Handle<Smi> StoreHandler::TransitionToField(Isolate* isolate, int descriptor,
     180             :                                             FieldIndex field_index,
     181             :                                             Representation representation,
     182             :                                             bool extend_storage) {
     183             :   return StoreField(isolate, kTransitionToField, descriptor, field_index,
     184      209705 :                     representation, extend_storage);
     185             : }
     186             : 
     187         217 : Handle<Smi> StoreHandler::TransitionToConstant(Isolate* isolate,
     188             :                                                int descriptor) {
     189             :   DCHECK(!FLAG_track_constant_fields);
     190             :   int config =
     191         217 :       StoreHandler::KindBits::encode(StoreHandler::kTransitionToConstant) |
     192         434 :       StoreHandler::DescriptorBits::encode(descriptor);
     193         217 :   return handle(Smi::FromInt(config), isolate);
     194             : }
     195             : 
     196             : // static
     197      331467 : WeakCell* StoreHandler::GetTransitionCell(Object* handler) {
     198      331467 :   if (handler->IsTuple3()) {
     199             :     STATIC_ASSERT(kTransitionOrHolderCellOffset == Tuple3::kValue1Offset);
     200             :     WeakCell* cell = WeakCell::cast(Tuple3::cast(handler)->value1());
     201             :     DCHECK(!cell->cleared());
     202      331467 :     return cell;
     203             :   }
     204             : 
     205             :   DCHECK(handler->IsFixedArray());
     206             :   WeakCell* cell = WeakCell::cast(
     207             :       FixedArray::cast(handler)->get(kTransitionMapOrHolderCellIndex));
     208             :   DCHECK(!cell->cleared());
     209           0 :   return cell;
     210             : }
     211             : 
     212             : // static
     213    26982327 : bool StoreHandler::IsHandler(Object* maybe_handler) {
     214    53964636 :   return maybe_handler->IsFixedArray() || maybe_handler->IsTuple3();
     215             : }
     216             : 
     217             : }  // namespace internal
     218             : }  // namespace v8
     219             : 
     220             : #endif  // V8_IC_HANDLER_CONFIGURATION_INL_H_

Generated by: LCOV version 1.10