| OLD | NEW |
| 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 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 CHECK(function2->shared()->is_compiled()); | 1109 CHECK(function2->shared()->is_compiled()); |
| 1110 | 1110 |
| 1111 // Clear references to functions so that one of them can die. | 1111 // Clear references to functions so that one of them can die. |
| 1112 { v8::HandleScope scope; | 1112 { v8::HandleScope scope; |
| 1113 CompileRun("foo = 0; bar = 0;"); | 1113 CompileRun("foo = 0; bar = 0;"); |
| 1114 } | 1114 } |
| 1115 | 1115 |
| 1116 // Bump the code age so that flushing is triggered while the function | 1116 // Bump the code age so that flushing is triggered while the function |
| 1117 // object is still located in new-space. | 1117 // object is still located in new-space. |
| 1118 const int kAgingThreshold = 6; | 1118 const int kAgingThreshold = 6; |
| 1119 function->shared()->set_code_age(kAgingThreshold); | 1119 for (int i = 0; i < kAgingThreshold; i++) { |
| 1120 function2->shared()->set_code_age(kAgingThreshold); | 1120 function->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); |
| 1121 function2->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); |
| 1122 } |
| 1121 | 1123 |
| 1122 // Simulate incremental marking so that the functions are enqueued as | 1124 // Simulate incremental marking so that the functions are enqueued as |
| 1123 // code flushing candidates. Then kill one of the functions. Finally | 1125 // code flushing candidates. Then kill one of the functions. Finally |
| 1124 // perform a scavenge while incremental marking is still running. | 1126 // perform a scavenge while incremental marking is still running. |
| 1125 SimulateIncrementalMarking(); | 1127 SimulateIncrementalMarking(); |
| 1126 *function2.location() = NULL; | 1128 *function2.location() = NULL; |
| 1127 HEAP->CollectGarbage(NEW_SPACE, "test scavenge while marking"); | 1129 HEAP->CollectGarbage(NEW_SPACE, "test scavenge while marking"); |
| 1128 | 1130 |
| 1129 // Simulate one final GC to make sure the candidate queue is sane. | 1131 // Simulate one final GC to make sure the candidate queue is sane. |
| 1130 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1132 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1159 Handle<JSFunction> function(JSFunction::cast(func_value)); | 1161 Handle<JSFunction> function(JSFunction::cast(func_value)); |
| 1160 CHECK(function->shared()->is_compiled()); | 1162 CHECK(function->shared()->is_compiled()); |
| 1161 | 1163 |
| 1162 // The code will survive at least two GCs. | 1164 // The code will survive at least two GCs. |
| 1163 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1165 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
| 1164 HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1166 HEAP->CollectAllGarbage(Heap::kNoGCFlags); |
| 1165 CHECK(function->shared()->is_compiled()); | 1167 CHECK(function->shared()->is_compiled()); |
| 1166 | 1168 |
| 1167 // Bump the code age so that flushing is triggered. | 1169 // Bump the code age so that flushing is triggered. |
| 1168 const int kAgingThreshold = 6; | 1170 const int kAgingThreshold = 6; |
| 1169 function->shared()->set_code_age(kAgingThreshold); | 1171 for (int i = 0; i < kAgingThreshold; i++) { |
| 1172 function->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2)); |
| 1173 } |
| 1170 | 1174 |
| 1171 // Simulate incremental marking so that the function is enqueued as | 1175 // Simulate incremental marking so that the function is enqueued as |
| 1172 // code flushing candidate. | 1176 // code flushing candidate. |
| 1173 SimulateIncrementalMarking(); | 1177 SimulateIncrementalMarking(); |
| 1174 | 1178 |
| 1175 // Enable the debugger and add a breakpoint while incremental marking | 1179 // Enable the debugger and add a breakpoint while incremental marking |
| 1176 // is running so that incremental marking aborts and code flushing is | 1180 // is running so that incremental marking aborts and code flushing is |
| 1177 // disabled. | 1181 // disabled. |
| 1178 int position = 0; | 1182 int position = 0; |
| 1179 Handle<Object> breakpoint_object(Smi::FromInt(0)); | 1183 Handle<Object> breakpoint_object(Smi::FromInt(0)); |
| (...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2497 Handle<Object> call_function(call); | 2501 Handle<Object> call_function(call); |
| 2498 | 2502 |
| 2499 // Now we are ready to mess up the heap. | 2503 // Now we are ready to mess up the heap. |
| 2500 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); | 2504 HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask); |
| 2501 | 2505 |
| 2502 // Either heap verification caught the problem already or we go kaboom once | 2506 // Either heap verification caught the problem already or we go kaboom once |
| 2503 // the CallIC is executed the next time. | 2507 // the CallIC is executed the next time. |
| 2504 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); | 2508 USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); |
| 2505 CompileRun("call();"); | 2509 CompileRun("call();"); |
| 2506 } | 2510 } |
| OLD | NEW |