| 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 storage->LinkTo(&free_list_); | 338 storage->LinkTo(&free_list_); |
| 339 } | 339 } |
| 340 | 340 |
| 341 Isolate* Isolate::default_isolate_ = NULL; | 341 Isolate* Isolate::default_isolate_ = NULL; |
| 342 Thread::LocalStorageKey Isolate::isolate_key_; | 342 Thread::LocalStorageKey Isolate::isolate_key_; |
| 343 Thread::LocalStorageKey Isolate::thread_id_key_; | 343 Thread::LocalStorageKey Isolate::thread_id_key_; |
| 344 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; | 344 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; |
| 345 #ifdef DEBUG | 345 #ifdef DEBUG |
| 346 Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; | 346 Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; |
| 347 #endif // DEBUG | 347 #endif // DEBUG |
| 348 RecursiveMutex Isolate::process_wide_mutex_; | 348 Mutex Isolate::process_wide_mutex_; |
| 349 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL; | 349 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL; |
| 350 Atomic32 Isolate::isolate_counter_ = 0; | 350 Atomic32 Isolate::isolate_counter_ = 0; |
| 351 | 351 |
| 352 Isolate::PerIsolateThreadData* Isolate::AllocatePerIsolateThreadData( | |
| 353 ThreadId thread_id) { | |
| 354 ASSERT(!thread_id.Equals(ThreadId::Invalid())); | |
| 355 PerIsolateThreadData* per_thread = new PerIsolateThreadData(this, thread_id); | |
| 356 { | |
| 357 LockGuard<RecursiveMutex> lock_guard(&process_wide_mutex_); | |
| 358 ASSERT(thread_data_table_->Lookup(this, thread_id) == NULL); | |
| 359 thread_data_table_->Insert(per_thread); | |
| 360 ASSERT(thread_data_table_->Lookup(this, thread_id) == per_thread); | |
| 361 } | |
| 362 return per_thread; | |
| 363 } | |
| 364 | |
| 365 | |
| 366 Isolate::PerIsolateThreadData* | 352 Isolate::PerIsolateThreadData* |
| 367 Isolate::FindOrAllocatePerThreadDataForThisThread() { | 353 Isolate::FindOrAllocatePerThreadDataForThisThread() { |
| 368 ThreadId thread_id = ThreadId::Current(); | 354 ThreadId thread_id = ThreadId::Current(); |
| 369 PerIsolateThreadData* per_thread = NULL; | 355 PerIsolateThreadData* per_thread = NULL; |
| 370 { | 356 { |
| 371 LockGuard<RecursiveMutex> lock_guard(&process_wide_mutex_); | 357 LockGuard<Mutex> lock_guard(&process_wide_mutex_); |
| 372 per_thread = thread_data_table_->Lookup(this, thread_id); | 358 per_thread = thread_data_table_->Lookup(this, thread_id); |
| 373 if (per_thread == NULL) { | 359 if (per_thread == NULL) { |
| 374 per_thread = AllocatePerIsolateThreadData(thread_id); | 360 per_thread = new PerIsolateThreadData(this, thread_id); |
| 361 thread_data_table_->Insert(per_thread); |
| 375 } | 362 } |
| 376 } | 363 } |
| 364 ASSERT(thread_data_table_->Lookup(this, thread_id) == per_thread); |
| 377 return per_thread; | 365 return per_thread; |
| 378 } | 366 } |
| 379 | 367 |
| 380 | 368 |
| 381 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThisThread() { | 369 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThisThread() { |
| 382 ThreadId thread_id = ThreadId::Current(); | 370 ThreadId thread_id = ThreadId::Current(); |
| 383 return FindPerThreadDataForThread(thread_id); | 371 return FindPerThreadDataForThread(thread_id); |
| 384 } | 372 } |
| 385 | 373 |
| 386 | 374 |
| 387 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThread( | 375 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThread( |
| 388 ThreadId thread_id) { | 376 ThreadId thread_id) { |
| 389 PerIsolateThreadData* per_thread = NULL; | 377 PerIsolateThreadData* per_thread = NULL; |
| 390 { | 378 { |
| 391 LockGuard<RecursiveMutex> lock_guard(&process_wide_mutex_); | 379 LockGuard<Mutex> lock_guard(&process_wide_mutex_); |
| 392 per_thread = thread_data_table_->Lookup(this, thread_id); | 380 per_thread = thread_data_table_->Lookup(this, thread_id); |
| 393 } | 381 } |
| 394 return per_thread; | 382 return per_thread; |
| 395 } | 383 } |
| 396 | 384 |
| 397 | 385 |
| 398 void Isolate::EnsureDefaultIsolate() { | 386 void Isolate::EnsureDefaultIsolate() { |
| 399 LockGuard<RecursiveMutex> lock_guard(&process_wide_mutex_); | 387 LockGuard<Mutex> lock_guard(&process_wide_mutex_); |
| 400 if (default_isolate_ == NULL) { | 388 if (default_isolate_ == NULL) { |
| 401 isolate_key_ = Thread::CreateThreadLocalKey(); | 389 isolate_key_ = Thread::CreateThreadLocalKey(); |
| 402 thread_id_key_ = Thread::CreateThreadLocalKey(); | 390 thread_id_key_ = Thread::CreateThreadLocalKey(); |
| 403 per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey(); | 391 per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey(); |
| 404 #ifdef DEBUG | 392 #ifdef DEBUG |
| 405 PerThreadAssertScopeBase::thread_local_key = Thread::CreateThreadLocalKey(); | 393 PerThreadAssertScopeBase::thread_local_key = Thread::CreateThreadLocalKey(); |
| 406 #endif // DEBUG | 394 #endif // DEBUG |
| 407 thread_data_table_ = new Isolate::ThreadDataTable(); | 395 thread_data_table_ = new Isolate::ThreadDataTable(); |
| 408 default_isolate_ = new Isolate(); | 396 default_isolate_ = new Isolate(); |
| 409 } | 397 } |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 reinterpret_cast<Address>(that->next_)); | 550 reinterpret_cast<Address>(that->next_)); |
| 563 thread_local_top()->catcher_ = NULL; | 551 thread_local_top()->catcher_ = NULL; |
| 564 SimulatorStack::UnregisterCTryCatch(); | 552 SimulatorStack::UnregisterCTryCatch(); |
| 565 } | 553 } |
| 566 | 554 |
| 567 | 555 |
| 568 Handle<String> Isolate::StackTraceString() { | 556 Handle<String> Isolate::StackTraceString() { |
| 569 if (stack_trace_nesting_level_ == 0) { | 557 if (stack_trace_nesting_level_ == 0) { |
| 570 stack_trace_nesting_level_++; | 558 stack_trace_nesting_level_++; |
| 571 HeapStringAllocator allocator; | 559 HeapStringAllocator allocator; |
| 572 StringStream::ClearMentionedObjectCache(); | 560 StringStream::ClearMentionedObjectCache(this); |
| 573 StringStream accumulator(&allocator); | 561 StringStream accumulator(&allocator); |
| 574 incomplete_message_ = &accumulator; | 562 incomplete_message_ = &accumulator; |
| 575 PrintStack(&accumulator); | 563 PrintStack(&accumulator); |
| 576 Handle<String> stack_trace = accumulator.ToString(); | 564 Handle<String> stack_trace = accumulator.ToString(this); |
| 577 incomplete_message_ = NULL; | 565 incomplete_message_ = NULL; |
| 578 stack_trace_nesting_level_ = 0; | 566 stack_trace_nesting_level_ = 0; |
| 579 return stack_trace; | 567 return stack_trace; |
| 580 } else if (stack_trace_nesting_level_ == 1) { | 568 } else if (stack_trace_nesting_level_ == 1) { |
| 581 stack_trace_nesting_level_++; | 569 stack_trace_nesting_level_++; |
| 582 OS::PrintError( | 570 OS::PrintError( |
| 583 "\n\nAttempt to print stack while printing stack (double fault)\n"); | 571 "\n\nAttempt to print stack while printing stack (double fault)\n"); |
| 584 OS::PrintError( | 572 OS::PrintError( |
| 585 "If you are lucky you may find a partial stack dump on stdout.\n\n"); | 573 "If you are lucky you may find a partial stack dump on stdout.\n\n"); |
| 586 incomplete_message_->OutputToStdOut(); | 574 incomplete_message_->OutputToStdOut(); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 if (stack_trace_nesting_level_ == 0) { | 854 if (stack_trace_nesting_level_ == 0) { |
| 867 stack_trace_nesting_level_++; | 855 stack_trace_nesting_level_++; |
| 868 | 856 |
| 869 StringAllocator* allocator; | 857 StringAllocator* allocator; |
| 870 if (preallocated_message_space_ == NULL) { | 858 if (preallocated_message_space_ == NULL) { |
| 871 allocator = new HeapStringAllocator(); | 859 allocator = new HeapStringAllocator(); |
| 872 } else { | 860 } else { |
| 873 allocator = preallocated_message_space_; | 861 allocator = preallocated_message_space_; |
| 874 } | 862 } |
| 875 | 863 |
| 876 StringStream::ClearMentionedObjectCache(); | 864 StringStream::ClearMentionedObjectCache(this); |
| 877 StringStream accumulator(allocator); | 865 StringStream accumulator(allocator); |
| 878 incomplete_message_ = &accumulator; | 866 incomplete_message_ = &accumulator; |
| 879 PrintStack(&accumulator); | 867 PrintStack(&accumulator); |
| 880 accumulator.OutputToFile(out); | 868 accumulator.OutputToFile(out); |
| 881 InitializeLoggingAndCounters(); | 869 InitializeLoggingAndCounters(); |
| 882 accumulator.Log(); | 870 accumulator.Log(); |
| 883 incomplete_message_ = NULL; | 871 incomplete_message_ = NULL; |
| 884 stack_trace_nesting_level_ = 0; | 872 stack_trace_nesting_level_ = 0; |
| 885 if (preallocated_message_space_ == NULL) { | 873 if (preallocated_message_space_ == NULL) { |
| 886 // Remove the HeapStringAllocator created above. | 874 // Remove the HeapStringAllocator created above. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 910 void Isolate::PrintStack(StringStream* accumulator) { | 898 void Isolate::PrintStack(StringStream* accumulator) { |
| 911 if (!IsInitialized()) { | 899 if (!IsInitialized()) { |
| 912 accumulator->Add( | 900 accumulator->Add( |
| 913 "\n==== JS stack trace is not available =======================\n\n"); | 901 "\n==== JS stack trace is not available =======================\n\n"); |
| 914 accumulator->Add( | 902 accumulator->Add( |
| 915 "\n==== Isolate for the thread is not initialized =============\n\n"); | 903 "\n==== Isolate for the thread is not initialized =============\n\n"); |
| 916 return; | 904 return; |
| 917 } | 905 } |
| 918 // The MentionedObjectCache is not GC-proof at the moment. | 906 // The MentionedObjectCache is not GC-proof at the moment. |
| 919 DisallowHeapAllocation no_gc; | 907 DisallowHeapAllocation no_gc; |
| 920 ASSERT(StringStream::IsMentionedObjectCacheClear()); | 908 ASSERT(StringStream::IsMentionedObjectCacheClear(this)); |
| 921 | 909 |
| 922 // Avoid printing anything if there are no frames. | 910 // Avoid printing anything if there are no frames. |
| 923 if (c_entry_fp(thread_local_top()) == 0) return; | 911 if (c_entry_fp(thread_local_top()) == 0) return; |
| 924 | 912 |
| 925 accumulator->Add( | 913 accumulator->Add( |
| 926 "\n==== JS stack trace =========================================\n\n"); | 914 "\n==== JS stack trace =========================================\n\n"); |
| 927 PrintFrames(this, accumulator, StackFrame::OVERVIEW); | 915 PrintFrames(this, accumulator, StackFrame::OVERVIEW); |
| 928 | 916 |
| 929 accumulator->Add( | 917 accumulator->Add( |
| 930 "\n==== Details ================================================\n\n"); | 918 "\n==== Details ================================================\n\n"); |
| 931 PrintFrames(this, accumulator, StackFrame::DETAILS); | 919 PrintFrames(this, accumulator, StackFrame::DETAILS); |
| 932 | 920 |
| 933 accumulator->PrintMentionedObjectCache(); | 921 accumulator->PrintMentionedObjectCache(this); |
| 934 accumulator->Add("=====================\n\n"); | 922 accumulator->Add("=====================\n\n"); |
| 935 } | 923 } |
| 936 | 924 |
| 937 | 925 |
| 938 void Isolate::SetFailedAccessCheckCallback( | 926 void Isolate::SetFailedAccessCheckCallback( |
| 939 v8::FailedAccessCheckCallback callback) { | 927 v8::FailedAccessCheckCallback callback) { |
| 940 thread_local_top()->failed_access_check_callback_ = callback; | 928 thread_local_top()->failed_access_check_callback_ = callback; |
| 941 } | 929 } |
| 942 | 930 |
| 943 | 931 |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 stack_trace_for_uncaught_exceptions_options_); | 1352 stack_trace_for_uncaught_exceptions_options_); |
| 1365 } | 1353 } |
| 1366 } | 1354 } |
| 1367 | 1355 |
| 1368 Handle<Object> exception_arg = exception_handle; | 1356 Handle<Object> exception_arg = exception_handle; |
| 1369 // If the exception argument is a custom object, turn it into a string | 1357 // If the exception argument is a custom object, turn it into a string |
| 1370 // before throwing as uncaught exception. Note that the pending | 1358 // before throwing as uncaught exception. Note that the pending |
| 1371 // exception object to be set later must not be turned into a string. | 1359 // exception object to be set later must not be turned into a string. |
| 1372 if (exception_arg->IsJSObject() && !IsErrorObject(exception_arg)) { | 1360 if (exception_arg->IsJSObject() && !IsErrorObject(exception_arg)) { |
| 1373 bool failed = false; | 1361 bool failed = false; |
| 1374 exception_arg = Execution::ToDetailString(exception_arg, &failed); | 1362 exception_arg = |
| 1363 Execution::ToDetailString(this, exception_arg, &failed); |
| 1375 if (failed) { | 1364 if (failed) { |
| 1376 exception_arg = factory()->InternalizeOneByteString( | 1365 exception_arg = factory()->InternalizeOneByteString( |
| 1377 STATIC_ASCII_VECTOR("exception")); | 1366 STATIC_ASCII_VECTOR("exception")); |
| 1378 } | 1367 } |
| 1379 } | 1368 } |
| 1380 Handle<Object> message_obj = MessageHandler::MakeMessageObject( | 1369 Handle<Object> message_obj = MessageHandler::MakeMessageObject( |
| 1381 this, | 1370 this, |
| 1382 "uncaught_exception", | 1371 "uncaught_exception", |
| 1383 location, | 1372 location, |
| 1384 HandleVector<Object>(&exception_arg, 1), | 1373 HandleVector<Object>(&exception_arg, 1), |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 | 1702 |
| 1714 | 1703 |
| 1715 void Isolate::ThreadDataTable::Remove(PerIsolateThreadData* data) { | 1704 void Isolate::ThreadDataTable::Remove(PerIsolateThreadData* data) { |
| 1716 if (list_ == data) list_ = data->next_; | 1705 if (list_ == data) list_ = data->next_; |
| 1717 if (data->next_ != NULL) data->next_->prev_ = data->prev_; | 1706 if (data->next_ != NULL) data->next_->prev_ = data->prev_; |
| 1718 if (data->prev_ != NULL) data->prev_->next_ = data->next_; | 1707 if (data->prev_ != NULL) data->prev_->next_ = data->next_; |
| 1719 delete data; | 1708 delete data; |
| 1720 } | 1709 } |
| 1721 | 1710 |
| 1722 | 1711 |
| 1723 void Isolate::ThreadDataTable::Remove(Isolate* isolate, | |
| 1724 ThreadId thread_id) { | |
| 1725 PerIsolateThreadData* data = Lookup(isolate, thread_id); | |
| 1726 if (data != NULL) { | |
| 1727 Remove(data); | |
| 1728 } | |
| 1729 } | |
| 1730 | |
| 1731 | |
| 1732 void Isolate::ThreadDataTable::RemoveAllThreads(Isolate* isolate) { | 1712 void Isolate::ThreadDataTable::RemoveAllThreads(Isolate* isolate) { |
| 1733 PerIsolateThreadData* data = list_; | 1713 PerIsolateThreadData* data = list_; |
| 1734 while (data != NULL) { | 1714 while (data != NULL) { |
| 1735 PerIsolateThreadData* next = data->next_; | 1715 PerIsolateThreadData* next = data->next_; |
| 1736 if (data->isolate() == isolate) Remove(data); | 1716 if (data->isolate() == isolate) Remove(data); |
| 1737 data = next; | 1717 data = next; |
| 1738 } | 1718 } |
| 1739 } | 1719 } |
| 1740 | 1720 |
| 1741 | 1721 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1789 global_handles_(NULL), | 1769 global_handles_(NULL), |
| 1790 eternal_handles_(NULL), | 1770 eternal_handles_(NULL), |
| 1791 context_switcher_(NULL), | 1771 context_switcher_(NULL), |
| 1792 thread_manager_(NULL), | 1772 thread_manager_(NULL), |
| 1793 fp_stubs_generated_(false), | 1773 fp_stubs_generated_(false), |
| 1794 has_installed_extensions_(false), | 1774 has_installed_extensions_(false), |
| 1795 string_tracker_(NULL), | 1775 string_tracker_(NULL), |
| 1796 regexp_stack_(NULL), | 1776 regexp_stack_(NULL), |
| 1797 date_cache_(NULL), | 1777 date_cache_(NULL), |
| 1798 code_stub_interface_descriptors_(NULL), | 1778 code_stub_interface_descriptors_(NULL), |
| 1779 has_fatal_error_(false), |
| 1780 use_crankshaft_(true), |
| 1799 initialized_from_snapshot_(false), | 1781 initialized_from_snapshot_(false), |
| 1800 cpu_profiler_(NULL), | 1782 cpu_profiler_(NULL), |
| 1801 heap_profiler_(NULL), | 1783 heap_profiler_(NULL), |
| 1802 function_entry_hook_(NULL), | 1784 function_entry_hook_(NULL), |
| 1803 deferred_handles_head_(NULL), | 1785 deferred_handles_head_(NULL), |
| 1804 optimizing_compiler_thread_(this), | 1786 optimizing_compiler_thread_(this), |
| 1805 marking_thread_(NULL), | 1787 marking_thread_(NULL), |
| 1806 sweeper_thread_(NULL), | 1788 sweeper_thread_(NULL), |
| 1807 stress_deopt_count_(0) { | 1789 stress_deopt_count_(0) { |
| 1808 id_ = NoBarrier_AtomicIncrement(&isolate_counter_, 1); | 1790 id_ = NoBarrier_AtomicIncrement(&isolate_counter_, 1); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1859 // Temporarily set this isolate as current so that various parts of | 1841 // Temporarily set this isolate as current so that various parts of |
| 1860 // the isolate can access it in their destructors without having a | 1842 // the isolate can access it in their destructors without having a |
| 1861 // direct pointer. We don't use Enter/Exit here to avoid | 1843 // direct pointer. We don't use Enter/Exit here to avoid |
| 1862 // initializing the thread data. | 1844 // initializing the thread data. |
| 1863 PerIsolateThreadData* saved_data = CurrentPerIsolateThreadData(); | 1845 PerIsolateThreadData* saved_data = CurrentPerIsolateThreadData(); |
| 1864 Isolate* saved_isolate = UncheckedCurrent(); | 1846 Isolate* saved_isolate = UncheckedCurrent(); |
| 1865 SetIsolateThreadLocals(this, NULL); | 1847 SetIsolateThreadLocals(this, NULL); |
| 1866 | 1848 |
| 1867 Deinit(); | 1849 Deinit(); |
| 1868 | 1850 |
| 1869 { LockGuard<RecursiveMutex> lock_guard(&process_wide_mutex_); | 1851 { LockGuard<Mutex> lock_guard(&process_wide_mutex_); |
| 1870 thread_data_table_->RemoveAllThreads(this); | 1852 thread_data_table_->RemoveAllThreads(this); |
| 1871 } | 1853 } |
| 1872 | 1854 |
| 1873 if (serialize_partial_snapshot_cache_ != NULL) { | 1855 if (serialize_partial_snapshot_cache_ != NULL) { |
| 1874 delete[] serialize_partial_snapshot_cache_; | 1856 delete[] serialize_partial_snapshot_cache_; |
| 1875 serialize_partial_snapshot_cache_ = NULL; | 1857 serialize_partial_snapshot_cache_ = NULL; |
| 1876 } | 1858 } |
| 1877 | 1859 |
| 1878 if (!IsDefaultIsolate()) { | 1860 if (!IsDefaultIsolate()) { |
| 1879 delete this; | 1861 delete this; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2140 InitializeLoggingAndCounters(); | 2122 InitializeLoggingAndCounters(); |
| 2141 debug_ = new Debug(this); | 2123 debug_ = new Debug(this); |
| 2142 debugger_ = new Debugger(this); | 2124 debugger_ = new Debugger(this); |
| 2143 Release_Store(&debugger_initialized_, true); | 2125 Release_Store(&debugger_initialized_, true); |
| 2144 #endif | 2126 #endif |
| 2145 } | 2127 } |
| 2146 | 2128 |
| 2147 | 2129 |
| 2148 bool Isolate::Init(Deserializer* des) { | 2130 bool Isolate::Init(Deserializer* des) { |
| 2149 ASSERT(state_ != INITIALIZED); | 2131 ASSERT(state_ != INITIALIZED); |
| 2150 ASSERT(Isolate::Current() == this); | |
| 2151 TRACE_ISOLATE(init); | 2132 TRACE_ISOLATE(init); |
| 2152 | 2133 |
| 2153 stress_deopt_count_ = FLAG_deopt_every_n_times; | 2134 stress_deopt_count_ = FLAG_deopt_every_n_times; |
| 2154 | 2135 |
| 2136 has_fatal_error_ = false; |
| 2137 |
| 2138 use_crankshaft_ = FLAG_crankshaft |
| 2139 && !Serializer::enabled() |
| 2140 && CPU::SupportsCrankshaft(); |
| 2141 |
| 2155 if (function_entry_hook() != NULL) { | 2142 if (function_entry_hook() != NULL) { |
| 2156 // When function entry hooking is in effect, we have to create the code | 2143 // When function entry hooking is in effect, we have to create the code |
| 2157 // stubs from scratch to get entry hooks, rather than loading the previously | 2144 // stubs from scratch to get entry hooks, rather than loading the previously |
| 2158 // generated stubs from disk. | 2145 // generated stubs from disk. |
| 2159 // If this assert fires, the initialization path has regressed. | 2146 // If this assert fires, the initialization path has regressed. |
| 2160 ASSERT(des == NULL); | 2147 ASSERT(des == NULL); |
| 2161 } | 2148 } |
| 2162 | 2149 |
| 2163 // The initialization process does not handle memory exhaustion. | 2150 // The initialization process does not handle memory exhaustion. |
| 2164 DisallowAllocationFailure disallow_allocation_failure; | 2151 DisallowAllocationFailure disallow_allocation_failure; |
| 2165 | 2152 |
| 2166 InitializeLoggingAndCounters(); | 2153 InitializeLoggingAndCounters(); |
| 2167 | 2154 |
| 2168 InitializeDebugger(); | 2155 InitializeDebugger(); |
| 2169 | 2156 |
| 2170 memory_allocator_ = new MemoryAllocator(this); | 2157 memory_allocator_ = new MemoryAllocator(this); |
| 2171 code_range_ = new CodeRange(this); | 2158 code_range_ = new CodeRange(this); |
| 2172 | 2159 |
| 2173 // Safe after setting Heap::isolate_, initializing StackGuard and | 2160 // Safe after setting Heap::isolate_, and initializing StackGuard |
| 2174 // ensuring that Isolate::Current() == this. | |
| 2175 heap_.SetStackLimits(); | 2161 heap_.SetStackLimits(); |
| 2176 | 2162 |
| 2177 #define ASSIGN_ELEMENT(CamelName, hacker_name) \ | 2163 #define ASSIGN_ELEMENT(CamelName, hacker_name) \ |
| 2178 isolate_addresses_[Isolate::k##CamelName##Address] = \ | 2164 isolate_addresses_[Isolate::k##CamelName##Address] = \ |
| 2179 reinterpret_cast<Address>(hacker_name##_address()); | 2165 reinterpret_cast<Address>(hacker_name##_address()); |
| 2180 FOR_EACH_ISOLATE_ADDRESS_NAME(ASSIGN_ELEMENT) | 2166 FOR_EACH_ISOLATE_ADDRESS_NAME(ASSIGN_ELEMENT) |
| 2181 #undef ASSIGN_ELEMENT | 2167 #undef ASSIGN_ELEMENT |
| 2182 | 2168 |
| 2183 string_tracker_ = new StringTracker(); | 2169 string_tracker_ = new StringTracker(); |
| 2184 string_tracker_->isolate_ = this; | 2170 string_tracker_->isolate_ = this; |
| 2185 compilation_cache_ = new CompilationCache(this); | 2171 compilation_cache_ = new CompilationCache(this); |
| 2186 transcendental_cache_ = new TranscendentalCache(); | 2172 transcendental_cache_ = new TranscendentalCache(this); |
| 2187 keyed_lookup_cache_ = new KeyedLookupCache(); | 2173 keyed_lookup_cache_ = new KeyedLookupCache(); |
| 2188 context_slot_cache_ = new ContextSlotCache(); | 2174 context_slot_cache_ = new ContextSlotCache(); |
| 2189 descriptor_lookup_cache_ = new DescriptorLookupCache(); | 2175 descriptor_lookup_cache_ = new DescriptorLookupCache(); |
| 2190 unicode_cache_ = new UnicodeCache(); | 2176 unicode_cache_ = new UnicodeCache(); |
| 2191 inner_pointer_to_code_cache_ = new InnerPointerToCodeCache(this); | 2177 inner_pointer_to_code_cache_ = new InnerPointerToCodeCache(this); |
| 2192 write_iterator_ = new ConsStringIteratorOp(); | 2178 write_iterator_ = new ConsStringIteratorOp(); |
| 2193 global_handles_ = new GlobalHandles(this); | 2179 global_handles_ = new GlobalHandles(this); |
| 2194 eternal_handles_ = new EternalHandles(); | 2180 eternal_handles_ = new EternalHandles(); |
| 2195 bootstrapper_ = new Bootstrapper(this); | 2181 bootstrapper_ = new Bootstrapper(this); |
| 2196 handle_scope_implementer_ = new HandleScopeImplementer(this); | 2182 handle_scope_implementer_ = new HandleScopeImplementer(this); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2261 v8::Locker locker(reinterpret_cast<v8::Isolate*>(this)); | 2247 v8::Locker locker(reinterpret_cast<v8::Isolate*>(this)); |
| 2262 v8::Locker::StartPreemption(100); | 2248 v8::Locker::StartPreemption(100); |
| 2263 } | 2249 } |
| 2264 | 2250 |
| 2265 #ifdef ENABLE_DEBUGGER_SUPPORT | 2251 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 2266 debug_->SetUp(create_heap_objects); | 2252 debug_->SetUp(create_heap_objects); |
| 2267 #endif | 2253 #endif |
| 2268 | 2254 |
| 2269 // If we are deserializing, read the state into the now-empty heap. | 2255 // If we are deserializing, read the state into the now-empty heap. |
| 2270 if (!create_heap_objects) { | 2256 if (!create_heap_objects) { |
| 2271 des->Deserialize(); | 2257 des->Deserialize(this); |
| 2272 } | 2258 } |
| 2273 stub_cache_->Initialize(); | 2259 stub_cache_->Initialize(); |
| 2274 | 2260 |
| 2275 // Finish initialization of ThreadLocal after deserialization is done. | 2261 // Finish initialization of ThreadLocal after deserialization is done. |
| 2276 clear_pending_exception(); | 2262 clear_pending_exception(); |
| 2277 clear_pending_message(); | 2263 clear_pending_message(); |
| 2278 clear_scheduled_exception(); | 2264 clear_scheduled_exception(); |
| 2279 | 2265 |
| 2280 // Deserializing may put strange things in the root array's copy of the | 2266 // Deserializing may put strange things in the root array's copy of the |
| 2281 // stack guard. | 2267 // stack guard. |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2532 | 2518 |
| 2533 #ifdef DEBUG | 2519 #ifdef DEBUG |
| 2534 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2520 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
| 2535 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2521 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
| 2536 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2522 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
| 2537 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2523 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
| 2538 #undef ISOLATE_FIELD_OFFSET | 2524 #undef ISOLATE_FIELD_OFFSET |
| 2539 #endif | 2525 #endif |
| 2540 | 2526 |
| 2541 } } // namespace v8::internal | 2527 } } // namespace v8::internal |
| OLD | NEW |