| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Tests of logging functions from log.h | 3 // Tests of logging functions from log.h |
| 4 | 4 |
| 5 #ifdef ENABLE_LOGGING_AND_PROFILING | 5 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 6 | 6 |
| 7 #ifdef __linux__ | 7 #ifdef __linux__ |
| 8 #include <math.h> | 8 #include <math.h> |
| 9 #include <pthread.h> | 9 #include <pthread.h> |
| 10 #include <signal.h> | 10 #include <signal.h> |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 }; | 382 }; |
| 383 | 383 |
| 384 | 384 |
| 385 class LoopingJsThread : public LoopingThread { | 385 class LoopingJsThread : public LoopingThread { |
| 386 public: | 386 public: |
| 387 explicit LoopingJsThread(v8::internal::Isolate* isolate) | 387 explicit LoopingJsThread(v8::internal::Isolate* isolate) |
| 388 : LoopingThread(isolate) { } | 388 : LoopingThread(isolate) { } |
| 389 void RunLoop() { | 389 void RunLoop() { |
| 390 v8::Locker locker; | 390 v8::Locker locker; |
| 391 CHECK(i::Isolate::Current() != NULL); | 391 CHECK(i::Isolate::Current() != NULL); |
| 392 CHECK(i::Isolate::Current()->thread_manager()->HasId()); | 392 CHECK(i::Isolate::Current()->thread_manager()->CurrentId() > 0); |
| 393 SetV8ThreadId(); | 393 SetV8ThreadId(); |
| 394 while (IsRunning()) { | 394 while (IsRunning()) { |
| 395 v8::HandleScope scope; | 395 v8::HandleScope scope; |
| 396 v8::Persistent<v8::Context> context = v8::Context::New(); | 396 v8::Persistent<v8::Context> context = v8::Context::New(); |
| 397 CHECK(!context.IsEmpty()); | 397 CHECK(!context.IsEmpty()); |
| 398 { | 398 { |
| 399 v8::Context::Scope context_scope(context); | 399 v8::Context::Scope context_scope(context); |
| 400 SignalRunning(); | 400 SignalRunning(); |
| 401 CompileAndRunScript( | 401 CompileAndRunScript( |
| 402 "var j; for (var i=0; i<10000; ++i) { j = Math.sin(i); }"); | 402 "var j; for (var i=0; i<10000; ++i) { j = Math.sin(i); }"); |
| 403 } | 403 } |
| 404 context.Dispose(); | 404 context.Dispose(); |
| 405 i::OS::Sleep(1); | 405 i::OS::Sleep(1); |
| 406 } | 406 } |
| 407 } | 407 } |
| 408 }; | 408 }; |
| 409 | 409 |
| 410 | 410 |
| 411 class LoopingNonJsThread : public LoopingThread { | 411 class LoopingNonJsThread : public LoopingThread { |
| 412 public: | 412 public: |
| 413 explicit LoopingNonJsThread(v8::internal::Isolate* isolate) | 413 explicit LoopingNonJsThread(v8::internal::Isolate* isolate) |
| 414 : LoopingThread(isolate) { } | 414 : LoopingThread(isolate) { } |
| 415 void RunLoop() { | 415 void RunLoop() { |
| 416 v8::Locker locker; | 416 v8::Locker locker; |
| 417 v8::Unlocker unlocker; | 417 v8::Unlocker unlocker; |
| 418 // Now thread has V8's id, but will not run VM code. | 418 // Now thread has V8's id, but will not run VM code. |
| 419 CHECK(i::Isolate::Current() != NULL); | 419 CHECK(i::Isolate::Current() != NULL); |
| 420 CHECK(i::Isolate::Current()->thread_manager()->HasId()); | 420 CHECK(i::Isolate::Current()->thread_manager()->CurrentId() > 0); |
| 421 double i = 10; | 421 double i = 10; |
| 422 SignalRunning(); | 422 SignalRunning(); |
| 423 while (IsRunning()) { | 423 while (IsRunning()) { |
| 424 i = sin(i); | 424 i = sin(i); |
| 425 i::OS::Sleep(1); | 425 i::OS::Sleep(1); |
| 426 } | 426 } |
| 427 } | 427 } |
| 428 }; | 428 }; |
| 429 | 429 |
| 430 | 430 |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 // Make sure that all log data is written prior crash due to CHECK failure. | 1195 // Make sure that all log data is written prior crash due to CHECK failure. |
| 1196 fflush(stdout); | 1196 fflush(stdout); |
| 1197 CHECK(results_equal); | 1197 CHECK(results_equal); |
| 1198 | 1198 |
| 1199 env->Exit(); | 1199 env->Exit(); |
| 1200 LOGGER->TearDown(); | 1200 LOGGER->TearDown(); |
| 1201 i::FLAG_always_compact = saved_always_compact; | 1201 i::FLAG_always_compact = saved_always_compact; |
| 1202 } | 1202 } |
| 1203 | 1203 |
| 1204 #endif // ENABLE_LOGGING_AND_PROFILING | 1204 #endif // ENABLE_LOGGING_AND_PROFILING |
| OLD | NEW |