LCOV - code coverage report
Current view: top level - js/src/vm - ReceiverGuard-inl.h (source / functions) Hit Total Coverage
Test: output.info Lines: 4 21 19.0 %
Date: 2017-07-14 16:53:18 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2             :  * vim: set ts=8 sts=4 et sw=4 tw=99:
       3             :  * This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef vm_ReceiverGuard_inl_h
       8             : #define vm_ReceiverGuard_inl_h
       9             : 
      10             : #include "vm/ReceiverGuard.h"
      11             : 
      12             : #include "jsobj.h"
      13             : 
      14             : #include "builtin/TypedObject.h"
      15             : #include "vm/ShapedObject.h"
      16             : #include "vm/UnboxedObject.h"
      17             : 
      18             : namespace js {
      19             : 
      20             : MOZ_ALWAYS_INLINE
      21         368 : ReceiverGuard::ReceiverGuard(JSObject* obj)
      22         368 :   : group(nullptr), shape(nullptr)
      23             : {
      24         368 :     if (!obj->isNative()) {
      25           0 :         if (obj->is<UnboxedPlainObject>()) {
      26           0 :             group = obj->group();
      27           0 :             if (UnboxedExpandoObject* expando = obj->as<UnboxedPlainObject>().maybeExpando())
      28           0 :                 shape = expando->lastProperty();
      29           0 :             return;
      30             :         }
      31           0 :         if (obj->is<UnboxedArrayObject>() || obj->is<TypedObject>()) {
      32           0 :             group = obj->group();
      33           0 :             return;
      34             :         }
      35             :     }
      36         368 :     shape = obj->as<ShapedObject>().shape();
      37             : }
      38             : 
      39             : MOZ_ALWAYS_INLINE
      40           0 : ReceiverGuard::ReceiverGuard(ObjectGroup* group, Shape* shape)
      41           0 :   : group(group), shape(shape)
      42             : {
      43           0 :     if (group) {
      44           0 :         const Class* clasp = group->clasp();
      45           0 :         if (clasp == &UnboxedPlainObject::class_) {
      46             :             // Keep both group and shape.
      47           0 :         } else if (clasp == &UnboxedArrayObject::class_ || IsTypedObjectClass(clasp)) {
      48           0 :             this->shape = nullptr;
      49             :         } else {
      50           0 :             this->group = nullptr;
      51             :         }
      52             :     }
      53           0 : }
      54             : 
      55             : } // namespace js
      56             : 
      57             : #endif /* vm_ReceiverGuard_inl_h */

Generated by: LCOV version 1.13