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

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: Limit to pre-age patch. 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
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 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 return; 1030 return;
1031 } 1031 }
1032 CHECK(HEAP->old_pointer_space()->Contains(clone->address())); 1032 CHECK(HEAP->old_pointer_space()->Contains(clone->address()));
1033 } 1033 }
1034 1034
1035 1035
1036 TEST(TestCodeFlushing) { 1036 TEST(TestCodeFlushing) {
1037 // If we do not flush code this test is invalid. 1037 // If we do not flush code this test is invalid.
1038 if (!FLAG_flush_code) return; 1038 if (!FLAG_flush_code) return;
1039 i::FLAG_allow_natives_syntax = true; 1039 i::FLAG_allow_natives_syntax = true;
1040 i::FLAG_force_memory_constrained = MaybeBoolFlag::Create(true, false);
1040 CcTest::InitializeVM(); 1041 CcTest::InitializeVM();
1041 Isolate* isolate = Isolate::Current(); 1042 Isolate* isolate = Isolate::Current();
1042 Factory* factory = isolate->factory(); 1043 Factory* factory = isolate->factory();
1043 v8::HandleScope scope(CcTest::isolate()); 1044 v8::HandleScope scope(CcTest::isolate());
1044 const char* source = "function foo() {" 1045 const char* source = "function foo() {"
1045 " var x = 42;" 1046 " var x = 42;"
1046 " var y = 42;" 1047 " var y = 42;"
1047 " var z = x + y;" 1048 " var z = x + y;"
1048 "};" 1049 "};"
1049 "foo()"; 1050 "foo()";
(...skipping 25 matching lines...) Expand all
1075 // foo should no longer be in the compilation cache 1076 // foo should no longer be in the compilation cache
1076 CHECK(!function->shared()->is_compiled() || function->IsOptimized()); 1077 CHECK(!function->shared()->is_compiled() || function->IsOptimized());
1077 CHECK(!function->is_compiled() || function->IsOptimized()); 1078 CHECK(!function->is_compiled() || function->IsOptimized());
1078 // Call foo to get it recompiled. 1079 // Call foo to get it recompiled.
1079 CompileRun("foo()"); 1080 CompileRun("foo()");
1080 CHECK(function->shared()->is_compiled()); 1081 CHECK(function->shared()->is_compiled());
1081 CHECK(function->is_compiled()); 1082 CHECK(function->is_compiled());
1082 } 1083 }
1083 1084
1084 1085
1086 TEST(TestCodeFlushingPreAged) {
1087 // If we do not flush code this test is invalid.
1088 if (!FLAG_flush_code) return;
1089 i::FLAG_allow_natives_syntax = true;
1090 i::FLAG_force_memory_constrained = MaybeBoolFlag::Create(true, true);
1091 CcTest::InitializeVM();
1092 Isolate* isolate = Isolate::Current();
1093 Factory* factory = isolate->factory();
1094 v8::HandleScope scope(CcTest::isolate());
1095 const char* source = "function foo() {"
1096 " var x = 42;"
1097 " var y = 42;"
1098 " var z = x + y;"
1099 "};"
1100 "foo()";
1101 Handle<String> foo_name = factory->InternalizeUtf8String("foo");
1102
1103 // This compile will add the code to the compilation cache.
1104 { v8::HandleScope scope(CcTest::isolate());
1105 CompileRun(source);
1106 }
1107
1108 // Check function is compiled.
1109 Object* func_value = Isolate::Current()->context()->global_object()->
1110 GetProperty(*foo_name)->ToObjectChecked();
1111 CHECK(func_value->IsJSFunction());
1112 Handle<JSFunction> function(JSFunction::cast(func_value));
1113 CHECK(function->shared()->is_compiled());
1114
1115 // The code will survive at least one GC (it will be pre-aged so may not
1116 // survive further).
1117 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1118 CHECK(function->shared()->is_compiled());
1119
1120 // Execute the function again to ensure it is reset to the young age.
1121 { v8::HandleScope scope(CcTest::isolate());
1122 CompileRun("foo();");
1123 }
1124
1125 // The code will survive at least two GC now that it is young again.
1126 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1127 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1128 CHECK(function->shared()->is_compiled());
1129
1130 // Simulate several GCs that use full marking.
1131 const int kAgingThreshold = 6;
1132 for (int i = 0; i < kAgingThreshold; i++) {
1133 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1134 }
1135
1136 // foo should no longer be in the compilation cache
1137 CHECK(!function->shared()->is_compiled() || function->IsOptimized());
1138 CHECK(!function->is_compiled() || function->IsOptimized());
1139 // Call foo to get it recompiled.
1140 CompileRun("foo()");
1141 CHECK(function->shared()->is_compiled());
1142 CHECK(function->is_compiled());
1143 }
1144
1145
1085 TEST(TestCodeFlushingIncremental) { 1146 TEST(TestCodeFlushingIncremental) {
1086 // If we do not flush code this test is invalid. 1147 // If we do not flush code this test is invalid.
1087 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; 1148 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
1088 i::FLAG_allow_natives_syntax = true; 1149 i::FLAG_allow_natives_syntax = true;
1150 i::FLAG_force_memory_constrained = MaybeBoolFlag::Create(true, false);
1089 CcTest::InitializeVM(); 1151 CcTest::InitializeVM();
1090 Isolate* isolate = Isolate::Current(); 1152 Isolate* isolate = Isolate::Current();
1091 Factory* factory = isolate->factory(); 1153 Factory* factory = isolate->factory();
1092 v8::HandleScope scope(CcTest::isolate()); 1154 v8::HandleScope scope(CcTest::isolate());
1093 const char* source = "function foo() {" 1155 const char* source = "function foo() {"
1094 " var x = 42;" 1156 " var x = 42;"
1095 " var y = 42;" 1157 " var y = 42;"
1096 " var z = x + y;" 1158 " var z = x + y;"
1097 "};" 1159 "};"
1098 "foo()"; 1160 "foo()";
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1209 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1148 CHECK(function->shared()->is_compiled() || !function->IsOptimized()); 1210 CHECK(function->shared()->is_compiled() || !function->IsOptimized());
1149 CHECK(function->is_compiled() || !function->IsOptimized()); 1211 CHECK(function->is_compiled() || !function->IsOptimized());
1150 } 1212 }
1151 1213
1152 1214
1153 TEST(TestCodeFlushingIncrementalScavenge) { 1215 TEST(TestCodeFlushingIncrementalScavenge) {
1154 // If we do not flush code this test is invalid. 1216 // If we do not flush code this test is invalid.
1155 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; 1217 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
1156 i::FLAG_allow_natives_syntax = true; 1218 i::FLAG_allow_natives_syntax = true;
1219 i::FLAG_force_memory_constrained = MaybeBoolFlag::Create(true, false);
1157 CcTest::InitializeVM(); 1220 CcTest::InitializeVM();
1158 Isolate* isolate = Isolate::Current(); 1221 Isolate* isolate = Isolate::Current();
1159 Factory* factory = isolate->factory(); 1222 Factory* factory = isolate->factory();
1160 v8::HandleScope scope(CcTest::isolate()); 1223 v8::HandleScope scope(CcTest::isolate());
1161 const char* source = "var foo = function() {" 1224 const char* source = "var foo = function() {"
1162 " var x = 42;" 1225 " var x = 42;"
1163 " var y = 42;" 1226 " var y = 42;"
1164 " var z = x + y;" 1227 " var z = x + y;"
1165 "};" 1228 "};"
1166 "foo();" 1229 "foo();"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1278 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1216 CHECK(!function->shared()->is_compiled() || function->IsOptimized()); 1279 CHECK(!function->shared()->is_compiled() || function->IsOptimized());
1217 CHECK(!function->is_compiled() || function->IsOptimized()); 1280 CHECK(!function->is_compiled() || function->IsOptimized());
1218 } 1281 }
1219 1282
1220 1283
1221 TEST(TestCodeFlushingIncrementalAbort) { 1284 TEST(TestCodeFlushingIncrementalAbort) {
1222 // If we do not flush code this test is invalid. 1285 // If we do not flush code this test is invalid.
1223 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; 1286 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
1224 i::FLAG_allow_natives_syntax = true; 1287 i::FLAG_allow_natives_syntax = true;
1288 i::FLAG_force_memory_constrained = MaybeBoolFlag::Create(true, false);
1225 CcTest::InitializeVM(); 1289 CcTest::InitializeVM();
1226 Isolate* isolate = Isolate::Current(); 1290 Isolate* isolate = Isolate::Current();
1227 Factory* factory = isolate->factory(); 1291 Factory* factory = isolate->factory();
1228 Heap* heap = isolate->heap(); 1292 Heap* heap = isolate->heap();
1229 v8::HandleScope scope(CcTest::isolate()); 1293 v8::HandleScope scope(CcTest::isolate());
1230 const char* source = "function foo() {" 1294 const char* source = "function foo() {"
1231 " var x = 42;" 1295 " var x = 42;"
1232 " var y = 42;" 1296 " var y = 42;"
1233 " var z = x + y;" 1297 " var z = x + y;"
1234 "};" 1298 "};"
(...skipping 2208 matching lines...) Expand 10 before | Expand all | Expand 10 after
3443 " var a = new Array(n);" 3507 " var a = new Array(n);"
3444 " for (var i = 0; i < n; i += 100) a[i] = i;" 3508 " for (var i = 0; i < n; i += 100) a[i] = i;"
3445 "};" 3509 "};"
3446 "f(10 * 1024 * 1024);"); 3510 "f(10 * 1024 * 1024);");
3447 IncrementalMarking* marking = HEAP->incremental_marking(); 3511 IncrementalMarking* marking = HEAP->incremental_marking();
3448 if (marking->IsStopped()) marking->Start(); 3512 if (marking->IsStopped()) marking->Start();
3449 // This big step should be sufficient to mark the whole array. 3513 // This big step should be sufficient to mark the whole array.
3450 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); 3514 marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
3451 ASSERT(marking->IsComplete()); 3515 ASSERT(marking->IsComplete());
3452 } 3516 }
OLDNEW
« src/ia32/full-codegen-ia32.cc ('K') | « src/x64/lithium-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698