Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/isolate.h

Issue 582953002: Revert "Require V8 to be explicitly initialized before an Isolate is created" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/d8.cc ('k') | src/isolate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_ISOLATE_H_ 5 #ifndef V8_ISOLATE_H_
6 #define V8_ISOLATE_H_ 6 #define V8_ISOLATE_H_
7 7
8 #include "include/v8-debug.h" 8 #include "include/v8-debug.h"
9 #include "src/allocation.h" 9 #include "src/allocation.h"
10 #include "src/assert-scope.h" 10 #include "src/assert-scope.h"
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 }; 459 };
460 460
461 461
462 enum AddressId { 462 enum AddressId {
463 #define DECLARE_ENUM(CamelName, hacker_name) k##CamelName##Address, 463 #define DECLARE_ENUM(CamelName, hacker_name) k##CamelName##Address,
464 FOR_EACH_ISOLATE_ADDRESS_NAME(DECLARE_ENUM) 464 FOR_EACH_ISOLATE_ADDRESS_NAME(DECLARE_ENUM)
465 #undef DECLARE_ENUM 465 #undef DECLARE_ENUM
466 kIsolateAddressCount 466 kIsolateAddressCount
467 }; 467 };
468 468
469 static void InitializeOncePerProcess();
470
471 // Returns the PerIsolateThreadData for the current thread (or NULL if one is 469 // Returns the PerIsolateThreadData for the current thread (or NULL if one is
472 // not currently set). 470 // not currently set).
473 static PerIsolateThreadData* CurrentPerIsolateThreadData() { 471 static PerIsolateThreadData* CurrentPerIsolateThreadData() {
472 EnsureInitialized();
474 return reinterpret_cast<PerIsolateThreadData*>( 473 return reinterpret_cast<PerIsolateThreadData*>(
475 base::Thread::GetThreadLocal(per_isolate_thread_data_key_)); 474 base::Thread::GetThreadLocal(per_isolate_thread_data_key_));
476 } 475 }
477 476
478 // Returns the isolate inside which the current thread is running. 477 // Returns the isolate inside which the current thread is running.
479 INLINE(static Isolate* Current()) { 478 INLINE(static Isolate* Current()) {
479 EnsureInitialized();
480 Isolate* isolate = reinterpret_cast<Isolate*>( 480 Isolate* isolate = reinterpret_cast<Isolate*>(
481 base::Thread::GetExistingThreadLocal(isolate_key_)); 481 base::Thread::GetExistingThreadLocal(isolate_key_));
482 DCHECK(isolate != NULL); 482 DCHECK(isolate != NULL);
483 return isolate; 483 return isolate;
484 } 484 }
485 485
486 INLINE(static Isolate* UncheckedCurrent()) { 486 INLINE(static Isolate* UncheckedCurrent()) {
487 EnsureInitialized();
487 return reinterpret_cast<Isolate*>( 488 return reinterpret_cast<Isolate*>(
488 base::Thread::GetThreadLocal(isolate_key_)); 489 base::Thread::GetThreadLocal(isolate_key_));
489 } 490 }
490 491
491 // Like UncheckedCurrent, but skips the check that |isolate_key_| was 492 // Like UncheckedCurrent, but skips the check that |isolate_key_| was
492 // initialized. Callers have to ensure that themselves. 493 // initialized. Callers have to ensure that themselves.
493 INLINE(static Isolate* UnsafeCurrent()) { 494 INLINE(static Isolate* UnsafeCurrent()) {
494 return reinterpret_cast<Isolate*>( 495 return reinterpret_cast<Isolate*>(
495 base::Thread::GetThreadLocal(isolate_key_)); 496 base::Thread::GetThreadLocal(isolate_key_));
496 } 497 }
(...skipping 24 matching lines...) Expand all
521 PerIsolateThreadData* FindPerThreadDataForThisThread(); 522 PerIsolateThreadData* FindPerThreadDataForThisThread();
522 523
523 // Find the PerThread for given (isolate, thread) combination 524 // Find the PerThread for given (isolate, thread) combination
524 // If one does not yet exist, return null. 525 // If one does not yet exist, return null.
525 PerIsolateThreadData* FindPerThreadDataForThread(ThreadId thread_id); 526 PerIsolateThreadData* FindPerThreadDataForThread(ThreadId thread_id);
526 527
527 // Returns the key used to store the pointer to the current isolate. 528 // Returns the key used to store the pointer to the current isolate.
528 // Used internally for V8 threads that do not execute JavaScript but still 529 // Used internally for V8 threads that do not execute JavaScript but still
529 // are part of the domain of an isolate (like the context switcher). 530 // are part of the domain of an isolate (like the context switcher).
530 static base::Thread::LocalStorageKey isolate_key() { 531 static base::Thread::LocalStorageKey isolate_key() {
532 EnsureInitialized();
531 return isolate_key_; 533 return isolate_key_;
532 } 534 }
533 535
534 // Returns the key used to store process-wide thread IDs. 536 // Returns the key used to store process-wide thread IDs.
535 static base::Thread::LocalStorageKey thread_id_key() { 537 static base::Thread::LocalStorageKey thread_id_key() {
538 EnsureInitialized();
536 return thread_id_key_; 539 return thread_id_key_;
537 } 540 }
538 541
539 static base::Thread::LocalStorageKey per_isolate_thread_data_key(); 542 static base::Thread::LocalStorageKey per_isolate_thread_data_key();
540 543
541 // Mutex for serializing access to break control structures. 544 // Mutex for serializing access to break control structures.
542 base::RecursiveMutex* break_access() { return &break_access_; } 545 base::RecursiveMutex* break_access() { return &break_access_; }
543 546
544 Address get_address_from_id(AddressId id); 547 Address get_address_from_id(AddressId id);
545 548
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 void AddCallCompletedCallback(CallCompletedCallback callback); 1103 void AddCallCompletedCallback(CallCompletedCallback callback);
1101 void RemoveCallCompletedCallback(CallCompletedCallback callback); 1104 void RemoveCallCompletedCallback(CallCompletedCallback callback);
1102 void FireCallCompletedCallback(); 1105 void FireCallCompletedCallback();
1103 1106
1104 void EnqueueMicrotask(Handle<Object> microtask); 1107 void EnqueueMicrotask(Handle<Object> microtask);
1105 void RunMicrotasks(); 1108 void RunMicrotasks();
1106 1109
1107 void SetUseCounterCallback(v8::Isolate::UseCounterCallback callback); 1110 void SetUseCounterCallback(v8::Isolate::UseCounterCallback callback);
1108 void CountUsage(v8::Isolate::UseCounterFeature feature); 1111 void CountUsage(v8::Isolate::UseCounterFeature feature);
1109 1112
1110 static Isolate* NewForTesting() { return new Isolate(); } 1113 private:
1114 static void EnsureInitialized();
1111 1115
1112 private:
1113 Isolate(); 1116 Isolate();
1114 1117
1115 friend struct GlobalState; 1118 friend struct GlobalState;
1116 friend struct InitializeGlobalState; 1119 friend struct InitializeGlobalState;
1117 1120
1118 enum State { 1121 enum State {
1119 UNINITIALIZED, // Some components may not have been allocated. 1122 UNINITIALIZED, // Some components may not have been allocated.
1120 INITIALIZED // All components are fully initialized. 1123 INITIALIZED // All components are fully initialized.
1121 }; 1124 };
1122 1125
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 1164
1162 int entry_count; 1165 int entry_count;
1163 PerIsolateThreadData* previous_thread_data; 1166 PerIsolateThreadData* previous_thread_data;
1164 Isolate* previous_isolate; 1167 Isolate* previous_isolate;
1165 EntryStackItem* previous_item; 1168 EntryStackItem* previous_item;
1166 1169
1167 private: 1170 private:
1168 DISALLOW_COPY_AND_ASSIGN(EntryStackItem); 1171 DISALLOW_COPY_AND_ASSIGN(EntryStackItem);
1169 }; 1172 };
1170 1173
1171 static base::LazyMutex thread_data_table_mutex_; 1174 // This mutex protects highest_thread_id_ and thread_data_table_.
1175 static base::LazyMutex process_wide_mutex_;
1172 1176
1173 static base::Thread::LocalStorageKey per_isolate_thread_data_key_; 1177 static base::Thread::LocalStorageKey per_isolate_thread_data_key_;
1174 static base::Thread::LocalStorageKey isolate_key_; 1178 static base::Thread::LocalStorageKey isolate_key_;
1175 static base::Thread::LocalStorageKey thread_id_key_; 1179 static base::Thread::LocalStorageKey thread_id_key_;
1176 static ThreadDataTable* thread_data_table_; 1180 static ThreadDataTable* thread_data_table_;
1177 1181
1178 // A global counter for all generated Isolates, might overflow. 1182 // A global counter for all generated Isolates, might overflow.
1179 static base::Atomic32 isolate_counter_; 1183 static base::Atomic32 isolate_counter_;
1180 1184
1181 void Deinit(); 1185 void Deinit();
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 } 1553 }
1550 1554
1551 EmbeddedVector<char, 128> filename_; 1555 EmbeddedVector<char, 128> filename_;
1552 FILE* file_; 1556 FILE* file_;
1553 int scope_depth_; 1557 int scope_depth_;
1554 }; 1558 };
1555 1559
1556 } } // namespace v8::internal 1560 } } // namespace v8::internal
1557 1561
1558 #endif // V8_ISOLATE_H_ 1562 #endif // V8_ISOLATE_H_
OLDNEW
« no previous file with comments | « src/d8.cc ('k') | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698