Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: src/platform-linux.cc

Issue 6696042: Adding 'isolates' argument to LOG to get rid of multiple TLS fetches in profiling. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/isolates
Patch Set: Addressing code review feedback + rebase Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/platform-freebsd.cc ('k') | src/platform-macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 250
251 251
252 void* OS::Allocate(const size_t requested, 252 void* OS::Allocate(const size_t requested,
253 size_t* allocated, 253 size_t* allocated,
254 bool is_executable) { 254 bool is_executable) {
255 // TODO(805): Port randomization of allocated executable memory to Linux. 255 // TODO(805): Port randomization of allocated executable memory to Linux.
256 const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE)); 256 const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE));
257 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); 257 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
258 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 258 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
259 if (mbase == MAP_FAILED) { 259 if (mbase == MAP_FAILED) {
260 LOG(StringEvent("OS::Allocate", "mmap failed")); 260 LOG(i::Isolate::Current(),
261 StringEvent("OS::Allocate", "mmap failed"));
261 return NULL; 262 return NULL;
262 } 263 }
263 *allocated = msize; 264 *allocated = msize;
264 UpdateAllocatedSpaceLimits(mbase, msize); 265 UpdateAllocatedSpaceLimits(mbase, msize);
265 return mbase; 266 return mbase;
266 } 267 }
267 268
268 269
269 void OS::Free(void* address, const size_t size) { 270 void OS::Free(void* address, const size_t size) {
270 // TODO(1240712): munmap has a return value which is ignored here. 271 // TODO(1240712): munmap has a return value which is ignored here.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 // This function assumes that the layout of the file is as follows: 372 // This function assumes that the layout of the file is as follows:
372 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] 373 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name]
373 // If we encounter an unexpected situation we abort scanning further entries. 374 // If we encounter an unexpected situation we abort scanning further entries.
374 FILE* fp = fopen("/proc/self/maps", "r"); 375 FILE* fp = fopen("/proc/self/maps", "r");
375 if (fp == NULL) return; 376 if (fp == NULL) return;
376 377
377 // Allocate enough room to be able to store a full file name. 378 // Allocate enough room to be able to store a full file name.
378 const int kLibNameLen = FILENAME_MAX + 1; 379 const int kLibNameLen = FILENAME_MAX + 1;
379 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); 380 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen));
380 381
382 i::Isolate* isolate = ISOLATE;
381 // This loop will terminate once the scanning hits an EOF. 383 // This loop will terminate once the scanning hits an EOF.
382 while (true) { 384 while (true) {
383 uintptr_t start, end; 385 uintptr_t start, end;
384 char attr_r, attr_w, attr_x, attr_p; 386 char attr_r, attr_w, attr_x, attr_p;
385 // Parse the addresses and permission bits at the beginning of the line. 387 // Parse the addresses and permission bits at the beginning of the line.
386 if (fscanf(fp, "%" V8PRIxPTR "-%" V8PRIxPTR, &start, &end) != 2) break; 388 if (fscanf(fp, "%" V8PRIxPTR "-%" V8PRIxPTR, &start, &end) != 2) break;
387 if (fscanf(fp, " %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4) break; 389 if (fscanf(fp, " %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4) break;
388 390
389 int c; 391 int c;
390 if (attr_r == 'r' && attr_w != 'w' && attr_x == 'x') { 392 if (attr_r == 'r' && attr_w != 'w' && attr_x == 'x') {
(...skipping 13 matching lines...) Expand all
404 406
405 // Drop the newline character read by fgets. We do not need to check 407 // Drop the newline character read by fgets. We do not need to check
406 // for a zero-length string because we know that we at least read the 408 // for a zero-length string because we know that we at least read the
407 // '/' character. 409 // '/' character.
408 lib_name[strlen(lib_name) - 1] = '\0'; 410 lib_name[strlen(lib_name) - 1] = '\0';
409 } else { 411 } else {
410 // No library name found, just record the raw address range. 412 // No library name found, just record the raw address range.
411 snprintf(lib_name, kLibNameLen, 413 snprintf(lib_name, kLibNameLen,
412 "%08" V8PRIxPTR "-%08" V8PRIxPTR, start, end); 414 "%08" V8PRIxPTR "-%08" V8PRIxPTR, start, end);
413 } 415 }
414 LOG(SharedLibraryEvent(lib_name, start, end)); 416 LOG(isolate, SharedLibraryEvent(lib_name, start, end));
415 } else { 417 } else {
416 // Entry not describing executable data. Skip to end of line to setup 418 // Entry not describing executable data. Skip to end of line to setup
417 // reading the next entry. 419 // reading the next entry.
418 do { 420 do {
419 c = getc(fp); 421 c = getc(fp);
420 } while ((c != EOF) && (c != '\n')); 422 } while ((c != EOF) && (c != '\n'));
421 if (c == EOF) break; 423 if (c == EOF) break;
422 } 424 }
423 } 425 }
424 free(lib_name); 426 free(lib_name);
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 1033
1032 void Sampler::Stop() { 1034 void Sampler::Stop() {
1033 ASSERT(IsActive()); 1035 ASSERT(IsActive());
1034 SignalSender::RemoveActiveSampler(this); 1036 SignalSender::RemoveActiveSampler(this);
1035 SetActive(false); 1037 SetActive(false);
1036 } 1038 }
1037 1039
1038 #endif // ENABLE_LOGGING_AND_PROFILING 1040 #endif // ENABLE_LOGGING_AND_PROFILING
1039 1041
1040 } } // namespace v8::internal 1042 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-freebsd.cc ('k') | src/platform-macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698