| 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 24 matching lines...) Expand all Loading... |
| 35 #include "codegen.h" | 35 #include "codegen.h" |
| 36 #include "compilation-cache.h" | 36 #include "compilation-cache.h" |
| 37 #include "cpu-profiler.h" | 37 #include "cpu-profiler.h" |
| 38 #include "debug.h" | 38 #include "debug.h" |
| 39 #include "deoptimizer.h" | 39 #include "deoptimizer.h" |
| 40 #include "heap-profiler.h" | 40 #include "heap-profiler.h" |
| 41 #include "hydrogen.h" | 41 #include "hydrogen.h" |
| 42 #include "isolate-inl.h" | 42 #include "isolate-inl.h" |
| 43 #include "lithium-allocator.h" | 43 #include "lithium-allocator.h" |
| 44 #include "log.h" | 44 #include "log.h" |
| 45 #include "marking-thread.h" | |
| 46 #include "messages.h" | 45 #include "messages.h" |
| 47 #include "platform.h" | 46 #include "platform.h" |
| 48 #include "regexp-stack.h" | 47 #include "regexp-stack.h" |
| 49 #include "runtime-profiler.h" | 48 #include "runtime-profiler.h" |
| 50 #include "sampler.h" | 49 #include "sampler.h" |
| 51 #include "scopeinfo.h" | 50 #include "scopeinfo.h" |
| 52 #include "serialize.h" | 51 #include "serialize.h" |
| 53 #include "simulator.h" | 52 #include "simulator.h" |
| 54 #include "spaces.h" | 53 #include "spaces.h" |
| 55 #include "stub-cache.h" | 54 #include "stub-cache.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 rethrowing_message_ = false; | 113 rethrowing_message_ = false; |
| 115 pending_message_obj_ = NULL; | 114 pending_message_obj_ = NULL; |
| 116 pending_message_script_ = NULL; | 115 pending_message_script_ = NULL; |
| 117 scheduled_exception_ = NULL; | 116 scheduled_exception_ = NULL; |
| 118 } | 117 } |
| 119 | 118 |
| 120 | 119 |
| 121 void ThreadLocalTop::Initialize() { | 120 void ThreadLocalTop::Initialize() { |
| 122 InitializeInternal(); | 121 InitializeInternal(); |
| 123 #ifdef USE_SIMULATOR | 122 #ifdef USE_SIMULATOR |
| 124 #if V8_TARGET_ARCH_A64 | |
| 125 simulator_ = Simulator::current(isolate_); | 123 simulator_ = Simulator::current(isolate_); |
| 126 #elif V8_TARGET_ARCH_ARM | |
| 127 simulator_ = Simulator::current(isolate_); | |
| 128 #elif V8_TARGET_ARCH_MIPS | |
| 129 simulator_ = Simulator::current(isolate_); | |
| 130 #endif | |
| 131 #endif | 124 #endif |
| 132 thread_id_ = ThreadId::Current(); | 125 thread_id_ = ThreadId::Current(); |
| 133 } | 126 } |
| 134 | 127 |
| 135 | 128 |
| 136 v8::TryCatch* ThreadLocalTop::TryCatchHandler() { | 129 v8::TryCatch* ThreadLocalTop::TryCatchHandler() { |
| 137 return TRY_CATCH_FROM_ADDRESS(try_catch_handler_address()); | 130 return TRY_CATCH_FROM_ADDRESS(try_catch_handler_address()); |
| 138 } | 131 } |
| 139 | 132 |
| 140 | 133 |
| 141 int SystemThreadManager::NumberOfParallelSystemThreads( | 134 int SystemThreadManager::NumberOfParallelSystemThreads( |
| 142 ParallelSystemComponent type) { | 135 ParallelSystemComponent type) { |
| 143 int number_of_threads = Min(CPU::NumberOfProcessorsOnline(), kMaxThreads); | 136 int number_of_threads = Min(CPU::NumberOfProcessorsOnline(), kMaxThreads); |
| 144 ASSERT(number_of_threads > 0); | 137 ASSERT(number_of_threads > 0); |
| 145 if (number_of_threads == 1) { | 138 if (number_of_threads == 1) { |
| 146 return 0; | 139 return 0; |
| 147 } | 140 } |
| 148 if (type == PARALLEL_SWEEPING) { | 141 if (type == PARALLEL_SWEEPING) { |
| 149 return number_of_threads; | 142 return number_of_threads; |
| 150 } else if (type == CONCURRENT_SWEEPING) { | 143 } else if (type == CONCURRENT_SWEEPING) { |
| 151 return number_of_threads - 1; | 144 return number_of_threads - 1; |
| 152 } else if (type == PARALLEL_MARKING) { | |
| 153 return number_of_threads; | |
| 154 } | 145 } |
| 155 return 1; | 146 return 1; |
| 156 } | 147 } |
| 157 | 148 |
| 158 | 149 |
| 159 // Create a dummy thread that will wait forever on a semaphore. The only | 150 // Create a dummy thread that will wait forever on a semaphore. The only |
| 160 // purpose for this thread is to have some stack area to save essential data | 151 // purpose for this thread is to have some stack area to save essential data |
| 161 // into for use by a stacks only core dump (aka minidump). | 152 // into for use by a stacks only core dump (aka minidump). |
| 162 class PreallocatedMemoryThread: public Thread { | 153 class PreallocatedMemoryThread: public Thread { |
| 163 public: | 154 public: |
| (...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 return to + sizeof(ThreadLocalTop); | 1659 return to + sizeof(ThreadLocalTop); |
| 1669 } | 1660 } |
| 1670 | 1661 |
| 1671 | 1662 |
| 1672 char* Isolate::RestoreThread(char* from) { | 1663 char* Isolate::RestoreThread(char* from) { |
| 1673 OS::MemCopy(reinterpret_cast<char*>(thread_local_top()), from, | 1664 OS::MemCopy(reinterpret_cast<char*>(thread_local_top()), from, |
| 1674 sizeof(ThreadLocalTop)); | 1665 sizeof(ThreadLocalTop)); |
| 1675 // This might be just paranoia, but it seems to be needed in case a | 1666 // This might be just paranoia, but it seems to be needed in case a |
| 1676 // thread_local_top_ is restored on a separate OS thread. | 1667 // thread_local_top_ is restored on a separate OS thread. |
| 1677 #ifdef USE_SIMULATOR | 1668 #ifdef USE_SIMULATOR |
| 1678 #if V8_TARGET_ARCH_A64 | |
| 1679 thread_local_top()->simulator_ = Simulator::current(this); | 1669 thread_local_top()->simulator_ = Simulator::current(this); |
| 1680 #elif V8_TARGET_ARCH_ARM | |
| 1681 thread_local_top()->simulator_ = Simulator::current(this); | |
| 1682 #elif V8_TARGET_ARCH_MIPS | |
| 1683 thread_local_top()->simulator_ = Simulator::current(this); | |
| 1684 #endif | |
| 1685 #endif | 1670 #endif |
| 1686 ASSERT(context() == NULL || context()->IsContext()); | 1671 ASSERT(context() == NULL || context()->IsContext()); |
| 1687 return from + sizeof(ThreadLocalTop); | 1672 return from + sizeof(ThreadLocalTop); |
| 1688 } | 1673 } |
| 1689 | 1674 |
| 1690 | 1675 |
| 1691 Isolate::ThreadDataTable::ThreadDataTable() | 1676 Isolate::ThreadDataTable::ThreadDataTable() |
| 1692 : list_(NULL) { | 1677 : list_(NULL) { |
| 1693 } | 1678 } |
| 1694 | 1679 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 // be fixed once the default isolate cleanup is done. | 1782 // be fixed once the default isolate cleanup is done. |
| 1798 random_number_generator_(NULL), | 1783 random_number_generator_(NULL), |
| 1799 has_fatal_error_(false), | 1784 has_fatal_error_(false), |
| 1800 use_crankshaft_(true), | 1785 use_crankshaft_(true), |
| 1801 initialized_from_snapshot_(false), | 1786 initialized_from_snapshot_(false), |
| 1802 cpu_profiler_(NULL), | 1787 cpu_profiler_(NULL), |
| 1803 heap_profiler_(NULL), | 1788 heap_profiler_(NULL), |
| 1804 function_entry_hook_(NULL), | 1789 function_entry_hook_(NULL), |
| 1805 deferred_handles_head_(NULL), | 1790 deferred_handles_head_(NULL), |
| 1806 optimizing_compiler_thread_(NULL), | 1791 optimizing_compiler_thread_(NULL), |
| 1807 marking_thread_(NULL), | |
| 1808 sweeper_thread_(NULL), | 1792 sweeper_thread_(NULL), |
| 1809 stress_deopt_count_(0) { | 1793 stress_deopt_count_(0) { |
| 1810 id_ = NoBarrier_AtomicIncrement(&isolate_counter_, 1); | 1794 id_ = NoBarrier_AtomicIncrement(&isolate_counter_, 1); |
| 1811 TRACE_ISOLATE(constructor); | 1795 TRACE_ISOLATE(constructor); |
| 1812 | 1796 |
| 1813 memset(isolate_addresses_, 0, | 1797 memset(isolate_addresses_, 0, |
| 1814 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); | 1798 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); |
| 1815 | 1799 |
| 1816 heap_.isolate_ = this; | 1800 heap_.isolate_ = this; |
| 1817 stack_guard_.isolate_ = this; | 1801 stack_guard_.isolate_ = this; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1905 } | 1889 } |
| 1906 | 1890 |
| 1907 if (FLAG_sweeper_threads > 0) { | 1891 if (FLAG_sweeper_threads > 0) { |
| 1908 for (int i = 0; i < FLAG_sweeper_threads; i++) { | 1892 for (int i = 0; i < FLAG_sweeper_threads; i++) { |
| 1909 sweeper_thread_[i]->Stop(); | 1893 sweeper_thread_[i]->Stop(); |
| 1910 delete sweeper_thread_[i]; | 1894 delete sweeper_thread_[i]; |
| 1911 } | 1895 } |
| 1912 delete[] sweeper_thread_; | 1896 delete[] sweeper_thread_; |
| 1913 } | 1897 } |
| 1914 | 1898 |
| 1915 if (FLAG_marking_threads > 0) { | |
| 1916 for (int i = 0; i < FLAG_marking_threads; i++) { | |
| 1917 marking_thread_[i]->Stop(); | |
| 1918 delete marking_thread_[i]; | |
| 1919 } | |
| 1920 delete[] marking_thread_; | |
| 1921 } | |
| 1922 | |
| 1923 if (FLAG_hydrogen_stats) GetHStatistics()->Print(); | 1899 if (FLAG_hydrogen_stats) GetHStatistics()->Print(); |
| 1924 | 1900 |
| 1925 if (FLAG_print_deopt_stress) { | 1901 if (FLAG_print_deopt_stress) { |
| 1926 PrintF(stdout, "=== Stress deopt counter: %u\n", stress_deopt_count_); | 1902 PrintF(stdout, "=== Stress deopt counter: %u\n", stress_deopt_count_); |
| 1927 } | 1903 } |
| 1928 | 1904 |
| 1929 // We must stop the logger before we tear down other components. | 1905 // We must stop the logger before we tear down other components. |
| 1930 Sampler* sampler = logger_->sampler(); | 1906 Sampler* sampler = logger_->sampler(); |
| 1931 if (sampler && sampler->IsActive()) sampler->Stop(); | 1907 if (sampler && sampler->IsActive()) sampler->Stop(); |
| 1932 | 1908 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2339 CodeStub::GenerateFPStubs(this); | 2315 CodeStub::GenerateFPStubs(this); |
| 2340 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(this); | 2316 StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(this); |
| 2341 StubFailureTrampolineStub::GenerateAheadOfTime(this); | 2317 StubFailureTrampolineStub::GenerateAheadOfTime(this); |
| 2342 // TODO(mstarzinger): The following is an ugly hack to make sure the | 2318 // TODO(mstarzinger): The following is an ugly hack to make sure the |
| 2343 // interface descriptor is initialized even when stubs have been | 2319 // interface descriptor is initialized even when stubs have been |
| 2344 // deserialized out of the snapshot without the graph builder. | 2320 // deserialized out of the snapshot without the graph builder. |
| 2345 FastCloneShallowArrayStub stub(FastCloneShallowArrayStub::CLONE_ELEMENTS, | 2321 FastCloneShallowArrayStub stub(FastCloneShallowArrayStub::CLONE_ELEMENTS, |
| 2346 DONT_TRACK_ALLOCATION_SITE, 0); | 2322 DONT_TRACK_ALLOCATION_SITE, 0); |
| 2347 stub.InitializeInterfaceDescriptor( | 2323 stub.InitializeInterfaceDescriptor( |
| 2348 this, code_stub_interface_descriptor(CodeStub::FastCloneShallowArray)); | 2324 this, code_stub_interface_descriptor(CodeStub::FastCloneShallowArray)); |
| 2325 BinaryOpStub::InitializeForIsolate(this); |
| 2349 CompareNilICStub::InitializeForIsolate(this); | 2326 CompareNilICStub::InitializeForIsolate(this); |
| 2350 ToBooleanStub::InitializeForIsolate(this); | 2327 ToBooleanStub::InitializeForIsolate(this); |
| 2351 ArrayConstructorStubBase::InstallDescriptors(this); | 2328 ArrayConstructorStubBase::InstallDescriptors(this); |
| 2352 InternalArrayConstructorStubBase::InstallDescriptors(this); | 2329 InternalArrayConstructorStubBase::InstallDescriptors(this); |
| 2353 FastNewClosureStub::InstallDescriptors(this); | 2330 FastNewClosureStub::InstallDescriptors(this); |
| 2354 } | 2331 } |
| 2355 | 2332 |
| 2356 if (FLAG_marking_threads > 0) { | |
| 2357 marking_thread_ = new MarkingThread*[FLAG_marking_threads]; | |
| 2358 for (int i = 0; i < FLAG_marking_threads; i++) { | |
| 2359 marking_thread_[i] = new MarkingThread(this); | |
| 2360 marking_thread_[i]->Start(); | |
| 2361 } | |
| 2362 } | |
| 2363 | |
| 2364 if (FLAG_sweeper_threads > 0) { | 2333 if (FLAG_sweeper_threads > 0) { |
| 2365 sweeper_thread_ = new SweeperThread*[FLAG_sweeper_threads]; | 2334 sweeper_thread_ = new SweeperThread*[FLAG_sweeper_threads]; |
| 2366 for (int i = 0; i < FLAG_sweeper_threads; i++) { | 2335 for (int i = 0; i < FLAG_sweeper_threads; i++) { |
| 2367 sweeper_thread_[i] = new SweeperThread(this); | 2336 sweeper_thread_[i] = new SweeperThread(this); |
| 2368 sweeper_thread_[i]->Start(); | 2337 sweeper_thread_[i]->Start(); |
| 2369 } | 2338 } |
| 2370 } | 2339 } |
| 2371 | 2340 |
| 2372 initialized_from_snapshot_ = (des != NULL); | 2341 initialized_from_snapshot_ = (des != NULL); |
| 2373 | 2342 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2547 | 2516 |
| 2548 #ifdef DEBUG | 2517 #ifdef DEBUG |
| 2549 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2518 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
| 2550 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2519 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
| 2551 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2520 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
| 2552 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2521 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
| 2553 #undef ISOLATE_FIELD_OFFSET | 2522 #undef ISOLATE_FIELD_OFFSET |
| 2554 #endif | 2523 #endif |
| 2555 | 2524 |
| 2556 } } // namespace v8::internal | 2525 } } // namespace v8::internal |
| OLD | NEW |