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

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

Issue 12218051: Fix NULL-pointer arithmetic abuse in tests surfaced by clang (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 7 years, 10 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 | « 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 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 static v8::Persistent<v8::Context> env; 46 static v8::Persistent<v8::Context> env;
47 47
48 static void InitializeVM() { 48 static void InitializeVM() {
49 if (env.IsEmpty()) env = v8::Context::New(); 49 if (env.IsEmpty()) env = v8::Context::New();
50 v8::HandleScope scope; 50 v8::HandleScope scope;
51 env->Enter(); 51 env->Enter();
52 } 52 }
53 53
54 54
55 TEST(MarkingDeque) { 55 TEST(MarkingDeque) {
56 InitializeVM();
56 int mem_size = 20 * kPointerSize; 57 int mem_size = 20 * kPointerSize;
57 byte* mem = NewArray<byte>(20*kPointerSize); 58 byte* mem = NewArray<byte>(20*kPointerSize);
58 Address low = reinterpret_cast<Address>(mem); 59 Address low = reinterpret_cast<Address>(mem);
59 Address high = low + mem_size; 60 Address high = low + mem_size;
60 MarkingDeque s; 61 MarkingDeque s;
61 s.Initialize(low, high); 62 s.Initialize(low, high);
62 63
63 Address address = NULL; 64 Address original_address = reinterpret_cast<Address>(&s);
65 Address current_address = original_address;
64 while (!s.IsFull()) { 66 while (!s.IsFull()) {
65 s.PushBlack(HeapObject::FromAddress(address)); 67 s.PushBlack(HeapObject::FromAddress(current_address));
66 address += kPointerSize; 68 current_address += kPointerSize;
67 } 69 }
68 70
69 while (!s.IsEmpty()) { 71 while (!s.IsEmpty()) {
70 Address value = s.Pop()->address(); 72 Address value = s.Pop()->address();
71 address -= kPointerSize; 73 current_address -= kPointerSize;
72 CHECK_EQ(address, value); 74 CHECK_EQ(current_address, value);
73 } 75 }
74 76
75 CHECK_EQ(NULL, address); 77 CHECK_EQ(original_address, current_address);
76 DeleteArray(mem); 78 DeleteArray(mem);
77 } 79 }
78 80
79 81
80 TEST(Promotion) { 82 TEST(Promotion) {
81 // This test requires compaction. If compaction is turned off, we 83 // This test requires compaction. If compaction is turned off, we
82 // skip the entire test. 84 // skip the entire test.
83 if (FLAG_never_compact) return; 85 if (FLAG_never_compact) return;
84 86
85 // Ensure that we get a compacting collection so that objects are promoted 87 // Ensure that we get a compacting collection so that objects are promoted
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 if (v8::internal::Snapshot::IsEnabled()) { 566 if (v8::internal::Snapshot::IsEnabled()) {
565 CHECK_LE(delta, 2600 * 1024); 567 CHECK_LE(delta, 2600 * 1024);
566 } else { 568 } else {
567 CHECK_LE(delta, 3100 * 1024); 569 CHECK_LE(delta, 3100 * 1024);
568 } 570 }
569 } 571 }
570 } 572 }
571 } 573 }
572 574
573 #endif // __linux__ and !USE_SIMULATOR 575 #endif // __linux__ and !USE_SIMULATOR
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