LCOV - code coverage report
Current view: top level - src/objects - arguments-inl.h (source / functions) Hit Total Coverage
Test: app.info Lines: 14 26 53.8 %
Date: 2019-01-20 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             : #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     1621980 : OBJECT_CONSTRUCTORS_IMPL(SloppyArgumentsElements, FixedArray)
      22             : OBJECT_CONSTRUCTORS_IMPL(JSArgumentsObject, JSObject)
      23         294 : OBJECT_CONSTRUCTORS_IMPL(AliasedArgumentsEntry, Struct)
      24             : 
      25         147 : CAST_ACCESSOR(AliasedArgumentsEntry)
      26      810990 : CAST_ACCESSOR(SloppyArgumentsElements)
      27             : CAST_ACCESSOR(JSArgumentsObject)
      28             : 
      29         239 : SMI_ACCESSORS(AliasedArgumentsEntry, aliased_context_slot, kAliasedContextSlot)
      30             : 
      31       48157 : Context SloppyArgumentsElements::context() {
      32       48157 :   return Context::cast(get(kContextIndex));
      33             : }
      34             : 
      35      683266 : FixedArray SloppyArgumentsElements::arguments() {
      36      683266 :   return FixedArray::cast(get(kArgumentsIndex));
      37             : }
      38             : 
      39             : void SloppyArgumentsElements::set_arguments(FixedArray arguments) {
      40       21884 :   set(kArgumentsIndex, arguments);
      41             : }
      42             : 
      43             : uint32_t SloppyArgumentsElements::parameter_map_length() {
      44      552376 :   return length() - kParameterMapStart;
      45             : }
      46             : 
      47      100613 : Object SloppyArgumentsElements::get_mapped_entry(uint32_t entry) {
      48      201226 :   return get(entry + kParameterMapStart);
      49             : }
      50             : 
      51             : void SloppyArgumentsElements::set_mapped_entry(uint32_t entry, Object object) {
      52         595 :   set(entry + kParameterMapStart, object);
      53             : }
      54             : 
      55             : // TODO(danno): This shouldn't be inline here, but to defensively avoid
      56             : // regressions associated with the fix for the bug 778574, it's staying that way
      57             : // until the splice implementation in builtin-arrays.cc can be removed and this
      58             : // function can be moved into runtime-arrays.cc near its other usage.
      59           0 : bool JSSloppyArgumentsObject::GetSloppyArgumentsLength(Isolate* isolate,
      60             :                                                        Handle<JSObject> object,
      61             :                                                        int* out) {
      62           0 :   Context context = *isolate->native_context();
      63             :   Map map = object->map();
      64           0 :   if (map != context->sloppy_arguments_map() &&
      65           0 :       map != context->strict_arguments_map() &&
      66           0 :       map != context->fast_aliased_arguments_map()) {
      67             :     return false;
      68             :   }
      69             :   DCHECK(object->HasFastElements() || object->HasFastArgumentsElements());
      70             :   Object len_obj =
      71           0 :       object->InObjectPropertyAt(JSArgumentsObjectWithLength::kLengthIndex);
      72           0 :   if (!len_obj->IsSmi()) return false;
      73           0 :   *out = Max(0, Smi::ToInt(len_obj));
      74             : 
      75           0 :   FixedArray parameters = FixedArray::cast(object->elements());
      76           0 :   if (object->HasSloppyArgumentsElements()) {
      77             :     FixedArray arguments = FixedArray::cast(parameters->get(1));
      78           0 :     return *out <= arguments->length();
      79             :   }
      80           0 :   return *out <= parameters->length();
      81             : }
      82             : 
      83             : }  // namespace internal
      84             : }  // namespace v8
      85             : 
      86             : #include "src/objects/object-macros-undef.h"
      87             : 
      88             : #endif  // V8_OBJECTS_ARGUMENTS_INL_H_

Generated by: LCOV version 1.10