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

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

Issue 23480031: Enable preaging of code objects when --optimize-for-size. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Make pre-aging conditional on is_memory_constrained() Created 7 years, 3 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/x64/lithium-codegen-x64.cc ('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 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 CompileRun(source); 1054 CompileRun(source);
1055 } 1055 }
1056 1056
1057 // Check function is compiled. 1057 // Check function is compiled.
1058 Object* func_value = Isolate::Current()->context()->global_object()-> 1058 Object* func_value = Isolate::Current()->context()->global_object()->
1059 GetProperty(*foo_name)->ToObjectChecked(); 1059 GetProperty(*foo_name)->ToObjectChecked();
1060 CHECK(func_value->IsJSFunction()); 1060 CHECK(func_value->IsJSFunction());
1061 Handle<JSFunction> function(JSFunction::cast(func_value)); 1061 Handle<JSFunction> function(JSFunction::cast(func_value));
1062 CHECK(function->shared()->is_compiled()); 1062 CHECK(function->shared()->is_compiled());
1063 1063
1064 // The code will survive at least two GCs. 1064 // The code will survive at least one GC (it will be pre-aged so may not
1065 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 1065 // survive further).
Hannes Payer (out of office) 2013/09/16 14:31:45 Since we have the mode now which is turned on on m
rmcilroy 2013/09/16 15:45:47 Sounds like a plan. Done.
1066 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 1066 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1067 CHECK(function->shared()->is_compiled()); 1067 CHECK(function->shared()->is_compiled());
1068 1068
1069 // Simulate several GCs that use full marking. 1069 // Simulate several GCs that use full marking.
1070 const int kAgingThreshold = 6; 1070 const int kAgingThreshold = 6;
1071 for (int i = 0; i < kAgingThreshold; i++) { 1071 for (int i = 0; i < kAgingThreshold; i++) {
1072 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 1072 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1073 } 1073 }
1074 1074
1075 // foo should no longer be in the compilation cache 1075 // foo should no longer be in the compilation cache
(...skipping 27 matching lines...) Expand all
1103 CompileRun(source); 1103 CompileRun(source);
1104 } 1104 }
1105 1105
1106 // Check function is compiled. 1106 // Check function is compiled.
1107 Object* func_value = Isolate::Current()->context()->global_object()-> 1107 Object* func_value = Isolate::Current()->context()->global_object()->
1108 GetProperty(*foo_name)->ToObjectChecked(); 1108 GetProperty(*foo_name)->ToObjectChecked();
1109 CHECK(func_value->IsJSFunction()); 1109 CHECK(func_value->IsJSFunction());
1110 Handle<JSFunction> function(JSFunction::cast(func_value)); 1110 Handle<JSFunction> function(JSFunction::cast(func_value));
1111 CHECK(function->shared()->is_compiled()); 1111 CHECK(function->shared()->is_compiled());
1112 1112
1113 // The code will survive at least two GCs. 1113 // The code will survive at least one GC (it will be pre-aged so may not
1114 // survive further).
1115 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1116 CHECK(function->shared()->is_compiled());
1117
1118 // Execute the function again to ensure it is reset to the young age.
1119 { v8::HandleScope scope(CcTest::isolate());
1120 CompileRun("foo();");
1121 }
1122
1123 // The code will survive at least two GC now that it is young again.
1114 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 1124 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1115 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 1125 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1116 CHECK(function->shared()->is_compiled()); 1126 CHECK(function->shared()->is_compiled());
1117 1127
1118 // Simulate several GCs that use incremental marking. 1128 // Simulate several GCs that use incremental marking.
1119 const int kAgingThreshold = 6; 1129 const int kAgingThreshold = 6;
1120 for (int i = 0; i < kAgingThreshold; i++) { 1130 for (int i = 0; i < kAgingThreshold; i++) {
1121 SimulateIncrementalMarking(); 1131 SimulateIncrementalMarking();
1122 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1132 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1123 } 1133 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 CompileRun(source); 1250 CompileRun(source);
1241 } 1251 }
1242 1252
1243 // Check function is compiled. 1253 // Check function is compiled.
1244 Object* func_value = Isolate::Current()->context()->global_object()-> 1254 Object* func_value = Isolate::Current()->context()->global_object()->
1245 GetProperty(*foo_name)->ToObjectChecked(); 1255 GetProperty(*foo_name)->ToObjectChecked();
1246 CHECK(func_value->IsJSFunction()); 1256 CHECK(func_value->IsJSFunction());
1247 Handle<JSFunction> function(JSFunction::cast(func_value)); 1257 Handle<JSFunction> function(JSFunction::cast(func_value));
1248 CHECK(function->shared()->is_compiled()); 1258 CHECK(function->shared()->is_compiled());
1249 1259
1250 // The code will survive at least two GCs. 1260 // The code will survive at least one GC (it will be pre-aged so may not
1251 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 1261 // survive further).
1252 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 1262 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1253 CHECK(function->shared()->is_compiled()); 1263 CHECK(function->shared()->is_compiled());
1254 1264
1255 // Bump the code age so that flushing is triggered. 1265 // Bump the code age so that flushing is triggered.
1256 const int kAgingThreshold = 6; 1266 const int kAgingThreshold = 6;
1257 for (int i = 0; i < kAgingThreshold; i++) { 1267 for (int i = 0; i < kAgingThreshold; i++) {
1258 function->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 1268 function->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
1259 } 1269 }
1260 1270
1261 // Simulate incremental marking so that the function is enqueued as 1271 // Simulate incremental marking so that the function is enqueued as
1262 // code flushing candidate. 1272 // code flushing candidate.
(...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after
3447 " var a = new Array(n);" 3457 " var a = new Array(n);"
3448 " for (var i = 0; i < n; i += 100) a[i] = i;" 3458 " for (var i = 0; i < n; i += 100) a[i] = i;"
3449 "};" 3459 "};"
3450 "f(10 * 1024 * 1024);"); 3460 "f(10 * 1024 * 1024);");
3451 IncrementalMarking* marking = HEAP->incremental_marking(); 3461 IncrementalMarking* marking = HEAP->incremental_marking();
3452 if (marking->IsStopped()) marking->Start(); 3462 if (marking->IsStopped()) marking->Start();
3453 // This big step should be sufficient to mark the whole array. 3463 // This big step should be sufficient to mark the whole array.
3454 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 3464 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
3455 ASSERT(marking->IsComplete()); 3465 ASSERT(marking->IsComplete());
3456 } 3466 }
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698