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

Side by Side Diff: test/cctest/test-constantpool.cc

Issue 413173002: Revert r22597 (which should have been called: "Tests that the GC doesn't mistake non-pointer consta… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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/objects-inl.h ('k') | 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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 2
3 // Test constant pool array code. 3 // Test constant pool array code.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/factory.h" 7 #include "src/factory.h"
8 #include "src/objects.h" 8 #include "src/objects.h"
9 #include "test/cctest/cctest.h" 9 #include "test/cctest/cctest.h"
10 10
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 int expected_int64_indexs[] = { 0, 5, 6, 7, 8, 9 }; 236 int expected_int64_indexs[] = { 0, 5, 6, 7, 8, 9 };
237 CheckIterator(array, ConstantPoolArray::INT64, expected_int64_indexs, 6); 237 CheckIterator(array, ConstantPoolArray::INT64, expected_int64_indexs, 6);
238 int expected_code_indexs[1]; 238 int expected_code_indexs[1];
239 CheckIterator(array, ConstantPoolArray::CODE_PTR, expected_code_indexs, 0); 239 CheckIterator(array, ConstantPoolArray::CODE_PTR, expected_code_indexs, 0);
240 int expected_heap_indexs[] = { 10, 11, 12 }; 240 int expected_heap_indexs[] = { 10, 11, 12 };
241 CheckIterator(array, ConstantPoolArray::HEAP_PTR, expected_heap_indexs, 3); 241 CheckIterator(array, ConstantPoolArray::HEAP_PTR, expected_heap_indexs, 3);
242 int expected_int32_indexs[] = { 1, 2, 3, 4 }; 242 int expected_int32_indexs[] = { 1, 2, 3, 4 };
243 CheckIterator(array, ConstantPoolArray::INT32, expected_int32_indexs, 4); 243 CheckIterator(array, ConstantPoolArray::INT32, expected_int32_indexs, 4);
244 } 244 }
245
246
247 TEST(ConstantPoolPreciseGC) {
248 LocalContext context;
249 Isolate* isolate = CcTest::i_isolate();
250 Heap* heap = isolate->heap();
251 Factory* factory = isolate->factory();
252 v8::HandleScope scope(context->GetIsolate());
253
254 ConstantPoolArray::NumberOfEntries small(1, 0, 0, 1);
255 Handle<ConstantPoolArray> array = factory->NewConstantPoolArray(small);
256
257 // Check that the store buffer knows which entries are pointers and which are
258 // not. To do this, make non-pointer entries which look like new space
259 // pointers but are actually invalid and ensure the GC doesn't try to move
260 // them.
261 Handle<HeapObject> object = factory->NewHeapNumber(4.0);
262 Object* raw_ptr = *object;
263 // If interpreted as a pointer, this should be right inside the heap number
264 // which will cause a crash when trying to lookup the 'map' pointer.
265 int32_t invalid_ptr_int32 = reinterpret_cast<int32_t>(raw_ptr) + kInt32Size;
266 int64_t invalid_ptr_int64 = reinterpret_cast<int64_t>(raw_ptr) + kInt32Size;
267 array->set(0, invalid_ptr_int64);
268 array->set(1, invalid_ptr_int32);
269
270 // Ensure we perform a scan on scavenge for the constant pool's page.
271 MemoryChunk::FromAddress(array->address())->set_scan_on_scavenge(true);
272 heap->CollectGarbage(NEW_SPACE);
273
274 // Check the object was moved by GC.
275 CHECK_NE(*object, raw_ptr);
276
277 // Check the non-pointer entries weren't changed.
278 CHECK_EQ(invalid_ptr_int64, array->get_int64_entry(0));
279 CHECK_EQ(invalid_ptr_int32, array->get_int32_entry(1));
280 }
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698