LCOV - code coverage report
Current view: directory - js/src - jscell.h (source / functions) Found Hit Coverage
Test: app.info Lines: 1 1 100.0 %
Date: 2012-06-02 Functions: 1 1 100.0 %

       1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2                 :  *
       3                 :  * ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is SpiderMonkey code.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  * Mozilla Corporation.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 2010
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  * Gregor Wagner <anygregor@gmail.com>
      25                 :  *
      26                 :  * Alternatively, the contents of this file may be used under the terms of
      27                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      28                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      30                 :  * of those above. If you wish to allow use of your version of this file only
      31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      32                 :  * use your version of this file under the terms of the MPL, indicate your
      33                 :  * decision by deleting the provisions above and replace them with the notice
      34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      35                 :  * the provisions above, a recipient may use your version of this file under
      36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      37                 :  *
      38                 :  * ***** END LICENSE BLOCK ***** */
      39                 : 
      40                 : #ifndef jscell_h___
      41                 : #define jscell_h___
      42                 : 
      43                 : #include "jspubtd.h"
      44                 : 
      45                 : struct JSCompartment;
      46                 : 
      47                 : namespace js {
      48                 : namespace gc {
      49                 : 
      50                 : struct ArenaHeader;
      51                 : struct Chunk;
      52                 : 
      53                 : /* The GC allocation kinds. */
      54                 : enum AllocKind {
      55                 :     FINALIZE_OBJECT0,
      56                 :     FINALIZE_OBJECT0_BACKGROUND,
      57                 :     FINALIZE_OBJECT2,
      58                 :     FINALIZE_OBJECT2_BACKGROUND,
      59                 :     FINALIZE_OBJECT4,
      60                 :     FINALIZE_OBJECT4_BACKGROUND,
      61                 :     FINALIZE_OBJECT8,
      62                 :     FINALIZE_OBJECT8_BACKGROUND,
      63                 :     FINALIZE_OBJECT12,
      64                 :     FINALIZE_OBJECT12_BACKGROUND,
      65                 :     FINALIZE_OBJECT16,
      66                 :     FINALIZE_OBJECT16_BACKGROUND,
      67                 :     FINALIZE_OBJECT_LAST = FINALIZE_OBJECT16_BACKGROUND,
      68                 :     FINALIZE_SCRIPT,
      69                 :     FINALIZE_SHAPE,
      70                 :     FINALIZE_BASE_SHAPE,
      71                 :     FINALIZE_TYPE_OBJECT,
      72                 : #if JS_HAS_XML_SUPPORT
      73                 :     FINALIZE_XML,
      74                 : #endif
      75                 :     FINALIZE_SHORT_STRING,
      76                 :     FINALIZE_STRING,
      77                 :     FINALIZE_EXTERNAL_STRING,
      78                 :     FINALIZE_LAST = FINALIZE_EXTERNAL_STRING
      79                 : };
      80                 : 
      81                 : static const unsigned FINALIZE_LIMIT = FINALIZE_LAST + 1;
      82                 : static const unsigned FINALIZE_OBJECT_LIMIT = FINALIZE_OBJECT_LAST + 1;
      83                 : 
      84                 : /*
      85                 :  * Live objects are marked black. How many other additional colors are available
      86                 :  * depends on the size of the GCThing. Objects marked gray are eligible for
      87                 :  * cycle collection.
      88                 :  */
      89                 : static const uint32_t BLACK = 0;
      90                 : static const uint32_t GRAY = 1;
      91                 : 
      92                 : /*
      93                 :  * A GC cell is the base class for all GC things.
      94                 :  */
      95        43494950 : struct Cell {
      96                 :     static const size_t CellShift = 3;
      97                 :     static const size_t CellSize = size_t(1) << CellShift;
      98                 :     static const size_t CellMask = CellSize - 1;
      99                 : 
     100                 :     inline uintptr_t address() const;
     101                 :     inline ArenaHeader *arenaHeader() const;
     102                 :     inline Chunk *chunk() const;
     103                 :     inline AllocKind getAllocKind() const;
     104                 : 
     105                 :     JS_ALWAYS_INLINE bool isMarked(uint32_t color = BLACK) const;
     106                 :     JS_ALWAYS_INLINE bool markIfUnmarked(uint32_t color = BLACK) const;
     107                 :     JS_ALWAYS_INLINE void unmark(uint32_t color) const;
     108                 : 
     109                 :     inline JSCompartment *compartment() const;
     110                 : 
     111                 : #ifdef DEBUG
     112                 :     inline bool isAligned() const;
     113                 : #endif
     114                 : };
     115                 : 
     116                 : } /* namespace gc */
     117                 : } /* namespace js */
     118                 : 
     119                 : #endif /* jscell_h___ */

Generated by: LCOV version 1.7