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

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

Issue 20867003: More cleanup regarding the maximum non-large object allocation size. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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/spaces.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 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 } 953 }
954 954
955 955
956 TEST(Regression39128) { 956 TEST(Regression39128) {
957 // Test case for crbug.com/39128. 957 // Test case for crbug.com/39128.
958 CcTest::InitializeVM(); 958 CcTest::InitializeVM();
959 Isolate* isolate = Isolate::Current(); 959 Isolate* isolate = Isolate::Current();
960 Factory* factory = isolate->factory(); 960 Factory* factory = isolate->factory();
961 961
962 // Increase the chance of 'bump-the-pointer' allocation in old space. 962 // Increase the chance of 'bump-the-pointer' allocation in old space.
963 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 963 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
964 964
965 v8::HandleScope scope(CcTest::isolate()); 965 v8::HandleScope scope(CcTest::isolate());
966 966
967 // The plan: create JSObject which references objects in new space. 967 // The plan: create JSObject which references objects in new space.
968 // Then clone this object (forcing it to go into old space) and check 968 // Then clone this object (forcing it to go into old space) and check
969 // that region dirty marks are updated correctly. 969 // that region dirty marks are updated correctly.
970 970
971 // Step 1: prepare a map for the object. We add 1 inobject property to it. 971 // Step 1: prepare a map for the object. We add 1 inobject property to it.
972 Handle<JSFunction> object_ctor( 972 Handle<JSFunction> object_ctor(
973 Isolate::Current()->native_context()->object_function()); 973 Isolate::Current()->native_context()->object_function());
974 CHECK(object_ctor->has_initial_map()); 974 CHECK(object_ctor->has_initial_map());
975 Handle<Map> object_map(object_ctor->initial_map()); 975 Handle<Map> object_map(object_ctor->initial_map());
976 // Create a map with single inobject property. 976 // Create a map with single inobject property.
977 Handle<Map> my_map = factory->CopyMap(object_map, 1); 977 Handle<Map> my_map = factory->CopyMap(object_map, 1);
978 int n_properties = my_map->inobject_properties(); 978 int n_properties = my_map->inobject_properties();
979 CHECK_GT(n_properties, 0); 979 CHECK_GT(n_properties, 0);
980 980
981 int object_size = my_map->instance_size(); 981 int object_size = my_map->instance_size();
982 982
983 // Step 2: allocate a lot of objects so to almost fill new space: we need 983 // Step 2: allocate a lot of objects so to almost fill new space: we need
984 // just enough room to allocate JSObject and thus fill the newspace. 984 // just enough room to allocate JSObject and thus fill the newspace.
985 985
986 int allocation_amount = Min(FixedArray::kMaxSize, 986 int allocation_amount = Min(FixedArray::kMaxSize,
987 Page::kMaxNonCodeHeapObjectSize); 987 Page::kMaxNonCodeHeapObjectSize + kPointerSize);
988 int allocation_len = LenFromSize(allocation_amount); 988 int allocation_len = LenFromSize(allocation_amount);
989 NewSpace* new_space = HEAP->new_space(); 989 NewSpace* new_space = HEAP->new_space();
990 Address* top_addr = new_space->allocation_top_address(); 990 Address* top_addr = new_space->allocation_top_address();
991 Address* limit_addr = new_space->allocation_limit_address(); 991 Address* limit_addr = new_space->allocation_limit_address();
992 while ((*limit_addr - *top_addr) > allocation_amount) { 992 while ((*limit_addr - *top_addr) > allocation_amount) {
993 CHECK(!HEAP->always_allocate()); 993 CHECK(!HEAP->always_allocate());
994 Object* array = HEAP->AllocateFixedArray(allocation_len)->ToObjectChecked(); 994 Object* array = HEAP->AllocateFixedArray(allocation_len)->ToObjectChecked();
995 CHECK(!array->IsFailure()); 995 CHECK(!array->IsFailure());
996 CHECK(new_space->Contains(array)); 996 CHECK(new_space->Contains(array));
997 } 997 }
(...skipping 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after
3379 " var a = new Array(n);" 3379 " var a = new Array(n);"
3380 " for (var i = 0; i < n; i += 100) a[i] = i;" 3380 " for (var i = 0; i < n; i += 100) a[i] = i;"
3381 "};" 3381 "};"
3382 "f(10 * 1024 * 1024);"); 3382 "f(10 * 1024 * 1024);");
3383 IncrementalMarking* marking = HEAP->incremental_marking(); 3383 IncrementalMarking* marking = HEAP->incremental_marking();
3384 if (marking->IsStopped()) marking->Start(); 3384 if (marking->IsStopped()) marking->Start();
3385 // This big step should be sufficient to mark the whole array. 3385 // This big step should be sufficient to mark the whole array.
3386 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 3386 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
3387 ASSERT(marking->IsComplete()); 3387 ASSERT(marking->IsComplete());
3388 } 3388 }
OLDNEW
« no previous file with comments | « src/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698