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 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 inner_pointer_to_code_cache_(NULL), | 1628 inner_pointer_to_code_cache_(NULL), |
1629 write_input_buffer_(NULL), | 1629 write_input_buffer_(NULL), |
1630 global_handles_(NULL), | 1630 global_handles_(NULL), |
1631 context_switcher_(NULL), | 1631 context_switcher_(NULL), |
1632 thread_manager_(NULL), | 1632 thread_manager_(NULL), |
1633 fp_stubs_generated_(false), | 1633 fp_stubs_generated_(false), |
1634 has_installed_extensions_(false), | 1634 has_installed_extensions_(false), |
1635 string_tracker_(NULL), | 1635 string_tracker_(NULL), |
1636 regexp_stack_(NULL), | 1636 regexp_stack_(NULL), |
1637 date_cache_(NULL), | 1637 date_cache_(NULL), |
1638 code_stub_interface_descriptors_(NULL), | |
1639 context_exit_happened_(false), | 1638 context_exit_happened_(false), |
1640 deferred_handles_head_(NULL), | 1639 deferred_handles_head_(NULL), |
1641 optimizing_compiler_thread_(this) { | 1640 optimizing_compiler_thread_(this) { |
1642 TRACE_ISOLATE(constructor); | 1641 TRACE_ISOLATE(constructor); |
1643 | 1642 |
1644 memset(isolate_addresses_, 0, | 1643 memset(isolate_addresses_, 0, |
1645 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); | 1644 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); |
1646 | 1645 |
1647 heap_.isolate_ = this; | 1646 heap_.isolate_ = this; |
1648 stack_guard_.isolate_ = this; | 1647 stack_guard_.isolate_ = this; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 | 1790 |
1792 delete[] assembler_spare_buffer_; | 1791 delete[] assembler_spare_buffer_; |
1793 assembler_spare_buffer_ = NULL; | 1792 assembler_spare_buffer_ = NULL; |
1794 | 1793 |
1795 delete unicode_cache_; | 1794 delete unicode_cache_; |
1796 unicode_cache_ = NULL; | 1795 unicode_cache_ = NULL; |
1797 | 1796 |
1798 delete date_cache_; | 1797 delete date_cache_; |
1799 date_cache_ = NULL; | 1798 date_cache_ = NULL; |
1800 | 1799 |
1801 delete[] code_stub_interface_descriptors_; | |
1802 code_stub_interface_descriptors_ = NULL; | |
1803 | |
1804 delete regexp_stack_; | 1800 delete regexp_stack_; |
1805 regexp_stack_ = NULL; | 1801 regexp_stack_ = NULL; |
1806 | 1802 |
1807 delete descriptor_lookup_cache_; | 1803 delete descriptor_lookup_cache_; |
1808 descriptor_lookup_cache_ = NULL; | 1804 descriptor_lookup_cache_ = NULL; |
1809 delete context_slot_cache_; | 1805 delete context_slot_cache_; |
1810 context_slot_cache_ = NULL; | 1806 context_slot_cache_ = NULL; |
1811 delete keyed_lookup_cache_; | 1807 delete keyed_lookup_cache_; |
1812 keyed_lookup_cache_ = NULL; | 1808 keyed_lookup_cache_ = NULL; |
1813 | 1809 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1957 unicode_cache_ = new UnicodeCache(); | 1953 unicode_cache_ = new UnicodeCache(); |
1958 inner_pointer_to_code_cache_ = new InnerPointerToCodeCache(this); | 1954 inner_pointer_to_code_cache_ = new InnerPointerToCodeCache(this); |
1959 write_input_buffer_ = new StringInputBuffer(); | 1955 write_input_buffer_ = new StringInputBuffer(); |
1960 global_handles_ = new GlobalHandles(this); | 1956 global_handles_ = new GlobalHandles(this); |
1961 bootstrapper_ = new Bootstrapper(); | 1957 bootstrapper_ = new Bootstrapper(); |
1962 handle_scope_implementer_ = new HandleScopeImplementer(this); | 1958 handle_scope_implementer_ = new HandleScopeImplementer(this); |
1963 stub_cache_ = new StubCache(this, runtime_zone()); | 1959 stub_cache_ = new StubCache(this, runtime_zone()); |
1964 regexp_stack_ = new RegExpStack(); | 1960 regexp_stack_ = new RegExpStack(); |
1965 regexp_stack_->isolate_ = this; | 1961 regexp_stack_->isolate_ = this; |
1966 date_cache_ = new DateCache(); | 1962 date_cache_ = new DateCache(); |
1967 code_stub_interface_descriptors_ = | |
1968 new CodeStubInterfaceDescriptor[CodeStub::NUMBER_OF_IDS]; | |
1969 memset(code_stub_interface_descriptors_, 0, | |
1970 kPointerSize * CodeStub::NUMBER_OF_IDS); | |
1971 | 1963 |
1972 // Enable logging before setting up the heap | 1964 // Enable logging before setting up the heap |
1973 logger_->SetUp(); | 1965 logger_->SetUp(); |
1974 | 1966 |
1975 CpuProfiler::SetUp(); | 1967 CpuProfiler::SetUp(); |
1976 HeapProfiler::SetUp(); | 1968 HeapProfiler::SetUp(); |
1977 | 1969 |
1978 // Initialize other runtime facilities | 1970 // Initialize other runtime facilities |
1979 #if defined(USE_SIMULATOR) | 1971 #if defined(USE_SIMULATOR) |
1980 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) | 1972 #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_MIPS) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2021 | 2013 |
2022 if (FLAG_preemption) { | 2014 if (FLAG_preemption) { |
2023 v8::Locker locker; | 2015 v8::Locker locker; |
2024 v8::Locker::StartPreemption(100); | 2016 v8::Locker::StartPreemption(100); |
2025 } | 2017 } |
2026 | 2018 |
2027 #ifdef ENABLE_DEBUGGER_SUPPORT | 2019 #ifdef ENABLE_DEBUGGER_SUPPORT |
2028 debug_->SetUp(create_heap_objects); | 2020 debug_->SetUp(create_heap_objects); |
2029 #endif | 2021 #endif |
2030 | 2022 |
2031 deoptimizer_data_ = new DeoptimizerData; | |
2032 | |
2033 // If we are deserializing, read the state into the now-empty heap. | 2023 // If we are deserializing, read the state into the now-empty heap. |
2034 if (!create_heap_objects) { | 2024 if (!create_heap_objects) { |
2035 des->Deserialize(); | 2025 des->Deserialize(); |
2036 } | 2026 } |
2037 stub_cache_->Initialize(); | 2027 stub_cache_->Initialize(); |
2038 | 2028 |
2039 // Finish initialization of ThreadLocal after deserialization is done. | 2029 // Finish initialization of ThreadLocal after deserialization is done. |
2040 clear_pending_exception(); | 2030 clear_pending_exception(); |
2041 clear_pending_message(); | 2031 clear_pending_message(); |
2042 clear_scheduled_exception(); | 2032 clear_scheduled_exception(); |
2043 | 2033 |
2044 // Deserializing may put strange things in the root array's copy of the | 2034 // Deserializing may put strange things in the root array's copy of the |
2045 // stack guard. | 2035 // stack guard. |
2046 heap_.SetStackLimits(); | 2036 heap_.SetStackLimits(); |
2047 | 2037 |
2048 // Quiet the heap NaN if needed on target platform. | 2038 // Quiet the heap NaN if needed on target platform. |
2049 if (!create_heap_objects) Assembler::QuietNaN(heap_.nan_value()); | 2039 if (!create_heap_objects) Assembler::QuietNaN(heap_.nan_value()); |
2050 | 2040 |
| 2041 deoptimizer_data_ = new DeoptimizerData; |
2051 runtime_profiler_ = new RuntimeProfiler(this); | 2042 runtime_profiler_ = new RuntimeProfiler(this); |
2052 runtime_profiler_->SetUp(); | 2043 runtime_profiler_->SetUp(); |
2053 | 2044 |
2054 // If we are deserializing, log non-function code objects and compiled | 2045 // If we are deserializing, log non-function code objects and compiled |
2055 // functions found in the snapshot. | 2046 // functions found in the snapshot. |
2056 if (!create_heap_objects && | 2047 if (!create_heap_objects && |
2057 (FLAG_log_code || FLAG_ll_prof || logger_->is_logging_code_events())) { | 2048 (FLAG_log_code || FLAG_ll_prof || logger_->is_logging_code_events())) { |
2058 HandleScope scope; | 2049 HandleScope scope; |
2059 LOG(this, LogCodeObjects()); | 2050 LOG(this, LogCodeObjects()); |
2060 LOG(this, LogCompiledFunctions()); | 2051 LOG(this, LogCompiledFunctions()); |
2061 } | 2052 } |
2062 | 2053 |
2063 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, state_)), | 2054 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, state_)), |
2064 Internals::kIsolateStateOffset); | 2055 Internals::kIsolateStateOffset); |
2065 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, embedder_data_)), | 2056 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, embedder_data_)), |
2066 Internals::kIsolateEmbedderDataOffset); | 2057 Internals::kIsolateEmbedderDataOffset); |
2067 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, heap_.roots_)), | 2058 CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, heap_.roots_)), |
2068 Internals::kIsolateRootsOffset); | 2059 Internals::kIsolateRootsOffset); |
2069 | 2060 |
2070 state_ = INITIALIZED; | 2061 state_ = INITIALIZED; |
2071 time_millis_at_init_ = OS::TimeCurrentMillis(); | 2062 time_millis_at_init_ = OS::TimeCurrentMillis(); |
2072 | |
2073 if (!create_heap_objects) { | |
2074 // Now that the heap is consistent, it's OK to generate the code for the | |
2075 // deopt entry table that might have been referred to by optimized code in | |
2076 // the snapshot. | |
2077 HandleScope scope(this); | |
2078 Deoptimizer::EnsureCodeForDeoptimizationEntry( | |
2079 Deoptimizer::LAZY, | |
2080 kDeoptTableSerializeEntryCount - 1); | |
2081 } | |
2082 | |
2083 if (FLAG_parallel_recompilation) optimizing_compiler_thread_.Start(); | 2063 if (FLAG_parallel_recompilation) optimizing_compiler_thread_.Start(); |
2084 return true; | 2064 return true; |
2085 } | 2065 } |
2086 | 2066 |
2087 | 2067 |
2088 // Initialized lazily to allow early | 2068 // Initialized lazily to allow early |
2089 // v8::V8::SetAddHistogramSampleFunction calls. | 2069 // v8::V8::SetAddHistogramSampleFunction calls. |
2090 StatsTable* Isolate::stats_table() { | 2070 StatsTable* Isolate::stats_table() { |
2091 if (stats_table_ == NULL) { | 2071 if (stats_table_ == NULL) { |
2092 stats_table_ = new StatsTable; | 2072 stats_table_ = new StatsTable; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2187 } | 2167 } |
2188 if (deferred->next_ != NULL) { | 2168 if (deferred->next_ != NULL) { |
2189 deferred->next_->previous_ = deferred->previous_; | 2169 deferred->next_->previous_ = deferred->previous_; |
2190 } | 2170 } |
2191 if (deferred->previous_ != NULL) { | 2171 if (deferred->previous_ != NULL) { |
2192 deferred->previous_->next_ = deferred->next_; | 2172 deferred->previous_->next_ = deferred->next_; |
2193 } | 2173 } |
2194 } | 2174 } |
2195 | 2175 |
2196 | 2176 |
2197 CodeStubInterfaceDescriptor* | |
2198 Isolate::code_stub_interface_descriptor(int index) { | |
2199 return code_stub_interface_descriptors_ + index; | |
2200 } | |
2201 | |
2202 | |
2203 #ifdef DEBUG | 2177 #ifdef DEBUG |
2204 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2178 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
2205 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2179 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
2206 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2180 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
2207 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2181 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
2208 #undef ISOLATE_FIELD_OFFSET | 2182 #undef ISOLATE_FIELD_OFFSET |
2209 #endif | 2183 #endif |
2210 | 2184 |
2211 } } // namespace v8::internal | 2185 } } // namespace v8::internal |
OLD | NEW |