OLD | NEW |
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 #include <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
11 #include "src/base/sys-info.h" | 11 #include "src/base/sys-info.h" |
12 #include "src/base/utils/random-number-generator.h" | 12 #include "src/base/utils/random-number-generator.h" |
13 #include "src/basic-block-profiler.h" | 13 #include "src/basic-block-profiler.h" |
14 #include "src/bootstrapper.h" | 14 #include "src/bootstrapper.h" |
15 #include "src/codegen.h" | 15 #include "src/codegen.h" |
16 #include "src/compilation-cache.h" | 16 #include "src/compilation-cache.h" |
17 #include "src/cpu-profiler.h" | 17 #include "src/cpu-profiler.h" |
18 #include "src/debug.h" | 18 #include "src/debug.h" |
19 #include "src/deoptimizer.h" | 19 #include "src/deoptimizer.h" |
20 #include "src/heap/spaces.h" | 20 #include "src/heap/spaces.h" |
21 #include "src/heap/sweeper-thread.h" | |
22 #include "src/heap-profiler.h" | 21 #include "src/heap-profiler.h" |
23 #include "src/hydrogen.h" | 22 #include "src/hydrogen.h" |
24 #include "src/ic/stub-cache.h" | 23 #include "src/ic/stub-cache.h" |
25 #include "src/isolate-inl.h" | 24 #include "src/isolate-inl.h" |
26 #include "src/lithium-allocator.h" | 25 #include "src/lithium-allocator.h" |
27 #include "src/log.h" | 26 #include "src/log.h" |
28 #include "src/messages.h" | 27 #include "src/messages.h" |
29 #include "src/prototype.h" | 28 #include "src/prototype.h" |
30 #include "src/regexp-stack.h" | 29 #include "src/regexp-stack.h" |
31 #include "src/runtime-profiler.h" | 30 #include "src/runtime-profiler.h" |
(...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 // be fixed once the default isolate cleanup is done. | 1498 // be fixed once the default isolate cleanup is done. |
1500 random_number_generator_(NULL), | 1499 random_number_generator_(NULL), |
1501 serializer_enabled_(false), | 1500 serializer_enabled_(false), |
1502 has_fatal_error_(false), | 1501 has_fatal_error_(false), |
1503 initialized_from_snapshot_(false), | 1502 initialized_from_snapshot_(false), |
1504 cpu_profiler_(NULL), | 1503 cpu_profiler_(NULL), |
1505 heap_profiler_(NULL), | 1504 heap_profiler_(NULL), |
1506 function_entry_hook_(NULL), | 1505 function_entry_hook_(NULL), |
1507 deferred_handles_head_(NULL), | 1506 deferred_handles_head_(NULL), |
1508 optimizing_compiler_thread_(NULL), | 1507 optimizing_compiler_thread_(NULL), |
1509 sweeper_thread_(NULL), | |
1510 num_sweeper_threads_(0), | |
1511 stress_deopt_count_(0), | 1508 stress_deopt_count_(0), |
1512 next_optimization_id_(0), | 1509 next_optimization_id_(0), |
1513 use_counter_callback_(NULL), | 1510 use_counter_callback_(NULL), |
1514 basic_block_profiler_(NULL) { | 1511 basic_block_profiler_(NULL) { |
1515 { | 1512 { |
1516 base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); | 1513 base::LockGuard<base::Mutex> lock_guard(thread_data_table_mutex_.Pointer()); |
1517 CHECK(thread_data_table_); | 1514 CHECK(thread_data_table_); |
1518 } | 1515 } |
1519 id_ = base::NoBarrier_AtomicIncrement(&isolate_counter_, 1); | 1516 id_ = base::NoBarrier_AtomicIncrement(&isolate_counter_, 1); |
1520 TRACE_ISOLATE(constructor); | 1517 TRACE_ISOLATE(constructor); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 debug()->Unload(); | 1592 debug()->Unload(); |
1596 | 1593 |
1597 FreeThreadResources(); | 1594 FreeThreadResources(); |
1598 | 1595 |
1599 if (concurrent_recompilation_enabled()) { | 1596 if (concurrent_recompilation_enabled()) { |
1600 optimizing_compiler_thread_->Stop(); | 1597 optimizing_compiler_thread_->Stop(); |
1601 delete optimizing_compiler_thread_; | 1598 delete optimizing_compiler_thread_; |
1602 optimizing_compiler_thread_ = NULL; | 1599 optimizing_compiler_thread_ = NULL; |
1603 } | 1600 } |
1604 | 1601 |
1605 for (int i = 0; i < num_sweeper_threads_; i++) { | 1602 if (heap_.mark_compact_collector()->sweeping_in_progress()) { |
1606 sweeper_thread_[i]->Stop(); | |
1607 delete sweeper_thread_[i]; | |
1608 sweeper_thread_[i] = NULL; | |
1609 } | |
1610 delete[] sweeper_thread_; | |
1611 sweeper_thread_ = NULL; | |
1612 | |
1613 if (FLAG_job_based_sweeping && | |
1614 heap_.mark_compact_collector()->sweeping_in_progress()) { | |
1615 heap_.mark_compact_collector()->EnsureSweepingCompleted(); | 1603 heap_.mark_compact_collector()->EnsureSweepingCompleted(); |
1616 } | 1604 } |
1617 | 1605 |
1618 if (FLAG_turbo_stats) GetTStatistics()->Print("TurboFan"); | 1606 if (FLAG_turbo_stats) GetTStatistics()->Print("TurboFan"); |
1619 if (FLAG_hydrogen_stats) GetHStatistics()->Print("Hydrogen"); | 1607 if (FLAG_hydrogen_stats) GetHStatistics()->Print("Hydrogen"); |
1620 | 1608 |
1621 if (FLAG_print_deopt_stress) { | 1609 if (FLAG_print_deopt_stress) { |
1622 PrintF(stdout, "=== Stress deopt counter: %u\n", stress_deopt_count_); | 1610 PrintF(stdout, "=== Stress deopt counter: %u\n", stress_deopt_count_); |
1623 } | 1611 } |
1624 | 1612 |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1933 | 1921 |
1934 // Set default value if not yet set. | 1922 // Set default value if not yet set. |
1935 // TODO(yangguo): move this to ResourceConstraints::ConfigureDefaults | 1923 // TODO(yangguo): move this to ResourceConstraints::ConfigureDefaults |
1936 // once ResourceConstraints becomes an argument to the Isolate constructor. | 1924 // once ResourceConstraints becomes an argument to the Isolate constructor. |
1937 if (max_available_threads_ < 1) { | 1925 if (max_available_threads_ < 1) { |
1938 // Choose the default between 1 and 4. | 1926 // Choose the default between 1 and 4. |
1939 max_available_threads_ = | 1927 max_available_threads_ = |
1940 Max(Min(base::SysInfo::NumberOfProcessors(), 4), 1); | 1928 Max(Min(base::SysInfo::NumberOfProcessors(), 4), 1); |
1941 } | 1929 } |
1942 | 1930 |
1943 if (!FLAG_job_based_sweeping) { | |
1944 num_sweeper_threads_ = | |
1945 SweeperThread::NumberOfThreads(max_available_threads_); | |
1946 } | |
1947 | |
1948 if (FLAG_trace_hydrogen || FLAG_trace_hydrogen_stubs) { | 1931 if (FLAG_trace_hydrogen || FLAG_trace_hydrogen_stubs) { |
1949 PrintF("Concurrent recompilation has been disabled for tracing.\n"); | 1932 PrintF("Concurrent recompilation has been disabled for tracing.\n"); |
1950 } else if (OptimizingCompilerThread::Enabled(max_available_threads_)) { | 1933 } else if (OptimizingCompilerThread::Enabled(max_available_threads_)) { |
1951 optimizing_compiler_thread_ = new OptimizingCompilerThread(this); | 1934 optimizing_compiler_thread_ = new OptimizingCompilerThread(this); |
1952 optimizing_compiler_thread_->Start(); | 1935 optimizing_compiler_thread_->Start(); |
1953 } | 1936 } |
1954 | 1937 |
1955 if (num_sweeper_threads_ > 0) { | |
1956 sweeper_thread_ = new SweeperThread*[num_sweeper_threads_]; | |
1957 for (int i = 0; i < num_sweeper_threads_; i++) { | |
1958 sweeper_thread_[i] = new SweeperThread(this); | |
1959 sweeper_thread_[i]->Start(); | |
1960 } | |
1961 } | |
1962 | |
1963 // If we are deserializing, read the state into the now-empty heap. | 1938 // If we are deserializing, read the state into the now-empty heap. |
1964 if (!create_heap_objects) { | 1939 if (!create_heap_objects) { |
1965 des->Deserialize(this); | 1940 des->Deserialize(this); |
1966 } | 1941 } |
1967 stub_cache_->Initialize(); | 1942 stub_cache_->Initialize(); |
1968 | 1943 |
1969 // Finish initialization of ThreadLocal after deserialization is done. | 1944 // Finish initialization of ThreadLocal after deserialization is done. |
1970 clear_pending_exception(); | 1945 clear_pending_exception(); |
1971 clear_pending_message(); | 1946 clear_pending_message(); |
1972 clear_scheduled_exception(); | 1947 clear_scheduled_exception(); |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2387 if (prev_ && prev_->Intercept(flag)) return true; | 2362 if (prev_ && prev_->Intercept(flag)) return true; |
2388 // Then check whether this scope intercepts. | 2363 // Then check whether this scope intercepts. |
2389 if ((flag & intercept_mask_)) { | 2364 if ((flag & intercept_mask_)) { |
2390 intercepted_flags_ |= flag; | 2365 intercepted_flags_ |= flag; |
2391 return true; | 2366 return true; |
2392 } | 2367 } |
2393 return false; | 2368 return false; |
2394 } | 2369 } |
2395 | 2370 |
2396 } } // namespace v8::internal | 2371 } } // namespace v8::internal |
OLD | NEW |