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

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

Issue 11464021: Make test-heap resilient against GC stress. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years 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 | « no previous file | 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 2
3 #include <stdlib.h> 3 #include <stdlib.h>
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "compilation-cache.h" 7 #include "compilation-cache.h"
8 #include "execution.h" 8 #include "execution.h"
9 #include "factory.h" 9 #include "factory.h"
10 #include "macro-assembler.h" 10 #include "macro-assembler.h"
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 } 974 }
975 975
976 // Check function is compiled. 976 // Check function is compiled.
977 Object* func_value = Isolate::Current()->context()->global_object()-> 977 Object* func_value = Isolate::Current()->context()->global_object()->
978 GetProperty(*foo_name)->ToObjectChecked(); 978 GetProperty(*foo_name)->ToObjectChecked();
979 CHECK(func_value->IsJSFunction()); 979 CHECK(func_value->IsJSFunction());
980 Handle<JSFunction> function(JSFunction::cast(func_value)); 980 Handle<JSFunction> function(JSFunction::cast(func_value));
981 CHECK(function->shared()->is_compiled()); 981 CHECK(function->shared()->is_compiled());
982 982
983 // The code will survive at least two GCs. 983 // The code will survive at least two GCs.
984 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 984 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
985 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 985 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
986 CHECK(function->shared()->is_compiled()); 986 CHECK(function->shared()->is_compiled());
987 987
988 // Simulate several GCs that use full marking. 988 // Simulate several GCs that use full marking.
989 const int kAgingThreshold = 6; 989 const int kAgingThreshold = 6;
990 for (int i = 0; i < kAgingThreshold; i++) { 990 for (int i = 0; i < kAgingThreshold; i++) {
991 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); 991 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
992 } 992 }
993 993
994 // foo should no longer be in the compilation cache 994 // foo should no longer be in the compilation cache
995 CHECK(!function->shared()->is_compiled() || function->IsOptimized()); 995 CHECK(!function->shared()->is_compiled() || function->IsOptimized());
(...skipping 25 matching lines...) Expand all
1021 } 1021 }
1022 1022
1023 // Check function is compiled. 1023 // Check function is compiled.
1024 Object* func_value = Isolate::Current()->context()->global_object()-> 1024 Object* func_value = Isolate::Current()->context()->global_object()->
1025 GetProperty(*foo_name)->ToObjectChecked(); 1025 GetProperty(*foo_name)->ToObjectChecked();
1026 CHECK(func_value->IsJSFunction()); 1026 CHECK(func_value->IsJSFunction());
1027 Handle<JSFunction> function(JSFunction::cast(func_value)); 1027 Handle<JSFunction> function(JSFunction::cast(func_value));
1028 CHECK(function->shared()->is_compiled()); 1028 CHECK(function->shared()->is_compiled());
1029 1029
1030 // The code will survive at least two GCs. 1030 // The code will survive at least two GCs.
1031 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1031 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1032 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1032 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1033 CHECK(function->shared()->is_compiled()); 1033 CHECK(function->shared()->is_compiled());
1034 1034
1035 // Simulate several GCs that use incremental marking. 1035 // Simulate several GCs that use incremental marking.
1036 const int kAgingThreshold = 6; 1036 const int kAgingThreshold = 6;
1037 for (int i = 0; i < kAgingThreshold; i++) { 1037 for (int i = 0; i < kAgingThreshold; i++) {
1038 HEAP->incremental_marking()->Abort(); 1038 HEAP->incremental_marking()->Abort();
1039 SimulateIncrementalMarking(); 1039 SimulateIncrementalMarking();
1040 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1040 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1041 } 1041 }
1042 CHECK(!function->shared()->is_compiled() || function->IsOptimized()); 1042 CHECK(!function->shared()->is_compiled() || function->IsOptimized());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 "};" 1082 "};"
1083 "foo();" 1083 "foo();"
1084 "var bar = function() {" 1084 "var bar = function() {"
1085 " var x = 23;" 1085 " var x = 23;"
1086 "};" 1086 "};"
1087 "bar();"; 1087 "bar();";
1088 Handle<String> foo_name = FACTORY->LookupAsciiSymbol("foo"); 1088 Handle<String> foo_name = FACTORY->LookupAsciiSymbol("foo");
1089 Handle<String> bar_name = FACTORY->LookupAsciiSymbol("bar"); 1089 Handle<String> bar_name = FACTORY->LookupAsciiSymbol("bar");
1090 1090
1091 // Perfrom one initial GC to enable code flushing. 1091 // Perfrom one initial GC to enable code flushing.
1092 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1092 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1093 1093
1094 // This compile will add the code to the compilation cache. 1094 // This compile will add the code to the compilation cache.
1095 { v8::HandleScope scope; 1095 { v8::HandleScope scope;
1096 CompileRun(source); 1096 CompileRun(source);
1097 } 1097 }
1098 1098
1099 // Check functions are compiled. 1099 // Check functions are compiled.
1100 Object* func_value = Isolate::Current()->context()->global_object()-> 1100 Object* func_value = Isolate::Current()->context()->global_object()->
1101 GetProperty(*foo_name)->ToObjectChecked(); 1101 GetProperty(*foo_name)->ToObjectChecked();
1102 CHECK(func_value->IsJSFunction()); 1102 CHECK(func_value->IsJSFunction());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 } 1155 }
1156 1156
1157 // Check function is compiled. 1157 // Check function is compiled.
1158 Object* func_value = Isolate::Current()->context()->global_object()-> 1158 Object* func_value = Isolate::Current()->context()->global_object()->
1159 GetProperty(*foo_name)->ToObjectChecked(); 1159 GetProperty(*foo_name)->ToObjectChecked();
1160 CHECK(func_value->IsJSFunction()); 1160 CHECK(func_value->IsJSFunction());
1161 Handle<JSFunction> function(JSFunction::cast(func_value)); 1161 Handle<JSFunction> function(JSFunction::cast(func_value));
1162 CHECK(function->shared()->is_compiled()); 1162 CHECK(function->shared()->is_compiled());
1163 1163
1164 // The code will survive at least two GCs. 1164 // The code will survive at least two GCs.
1165 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1165 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1166 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 1166 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1167 CHECK(function->shared()->is_compiled()); 1167 CHECK(function->shared()->is_compiled());
1168 1168
1169 // Bump the code age so that flushing is triggered. 1169 // Bump the code age so that flushing is triggered.
1170 const int kAgingThreshold = 6; 1170 const int kAgingThreshold = 6;
1171 for (int i = 0; i < kAgingThreshold; i++) { 1171 for (int i = 0; i < kAgingThreshold; i++) {
1172 function->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); 1172 function->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
1173 } 1173 }
1174 1174
1175 // Simulate incremental marking so that the function is enqueued as 1175 // Simulate incremental marking so that the function is enqueued as
1176 // code flushing candidate. 1176 // code flushing candidate.
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
2510 } 2510 }
2511 2511
2512 2512
2513 TEST(Regress159140) { 2513 TEST(Regress159140) {
2514 i::FLAG_allow_natives_syntax = true; 2514 i::FLAG_allow_natives_syntax = true;
2515 i::FLAG_flush_code_incrementally = true; 2515 i::FLAG_flush_code_incrementally = true;
2516 InitializeVM(); 2516 InitializeVM();
2517 v8::HandleScope scope; 2517 v8::HandleScope scope;
2518 2518
2519 // Perform one initial GC to enable code flushing. 2519 // Perform one initial GC to enable code flushing.
2520 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 2520 HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
2521 2521
2522 // Prepare several closures that are all eligible for code flushing 2522 // Prepare several closures that are all eligible for code flushing
2523 // because all reachable ones are not optimized. Make sure that the 2523 // because all reachable ones are not optimized. Make sure that the
2524 // optimized code object is directly reachable through a handle so 2524 // optimized code object is directly reachable through a handle so
2525 // that it is marked black during incremental marking. 2525 // that it is marked black during incremental marking.
2526 Handle<Code> code; 2526 Handle<Code> code;
2527 { 2527 {
2528 HandleScope inner_scope; 2528 HandleScope inner_scope;
2529 CompileRun("function h(x) {}" 2529 CompileRun("function h(x) {}"
2530 "function mkClosure() {" 2530 "function mkClosure() {"
(...skipping 30 matching lines...) Expand all
2561 // Simulate incremental marking so that the functions are enqueued as 2561 // Simulate incremental marking so that the functions are enqueued as
2562 // code flushing candidates. Then optimize one function. Finally 2562 // code flushing candidates. Then optimize one function. Finally
2563 // finish the GC to complete code flushing. 2563 // finish the GC to complete code flushing.
2564 SimulateIncrementalMarking(); 2564 SimulateIncrementalMarking();
2565 CompileRun("%OptimizeFunctionOnNextCall(g); g(3);"); 2565 CompileRun("%OptimizeFunctionOnNextCall(g); g(3);");
2566 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 2566 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2567 2567
2568 // Unoptimized code is missing and the deoptimizer will go ballistic. 2568 // Unoptimized code is missing and the deoptimizer will go ballistic.
2569 CompileRun("g('bozo');"); 2569 CompileRun("g('bozo');");
2570 } 2570 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698