OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
449 | 449 |
450 | 450 |
451 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) { | 451 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) { |
452 FILE* file = fopen(name, "r+"); | 452 FILE* file = fopen(name, "r+"); |
453 if (file == NULL) return NULL; | 453 if (file == NULL) return NULL; |
454 | 454 |
455 fseek(file, 0, SEEK_END); | 455 fseek(file, 0, SEEK_END); |
456 int size = ftell(file); | 456 int size = ftell(file); |
457 | 457 |
458 void* memory = | 458 void* memory = |
459 mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); | 459 mmap(GetRandomMmapAddr(), size, PROT_READ | PROT_WRITE, |
Vyacheslav Egorov (Chromium)
2011/10/04 09:18:33
preferred formatting is one arguments per line
Cris Neckar
2011/10/04 19:20:47
Done.
| |
460 MAP_SHARED, fileno(file), 0); | |
460 return new PosixMemoryMappedFile(file, memory, size); | 461 return new PosixMemoryMappedFile(file, memory, size); |
461 } | 462 } |
462 | 463 |
463 | 464 |
464 OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size, | 465 OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size, |
465 void* initial) { | 466 void* initial) { |
466 FILE* file = fopen(name, "w+"); | 467 FILE* file = fopen(name, "w+"); |
467 if (file == NULL) return NULL; | 468 if (file == NULL) return NULL; |
468 int result = fwrite(initial, size, 1, file); | 469 int result = fwrite(initial, size, 1, file); |
469 if (result < 1) { | 470 if (result < 1) { |
470 fclose(file); | 471 fclose(file); |
471 return NULL; | 472 return NULL; |
472 } | 473 } |
473 void* memory = | 474 void* memory = |
474 mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); | 475 mmap(GetRandomMmapAddr(), size, PROT_READ | PROT_WRITE, |
Vyacheslav Egorov (Chromium)
2011/10/04 09:18:33
ditto
Cris Neckar
2011/10/04 19:20:47
Done.
| |
476 MAP_SHARED, fileno(file), 0); | |
475 return new PosixMemoryMappedFile(file, memory, size); | 477 return new PosixMemoryMappedFile(file, memory, size); |
476 } | 478 } |
477 | 479 |
478 | 480 |
479 PosixMemoryMappedFile::~PosixMemoryMappedFile() { | 481 PosixMemoryMappedFile::~PosixMemoryMappedFile() { |
480 if (memory_) OS::Free(memory_, size_); | 482 if (memory_) OS::Free(memory_, size_); |
481 fclose(file_); | 483 fclose(file_); |
482 } | 484 } |
483 | 485 |
484 | 486 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 // Support for ll_prof.py. | 551 // Support for ll_prof.py. |
550 // | 552 // |
551 // The Linux profiler built into the kernel logs all mmap's with | 553 // The Linux profiler built into the kernel logs all mmap's with |
552 // PROT_EXEC so that analysis tools can properly attribute ticks. We | 554 // PROT_EXEC so that analysis tools can properly attribute ticks. We |
553 // do a mmap with a name known by ll_prof.py and immediately munmap | 555 // do a mmap with a name known by ll_prof.py and immediately munmap |
554 // it. This injects a GC marker into the stream of events generated | 556 // it. This injects a GC marker into the stream of events generated |
555 // by the kernel and allows us to synchronize V8 code log and the | 557 // by the kernel and allows us to synchronize V8 code log and the |
556 // kernel log. | 558 // kernel log. |
557 int size = sysconf(_SC_PAGESIZE); | 559 int size = sysconf(_SC_PAGESIZE); |
558 FILE* f = fopen(kGCFakeMmap, "w+"); | 560 FILE* f = fopen(kGCFakeMmap, "w+"); |
559 void* addr = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_PRIVATE, | 561 void* addr = mmap(GetRandomMmapAddr(), size, PROT_READ | PROT_EXEC, |
Vyacheslav Egorov (Chromium)
2011/10/04 09:18:33
ditto
Cris Neckar
2011/10/04 19:20:47
Done.
| |
560 fileno(f), 0); | 562 MAP_PRIVATE, fileno(f), 0); |
561 ASSERT(addr != MAP_FAILED); | 563 ASSERT(addr != MAP_FAILED); |
562 OS::Free(addr, size); | 564 OS::Free(addr, size); |
563 fclose(f); | 565 fclose(f); |
564 } | 566 } |
565 | 567 |
566 | 568 |
567 int OS::StackWalk(Vector<OS::StackFrame> frames) { | 569 int OS::StackWalk(Vector<OS::StackFrame> frames) { |
568 // backtrace is a glibc extension. | 570 // backtrace is a glibc extension. |
569 #ifdef __GLIBC__ | 571 #ifdef __GLIBC__ |
570 int frames_size = frames.length(); | 572 int frames_size = frames.length(); |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1222 | 1224 |
1223 | 1225 |
1224 void Sampler::Stop() { | 1226 void Sampler::Stop() { |
1225 ASSERT(IsActive()); | 1227 ASSERT(IsActive()); |
1226 SignalSender::RemoveActiveSampler(this); | 1228 SignalSender::RemoveActiveSampler(this); |
1227 SetActive(false); | 1229 SetActive(false); |
1228 } | 1230 } |
1229 | 1231 |
1230 | 1232 |
1231 } } // namespace v8::internal | 1233 } } // namespace v8::internal |
OLD | NEW |