| 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" |
| 11 #include "src/base/utils/random-number-generator.h" |
| 10 #include "src/bootstrapper.h" | 12 #include "src/bootstrapper.h" |
| 11 #include "src/codegen.h" | 13 #include "src/codegen.h" |
| 12 #include "src/compilation-cache.h" | 14 #include "src/compilation-cache.h" |
| 13 #include "src/cpu-profiler.h" | 15 #include "src/cpu-profiler.h" |
| 14 #include "src/debug.h" | 16 #include "src/debug.h" |
| 15 #include "src/deoptimizer.h" | 17 #include "src/deoptimizer.h" |
| 16 #include "src/heap-profiler.h" | 18 #include "src/heap-profiler.h" |
| 17 #include "src/hydrogen.h" | 19 #include "src/hydrogen.h" |
| 18 #include "src/isolate-inl.h" | 20 #include "src/isolate-inl.h" |
| 19 #include "src/lithium-allocator.h" | 21 #include "src/lithium-allocator.h" |
| 20 #include "src/log.h" | 22 #include "src/log.h" |
| 21 #include "src/messages.h" | 23 #include "src/messages.h" |
| 22 #include "src/platform.h" | |
| 23 #include "src/regexp-stack.h" | 24 #include "src/regexp-stack.h" |
| 24 #include "src/runtime-profiler.h" | 25 #include "src/runtime-profiler.h" |
| 25 #include "src/sampler.h" | 26 #include "src/sampler.h" |
| 26 #include "src/scopeinfo.h" | 27 #include "src/scopeinfo.h" |
| 27 #include "src/serialize.h" | 28 #include "src/serialize.h" |
| 28 #include "src/simulator.h" | 29 #include "src/simulator.h" |
| 29 #include "src/spaces.h" | 30 #include "src/spaces.h" |
| 30 #include "src/stub-cache.h" | 31 #include "src/stub-cache.h" |
| 31 #include "src/sweeper-thread.h" | 32 #include "src/sweeper-thread.h" |
| 32 #include "src/utils/random-number-generator.h" | |
| 33 #include "src/version.h" | 33 #include "src/version.h" |
| 34 #include "src/vm-state-inl.h" | 34 #include "src/vm-state-inl.h" |
| 35 | 35 |
| 36 | 36 |
| 37 namespace v8 { | 37 namespace v8 { |
| 38 namespace internal { | 38 namespace internal { |
| 39 | 39 |
| 40 base::Atomic32 ThreadId::highest_thread_id_ = 0; | 40 base::Atomic32 ThreadId::highest_thread_id_ = 0; |
| 41 | 41 |
| 42 int ThreadId::AllocateThreadId() { | 42 int ThreadId::AllocateThreadId() { |
| 43 int new_id = base::NoBarrier_AtomicIncrement(&highest_thread_id_, 1); | 43 int new_id = base::NoBarrier_AtomicIncrement(&highest_thread_id_, 1); |
| 44 return new_id; | 44 return new_id; |
| 45 } | 45 } |
| 46 | 46 |
| 47 | 47 |
| 48 int ThreadId::GetCurrentThreadId() { | 48 int ThreadId::GetCurrentThreadId() { |
| 49 int thread_id = Thread::GetThreadLocalInt(Isolate::thread_id_key_); | 49 int thread_id = base::Thread::GetThreadLocalInt(Isolate::thread_id_key_); |
| 50 if (thread_id == 0) { | 50 if (thread_id == 0) { |
| 51 thread_id = AllocateThreadId(); | 51 thread_id = AllocateThreadId(); |
| 52 Thread::SetThreadLocalInt(Isolate::thread_id_key_, thread_id); | 52 base::Thread::SetThreadLocalInt(Isolate::thread_id_key_, thread_id); |
| 53 } | 53 } |
| 54 return thread_id; | 54 return thread_id; |
| 55 } | 55 } |
| 56 | 56 |
| 57 | 57 |
| 58 ThreadLocalTop::ThreadLocalTop() { | 58 ThreadLocalTop::ThreadLocalTop() { |
| 59 InitializeInternal(); | 59 InitializeInternal(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 | 62 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 91 | 91 |
| 92 void ThreadLocalTop::Initialize() { | 92 void ThreadLocalTop::Initialize() { |
| 93 InitializeInternal(); | 93 InitializeInternal(); |
| 94 #ifdef USE_SIMULATOR | 94 #ifdef USE_SIMULATOR |
| 95 simulator_ = Simulator::current(isolate_); | 95 simulator_ = Simulator::current(isolate_); |
| 96 #endif | 96 #endif |
| 97 thread_id_ = ThreadId::Current(); | 97 thread_id_ = ThreadId::Current(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 | 100 |
| 101 Thread::LocalStorageKey Isolate::isolate_key_; | 101 base::Thread::LocalStorageKey Isolate::isolate_key_; |
| 102 Thread::LocalStorageKey Isolate::thread_id_key_; | 102 base::Thread::LocalStorageKey Isolate::thread_id_key_; |
| 103 Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; | 103 base::Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; |
| 104 #ifdef DEBUG | 104 #ifdef DEBUG |
| 105 Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; | 105 base::Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; |
| 106 #endif // DEBUG | 106 #endif // DEBUG |
| 107 Mutex Isolate::process_wide_mutex_; | 107 base::Mutex Isolate::process_wide_mutex_; |
| 108 // TODO(dcarney): Remove with default isolate. | 108 // TODO(dcarney): Remove with default isolate. |
| 109 enum DefaultIsolateStatus { | 109 enum DefaultIsolateStatus { |
| 110 kDefaultIsolateUninitialized, | 110 kDefaultIsolateUninitialized, |
| 111 kDefaultIsolateInitialized, | 111 kDefaultIsolateInitialized, |
| 112 kDefaultIsolateCrashIfInitialized | 112 kDefaultIsolateCrashIfInitialized |
| 113 }; | 113 }; |
| 114 static DefaultIsolateStatus default_isolate_status_ | 114 static DefaultIsolateStatus default_isolate_status_ |
| 115 = kDefaultIsolateUninitialized; | 115 = kDefaultIsolateUninitialized; |
| 116 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL; | 116 Isolate::ThreadDataTable* Isolate::thread_data_table_ = NULL; |
| 117 base::Atomic32 Isolate::isolate_counter_ = 0; | 117 base::Atomic32 Isolate::isolate_counter_ = 0; |
| 118 | 118 |
| 119 Isolate::PerIsolateThreadData* | 119 Isolate::PerIsolateThreadData* |
| 120 Isolate::FindOrAllocatePerThreadDataForThisThread() { | 120 Isolate::FindOrAllocatePerThreadDataForThisThread() { |
| 121 ThreadId thread_id = ThreadId::Current(); | 121 ThreadId thread_id = ThreadId::Current(); |
| 122 PerIsolateThreadData* per_thread = NULL; | 122 PerIsolateThreadData* per_thread = NULL; |
| 123 { | 123 { |
| 124 LockGuard<Mutex> lock_guard(&process_wide_mutex_); | 124 base::LockGuard<base::Mutex> lock_guard(&process_wide_mutex_); |
| 125 per_thread = thread_data_table_->Lookup(this, thread_id); | 125 per_thread = thread_data_table_->Lookup(this, thread_id); |
| 126 if (per_thread == NULL) { | 126 if (per_thread == NULL) { |
| 127 per_thread = new PerIsolateThreadData(this, thread_id); | 127 per_thread = new PerIsolateThreadData(this, thread_id); |
| 128 thread_data_table_->Insert(per_thread); | 128 thread_data_table_->Insert(per_thread); |
| 129 } | 129 } |
| 130 ASSERT(thread_data_table_->Lookup(this, thread_id) == per_thread); | 130 ASSERT(thread_data_table_->Lookup(this, thread_id) == per_thread); |
| 131 } | 131 } |
| 132 return per_thread; | 132 return per_thread; |
| 133 } | 133 } |
| 134 | 134 |
| 135 | 135 |
| 136 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThisThread() { | 136 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThisThread() { |
| 137 ThreadId thread_id = ThreadId::Current(); | 137 ThreadId thread_id = ThreadId::Current(); |
| 138 return FindPerThreadDataForThread(thread_id); | 138 return FindPerThreadDataForThread(thread_id); |
| 139 } | 139 } |
| 140 | 140 |
| 141 | 141 |
| 142 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThread( | 142 Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThread( |
| 143 ThreadId thread_id) { | 143 ThreadId thread_id) { |
| 144 PerIsolateThreadData* per_thread = NULL; | 144 PerIsolateThreadData* per_thread = NULL; |
| 145 { | 145 { |
| 146 LockGuard<Mutex> lock_guard(&process_wide_mutex_); | 146 base::LockGuard<base::Mutex> lock_guard(&process_wide_mutex_); |
| 147 per_thread = thread_data_table_->Lookup(this, thread_id); | 147 per_thread = thread_data_table_->Lookup(this, thread_id); |
| 148 } | 148 } |
| 149 return per_thread; | 149 return per_thread; |
| 150 } | 150 } |
| 151 | 151 |
| 152 | 152 |
| 153 void Isolate::SetCrashIfDefaultIsolateInitialized() { | 153 void Isolate::SetCrashIfDefaultIsolateInitialized() { |
| 154 LockGuard<Mutex> lock_guard(&process_wide_mutex_); | 154 base::LockGuard<base::Mutex> lock_guard(&process_wide_mutex_); |
| 155 CHECK(default_isolate_status_ != kDefaultIsolateInitialized); | 155 CHECK(default_isolate_status_ != kDefaultIsolateInitialized); |
| 156 default_isolate_status_ = kDefaultIsolateCrashIfInitialized; | 156 default_isolate_status_ = kDefaultIsolateCrashIfInitialized; |
| 157 } | 157 } |
| 158 | 158 |
| 159 | 159 |
| 160 void Isolate::EnsureDefaultIsolate() { | 160 void Isolate::EnsureDefaultIsolate() { |
| 161 LockGuard<Mutex> lock_guard(&process_wide_mutex_); | 161 base::LockGuard<base::Mutex> lock_guard(&process_wide_mutex_); |
| 162 CHECK(default_isolate_status_ != kDefaultIsolateCrashIfInitialized); | 162 CHECK(default_isolate_status_ != kDefaultIsolateCrashIfInitialized); |
| 163 if (thread_data_table_ == NULL) { | 163 if (thread_data_table_ == NULL) { |
| 164 isolate_key_ = Thread::CreateThreadLocalKey(); | 164 isolate_key_ = base::Thread::CreateThreadLocalKey(); |
| 165 thread_id_key_ = Thread::CreateThreadLocalKey(); | 165 thread_id_key_ = base::Thread::CreateThreadLocalKey(); |
| 166 per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey(); | 166 per_isolate_thread_data_key_ = base::Thread::CreateThreadLocalKey(); |
| 167 #ifdef DEBUG | 167 #ifdef DEBUG |
| 168 PerThreadAssertScopeBase::thread_local_key = Thread::CreateThreadLocalKey(); | 168 PerThreadAssertScopeBase::thread_local_key = |
| 169 base::Thread::CreateThreadLocalKey(); |
| 169 #endif // DEBUG | 170 #endif // DEBUG |
| 170 thread_data_table_ = new Isolate::ThreadDataTable(); | 171 thread_data_table_ = new Isolate::ThreadDataTable(); |
| 171 } | 172 } |
| 172 } | 173 } |
| 173 | 174 |
| 174 struct StaticInitializer { | 175 struct StaticInitializer { |
| 175 StaticInitializer() { | 176 StaticInitializer() { |
| 176 Isolate::EnsureDefaultIsolate(); | 177 Isolate::EnsureDefaultIsolate(); |
| 177 } | 178 } |
| 178 } static_initializer; | 179 } static_initializer; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 StringStream::ClearMentionedObjectCache(this); | 280 StringStream::ClearMentionedObjectCache(this); |
| 280 StringStream accumulator(&allocator); | 281 StringStream accumulator(&allocator); |
| 281 incomplete_message_ = &accumulator; | 282 incomplete_message_ = &accumulator; |
| 282 PrintStack(&accumulator); | 283 PrintStack(&accumulator); |
| 283 Handle<String> stack_trace = accumulator.ToString(this); | 284 Handle<String> stack_trace = accumulator.ToString(this); |
| 284 incomplete_message_ = NULL; | 285 incomplete_message_ = NULL; |
| 285 stack_trace_nesting_level_ = 0; | 286 stack_trace_nesting_level_ = 0; |
| 286 return stack_trace; | 287 return stack_trace; |
| 287 } else if (stack_trace_nesting_level_ == 1) { | 288 } else if (stack_trace_nesting_level_ == 1) { |
| 288 stack_trace_nesting_level_++; | 289 stack_trace_nesting_level_++; |
| 289 OS::PrintError( | 290 base::OS::PrintError( |
| 290 "\n\nAttempt to print stack while printing stack (double fault)\n"); | 291 "\n\nAttempt to print stack while printing stack (double fault)\n"); |
| 291 OS::PrintError( | 292 base::OS::PrintError( |
| 292 "If you are lucky you may find a partial stack dump on stdout.\n\n"); | 293 "If you are lucky you may find a partial stack dump on stdout.\n\n"); |
| 293 incomplete_message_->OutputToStdOut(); | 294 incomplete_message_->OutputToStdOut(); |
| 294 return factory()->empty_string(); | 295 return factory()->empty_string(); |
| 295 } else { | 296 } else { |
| 296 OS::Abort(); | 297 base::OS::Abort(); |
| 297 // Unreachable | 298 // Unreachable |
| 298 return factory()->empty_string(); | 299 return factory()->empty_string(); |
| 299 } | 300 } |
| 300 } | 301 } |
| 301 | 302 |
| 302 | 303 |
| 303 void Isolate::PushStackTraceAndDie(unsigned int magic, | 304 void Isolate::PushStackTraceAndDie(unsigned int magic, |
| 304 Object* object, | 305 Object* object, |
| 305 Map* map, | 306 Map* map, |
| 306 unsigned int magic2) { | 307 unsigned int magic2) { |
| 307 const int kMaxStackTraceSize = 8192; | 308 const int kMaxStackTraceSize = 8192; |
| 308 Handle<String> trace = StackTraceString(); | 309 Handle<String> trace = StackTraceString(); |
| 309 uint8_t buffer[kMaxStackTraceSize]; | 310 uint8_t buffer[kMaxStackTraceSize]; |
| 310 int length = Min(kMaxStackTraceSize - 1, trace->length()); | 311 int length = Min(kMaxStackTraceSize - 1, trace->length()); |
| 311 String::WriteToFlat(*trace, buffer, 0, length); | 312 String::WriteToFlat(*trace, buffer, 0, length); |
| 312 buffer[length] = '\0'; | 313 buffer[length] = '\0'; |
| 313 // TODO(dcarney): convert buffer to utf8? | 314 // TODO(dcarney): convert buffer to utf8? |
| 314 OS::PrintError("Stacktrace (%x-%x) %p %p: %s\n", | 315 base::OS::PrintError("Stacktrace (%x-%x) %p %p: %s\n", magic, magic2, |
| 315 magic, magic2, | 316 static_cast<void*>(object), static_cast<void*>(map), |
| 316 static_cast<void*>(object), static_cast<void*>(map), | 317 reinterpret_cast<char*>(buffer)); |
| 317 reinterpret_cast<char*>(buffer)); | 318 base::OS::Abort(); |
| 318 OS::Abort(); | |
| 319 } | 319 } |
| 320 | 320 |
| 321 | 321 |
| 322 // Determines whether the given stack frame should be displayed in | 322 // Determines whether the given stack frame should be displayed in |
| 323 // a stack trace. The caller is the error constructor that asked | 323 // a stack trace. The caller is the error constructor that asked |
| 324 // for the stack trace to be collected. The first time a construct | 324 // for the stack trace to be collected. The first time a construct |
| 325 // call to this function is encountered it is skipped. The seen_caller | 325 // call to this function is encountered it is skipped. The seen_caller |
| 326 // in/out parameter is used to remember if the caller has been seen | 326 // in/out parameter is used to remember if the caller has been seen |
| 327 // yet. | 327 // yet. |
| 328 static bool IsVisibleInStackTrace(StackFrame* raw_frame, | 328 static bool IsVisibleInStackTrace(StackFrame* raw_frame, |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 StringStream accumulator(&allocator); | 564 StringStream accumulator(&allocator); |
| 565 incomplete_message_ = &accumulator; | 565 incomplete_message_ = &accumulator; |
| 566 PrintStack(&accumulator); | 566 PrintStack(&accumulator); |
| 567 accumulator.OutputToFile(out); | 567 accumulator.OutputToFile(out); |
| 568 InitializeLoggingAndCounters(); | 568 InitializeLoggingAndCounters(); |
| 569 accumulator.Log(this); | 569 accumulator.Log(this); |
| 570 incomplete_message_ = NULL; | 570 incomplete_message_ = NULL; |
| 571 stack_trace_nesting_level_ = 0; | 571 stack_trace_nesting_level_ = 0; |
| 572 } else if (stack_trace_nesting_level_ == 1) { | 572 } else if (stack_trace_nesting_level_ == 1) { |
| 573 stack_trace_nesting_level_++; | 573 stack_trace_nesting_level_++; |
| 574 OS::PrintError( | 574 base::OS::PrintError( |
| 575 "\n\nAttempt to print stack while printing stack (double fault)\n"); | 575 "\n\nAttempt to print stack while printing stack (double fault)\n"); |
| 576 OS::PrintError( | 576 base::OS::PrintError( |
| 577 "If you are lucky you may find a partial stack dump on stdout.\n\n"); | 577 "If you are lucky you may find a partial stack dump on stdout.\n\n"); |
| 578 incomplete_message_->OutputToFile(out); | 578 incomplete_message_->OutputToFile(out); |
| 579 } | 579 } |
| 580 } | 580 } |
| 581 | 581 |
| 582 | 582 |
| 583 static void PrintFrames(Isolate* isolate, | 583 static void PrintFrames(Isolate* isolate, |
| 584 StringStream* accumulator, | 584 StringStream* accumulator, |
| 585 StackFrame::PrintMode mode) { | 585 StackFrame::PrintMode mode) { |
| 586 StackFrameIterator it(isolate); | 586 StackFrameIterator it(isolate); |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 // present. This flag is intended for use by JavaScript developers, so | 1101 // present. This flag is intended for use by JavaScript developers, so |
| 1102 // print a user-friendly stack trace (not an internal one). | 1102 // print a user-friendly stack trace (not an internal one). |
| 1103 if (fatal_exception_depth == 0 && | 1103 if (fatal_exception_depth == 0 && |
| 1104 FLAG_abort_on_uncaught_exception && | 1104 FLAG_abort_on_uncaught_exception && |
| 1105 (report_exception || can_be_caught_externally)) { | 1105 (report_exception || can_be_caught_externally)) { |
| 1106 fatal_exception_depth++; | 1106 fatal_exception_depth++; |
| 1107 PrintF(stderr, | 1107 PrintF(stderr, |
| 1108 "%s\n\nFROM\n", | 1108 "%s\n\nFROM\n", |
| 1109 MessageHandler::GetLocalizedMessage(this, message_obj).get()); | 1109 MessageHandler::GetLocalizedMessage(this, message_obj).get()); |
| 1110 PrintCurrentStackTrace(stderr); | 1110 PrintCurrentStackTrace(stderr); |
| 1111 OS::Abort(); | 1111 base::OS::Abort(); |
| 1112 } | 1112 } |
| 1113 } else if (location != NULL && !location->script().is_null()) { | 1113 } else if (location != NULL && !location->script().is_null()) { |
| 1114 // We are bootstrapping and caught an error where the location is set | 1114 // We are bootstrapping and caught an error where the location is set |
| 1115 // and we have a script for the location. | 1115 // and we have a script for the location. |
| 1116 // In this case we could have an extension (or an internal error | 1116 // In this case we could have an extension (or an internal error |
| 1117 // somewhere) and we print out the line number at which the error occured | 1117 // somewhere) and we print out the line number at which the error occured |
| 1118 // to the console for easier debugging. | 1118 // to the console for easier debugging. |
| 1119 int line_number = | 1119 int line_number = |
| 1120 location->script()->GetLineNumber(location->start_pos()) + 1; | 1120 location->script()->GetLineNumber(location->start_pos()) + 1; |
| 1121 if (exception->IsString() && location->script()->name()->IsString()) { | 1121 if (exception->IsString() && location->script()->name()->IsString()) { |
| 1122 OS::PrintError( | 1122 base::OS::PrintError( |
| 1123 "Extension or internal compilation error: %s in %s at line %d.\n", | 1123 "Extension or internal compilation error: %s in %s at line %d.\n", |
| 1124 String::cast(exception)->ToCString().get(), | 1124 String::cast(exception)->ToCString().get(), |
| 1125 String::cast(location->script()->name())->ToCString().get(), | 1125 String::cast(location->script()->name())->ToCString().get(), |
| 1126 line_number); | 1126 line_number); |
| 1127 } else if (location->script()->name()->IsString()) { | 1127 } else if (location->script()->name()->IsString()) { |
| 1128 OS::PrintError( | 1128 base::OS::PrintError( |
| 1129 "Extension or internal compilation error in %s at line %d.\n", | 1129 "Extension or internal compilation error in %s at line %d.\n", |
| 1130 String::cast(location->script()->name())->ToCString().get(), | 1130 String::cast(location->script()->name())->ToCString().get(), |
| 1131 line_number); | 1131 line_number); |
| 1132 } else { | 1132 } else { |
| 1133 OS::PrintError("Extension or internal compilation error.\n"); | 1133 base::OS::PrintError("Extension or internal compilation error.\n"); |
| 1134 } | 1134 } |
| 1135 #ifdef OBJECT_PRINT | 1135 #ifdef OBJECT_PRINT |
| 1136 // Since comments and empty lines have been stripped from the source of | 1136 // Since comments and empty lines have been stripped from the source of |
| 1137 // builtins, print the actual source here so that line numbers match. | 1137 // builtins, print the actual source here so that line numbers match. |
| 1138 if (location->script()->source()->IsString()) { | 1138 if (location->script()->source()->IsString()) { |
| 1139 Handle<String> src(String::cast(location->script()->source())); | 1139 Handle<String> src(String::cast(location->script()->source())); |
| 1140 PrintF("Failing script:\n"); | 1140 PrintF("Failing script:\n"); |
| 1141 int len = src->length(); | 1141 int len = src->length(); |
| 1142 int line_number = 1; | 1142 int line_number = 1; |
| 1143 PrintF("%5d: ", line_number); | 1143 PrintF("%5d: ", line_number); |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 // Temporarily set this isolate as current so that various parts of | 1524 // Temporarily set this isolate as current so that various parts of |
| 1525 // the isolate can access it in their destructors without having a | 1525 // the isolate can access it in their destructors without having a |
| 1526 // direct pointer. We don't use Enter/Exit here to avoid | 1526 // direct pointer. We don't use Enter/Exit here to avoid |
| 1527 // initializing the thread data. | 1527 // initializing the thread data. |
| 1528 PerIsolateThreadData* saved_data = CurrentPerIsolateThreadData(); | 1528 PerIsolateThreadData* saved_data = CurrentPerIsolateThreadData(); |
| 1529 Isolate* saved_isolate = UncheckedCurrent(); | 1529 Isolate* saved_isolate = UncheckedCurrent(); |
| 1530 SetIsolateThreadLocals(this, NULL); | 1530 SetIsolateThreadLocals(this, NULL); |
| 1531 | 1531 |
| 1532 Deinit(); | 1532 Deinit(); |
| 1533 | 1533 |
| 1534 { LockGuard<Mutex> lock_guard(&process_wide_mutex_); | 1534 { base::LockGuard<base::Mutex> lock_guard(&process_wide_mutex_); |
| 1535 thread_data_table_->RemoveAllThreads(this); | 1535 thread_data_table_->RemoveAllThreads(this); |
| 1536 } | 1536 } |
| 1537 | 1537 |
| 1538 if (serialize_partial_snapshot_cache_ != NULL) { | 1538 if (serialize_partial_snapshot_cache_ != NULL) { |
| 1539 delete[] serialize_partial_snapshot_cache_; | 1539 delete[] serialize_partial_snapshot_cache_; |
| 1540 serialize_partial_snapshot_cache_ = NULL; | 1540 serialize_partial_snapshot_cache_ = NULL; |
| 1541 } | 1541 } |
| 1542 | 1542 |
| 1543 delete this; | 1543 delete this; |
| 1544 | 1544 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1625 set_serialize_partial_snapshot_cache_capacity(new_capacity); | 1625 set_serialize_partial_snapshot_cache_capacity(new_capacity); |
| 1626 } | 1626 } |
| 1627 | 1627 |
| 1628 serialize_partial_snapshot_cache()[length] = obj; | 1628 serialize_partial_snapshot_cache()[length] = obj; |
| 1629 set_serialize_partial_snapshot_cache_length(length + 1); | 1629 set_serialize_partial_snapshot_cache_length(length + 1); |
| 1630 } | 1630 } |
| 1631 | 1631 |
| 1632 | 1632 |
| 1633 void Isolate::SetIsolateThreadLocals(Isolate* isolate, | 1633 void Isolate::SetIsolateThreadLocals(Isolate* isolate, |
| 1634 PerIsolateThreadData* data) { | 1634 PerIsolateThreadData* data) { |
| 1635 Thread::SetThreadLocal(isolate_key_, isolate); | 1635 base::Thread::SetThreadLocal(isolate_key_, isolate); |
| 1636 Thread::SetThreadLocal(per_isolate_thread_data_key_, data); | 1636 base::Thread::SetThreadLocal(per_isolate_thread_data_key_, data); |
| 1637 } | 1637 } |
| 1638 | 1638 |
| 1639 | 1639 |
| 1640 Isolate::~Isolate() { | 1640 Isolate::~Isolate() { |
| 1641 TRACE_ISOLATE(destructor); | 1641 TRACE_ISOLATE(destructor); |
| 1642 | 1642 |
| 1643 // Has to be called while counters_ are still alive | 1643 // Has to be called while counters_ are still alive |
| 1644 runtime_zone_.DeleteKeptSegment(); | 1644 runtime_zone_.DeleteKeptSegment(); |
| 1645 | 1645 |
| 1646 // The entry stack must be empty when we get here. | 1646 // The entry stack must be empty when we get here. |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 set_event_logger(Logger::LogInternalEvents); | 1894 set_event_logger(Logger::LogInternalEvents); |
| 1895 } else { | 1895 } else { |
| 1896 set_event_logger(Logger::EmptyLogInternalEvents); | 1896 set_event_logger(Logger::EmptyLogInternalEvents); |
| 1897 } | 1897 } |
| 1898 | 1898 |
| 1899 // Set default value if not yet set. | 1899 // Set default value if not yet set. |
| 1900 // TODO(yangguo): move this to ResourceConstraints::ConfigureDefaults | 1900 // TODO(yangguo): move this to ResourceConstraints::ConfigureDefaults |
| 1901 // once ResourceConstraints becomes an argument to the Isolate constructor. | 1901 // once ResourceConstraints becomes an argument to the Isolate constructor. |
| 1902 if (max_available_threads_ < 1) { | 1902 if (max_available_threads_ < 1) { |
| 1903 // Choose the default between 1 and 4. | 1903 // Choose the default between 1 and 4. |
| 1904 max_available_threads_ = Max(Min(OS::NumberOfProcessorsOnline(), 4), 1); | 1904 max_available_threads_ = |
| 1905 Max(Min(base::OS::NumberOfProcessorsOnline(), 4), 1); |
| 1905 } | 1906 } |
| 1906 | 1907 |
| 1907 if (!FLAG_job_based_sweeping) { | 1908 if (!FLAG_job_based_sweeping) { |
| 1908 num_sweeper_threads_ = | 1909 num_sweeper_threads_ = |
| 1909 SweeperThread::NumberOfThreads(max_available_threads_); | 1910 SweeperThread::NumberOfThreads(max_available_threads_); |
| 1910 } | 1911 } |
| 1911 | 1912 |
| 1912 if (FLAG_trace_hydrogen || FLAG_trace_hydrogen_stubs) { | 1913 if (FLAG_trace_hydrogen || FLAG_trace_hydrogen_stubs) { |
| 1913 PrintF("Concurrent recompilation has been disabled for tracing.\n"); | 1914 PrintF("Concurrent recompilation has been disabled for tracing.\n"); |
| 1914 } else if (OptimizingCompilerThread::Enabled(max_available_threads_)) { | 1915 } else if (OptimizingCompilerThread::Enabled(max_available_threads_)) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1969 Internals::kIsolateRootsOffset); | 1970 Internals::kIsolateRootsOffset); |
| 1970 CHECK_EQ(static_cast<int>( | 1971 CHECK_EQ(static_cast<int>( |
| 1971 OFFSET_OF(Isolate, heap_.amount_of_external_allocated_memory_)), | 1972 OFFSET_OF(Isolate, heap_.amount_of_external_allocated_memory_)), |
| 1972 Internals::kAmountOfExternalAllocatedMemoryOffset); | 1973 Internals::kAmountOfExternalAllocatedMemoryOffset); |
| 1973 CHECK_EQ(static_cast<int>(OFFSET_OF( | 1974 CHECK_EQ(static_cast<int>(OFFSET_OF( |
| 1974 Isolate, | 1975 Isolate, |
| 1975 heap_.amount_of_external_allocated_memory_at_last_global_gc_)), | 1976 heap_.amount_of_external_allocated_memory_at_last_global_gc_)), |
| 1976 Internals::kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset); | 1977 Internals::kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset); |
| 1977 | 1978 |
| 1978 state_ = INITIALIZED; | 1979 state_ = INITIALIZED; |
| 1979 time_millis_at_init_ = OS::TimeCurrentMillis(); | 1980 time_millis_at_init_ = base::OS::TimeCurrentMillis(); |
| 1980 | 1981 |
| 1981 if (!create_heap_objects) { | 1982 if (!create_heap_objects) { |
| 1982 // Now that the heap is consistent, it's OK to generate the code for the | 1983 // Now that the heap is consistent, it's OK to generate the code for the |
| 1983 // deopt entry table that might have been referred to by optimized code in | 1984 // deopt entry table that might have been referred to by optimized code in |
| 1984 // the snapshot. | 1985 // the snapshot. |
| 1985 HandleScope scope(this); | 1986 HandleScope scope(this); |
| 1986 Deoptimizer::EnsureCodeForDeoptimizationEntry( | 1987 Deoptimizer::EnsureCodeForDeoptimizationEntry( |
| 1987 this, | 1988 this, |
| 1988 Deoptimizer::LAZY, | 1989 Deoptimizer::LAZY, |
| 1989 kDeoptTableSerializeEntryCount - 1); | 1990 kDeoptTableSerializeEntryCount - 1); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2365 // The simulator uses a separate JS stack. | 2366 // The simulator uses a separate JS stack. |
| 2366 Address jssp_address = Simulator::current(isolate_)->get_sp(); | 2367 Address jssp_address = Simulator::current(isolate_)->get_sp(); |
| 2367 uintptr_t jssp = reinterpret_cast<uintptr_t>(jssp_address); | 2368 uintptr_t jssp = reinterpret_cast<uintptr_t>(jssp_address); |
| 2368 if (jssp < stack_guard->real_jslimit()) return true; | 2369 if (jssp < stack_guard->real_jslimit()) return true; |
| 2369 #endif // USE_SIMULATOR | 2370 #endif // USE_SIMULATOR |
| 2370 return reinterpret_cast<uintptr_t>(this) < stack_guard->real_climit(); | 2371 return reinterpret_cast<uintptr_t>(this) < stack_guard->real_climit(); |
| 2371 } | 2372 } |
| 2372 | 2373 |
| 2373 | 2374 |
| 2374 } } // namespace v8::internal | 2375 } } // namespace v8::internal |
| OLD | NEW |