Added MacOS, gcc, and clang support. Preliminary crappy autoconf scripts of course.
2 * Copyright (C) 2012 David Anderson
4 * This file is part of JITCraft.
6 * JITCraft 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)
11 * Foobar 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.
15 * You should have received a copy of the GNU General Public License along with
16 * JITCraft. If not, see http://www.gnu.org/licenses/.
18 #ifndef _include_jitcraft_objects_h_
19 #define _include_jitcraft_objects_h_
29 // Garbage-collection objects require a header to describe their layout. This
30 // header is called a "map". The different kinds of maps are enumerated below.
35 // Represents Type objects.
38 // Represents basic data structures. When adding to this, don't forget
39 // to update Zone::initialize(), or you'll get a NULL crash trying to
40 // allocate, since these maps are cached.
48 // Used to represent Arrays. This does not have a canonical map.
51 // These represent special Map subclasses that require special tracing.
53 MapKind_Meta, // (default map class)
54 MapKind_MetaArray, // ArrayMap instances
60 typedef void * VoidPtr;
62 // All garbage collected objects must inherit from GCObject. Note that using
63 // virtual functions is illegal, as the |map| field would be displaced.
76 inline bool is(MapKind map);
78 inline void write(Zone *zone, Object **ptr, Object *value);
81 // Maps describe the layout of GCObjects. Every GCObject requires a map.
82 class Map : public Object
87 void setKind(MapKind kind) {
94 static inline Map *cast(Object *obj) {
95 // Note that ArrayMap is a map, but a special one: since it is non-
96 assert(obj->map()->kind() > MapKinds_Special &&
97 obj->map()->kind() < MapKinds_EndSpecial);
98 return reinterpret_cast<Map *>(obj);
103 Object::is(MapKind kind)
105 return map()->kind() == kind;
110 #endif //_include_jitcraft_objects_h_