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

Side by Side Diff: test/cctest/test-mark-compact.cc

Issue 8750001: Introduce a test of how much memory it takes to boot up V8. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years 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 | « no previous file | no next file » | 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 29
30 #ifdef __linux__
31 #include <sys/types.h>
32 #include <sys/stat.h>
33 #include <fcntl.h>
34 #include <unistd.h>
35 #include <errno.h>
36 #endif
37
30 #include "v8.h" 38 #include "v8.h"
31 39
32 #include "global-handles.h" 40 #include "global-handles.h"
33 #include "snapshot.h" 41 #include "snapshot.h"
34 #include "cctest.h" 42 #include "cctest.h"
35 43
36 using namespace v8::internal; 44 using namespace v8::internal;
37 45
38 static v8::Persistent<v8::Context> env; 46 static v8::Persistent<v8::Context> env;
39 47
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 Handle<Object> object = 445 Handle<Object> object =
438 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); 446 global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
439 447
440 TestRetainedObjectInfo info; 448 TestRetainedObjectInfo info;
441 global_handles->AddObjectGroup(NULL, 0, &info); 449 global_handles->AddObjectGroup(NULL, 0, &info);
442 ASSERT(info.has_been_disposed()); 450 ASSERT(info.has_been_disposed());
443 451
444 global_handles->AddImplicitReferences( 452 global_handles->AddImplicitReferences(
445 Handle<HeapObject>::cast(object).location(), NULL, 0); 453 Handle<HeapObject>::cast(object).location(), NULL, 0);
446 } 454 }
455
456
457 #ifdef __linux__
458
459
460 static uintptr_t ReadLong(char* buffer, intptr_t* position, int base) {
461 char* end_address = buffer + *position;
462 uintptr_t result = strtoul(buffer + *position, &end_address, base);
463 CHECK(result != ULONG_MAX || errno != ERANGE);
464 CHECK(end_address > buffer + *position);
465 *position = end_address - buffer;
466 return result;
467 }
468
469
470 static intptr_t MemoryInUse() {
471 intptr_t memory_use = 0;
472
473 int fd = open("/proc/self/maps", O_RDONLY);
474 if (fd < 0) return -1;
475
476 const int kBufSize = 10000;
477 char buffer[kBufSize];
478 int length = read(fd, buffer, kBufSize);
479 intptr_t line_start = 0;
480 CHECK_LT(length, kBufSize); // Make the buffer bigger.
481 CHECK_GT(length, 0); // We have to find some data in the file.
482 while (line_start < length) {
483 if (buffer[line_start] == '\n') {
484 line_start++;
485 continue;
486 }
487 intptr_t position = line_start;
488 uintptr_t start = ReadLong(buffer, &position, 16);
489 CHECK_EQ(buffer[position++], '-');
490 uintptr_t end = ReadLong(buffer, &position, 16);
491 CHECK_EQ(buffer[position++], ' ');
492 CHECK(buffer[position] == '-' || buffer[position] == 'r');
493 bool read_permission = (buffer[position++] == 'r');
494 CHECK(buffer[position] == '-' || buffer[position] == 'w');
495 bool write_permission = (buffer[position++] == 'w');
496 CHECK(buffer[position] == '-' || buffer[position] == 'x');
497 bool execute_permission = (buffer[position++] == 'x');
498 CHECK(buffer[position] == '-' || buffer[position] == 'p');
499 bool private_mapping = (buffer[position++] == 'p');
500 CHECK_EQ(buffer[position++], ' ');
501 uintptr_t offset = ReadLong(buffer, &position, 16);
502 USE(offset);
503 CHECK_EQ(buffer[position++], ' ');
504 uintptr_t major = ReadLong(buffer, &position, 16);
505 USE(major);
506 CHECK_EQ(buffer[position++], ':');
507 uintptr_t minor = ReadLong(buffer, &position, 16);
508 USE(minor);
509 CHECK_EQ(buffer[position++], ' ');
510 uintptr_t inode = ReadLong(buffer, &position, 10);
511 while (position < length && buffer[position] != '\n') position++;
512 if ((read_permission || write_permission || execute_permission) &&
513 private_mapping && inode == 0) {
514 memory_use += (end - start);
515 }
516
517 line_start = position;
518 }
519 close(fd);
520 return memory_use;
521 }
522
523
524 TEST(BootUpMemoryUse) {
525 intptr_t initial_memory = MemoryInUse();
526 // Only Linux has the proc filesystem and only if it is mapped. If it's not
527 // there we just skip the test.
528 if (initial_memory >= 0) {
529 InitializeVM();
530 intptr_t booted_memory = MemoryInUse();
531 CHECK_LE(booted_memory - initial_memory, 20 * 1024 * 1024);
532 }
533 }
534
535 #endif
Michael Starzinger 2011/12/01 11:44:13 Please add an "// __linux__" comment here.
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698