| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_ISOLATE_H_ | 28 #ifndef V8_ISOLATE_H_ |
| 29 #define V8_ISOLATE_H_ | 29 #define V8_ISOLATE_H_ |
| 30 | 30 |
| 31 // #define V8_USE_TLS_FOR_GLOBAL_ISOLATE |
| 32 |
| 31 #include "apiutils.h" | 33 #include "apiutils.h" |
| 32 #include "heap.h" | 34 #include "heap.h" |
| 33 #include "execution.h" | 35 #include "execution.h" |
| 34 #include "zone.h" | 36 #include "zone.h" |
| 35 | 37 |
| 36 namespace v8 { | 38 namespace v8 { |
| 37 namespace internal { | 39 namespace internal { |
| 38 | 40 |
| 39 class Bootstrapper; | 41 class Bootstrapper; |
| 40 class ContextSlotCache; | 42 class ContextSlotCache; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 /* A previously allocated buffer of kMinimalBufferSize bytes, or NULL. */ \ | 147 /* A previously allocated buffer of kMinimalBufferSize bytes, or NULL. */ \ |
| 146 V(byte*, assembler_spare_buffer, NULL) \ | 148 V(byte*, assembler_spare_buffer, NULL) \ |
| 147 ISOLATE_PLATFORM_INIT_LIST(V) | 149 ISOLATE_PLATFORM_INIT_LIST(V) |
| 148 | 150 |
| 149 class Isolate { | 151 class Isolate { |
| 150 public: | 152 public: |
| 151 ~Isolate(); | 153 ~Isolate(); |
| 152 | 154 |
| 153 // Returns the single global isolate. | 155 // Returns the single global isolate. |
| 154 static Isolate* Current() { | 156 static Isolate* Current() { |
| 155 ASSERT(global_isolate != NULL); | 157 #ifdef V8_USE_TLS_FOR_GLOBAL_ISOLATE |
| 156 return global_isolate; | 158 Isolate* isolate = reinterpret_cast<Isolate*>( |
| 159 Thread::GetThreadLocal(global_isolate_key_)); |
| 160 if (isolate == NULL) { |
| 161 isolate = InitThreadForGlobalIsolate(); |
| 162 ASSERT(isolate != NULL); |
| 163 } |
| 164 return isolate; |
| 165 #else |
| 166 ASSERT(global_isolate_ != NULL); |
| 167 return global_isolate_; |
| 168 #endif |
| 157 } | 169 } |
| 158 | 170 |
| 171 #ifdef V8_USE_TLS_FOR_GLOBAL_ISOLATE |
| 172 static Isolate* InitThreadForGlobalIsolate(); |
| 173 #endif |
| 174 |
| 159 // Creates a new isolate (perhaps using a deserializer). Returns null | 175 // Creates a new isolate (perhaps using a deserializer). Returns null |
| 160 // on failure. | 176 // on failure. |
| 161 static Isolate* Create(Deserializer* des); | 177 static Isolate* Create(Deserializer* des); |
| 162 | 178 |
| 163 #define GLOBAL_ACCESSOR(type, name, initialvalue) \ | 179 #define GLOBAL_ACCESSOR(type, name, initialvalue) \ |
| 164 type name() const { return name##_; } \ | 180 type name() const { return name##_; } \ |
| 165 void set_##name(type value) { name##_ = value; } | 181 void set_##name(type value) { name##_ = value; } |
| 166 ISOLATE_INIT_LIST(GLOBAL_ACCESSOR) | 182 ISOLATE_INIT_LIST(GLOBAL_ACCESSOR) |
| 167 #undef GLOBAL_ACCESSOR | 183 #undef GLOBAL_ACCESSOR |
| 168 | 184 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 Zone* zone() { return &zone_; } | 225 Zone* zone() { return &zone_; } |
| 210 | 226 |
| 211 // SerializerDeserializer state. | 227 // SerializerDeserializer state. |
| 212 static const int kPartialSnapshotCacheCapacity = 1300; | 228 static const int kPartialSnapshotCacheCapacity = 1300; |
| 213 | 229 |
| 214 static int number_of_isolates() { return number_of_isolates_; } | 230 static int number_of_isolates() { return number_of_isolates_; } |
| 215 | 231 |
| 216 private: | 232 private: |
| 217 Isolate(); | 233 Isolate(); |
| 218 | 234 |
| 219 static Isolate* global_isolate; | 235 #ifdef V8_USE_TLS_FOR_GLOBAL_ISOLATE |
| 236 static Thread::LocalStorageKey global_isolate_key_; |
| 237 #endif |
| 238 static Isolate* global_isolate_; |
| 239 |
| 220 // TODO(isolates): Access to this global counter should be serialized. | 240 // TODO(isolates): Access to this global counter should be serialized. |
| 221 static int number_of_isolates_; | 241 static int number_of_isolates_; |
| 222 | 242 |
| 223 // Initialize process-wide state. | 243 // Initialize process-wide state. |
| 224 static void InitOnce(); | 244 static void InitOnce(); |
| 225 | 245 |
| 226 bool PreInit(); | 246 bool PreInit(); |
| 227 | 247 |
| 228 bool Init(Deserializer* des); | 248 bool Init(Deserializer* des); |
| 229 | 249 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 | 338 |
| 319 | 339 |
| 320 // Temporary macro to be used to flag classes that are completely converted | 340 // Temporary macro to be used to flag classes that are completely converted |
| 321 // to be isolate-friendly. Their mix of static/nonstatic methods/fields is | 341 // to be isolate-friendly. Their mix of static/nonstatic methods/fields is |
| 322 // correct. | 342 // correct. |
| 323 #define ISOLATED_CLASS class | 343 #define ISOLATED_CLASS class |
| 324 | 344 |
| 325 } } // namespace v8::internal | 345 } } // namespace v8::internal |
| 326 | 346 |
| 327 #endif // V8_ISOLATE_H_ | 347 #endif // V8_ISOLATE_H_ |
| OLD | NEW |