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

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

Issue 1058793002: Support for typed arrays added to Heap::RightTrimFixedArray(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 5 years, 8 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
« 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 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 5294 matching lines...) Expand 10 before | Expand all | Expand 10 after
5305 5305
5306 TEST(WritableVsImmortalRoots) { 5306 TEST(WritableVsImmortalRoots) {
5307 for (int i = 0; i < Heap::kStrongRootListLength; ++i) { 5307 for (int i = 0; i < Heap::kStrongRootListLength; ++i) {
5308 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); 5308 Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i);
5309 bool writable = Heap::RootCanBeWrittenAfterInitialization(root_index); 5309 bool writable = Heap::RootCanBeWrittenAfterInitialization(root_index);
5310 bool immortal = Heap::RootIsImmortalImmovable(root_index); 5310 bool immortal = Heap::RootIsImmortalImmovable(root_index);
5311 // A root value can be writable, immortal, or neither, but not both. 5311 // A root value can be writable, immortal, or neither, but not both.
5312 CHECK(!immortal || !writable); 5312 CHECK(!immortal || !writable);
5313 } 5313 }
5314 } 5314 }
5315
5316
5317 static void TestRightTrimFixedTypedArray(v8::ExternalArrayType type,
5318 int initial_length,
5319 int elements_to_trim) {
5320 v8::HandleScope scope(CcTest::isolate());
5321 Isolate* isolate = CcTest::i_isolate();
5322 Factory* factory = isolate->factory();
5323 Heap* heap = isolate->heap();
5324
5325 Handle<FixedTypedArrayBase> array =
5326 factory->NewFixedTypedArray(initial_length, type);
5327 int old_size = array->size();
5328 heap->RightTrimFixedArray<Heap::FROM_MUTATOR>(*array, elements_to_trim);
5329
5330 // Check that free space filler is at the right place and did not smash the
5331 // array header.
5332 CHECK(array->IsFixedArrayBase());
5333 CHECK_EQ(initial_length - elements_to_trim, array->length());
5334 int new_size = array->size();
5335 if (new_size != old_size) {
5336 // Free space filler should be created in this case.
5337 Address next_obj_address = array->address() + array->size();
5338 CHECK(HeapObject::FromAddress(next_obj_address)->IsFiller());
5339 }
5340 heap->CollectAllAvailableGarbage();
5341 }
5342
5343
5344 TEST(Regress472513) {
5345 CcTest::InitializeVM();
5346 v8::HandleScope scope(CcTest::isolate());
5347
5348 // The combination of type/initial_length/elements_to_trim triggered
5349 // typed array header smashing with free space filler (crbug/472513).
5350
5351 // 64-bit cases.
5352 TestRightTrimFixedTypedArray(v8::kExternalUint8Array, 32, 6);
5353 TestRightTrimFixedTypedArray(v8::kExternalUint8Array, 32 - 7, 6);
5354 TestRightTrimFixedTypedArray(v8::kExternalUint16Array, 16, 6);
5355 TestRightTrimFixedTypedArray(v8::kExternalUint16Array, 16 - 3, 6);
5356 TestRightTrimFixedTypedArray(v8::kExternalUint32Array, 8, 6);
5357 TestRightTrimFixedTypedArray(v8::kExternalUint32Array, 8 - 1, 6);
5358
5359 // 32-bit cases.
5360 TestRightTrimFixedTypedArray(v8::kExternalUint8Array, 16, 3);
5361 TestRightTrimFixedTypedArray(v8::kExternalUint8Array, 16 - 3, 3);
5362 TestRightTrimFixedTypedArray(v8::kExternalUint16Array, 8, 3);
5363 TestRightTrimFixedTypedArray(v8::kExternalUint16Array, 8 - 1, 3);
5364 TestRightTrimFixedTypedArray(v8::kExternalUint32Array, 4, 3);
5365 }
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