src/GlobalRoots.h
author David Anderson <danderson@mozilla.com>
Thu Jul 26 00:16:53 2012 -0700 (2012-07-26)
changeset 100 3278e19f064d
parent 92 e3974e7360e9
child 126 0ddfc5bd00e2
permissions -rw-r--r--
Push build.
     1 /*
     2  * Copyright (C) 2004-2012 David Anderson
     3  *
     4  * This file is part of SourcePawn.
     5  *
     6  * SourcePawn is free software: you can redistribute it and/or modify it under
     7  * the terms of the GNU General Public License as published by the Free
     8  * Software Foundation, either version 3 of the License, or (at your option)
     9  * any later version.
    10  * 
    11  * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
    12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU General Public License along with
    16  * SourcePawn. If not, see http://www.gnu.org/licenses/.
    17  */
    18 #ifndef _include_ke_global_roots_h_
    19 #define _include_ke_global_roots_h_
    20 
    21 #include "Utility.h"
    22 #include "Handles.h"
    23 #include "InlineList.h"
    24 #include "VirtualObjectVisitor.h"
    25 
    26 namespace ke {
    27 
    28 class Zone;
    29 class Object;
    30 
    31 class HeapRoot : public InlineListNode<HeapRoot>
    32 {
    33   public:
    34     Object *obj;
    35     intptr_t refcount;
    36 };
    37 
    38 class GlobalRoots
    39 {
    40     Zone *zone_;
    41 
    42   public:
    43     GlobalRoots(Zone *zone);
    44     ~GlobalRoots();
    45 
    46     bool initialize();
    47 
    48     // The caller must immediately incref this.
    49     HeapRoot *create(Handle<Object> ptr);
    50 
    51     void incref(HeapRoot *root);
    52     void decref(HeapRoot *root);
    53 
    54     void accept(VirtualObjectVisitor *visitor);
    55 
    56   private:
    57     InlineList<HeapRoot> roots_;
    58 };
    59 
    60 }
    61 
    62 #endif // _include_ke_global_roots_h_