OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 } | 383 } |
384 | 384 |
385 | 385 |
386 void Isolate::SetCrashIfDefaultIsolateInitialized() { | 386 void Isolate::SetCrashIfDefaultIsolateInitialized() { |
387 LockGuard<Mutex> lock_guard(&process_wide_mutex_); | 387 LockGuard<Mutex> lock_guard(&process_wide_mutex_); |
388 CHECK(default_isolate_status_ != kDefaultIsolateInitialized); | 388 CHECK(default_isolate_status_ != kDefaultIsolateInitialized); |
389 default_isolate_status_ = kDefaultIsolateCrashIfInitialized; | 389 default_isolate_status_ = kDefaultIsolateCrashIfInitialized; |
390 } | 390 } |
391 | 391 |
392 | 392 |
393 Isolate* Isolate::EnsureDefaultIsolate() { | 393 Isolate* Isolate::EnsureDefaultIsolate(bool must_be_null) { |
394 static Isolate* default_isolate_ = NULL; | 394 static Isolate* default_isolate_ = NULL; |
395 LockGuard<Mutex> lock_guard(&process_wide_mutex_); | 395 LockGuard<Mutex> lock_guard(&process_wide_mutex_); |
396 CHECK(default_isolate_status_ != kDefaultIsolateCrashIfInitialized); | 396 CHECK(default_isolate_status_ != kDefaultIsolateCrashIfInitialized); |
| 397 if (must_be_null) { |
| 398 CHECK(default_isolate_ == NULL); |
| 399 } |
397 if (default_isolate_ == NULL) { | 400 if (default_isolate_ == NULL) { |
398 default_isolate_ = new Isolate(true); | 401 default_isolate_ = new Isolate(true); |
399 } | 402 } |
400 // Can't use SetIsolateThreadLocals(default_isolate_, NULL) here | 403 // Can't use SetIsolateThreadLocals(default_isolate_, NULL) here |
401 // because a non-null thread data may be already set. | 404 // because a non-null thread data may be already set. |
402 if (Thread::GetThreadLocal(isolate_key_) == NULL) { | 405 if (Thread::GetThreadLocal(isolate_key_) == NULL) { |
403 Thread::SetThreadLocal(isolate_key_, default_isolate_); | 406 Thread::SetThreadLocal(isolate_key_, default_isolate_); |
404 } | 407 } |
405 | 408 |
406 return default_isolate_; | 409 return default_isolate_; |
(...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2531 | 2534 |
2532 #ifdef DEBUG | 2535 #ifdef DEBUG |
2533 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2536 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
2534 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2537 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
2535 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2538 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
2536 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2539 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
2537 #undef ISOLATE_FIELD_OFFSET | 2540 #undef ISOLATE_FIELD_OFFSET |
2538 #endif | 2541 #endif |
2539 | 2542 |
2540 } } // namespace v8::internal | 2543 } } // namespace v8::internal |
OLD | NEW |