LCOV - code coverage report
Current view: top level - js/src/vm - ShapedObject.h (source / functions) Hit Total Coverage
Test: output.info Lines: 11 11 100.0 %
Date: 2017-07-14 16:53:18 Functions: 5 5 100.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_ShapedObject_h
       8             : #define vm_ShapedObject_h
       9             : 
      10             : #include "jsobj.h"
      11             : 
      12             : namespace js {
      13             : 
      14             : /*
      15             :  * Shaped objects extend the base implementation of an object with a shape
      16             :  * field.  Subclasses of ShapedObject ascribe meaning to this field.
      17             :  *
      18             :  * ShapedObject is only created as the base class of some other class.  It's
      19             :  * never created as a most-derived class.
      20             :  */
      21             : class ShapedObject : public JSObject
      22             : {
      23             :   protected:
      24             :     // Property layout description and other state.
      25             :     GCPtrShape shape_;
      26             : 
      27             :   public:
      28             :     // Set the shape of an object. This pointer is valid for native objects and
      29             :     // some non-native objects. After creating an object, the objects for which
      30             :     // the shape pointer is invalid need to overwrite this pointer before a GC
      31             :     // can occur.
      32      140695 :     void initShape(Shape* shape) {
      33      140695 :         this->shape_.init(shape);
      34      140695 :     }
      35             : 
      36       10037 :     void setShape(Shape* shape) {
      37       10037 :         this->shape_ = shape;
      38       10037 :     }
      39             : 
      40      729332 :     Shape* shape() const { return this->shape_; }
      41             : 
      42          25 :     void traceShape(JSTracer* trc) {
      43          25 :         TraceEdge(trc, &shape_, "shape");
      44          25 :     }
      45             : 
      46         419 :     static size_t offsetOfShape() { return offsetof(ShapedObject, shape_); }
      47             : 
      48             :   private:
      49             :     static void staticAsserts() {
      50             :         static_assert(offsetof(ShapedObject, shape_) == offsetof(shadow::Object, shape),
      51             :                       "shadow shape must match actual shape");
      52             :     }
      53             : };
      54             : 
      55             : } // namespace js
      56             : 
      57             : #endif /* vm_ShapedObject_h */

Generated by: LCOV version 1.13