LCOV - code coverage report
Current view: top level - src/objects - arguments-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 5 16 31.2 %
Date: 2019-04-17 Functions: 0 1 0.0 %

          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             : #ifndef V8_OBJECTS_ARGUMENTS_INL_H_
       6             : #define V8_OBJECTS_ARGUMENTS_INL_H_
       7             : 
       8             : #include "src/objects/arguments.h"
       9             : 
      10             : #include "src/contexts-inl.h"
      11             : #include "src/isolate-inl.h"
      12             : #include "src/objects-inl.h"
      13             : #include "src/objects/fixed-array-inl.h"
      14             : 
      15             : // Has to be the last include (doesn't have include guards):
      16             : #include "src/objects/object-macros.h"
      17             : 
      18             : namespace v8 {
      19             : namespace internal {
      20             : 
      21             : OBJECT_CONSTRUCTORS_IMPL(SloppyArgumentsElements, FixedArray)
      22             : OBJECT_CONSTRUCTORS_IMPL(JSArgumentsObject, JSObject)
      23             : OBJECT_CONSTRUCTORS_IMPL(AliasedArgumentsEntry, Struct)
      24             : 
      25             : CAST_ACCESSOR(AliasedArgumentsEntry)
      26             : CAST_ACCESSOR(SloppyArgumentsElements)
      27             : CAST_ACCESSOR(JSArgumentsObject)
      28             : 
      29         141 : SMI_ACCESSORS(AliasedArgumentsEntry, aliased_context_slot,
      30             :               kAliasedContextSlotOffset)
      31             : 
      32             : Context SloppyArgumentsElements::context() {
      33             :   return Context::cast(get(kContextIndex));
      34             : }
      35             : 
      36             : FixedArray SloppyArgumentsElements::arguments() {
      37             :   return FixedArray::cast(get(kArgumentsIndex));
      38             : }
      39             : 
      40             : void SloppyArgumentsElements::set_arguments(FixedArray arguments) {
      41       21934 :   set(kArgumentsIndex, arguments);
      42             : }
      43             : 
      44             : uint32_t SloppyArgumentsElements::parameter_map_length() {
      45      552950 :   return length() - kParameterMapStart;
      46             : }
      47             : 
      48             : Object SloppyArgumentsElements::get_mapped_entry(uint32_t entry) {
      49      100864 :   return get(entry + kParameterMapStart);
      50             : }
      51             : 
      52             : void SloppyArgumentsElements::set_mapped_entry(uint32_t entry, Object object) {
      53         593 :   set(entry + kParameterMapStart, object);
      54             : }
      55             : 
      56             : // TODO(danno): This shouldn't be inline here, but to defensively avoid
      57             : // regressions associated with the fix for the bug 778574, it's staying that way
      58             : // until the splice implementation in builtin-arrays.cc can be removed and this
      59             : // function can be moved into runtime-arrays.cc near its other usage.
      60           0 : bool JSSloppyArgumentsObject::GetSloppyArgumentsLength(Isolate* isolate,
      61             :                                                        Handle<JSObject> object,
      62             :                                                        int* out) {
      63           0 :   Context context = *isolate->native_context();
      64             :   Map map = object->map();
      65           0 :   if (map != context->sloppy_arguments_map() &&
      66           0 :       map != context->strict_arguments_map() &&
      67           0 :       map != context->fast_aliased_arguments_map()) {
      68             :     return false;
      69             :   }
      70             :   DCHECK(object->HasFastElements() || object->HasFastArgumentsElements());
      71             :   Object len_obj =
      72           0 :       object->InObjectPropertyAt(JSArgumentsObjectWithLength::kLengthIndex);
      73           0 :   if (!len_obj->IsSmi()) return false;
      74           0 :   *out = Max(0, Smi::ToInt(len_obj));
      75             : 
      76             :   FixedArray parameters = FixedArray::cast(object->elements());
      77           0 :   if (object->HasSloppyArgumentsElements()) {
      78             :     FixedArray arguments = FixedArray::cast(parameters->get(1));
      79           0 :     return *out <= arguments->length();
      80             :   }
      81           0 :   return *out <= parameters->length();
      82             : }
      83             : 
      84             : }  // namespace internal
      85             : }  // namespace v8
      86             : 
      87             : #include "src/objects/object-macros-undef.h"
      88             : 
      89             : #endif  // V8_OBJECTS_ARGUMENTS_INL_H_

Generated by: LCOV version 1.10