OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 static uintptr_t ReadLong(char* buffer, intptr_t* position, int base) { | 466 static uintptr_t ReadLong(char* buffer, intptr_t* position, int base) { |
467 char* end_address = buffer + *position; | 467 char* end_address = buffer + *position; |
468 uintptr_t result = strtoul(buffer + *position, &end_address, base); | 468 uintptr_t result = strtoul(buffer + *position, &end_address, base); |
469 CHECK(result != ULONG_MAX || errno != ERANGE); | 469 CHECK(result != ULONG_MAX || errno != ERANGE); |
470 CHECK(end_address > buffer + *position); | 470 CHECK(end_address > buffer + *position); |
471 *position = end_address - buffer; | 471 *position = end_address - buffer; |
472 return result; | 472 return result; |
473 } | 473 } |
474 | 474 |
475 | 475 |
| 476 // The memory use computed this way is not entirely accurate and depends on |
| 477 // the way malloc allocates memory. That's why the memory usage may seem to |
| 478 // increase even though the sum of the allocated memory sizes decreases. It |
| 479 // also means that the memory use depends on the kernel and stdlib. |
476 static intptr_t MemoryInUse() { | 480 static intptr_t MemoryInUse() { |
477 intptr_t memory_use = 0; | 481 intptr_t memory_use = 0; |
478 | 482 |
479 int fd = open("/proc/self/maps", O_RDONLY); | 483 int fd = open("/proc/self/maps", O_RDONLY); |
480 if (fd < 0) return -1; | 484 if (fd < 0) return -1; |
481 | 485 |
482 const int kBufSize = 10000; | 486 const int kBufSize = 10000; |
483 char buffer[kBufSize]; | 487 char buffer[kBufSize]; |
484 int length = read(fd, buffer, kBufSize); | 488 int length = read(fd, buffer, kBufSize); |
485 intptr_t line_start = 0; | 489 intptr_t line_start = 0; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 intptr_t initial_memory = MemoryInUse(); | 535 intptr_t initial_memory = MemoryInUse(); |
532 // Avoid flakiness. | 536 // Avoid flakiness. |
533 FLAG_crankshaft = false; | 537 FLAG_crankshaft = false; |
534 FLAG_parallel_recompilation = false; | 538 FLAG_parallel_recompilation = false; |
535 | 539 |
536 // Only Linux has the proc filesystem and only if it is mapped. If it's not | 540 // Only Linux has the proc filesystem and only if it is mapped. If it's not |
537 // there we just skip the test. | 541 // there we just skip the test. |
538 if (initial_memory >= 0) { | 542 if (initial_memory >= 0) { |
539 InitializeVM(); | 543 InitializeVM(); |
540 intptr_t delta = MemoryInUse() - initial_memory; | 544 intptr_t delta = MemoryInUse() - initial_memory; |
541 if (sizeof(initial_memory) == 8) { | 545 printf("delta: %" V8_PTR_PREFIX "d kB\n", delta / 1024); |
| 546 if (sizeof(initial_memory) == 8) { // 64-bit. |
542 if (v8::internal::Snapshot::IsEnabled()) { | 547 if (v8::internal::Snapshot::IsEnabled()) { |
543 CHECK_LE(delta, 3600 * 1024); // 3396. | 548 CHECK_LE(delta, 3700 * 1024); |
544 } else { | 549 } else { |
545 CHECK_LE(delta, 4000 * 1024); // 3948. | 550 CHECK_LE(delta, 4200 * 1024); |
546 } | 551 } |
547 } else { | 552 } else { // 32-bit. |
548 if (v8::internal::Snapshot::IsEnabled()) { | 553 if (v8::internal::Snapshot::IsEnabled()) { |
549 CHECK_LE(delta, 2600 * 1024); // 2400. | 554 CHECK_LE(delta, 2600 * 1024); |
550 } else { | 555 } else { |
551 CHECK_LE(delta, 3000 * 1024); // 2920. | 556 CHECK_LE(delta, 3000 * 1024); |
552 } | 557 } |
553 } | 558 } |
554 } | 559 } |
555 } | 560 } |
556 | 561 |
557 #endif // __linux__ and !USE_SIMULATOR | 562 #endif // __linux__ and !USE_SIMULATOR |
OLD | NEW |