OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 22 matching lines...) Expand all Loading... |
33 #include "execution.h" | 33 #include "execution.h" |
34 #include "messages.h" | 34 #include "messages.h" |
35 #include "platform.h" | 35 #include "platform.h" |
36 #include "simulator.h" | 36 #include "simulator.h" |
37 #include "string-stream.h" | 37 #include "string-stream.h" |
38 #include "vm-state-inl.h" | 38 #include "vm-state-inl.h" |
39 | 39 |
40 namespace v8 { | 40 namespace v8 { |
41 namespace internal { | 41 namespace internal { |
42 | 42 |
| 43 #ifdef ENABLE_LOGGING_AND_PROFILING |
43 Semaphore* Top::runtime_profiler_semaphore_ = NULL; | 44 Semaphore* Top::runtime_profiler_semaphore_ = NULL; |
| 45 #endif |
44 ThreadLocalTop Top::thread_local_; | 46 ThreadLocalTop Top::thread_local_; |
45 Mutex* Top::break_access_ = OS::CreateMutex(); | 47 Mutex* Top::break_access_ = OS::CreateMutex(); |
46 | 48 |
47 NoAllocationStringAllocator* preallocated_message_space = NULL; | 49 NoAllocationStringAllocator* preallocated_message_space = NULL; |
48 | 50 |
49 bool capture_stack_trace_for_uncaught_exceptions = false; | 51 bool capture_stack_trace_for_uncaught_exceptions = false; |
50 int stack_trace_for_uncaught_exceptions_frame_limit = 0; | 52 int stack_trace_for_uncaught_exceptions_frame_limit = 0; |
51 StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options = | 53 StackTrace::StackTraceOptions stack_trace_for_uncaught_exceptions_options = |
52 StackTrace::kOverview; | 54 StackTrace::kOverview; |
53 | 55 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 Semaphore* PreallocatedMemoryThread::wait_for_ever_semaphore_ = NULL; | 272 Semaphore* PreallocatedMemoryThread::wait_for_ever_semaphore_ = NULL; |
271 Semaphore* PreallocatedMemoryThread::data_ready_semaphore_ = NULL; | 273 Semaphore* PreallocatedMemoryThread::data_ready_semaphore_ = NULL; |
272 char* PreallocatedMemoryThread::data_ = NULL; | 274 char* PreallocatedMemoryThread::data_ = NULL; |
273 unsigned PreallocatedMemoryThread::length_ = 0; | 275 unsigned PreallocatedMemoryThread::length_ = 0; |
274 | 276 |
275 static bool initialized = false; | 277 static bool initialized = false; |
276 | 278 |
277 void Top::Initialize() { | 279 void Top::Initialize() { |
278 CHECK(!initialized); | 280 CHECK(!initialized); |
279 | 281 |
| 282 #ifdef ENABLE_LOGGING_AND_PROFILING |
280 ASSERT(runtime_profiler_semaphore_ == NULL); | 283 ASSERT(runtime_profiler_semaphore_ == NULL); |
281 runtime_profiler_semaphore_ = OS::CreateSemaphore(0); | 284 runtime_profiler_semaphore_ = OS::CreateSemaphore(0); |
282 | 285 #endif |
| 286 |
283 InitializeThreadLocal(); | 287 InitializeThreadLocal(); |
284 | 288 |
285 // Only preallocate on the first initialization. | 289 // Only preallocate on the first initialization. |
286 if (FLAG_preallocate_message_memory && (preallocated_message_space == NULL)) { | 290 if (FLAG_preallocate_message_memory && (preallocated_message_space == NULL)) { |
287 // Start the thread which will set aside some memory. | 291 // Start the thread which will set aside some memory. |
288 PreallocatedMemoryThread::StartThread(); | 292 PreallocatedMemoryThread::StartThread(); |
289 preallocated_message_space = | 293 preallocated_message_space = |
290 new NoAllocationStringAllocator(PreallocatedMemoryThread::data(), | 294 new NoAllocationStringAllocator(PreallocatedMemoryThread::data(), |
291 PreallocatedMemoryThread::length()); | 295 PreallocatedMemoryThread::length()); |
292 PreallocatedStorage::Init(PreallocatedMemoryThread::length() / 4); | 296 PreallocatedStorage::Init(PreallocatedMemoryThread::length() / 4); |
293 } | 297 } |
294 initialized = true; | 298 initialized = true; |
295 } | 299 } |
296 | 300 |
297 | 301 |
298 void Top::TearDown() { | 302 void Top::TearDown() { |
299 if (initialized) { | 303 if (initialized) { |
| 304 #ifdef ENABLE_LOGGING_AND_PROFILING |
300 delete runtime_profiler_semaphore_; | 305 delete runtime_profiler_semaphore_; |
301 runtime_profiler_semaphore_ = NULL; | 306 runtime_profiler_semaphore_ = NULL; |
302 | 307 #endif |
| 308 |
303 // Remove the external reference to the preallocated stack memory. | 309 // Remove the external reference to the preallocated stack memory. |
304 if (preallocated_message_space != NULL) { | 310 if (preallocated_message_space != NULL) { |
305 delete preallocated_message_space; | 311 delete preallocated_message_space; |
306 preallocated_message_space = NULL; | 312 preallocated_message_space = NULL; |
307 } | 313 } |
308 | 314 |
309 PreallocatedMemoryThread::StopThread(); | 315 PreallocatedMemoryThread::StopThread(); |
310 initialized = false; | 316 initialized = false; |
311 } | 317 } |
312 } | 318 } |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 #ifdef V8_TARGET_ARCH_ARM | 1095 #ifdef V8_TARGET_ARCH_ARM |
1090 thread_local_.simulator_ = assembler::arm::Simulator::current(); | 1096 thread_local_.simulator_ = assembler::arm::Simulator::current(); |
1091 #elif V8_TARGET_ARCH_MIPS | 1097 #elif V8_TARGET_ARCH_MIPS |
1092 thread_local_.simulator_ = assembler::mips::Simulator::current(); | 1098 thread_local_.simulator_ = assembler::mips::Simulator::current(); |
1093 #endif | 1099 #endif |
1094 #endif | 1100 #endif |
1095 return from + sizeof(thread_local_); | 1101 return from + sizeof(thread_local_); |
1096 } | 1102 } |
1097 | 1103 |
1098 } } // namespace v8::internal | 1104 } } // namespace v8::internal |
OLD | NEW |