Stop using ccache on OS X.
1 /* vim: set ts=4 sw=4 tw=99 et:
3 * Copyright (C) 2012 David Anderson
5 * This file is part of JITCraft.
7 * JITCraft is free software: you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License as published by the Free
9 * Software Foundation, either version 3 of the License, or (at your option)
12 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with
17 * JITCraft. If not, see http://www.gnu.org/licenses/.
19 #ifndef _include_jitcraft_thread_h_
20 #define _include_jitcraft_thread_h_
23 #include "PoolAllocator.h"
29 #include "RootScopes.h"
30 #include "VirtualObjectVisitor.h"
48 Unbarriered<Map> maps_[MapKinds_Total];
49 Unbarriered<ArrayMap> genericArrayMap_;
50 Unbarriered<ArrayMap> charArrayMap_;
54 GlobalRoots *globalRoots_;
57 Local<Object> *lastLocalRoot_;
58 RootScopeManager rootScopes_;
61 bool hasPendingException_;
62 Ke::IMessageReporter *reporter_;
65 Zone *thisFromCtor() {
74 PoolAllocator &pool() {
83 Object *allocate(MapKind kind, size_t bytes, Heap::Tenure tenure = Heap::Tenure_Default) {
85 Local<Map> map(this, maps_[kind]);
86 return allocate(map, bytes, tenure);
88 Object *allocate(Handle<Map> map, size_t bytes, Heap::Tenure tenure = Heap::Tenure_Default) {
89 return heap_.allocate(map, bytes, tenure);
91 Map *getMap(MapKind kind) {
94 Map *allocateMap(MapKind kind, size_t bytes, MapKind parent = MapKind_Meta);
96 ArrayMap *genericArrayMap() {
97 return genericArrayMap_;
99 ArrayMap *charArrayMap() {
100 return charArrayMap_;
103 TypeManager *types() const {
106 Local<Object> **lastLocalRoot() {
107 return &lastLocalRoot_;
109 Object **makeScopedRoot(Object *ptr) {
110 return rootScopes_.make(ptr);
112 RootScopeManager &rootScopes() {
115 StringPool *symbols() {
118 GlobalRoots *globalRoots() {
122 String *makeSymbol(const char *string, size_t length);
123 String *makeSymbol(const char *string);
125 void reportOutOfMemory();
126 void reportError(Message message, ...);
127 void reportErrorVA(Message message, va_list ap);
128 bool hasPendingException();
129 void installErrorReporter(Ke::IMessageReporter *reporter);
130 void beginCompilationErrors(const char *file);
131 void reportCompilationError(Message message, unsigned line, unsigned col, va_list ap);
132 void endCompilationErrors();
134 void accept(VirtualObjectVisitor *visitor);
137 // In a multi-threaded system, this would be a TLS variable.
138 // In the interest of simplicity, we are single-threaded for now.
139 extern Zone *SingleThreadedZone;
141 static inline Zone *ZONE()
143 return SingleThreadedZone;
146 template <typename T>
147 Local<T>::Local(Zone *zone, T *thing)
150 prev_(*zone->lastLocalRoot())
152 *zone->lastLocalRoot() = toRaw();
155 template <typename T>
158 assert(*zone_->lastLocalRoot() == toRaw());
159 *zone_->lastLocalRoot() = prev_;
162 template <typename T>
163 ScopedRoot<T>::ScopedRoot()
164 : thingp_(make(NULL))
168 template <typename T>
169 ScopedRoot<T>::ScopedRoot(T *thing)
170 : thingp_(make(thing))
172 // Type check that T is an Object.
173 (void)static_cast<Object *>(thing);
176 template <typename T> T **
177 ScopedRoot<T>::make(T *other)
179 return reinterpret_cast<T **>(ZONE()->makeScopedRoot(other));
182 RootScope::RootScope(Zone *zone)
183 : Ke::HandleScope(zone, zone->rootScopes().position(), *zone->rootScopes().scope())
189 #endif // _include_jitcraft_thread_h_