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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 } while ((c != EOF) && (c != '\n')); | 390 } while ((c != EOF) && (c != '\n')); |
391 if (c == EOF) break; | 391 if (c == EOF) break; |
392 } | 392 } |
393 } | 393 } |
394 free(lib_name); | 394 free(lib_name); |
395 fclose(fp); | 395 fclose(fp); |
396 #endif | 396 #endif |
397 } | 397 } |
398 | 398 |
399 | 399 |
| 400 static const char kGCFakeMmap[] = "/tmp/__v8_gc__"; |
| 401 |
| 402 |
| 403 void OS::SignalCodeMovingGC() { |
| 404 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 405 // Support for ll_prof.py. |
| 406 // |
| 407 // The Linux profiler built into the kernel logs all mmap's with |
| 408 // PROT_EXEC so that analysis tools can properly attribute ticks. We |
| 409 // do a mmap with a name known by ll_prof.py and immediately munmap |
| 410 // it. This injects a GC marker into the stream of events generated |
| 411 // by the kernel and allows us to synchronize V8 code log and the |
| 412 // kernel log. |
| 413 int size = sysconf(_SC_PAGESIZE); |
| 414 FILE* f = fopen(kGCFakeMmap, "w+"); |
| 415 void* addr = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_PRIVATE, |
| 416 fileno(f), 0); |
| 417 ASSERT(addr != MAP_FAILED); |
| 418 munmap(addr, size); |
| 419 fclose(f); |
| 420 #endif |
| 421 } |
| 422 |
| 423 |
400 int OS::StackWalk(Vector<OS::StackFrame> frames) { | 424 int OS::StackWalk(Vector<OS::StackFrame> frames) { |
401 // backtrace is a glibc extension. | 425 // backtrace is a glibc extension. |
402 #ifdef __GLIBC__ | 426 #ifdef __GLIBC__ |
403 int frames_size = frames.length(); | 427 int frames_size = frames.length(); |
404 ScopedVector<void*> addresses(frames_size); | 428 ScopedVector<void*> addresses(frames_size); |
405 | 429 |
406 int frames_count = backtrace(addresses.start(), frames_size); | 430 int frames_count = backtrace(addresses.start(), frames_size); |
407 | 431 |
408 char** symbols = backtrace_symbols(addresses.start(), frames_count); | 432 char** symbols = backtrace_symbols(addresses.start(), frames_count); |
409 if (symbols == NULL) { | 433 if (symbols == NULL) { |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 | 879 |
856 // This sampler is no longer the active sampler. | 880 // This sampler is no longer the active sampler. |
857 active_sampler_ = NULL; | 881 active_sampler_ = NULL; |
858 active_ = false; | 882 active_ = false; |
859 } | 883 } |
860 | 884 |
861 | 885 |
862 #endif // ENABLE_LOGGING_AND_PROFILING | 886 #endif // ENABLE_LOGGING_AND_PROFILING |
863 | 887 |
864 } } // namespace v8::internal | 888 } } // namespace v8::internal |
OLD | NEW |