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

Side by Side Diff: src/isolate.cc

Issue 6903154: Revert "This implements per-isolate locking and unlocking, including tests" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 7 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/isolate.h ('k') | src/objects.h » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 ScopedLock lock(process_wide_mutex_); 304 ScopedLock lock(process_wide_mutex_);
305 per_thread = thread_data_table_->Lookup(this, thread_id); 305 per_thread = thread_data_table_->Lookup(this, thread_id);
306 if (per_thread == NULL) { 306 if (per_thread == NULL) {
307 per_thread = AllocatePerIsolateThreadData(thread_id); 307 per_thread = AllocatePerIsolateThreadData(thread_id);
308 } 308 }
309 } 309 }
310 return per_thread; 310 return per_thread;
311 } 311 }
312 312
313 313
314 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThisThread() {
315 ThreadId thread_id = ThreadId::Current();
316 PerIsolateThreadData* per_thread = NULL;
317 {
318 ScopedLock lock(process_wide_mutex_);
319 per_thread = thread_data_table_->Lookup(this, thread_id);
320 }
321 return per_thread;
322 }
323
324
325 void Isolate::EnsureDefaultIsolate() { 314 void Isolate::EnsureDefaultIsolate() {
326 ScopedLock lock(process_wide_mutex_); 315 ScopedLock lock(process_wide_mutex_);
327 if (default_isolate_ == NULL) { 316 if (default_isolate_ == NULL) {
328 isolate_key_ = Thread::CreateThreadLocalKey(); 317 isolate_key_ = Thread::CreateThreadLocalKey();
329 thread_id_key_ = Thread::CreateThreadLocalKey(); 318 thread_id_key_ = Thread::CreateThreadLocalKey();
330 per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey(); 319 per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey();
331 thread_data_table_ = new Isolate::ThreadDataTable(); 320 thread_data_table_ = new Isolate::ThreadDataTable();
332 default_isolate_ = new Isolate(); 321 default_isolate_ = new Isolate();
333 } 322 }
334 // Can't use SetIsolateThreadLocals(default_isolate_, NULL) here 323 // Can't use SetIsolateThreadLocals(default_isolate_, NULL) here
335 // becase a non-null thread data may be already set. 324 // becase a non-null thread data may be already set.
336 if (Thread::GetThreadLocal(isolate_key_) == NULL) { 325 Thread::SetThreadLocal(isolate_key_, default_isolate_);
337 Thread::SetThreadLocal(isolate_key_, default_isolate_);
338 }
339 CHECK(default_isolate_->PreInit()); 326 CHECK(default_isolate_->PreInit());
340 } 327 }
341 328
342 329
343 #ifdef ENABLE_DEBUGGER_SUPPORT 330 #ifdef ENABLE_DEBUGGER_SUPPORT
344 Debugger* Isolate::GetDefaultIsolateDebugger() { 331 Debugger* Isolate::GetDefaultIsolateDebugger() {
345 EnsureDefaultIsolate(); 332 EnsureDefaultIsolate();
346 return default_isolate_->debugger(); 333 return default_isolate_->debugger();
347 } 334 }
348 #endif 335 #endif
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 result_constant_list_(0) { 451 result_constant_list_(0) {
465 TRACE_ISOLATE(constructor); 452 TRACE_ISOLATE(constructor);
466 453
467 memset(isolate_addresses_, 0, 454 memset(isolate_addresses_, 0,
468 sizeof(isolate_addresses_[0]) * (k_isolate_address_count + 1)); 455 sizeof(isolate_addresses_[0]) * (k_isolate_address_count + 1));
469 456
470 heap_.isolate_ = this; 457 heap_.isolate_ = this;
471 zone_.isolate_ = this; 458 zone_.isolate_ = this;
472 stack_guard_.isolate_ = this; 459 stack_guard_.isolate_ = this;
473 460
474 // ThreadManager is initialized early to support locking an isolate
475 // before it is entered.
476 thread_manager_ = new ThreadManager();
477 thread_manager_->isolate_ = this;
478
479 #if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__) || \ 461 #if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__) || \
480 defined(V8_TARGET_ARCH_MIPS) && !defined(__mips__) 462 defined(V8_TARGET_ARCH_MIPS) && !defined(__mips__)
481 simulator_initialized_ = false; 463 simulator_initialized_ = false;
482 simulator_i_cache_ = NULL; 464 simulator_i_cache_ = NULL;
483 simulator_redirection_ = NULL; 465 simulator_redirection_ = NULL;
484 #endif 466 #endif
485 467
486 #ifdef DEBUG 468 #ifdef DEBUG
487 // heap_histograms_ initializes itself. 469 // heap_histograms_ initializes itself.
488 memset(&js_spill_information_, 0, sizeof(js_spill_information_)); 470 memset(&js_spill_information_, 0, sizeof(js_spill_information_));
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 #endif 636 #endif
655 } 637 }
656 638
657 639
658 bool Isolate::PreInit() { 640 bool Isolate::PreInit() {
659 if (state_ != UNINITIALIZED) return true; 641 if (state_ != UNINITIALIZED) return true;
660 642
661 TRACE_ISOLATE(preinit); 643 TRACE_ISOLATE(preinit);
662 644
663 ASSERT(Isolate::Current() == this); 645 ASSERT(Isolate::Current() == this);
646
664 #ifdef ENABLE_DEBUGGER_SUPPORT 647 #ifdef ENABLE_DEBUGGER_SUPPORT
665 debug_ = new Debug(this); 648 debug_ = new Debug(this);
666 debugger_ = new Debugger(); 649 debugger_ = new Debugger();
667 debugger_->isolate_ = this; 650 debugger_->isolate_ = this;
668 #endif 651 #endif
669 652
670 memory_allocator_ = new MemoryAllocator(); 653 memory_allocator_ = new MemoryAllocator();
671 memory_allocator_->isolate_ = this; 654 memory_allocator_->isolate_ = this;
672 code_range_ = new CodeRange(); 655 code_range_ = new CodeRange();
673 code_range_->isolate_ = this; 656 code_range_->isolate_ = this;
674 657
675 // Safe after setting Heap::isolate_, initializing StackGuard and 658 // Safe after setting Heap::isolate_, initializing StackGuard and
676 // ensuring that Isolate::Current() == this. 659 // ensuring that Isolate::Current() == this.
677 heap_.SetStackLimits(); 660 heap_.SetStackLimits();
678 661
679 #ifdef DEBUG 662 #ifdef DEBUG
680 DisallowAllocationFailure disallow_allocation_failure; 663 DisallowAllocationFailure disallow_allocation_failure;
681 #endif 664 #endif
682 665
683 #define C(name) isolate_addresses_[Isolate::k_##name] = \ 666 #define C(name) isolate_addresses_[Isolate::k_##name] = \
684 reinterpret_cast<Address>(name()); 667 reinterpret_cast<Address>(name());
685 ISOLATE_ADDRESS_LIST(C) 668 ISOLATE_ADDRESS_LIST(C)
686 ISOLATE_ADDRESS_LIST_PROF(C) 669 ISOLATE_ADDRESS_LIST_PROF(C)
687 #undef C 670 #undef C
688 671
689 string_tracker_ = new StringTracker(); 672 string_tracker_ = new StringTracker();
690 string_tracker_->isolate_ = this; 673 string_tracker_->isolate_ = this;
674 thread_manager_ = new ThreadManager();
675 thread_manager_->isolate_ = this;
691 compilation_cache_ = new CompilationCache(this); 676 compilation_cache_ = new CompilationCache(this);
692 transcendental_cache_ = new TranscendentalCache(); 677 transcendental_cache_ = new TranscendentalCache();
693 keyed_lookup_cache_ = new KeyedLookupCache(); 678 keyed_lookup_cache_ = new KeyedLookupCache();
694 context_slot_cache_ = new ContextSlotCache(); 679 context_slot_cache_ = new ContextSlotCache();
695 descriptor_lookup_cache_ = new DescriptorLookupCache(); 680 descriptor_lookup_cache_ = new DescriptorLookupCache();
696 unicode_cache_ = new UnicodeCache(); 681 unicode_cache_ = new UnicodeCache();
697 pc_to_code_cache_ = new PcToCodeCache(this); 682 pc_to_code_cache_ = new PcToCodeCache(this);
698 write_input_buffer_ = new StringInputBuffer(); 683 write_input_buffer_ = new StringInputBuffer();
699 global_handles_ = new GlobalHandles(this); 684 global_handles_ = new GlobalHandles(this);
700 bootstrapper_ = new Bootstrapper(); 685 bootstrapper_ = new Bootstrapper();
701 handle_scope_implementer_ = new HandleScopeImplementer(this); 686 handle_scope_implementer_ = new HandleScopeImplementer();
702 stub_cache_ = new StubCache(this); 687 stub_cache_ = new StubCache(this);
703 ast_sentinels_ = new AstSentinels(); 688 ast_sentinels_ = new AstSentinels();
704 regexp_stack_ = new RegExpStack(); 689 regexp_stack_ = new RegExpStack();
705 regexp_stack_->isolate_ = this; 690 regexp_stack_->isolate_ = this;
706 691
707 #ifdef ENABLE_LOGGING_AND_PROFILING 692 #ifdef ENABLE_LOGGING_AND_PROFILING
708 producer_heap_profile_ = new ProducerHeapProfile(); 693 producer_heap_profile_ = new ProducerHeapProfile();
709 producer_heap_profile_->isolate_ = this; 694 producer_heap_profile_->isolate_ = this;
710 #endif 695 #endif
711 696
712 state_ = PREINITIALIZED; 697 state_ = PREINITIALIZED;
713 return true; 698 return true;
714 } 699 }
715 700
716 701
717 void Isolate::InitializeThreadLocal() { 702 void Isolate::InitializeThreadLocal() {
718 thread_local_top_.isolate_ = this;
719 thread_local_top_.Initialize(); 703 thread_local_top_.Initialize();
720 clear_pending_exception(); 704 clear_pending_exception();
721 clear_pending_message(); 705 clear_pending_message();
722 clear_scheduled_exception(); 706 clear_scheduled_exception();
723 } 707 }
724 708
725 709
726 void Isolate::PropagatePendingExceptionToExternalTryCatch() { 710 void Isolate::PropagatePendingExceptionToExternalTryCatch() {
727 ASSERT(has_pending_exception()); 711 ASSERT(has_pending_exception());
728 712
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 907
924 #ifdef DEBUG 908 #ifdef DEBUG
925 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 909 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
926 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 910 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
927 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 911 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
928 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 912 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
929 #undef ISOLATE_FIELD_OFFSET 913 #undef ISOLATE_FIELD_OFFSET
930 #endif 914 #endif
931 915
932 } } // namespace v8::internal 916 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698