| 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 frames_seen++; | 646 frames_seen++; |
| 647 } | 647 } |
| 648 it.Advance(); | 648 it.Advance(); |
| 649 } | 649 } |
| 650 | 650 |
| 651 stack_trace->set_length(Smi::FromInt(frames_seen)); | 651 stack_trace->set_length(Smi::FromInt(frames_seen)); |
| 652 return stack_trace; | 652 return stack_trace; |
| 653 } | 653 } |
| 654 | 654 |
| 655 | 655 |
| 656 void Isolate::PrintStack() { | |
| 657 PrintStack(stdout); | |
| 658 } | |
| 659 | |
| 660 | |
| 661 void Isolate::PrintStack(FILE* out) { | 656 void Isolate::PrintStack(FILE* out) { |
| 662 if (stack_trace_nesting_level_ == 0) { | 657 if (stack_trace_nesting_level_ == 0) { |
| 663 stack_trace_nesting_level_++; | 658 stack_trace_nesting_level_++; |
| 664 StringStream::ClearMentionedObjectCache(this); | 659 StringStream::ClearMentionedObjectCache(this); |
| 665 HeapStringAllocator allocator; | 660 HeapStringAllocator allocator; |
| 666 StringStream accumulator(&allocator); | 661 StringStream accumulator(&allocator); |
| 667 incomplete_message_ = &accumulator; | 662 incomplete_message_ = &accumulator; |
| 668 PrintStack(&accumulator); | 663 PrintStack(&accumulator); |
| 669 accumulator.OutputToFile(out); | 664 accumulator.OutputToFile(out); |
| 670 InitializeLoggingAndCounters(); | 665 InitializeLoggingAndCounters(); |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 PrintF("Isolate %p (id %d)" #tag "\n", \ | 1512 PrintF("Isolate %p (id %d)" #tag "\n", \ |
| 1518 reinterpret_cast<void*>(this), id()); \ | 1513 reinterpret_cast<void*>(this), id()); \ |
| 1519 } \ | 1514 } \ |
| 1520 } while (false) | 1515 } while (false) |
| 1521 #else | 1516 #else |
| 1522 #define TRACE_ISOLATE(tag) | 1517 #define TRACE_ISOLATE(tag) |
| 1523 #endif | 1518 #endif |
| 1524 | 1519 |
| 1525 | 1520 |
| 1526 Isolate::Isolate() | 1521 Isolate::Isolate() |
| 1527 : state_(UNINITIALIZED), | 1522 : embedder_data_(), |
| 1528 embedder_data_(NULL), | 1523 state_(UNINITIALIZED), |
| 1529 entry_stack_(NULL), | 1524 entry_stack_(NULL), |
| 1530 stack_trace_nesting_level_(0), | 1525 stack_trace_nesting_level_(0), |
| 1531 incomplete_message_(NULL), | 1526 incomplete_message_(NULL), |
| 1532 bootstrapper_(NULL), | 1527 bootstrapper_(NULL), |
| 1533 runtime_profiler_(NULL), | 1528 runtime_profiler_(NULL), |
| 1534 compilation_cache_(NULL), | 1529 compilation_cache_(NULL), |
| 1535 counters_(NULL), | 1530 counters_(NULL), |
| 1536 code_range_(NULL), | 1531 code_range_(NULL), |
| 1537 debugger_initialized_(false), | 1532 debugger_initialized_(false), |
| 1538 logger_(NULL), | 1533 logger_(NULL), |
| 1539 stats_table_(NULL), | 1534 stats_table_(NULL), |
| 1540 stub_cache_(NULL), | 1535 stub_cache_(NULL), |
| 1541 deoptimizer_data_(NULL), | 1536 deoptimizer_data_(NULL), |
| 1542 capture_stack_trace_for_uncaught_exceptions_(false), | 1537 capture_stack_trace_for_uncaught_exceptions_(false), |
| 1543 stack_trace_for_uncaught_exceptions_frame_limit_(0), | 1538 stack_trace_for_uncaught_exceptions_frame_limit_(0), |
| 1544 stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview), | 1539 stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview), |
| 1545 transcendental_cache_(NULL), | 1540 transcendental_cache_(NULL), |
| 1546 memory_allocator_(NULL), | 1541 memory_allocator_(NULL), |
| 1547 keyed_lookup_cache_(NULL), | 1542 keyed_lookup_cache_(NULL), |
| 1548 context_slot_cache_(NULL), | 1543 context_slot_cache_(NULL), |
| 1549 descriptor_lookup_cache_(NULL), | 1544 descriptor_lookup_cache_(NULL), |
| 1550 handle_scope_implementer_(NULL), | 1545 handle_scope_implementer_(NULL), |
| 1551 unicode_cache_(NULL), | 1546 unicode_cache_(NULL), |
| 1552 runtime_zone_(this), | 1547 runtime_zone_(this), |
| 1553 inner_pointer_to_code_cache_(NULL), | 1548 inner_pointer_to_code_cache_(NULL), |
| 1554 write_iterator_(NULL), | 1549 write_iterator_(NULL), |
| 1555 global_handles_(NULL), | 1550 global_handles_(NULL), |
| 1556 eternal_handles_(NULL), | 1551 eternal_handles_(NULL), |
| 1557 context_switcher_(NULL), | |
| 1558 thread_manager_(NULL), | 1552 thread_manager_(NULL), |
| 1559 fp_stubs_generated_(false), | 1553 fp_stubs_generated_(false), |
| 1560 has_installed_extensions_(false), | 1554 has_installed_extensions_(false), |
| 1561 string_tracker_(NULL), | 1555 string_tracker_(NULL), |
| 1562 regexp_stack_(NULL), | 1556 regexp_stack_(NULL), |
| 1563 date_cache_(NULL), | 1557 date_cache_(NULL), |
| 1564 code_stub_interface_descriptors_(NULL), | 1558 code_stub_interface_descriptors_(NULL), |
| 1565 // TODO(bmeurer) Initialized lazily because it depends on flags; can | 1559 // TODO(bmeurer) Initialized lazily because it depends on flags; can |
| 1566 // be fixed once the default isolate cleanup is done. | 1560 // be fixed once the default isolate cleanup is done. |
| 1567 random_number_generator_(NULL), | 1561 random_number_generator_(NULL), |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 if (FLAG_print_deopt_stress) { | 1683 if (FLAG_print_deopt_stress) { |
| 1690 PrintF(stdout, "=== Stress deopt counter: %u\n", stress_deopt_count_); | 1684 PrintF(stdout, "=== Stress deopt counter: %u\n", stress_deopt_count_); |
| 1691 } | 1685 } |
| 1692 | 1686 |
| 1693 // We must stop the logger before we tear down other components. | 1687 // We must stop the logger before we tear down other components. |
| 1694 Sampler* sampler = logger_->sampler(); | 1688 Sampler* sampler = logger_->sampler(); |
| 1695 if (sampler && sampler->IsActive()) sampler->Stop(); | 1689 if (sampler && sampler->IsActive()) sampler->Stop(); |
| 1696 | 1690 |
| 1697 delete deoptimizer_data_; | 1691 delete deoptimizer_data_; |
| 1698 deoptimizer_data_ = NULL; | 1692 deoptimizer_data_ = NULL; |
| 1699 if (FLAG_preemption) { | |
| 1700 v8::Locker locker(reinterpret_cast<v8::Isolate*>(this)); | |
| 1701 v8::Locker::StopPreemption(reinterpret_cast<v8::Isolate*>(this)); | |
| 1702 } | |
| 1703 builtins_.TearDown(); | 1693 builtins_.TearDown(); |
| 1704 bootstrapper_->TearDown(); | 1694 bootstrapper_->TearDown(); |
| 1705 | 1695 |
| 1706 if (runtime_profiler_ != NULL) { | 1696 if (runtime_profiler_ != NULL) { |
| 1707 runtime_profiler_->TearDown(); | 1697 runtime_profiler_->TearDown(); |
| 1708 delete runtime_profiler_; | 1698 delete runtime_profiler_; |
| 1709 runtime_profiler_ = NULL; | 1699 runtime_profiler_ = NULL; |
| 1710 } | 1700 } |
| 1711 heap_.TearDown(); | 1701 heap_.TearDown(); |
| 1712 logger_->TearDown(); | 1702 logger_->TearDown(); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 | 1794 |
| 1805 delete compilation_cache_; | 1795 delete compilation_cache_; |
| 1806 compilation_cache_ = NULL; | 1796 compilation_cache_ = NULL; |
| 1807 delete bootstrapper_; | 1797 delete bootstrapper_; |
| 1808 bootstrapper_ = NULL; | 1798 bootstrapper_ = NULL; |
| 1809 delete inner_pointer_to_code_cache_; | 1799 delete inner_pointer_to_code_cache_; |
| 1810 inner_pointer_to_code_cache_ = NULL; | 1800 inner_pointer_to_code_cache_ = NULL; |
| 1811 delete write_iterator_; | 1801 delete write_iterator_; |
| 1812 write_iterator_ = NULL; | 1802 write_iterator_ = NULL; |
| 1813 | 1803 |
| 1814 delete context_switcher_; | |
| 1815 context_switcher_ = NULL; | |
| 1816 delete thread_manager_; | 1804 delete thread_manager_; |
| 1817 thread_manager_ = NULL; | 1805 thread_manager_ = NULL; |
| 1818 | 1806 |
| 1819 delete string_tracker_; | 1807 delete string_tracker_; |
| 1820 string_tracker_ = NULL; | 1808 string_tracker_ = NULL; |
| 1821 | 1809 |
| 1822 delete memory_allocator_; | 1810 delete memory_allocator_; |
| 1823 memory_allocator_ = NULL; | 1811 memory_allocator_ = NULL; |
| 1824 delete code_range_; | 1812 delete code_range_; |
| 1825 code_range_ = NULL; | 1813 code_range_ = NULL; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2037 } | 2025 } |
| 2038 | 2026 |
| 2039 if (num_sweeper_threads_ > 0) { | 2027 if (num_sweeper_threads_ > 0) { |
| 2040 sweeper_thread_ = new SweeperThread*[num_sweeper_threads_]; | 2028 sweeper_thread_ = new SweeperThread*[num_sweeper_threads_]; |
| 2041 for (int i = 0; i < num_sweeper_threads_; i++) { | 2029 for (int i = 0; i < num_sweeper_threads_; i++) { |
| 2042 sweeper_thread_[i] = new SweeperThread(this); | 2030 sweeper_thread_[i] = new SweeperThread(this); |
| 2043 sweeper_thread_[i]->Start(); | 2031 sweeper_thread_[i]->Start(); |
| 2044 } | 2032 } |
| 2045 } | 2033 } |
| 2046 | 2034 |
| 2047 if (FLAG_preemption) { | |
| 2048 v8::Locker locker(reinterpret_cast<v8::Isolate*>(this)); | |
| 2049 v8::Locker::StartPreemption(reinterpret_cast<v8::Isolate*>(this), 100); | |
| 2050 } | |
| 2051 | |
| 2052 #ifdef ENABLE_DEBUGGER_SUPPORT | 2035 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 2053 debug_->SetUp(create_heap_objects); | 2036 debug_->SetUp(create_heap_objects); |
| 2054 #endif | 2037 #endif |
| 2055 | 2038 |
| 2056 // If we are deserializing, read the state into the now-empty heap. | 2039 // If we are deserializing, read the state into the now-empty heap. |
| 2057 if (!create_heap_objects) { | 2040 if (!create_heap_objects) { |
| 2058 des->Deserialize(this); | 2041 des->Deserialize(this); |
| 2059 } | 2042 } |
| 2060 stub_cache_->Initialize(); | 2043 stub_cache_->Initialize(); |
| 2061 | 2044 |
| 2062 // Finish initialization of ThreadLocal after deserialization is done. | 2045 // Finish initialization of ThreadLocal after deserialization is done. |
| 2063 clear_pending_exception(); | 2046 clear_pending_exception(); |
| 2064 clear_pending_message(); | 2047 clear_pending_message(); |
| 2065 clear_scheduled_exception(); | 2048 clear_scheduled_exception(); |
| 2066 | 2049 |
| 2067 // Deserializing may put strange things in the root array's copy of the | 2050 // Deserializing may put strange things in the root array's copy of the |
| 2068 // stack guard. | 2051 // stack guard. |
| 2069 heap_.SetStackLimits(); | 2052 heap_.SetStackLimits(); |
| 2070 | 2053 |
| 2071 // Quiet the heap NaN if needed on target platform. | 2054 // Quiet the heap NaN if needed on target platform. |
| 2072 if (!create_heap_objects) Assembler::QuietNaN(heap_.nan_value()); | 2055 if (!create_heap_objects) Assembler::QuietNaN(heap_.nan_value()); |
| 2073 | 2056 |
| 2074 runtime_profiler_ = new RuntimeProfiler(this); | 2057 runtime_profiler_ = new RuntimeProfiler(this); |
| 2075 runtime_profiler_->SetUp(); | 2058 runtime_profiler_->SetUp(); |
| 2076 | 2059 |
| 2077 // If we are deserializing, log non-function code objects and compiled | 2060 // If we are deserializing, log non-function code objects and compiled |
| 2078 // functions found in the snapshot. | 2061 // functions found in the snapshot. |
| 2079 if (!create_heap_objects && | 2062 if (!create_heap_objects && |
| 2080 (FLAG_log_code || FLAG_ll_prof || logger_->is_logging_code_events())) { | 2063 (FLAG_log_code || |
| 2064 FLAG_ll_prof || |
| 2065 FLAG_perf_jit_prof || |
| 2066 FLAG_perf_basic_prof || |
| 2067 logger_->is_logging_code_events())) { |
| 2081 HandleScope scope(this); | 2068 HandleScope scope(this); |
| 2082 LOG(this, LogCodeObjects()); | 2069 LOG(this, LogCodeObjects()); |
| 2083 LOG(this, LogCompiledFunctions()); | 2070 LOG(this, LogCompiledFunctions()); |
| 2084 } | 2071 } |
| 2085 | 2072 |
| 2073 // If we are profiling with the Linux perf tool, we need to disable |
| 2074 // code relocation. |
| 2075 if (FLAG_perf_jit_prof || FLAG_perf_basic_prof) { |
| 2076 FLAG_compact_code_space = false; |
| 2077 } |
| 2078 |
| 2086 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, embedder_data_)), | 2079 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, embedder_data_)), |
| 2087 Internals::kIsolateEmbedderDataOffset); | 2080 Internals::kIsolateEmbedderDataOffset); |
| 2088 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, heap_.roots_)), | 2081 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, heap_.roots_)), |
| 2089 Internals::kIsolateRootsOffset); | 2082 Internals::kIsolateRootsOffset); |
| 2090 | 2083 |
| 2091 state_ = INITIALIZED; | 2084 state_ = INITIALIZED; |
| 2092 time_millis_at_init_ = OS::TimeCurrentMillis(); | 2085 time_millis_at_init_ = OS::TimeCurrentMillis(); |
| 2093 | 2086 |
| 2094 if (!create_heap_objects) { | 2087 if (!create_heap_objects) { |
| 2095 // Now that the heap is consistent, it's OK to generate the code for the | 2088 // Now that the heap is consistent, it's OK to generate the code for the |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2311 | 2304 |
| 2312 #ifdef DEBUG | 2305 #ifdef DEBUG |
| 2313 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2306 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
| 2314 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2307 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
| 2315 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2308 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
| 2316 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2309 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
| 2317 #undef ISOLATE_FIELD_OFFSET | 2310 #undef ISOLATE_FIELD_OFFSET |
| 2318 #endif | 2311 #endif |
| 2319 | 2312 |
| 2320 } } // namespace v8::internal | 2313 } } // namespace v8::internal |
| OLD | NEW |