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

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

Powered by Google App Engine
This is Rietveld 408576698