OLD | NEW |
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 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 CHECK(!function->is_compiled() || function->IsOptimized()); | 1187 CHECK(!function->is_compiled() || function->IsOptimized()); |
1188 // Call foo to get it recompiled. | 1188 // Call foo to get it recompiled. |
1189 CompileRun("foo()"); | 1189 CompileRun("foo()"); |
1190 CHECK(function->shared()->is_compiled()); | 1190 CHECK(function->shared()->is_compiled()); |
1191 CHECK(function->is_compiled()); | 1191 CHECK(function->is_compiled()); |
1192 } | 1192 } |
1193 | 1193 |
1194 | 1194 |
1195 TEST(TestCodeFlushingIncremental) { | 1195 TEST(TestCodeFlushingIncremental) { |
1196 // If we do not flush code this test is invalid. | 1196 // If we do not flush code this test is invalid. |
1197 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; | 1197 if (!FLAG_flush_code) return; |
1198 i::FLAG_allow_natives_syntax = true; | 1198 i::FLAG_allow_natives_syntax = true; |
1199 i::FLAG_optimize_for_size = false; | 1199 i::FLAG_optimize_for_size = false; |
1200 CcTest::InitializeVM(); | 1200 CcTest::InitializeVM(); |
1201 Isolate* isolate = CcTest::i_isolate(); | 1201 Isolate* isolate = CcTest::i_isolate(); |
1202 Factory* factory = isolate->factory(); | 1202 Factory* factory = isolate->factory(); |
1203 v8::HandleScope scope(CcTest::isolate()); | 1203 v8::HandleScope scope(CcTest::isolate()); |
1204 const char* source = "function foo() {" | 1204 const char* source = "function foo() {" |
1205 " var x = 42;" | 1205 " var x = 42;" |
1206 " var y = 42;" | 1206 " var y = 42;" |
1207 " var z = x + y;" | 1207 " var z = x + y;" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 | 1256 |
1257 // Simulate one final GC to make sure the candidate queue is sane. | 1257 // Simulate one final GC to make sure the candidate queue is sane. |
1258 CcTest::heap()->CollectAllGarbage(); | 1258 CcTest::heap()->CollectAllGarbage(); |
1259 CHECK(function->shared()->is_compiled() || !function->IsOptimized()); | 1259 CHECK(function->shared()->is_compiled() || !function->IsOptimized()); |
1260 CHECK(function->is_compiled() || !function->IsOptimized()); | 1260 CHECK(function->is_compiled() || !function->IsOptimized()); |
1261 } | 1261 } |
1262 | 1262 |
1263 | 1263 |
1264 TEST(TestCodeFlushingIncrementalScavenge) { | 1264 TEST(TestCodeFlushingIncrementalScavenge) { |
1265 // If we do not flush code this test is invalid. | 1265 // If we do not flush code this test is invalid. |
1266 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; | 1266 if (!FLAG_flush_code) return; |
1267 i::FLAG_allow_natives_syntax = true; | 1267 i::FLAG_allow_natives_syntax = true; |
1268 i::FLAG_optimize_for_size = false; | 1268 i::FLAG_optimize_for_size = false; |
1269 CcTest::InitializeVM(); | 1269 CcTest::InitializeVM(); |
1270 Isolate* isolate = CcTest::i_isolate(); | 1270 Isolate* isolate = CcTest::i_isolate(); |
1271 Factory* factory = isolate->factory(); | 1271 Factory* factory = isolate->factory(); |
1272 v8::HandleScope scope(CcTest::isolate()); | 1272 v8::HandleScope scope(CcTest::isolate()); |
1273 const char* source = "var foo = function() {" | 1273 const char* source = "var foo = function() {" |
1274 " var x = 42;" | 1274 " var x = 42;" |
1275 " var y = 42;" | 1275 " var y = 42;" |
1276 " var z = x + y;" | 1276 " var z = x + y;" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 | 1325 |
1326 // Simulate one final GC to make sure the candidate queue is sane. | 1326 // Simulate one final GC to make sure the candidate queue is sane. |
1327 CcTest::heap()->CollectAllGarbage(); | 1327 CcTest::heap()->CollectAllGarbage(); |
1328 CHECK(!function->shared()->is_compiled() || function->IsOptimized()); | 1328 CHECK(!function->shared()->is_compiled() || function->IsOptimized()); |
1329 CHECK(!function->is_compiled() || function->IsOptimized()); | 1329 CHECK(!function->is_compiled() || function->IsOptimized()); |
1330 } | 1330 } |
1331 | 1331 |
1332 | 1332 |
1333 TEST(TestCodeFlushingIncrementalAbort) { | 1333 TEST(TestCodeFlushingIncrementalAbort) { |
1334 // If we do not flush code this test is invalid. | 1334 // If we do not flush code this test is invalid. |
1335 if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; | 1335 if (!FLAG_flush_code) return; |
1336 i::FLAG_allow_natives_syntax = true; | 1336 i::FLAG_allow_natives_syntax = true; |
1337 i::FLAG_optimize_for_size = false; | 1337 i::FLAG_optimize_for_size = false; |
1338 CcTest::InitializeVM(); | 1338 CcTest::InitializeVM(); |
1339 Isolate* isolate = CcTest::i_isolate(); | 1339 Isolate* isolate = CcTest::i_isolate(); |
1340 Factory* factory = isolate->factory(); | 1340 Factory* factory = isolate->factory(); |
1341 Heap* heap = isolate->heap(); | 1341 Heap* heap = isolate->heap(); |
1342 v8::HandleScope scope(CcTest::isolate()); | 1342 v8::HandleScope scope(CcTest::isolate()); |
1343 const char* source = "function foo() {" | 1343 const char* source = "function foo() {" |
1344 " var x = 42;" | 1344 " var x = 42;" |
1345 " var y = 42;" | 1345 " var y = 42;" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 // Simulate one final GC to make sure the candidate queue is sane. | 1393 // Simulate one final GC to make sure the candidate queue is sane. |
1394 heap->CollectAllGarbage(); | 1394 heap->CollectAllGarbage(); |
1395 CHECK(function->shared()->is_compiled() || !function->IsOptimized()); | 1395 CHECK(function->shared()->is_compiled() || !function->IsOptimized()); |
1396 CHECK(function->is_compiled() || !function->IsOptimized()); | 1396 CHECK(function->is_compiled() || !function->IsOptimized()); |
1397 } | 1397 } |
1398 | 1398 |
1399 | 1399 |
1400 TEST(CompilationCacheCachingBehavior) { | 1400 TEST(CompilationCacheCachingBehavior) { |
1401 // If we do not flush code, or have the compilation cache turned off, this | 1401 // If we do not flush code, or have the compilation cache turned off, this |
1402 // test is invalid. | 1402 // test is invalid. |
1403 if (!FLAG_flush_code || !FLAG_flush_code_incrementally || | 1403 if (!FLAG_flush_code || !FLAG_compilation_cache) { |
1404 !FLAG_compilation_cache) { | |
1405 return; | 1404 return; |
1406 } | 1405 } |
1407 CcTest::InitializeVM(); | 1406 CcTest::InitializeVM(); |
1408 Isolate* isolate = CcTest::i_isolate(); | 1407 Isolate* isolate = CcTest::i_isolate(); |
1409 Factory* factory = isolate->factory(); | 1408 Factory* factory = isolate->factory(); |
1410 Heap* heap = isolate->heap(); | 1409 Heap* heap = isolate->heap(); |
1411 CompilationCache* compilation_cache = isolate->compilation_cache(); | 1410 CompilationCache* compilation_cache = isolate->compilation_cache(); |
1412 LanguageMode language_mode = | 1411 LanguageMode language_mode = |
1413 construct_language_mode(FLAG_use_strict, FLAG_use_strong); | 1412 construct_language_mode(FLAG_use_strict, FLAG_use_strong); |
1414 | 1413 |
(...skipping 2587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4002 ReleaseStackTraceDataTest(isolate, source2, getter); | 4001 ReleaseStackTraceDataTest(isolate, source2, getter); |
4003 ReleaseStackTraceDataTest(isolate, source3, getter); | 4002 ReleaseStackTraceDataTest(isolate, source3, getter); |
4004 ReleaseStackTraceDataTest(isolate, source4, getter); | 4003 ReleaseStackTraceDataTest(isolate, source4, getter); |
4005 } | 4004 } |
4006 isolate->Dispose(); | 4005 isolate->Dispose(); |
4007 } | 4006 } |
4008 | 4007 |
4009 | 4008 |
4010 TEST(Regress159140) { | 4009 TEST(Regress159140) { |
4011 i::FLAG_allow_natives_syntax = true; | 4010 i::FLAG_allow_natives_syntax = true; |
4012 i::FLAG_flush_code_incrementally = true; | |
4013 CcTest::InitializeVM(); | 4011 CcTest::InitializeVM(); |
4014 Isolate* isolate = CcTest::i_isolate(); | 4012 Isolate* isolate = CcTest::i_isolate(); |
4015 Heap* heap = isolate->heap(); | 4013 Heap* heap = isolate->heap(); |
4016 HandleScope scope(isolate); | 4014 HandleScope scope(isolate); |
4017 | 4015 |
4018 // Perform one initial GC to enable code flushing. | 4016 // Perform one initial GC to enable code flushing. |
4019 heap->CollectAllGarbage(); | 4017 heap->CollectAllGarbage(); |
4020 | 4018 |
4021 // Prepare several closures that are all eligible for code flushing | 4019 // Prepare several closures that are all eligible for code flushing |
4022 // because all reachable ones are not optimized. Make sure that the | 4020 // because all reachable ones are not optimized. Make sure that the |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4064 CompileRun("%OptimizeFunctionOnNextCall(g); g(3);"); | 4062 CompileRun("%OptimizeFunctionOnNextCall(g); g(3);"); |
4065 heap->CollectAllGarbage(); | 4063 heap->CollectAllGarbage(); |
4066 | 4064 |
4067 // Unoptimized code is missing and the deoptimizer will go ballistic. | 4065 // Unoptimized code is missing and the deoptimizer will go ballistic. |
4068 CompileRun("g('bozo');"); | 4066 CompileRun("g('bozo');"); |
4069 } | 4067 } |
4070 | 4068 |
4071 | 4069 |
4072 TEST(Regress165495) { | 4070 TEST(Regress165495) { |
4073 i::FLAG_allow_natives_syntax = true; | 4071 i::FLAG_allow_natives_syntax = true; |
4074 i::FLAG_flush_code_incrementally = true; | |
4075 CcTest::InitializeVM(); | 4072 CcTest::InitializeVM(); |
4076 Isolate* isolate = CcTest::i_isolate(); | 4073 Isolate* isolate = CcTest::i_isolate(); |
4077 Heap* heap = isolate->heap(); | 4074 Heap* heap = isolate->heap(); |
4078 HandleScope scope(isolate); | 4075 HandleScope scope(isolate); |
4079 | 4076 |
4080 // Perform one initial GC to enable code flushing. | 4077 // Perform one initial GC to enable code flushing. |
4081 heap->CollectAllGarbage(); | 4078 heap->CollectAllGarbage(); |
4082 | 4079 |
4083 // Prepare an optimized closure that the optimized code map will get | 4080 // Prepare an optimized closure that the optimized code map will get |
4084 // populated. Then age the unoptimized code to trigger code flushing | 4081 // populated. Then age the unoptimized code to trigger code flushing |
(...skipping 27 matching lines...) Expand all Loading... |
4112 | 4109 |
4113 // Make a new closure that will get code installed from the code map. | 4110 // Make a new closure that will get code installed from the code map. |
4114 // Unoptimized code is missing and the deoptimizer will go ballistic. | 4111 // Unoptimized code is missing and the deoptimizer will go ballistic. |
4115 CompileRun("var g = mkClosure(); g('bozo');"); | 4112 CompileRun("var g = mkClosure(); g('bozo');"); |
4116 } | 4113 } |
4117 | 4114 |
4118 | 4115 |
4119 TEST(Regress169209) { | 4116 TEST(Regress169209) { |
4120 i::FLAG_stress_compaction = false; | 4117 i::FLAG_stress_compaction = false; |
4121 i::FLAG_allow_natives_syntax = true; | 4118 i::FLAG_allow_natives_syntax = true; |
4122 i::FLAG_flush_code_incrementally = true; | |
4123 | 4119 |
4124 CcTest::InitializeVM(); | 4120 CcTest::InitializeVM(); |
4125 Isolate* isolate = CcTest::i_isolate(); | 4121 Isolate* isolate = CcTest::i_isolate(); |
4126 Heap* heap = isolate->heap(); | 4122 Heap* heap = isolate->heap(); |
4127 HandleScope scope(isolate); | 4123 HandleScope scope(isolate); |
4128 | 4124 |
4129 // Perform one initial GC to enable code flushing. | 4125 // Perform one initial GC to enable code flushing. |
4130 heap->CollectAllGarbage(); | 4126 heap->CollectAllGarbage(); |
4131 | 4127 |
4132 // Prepare a shared function info eligible for code flushing for which | 4128 // Prepare a shared function info eligible for code flushing for which |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4261 AlwaysAllocateScope aa_scope(isolate); | 4257 AlwaysAllocateScope aa_scope(isolate); |
4262 v8::Script::Compile(mote_code_string)->Run(); | 4258 v8::Script::Compile(mote_code_string)->Run(); |
4263 } | 4259 } |
4264 | 4260 |
4265 | 4261 |
4266 TEST(Regress168801) { | 4262 TEST(Regress168801) { |
4267 if (i::FLAG_never_compact) return; | 4263 if (i::FLAG_never_compact) return; |
4268 i::FLAG_always_compact = true; | 4264 i::FLAG_always_compact = true; |
4269 i::FLAG_cache_optimized_code = false; | 4265 i::FLAG_cache_optimized_code = false; |
4270 i::FLAG_allow_natives_syntax = true; | 4266 i::FLAG_allow_natives_syntax = true; |
4271 i::FLAG_flush_code_incrementally = true; | |
4272 CcTest::InitializeVM(); | 4267 CcTest::InitializeVM(); |
4273 Isolate* isolate = CcTest::i_isolate(); | 4268 Isolate* isolate = CcTest::i_isolate(); |
4274 Heap* heap = isolate->heap(); | 4269 Heap* heap = isolate->heap(); |
4275 HandleScope scope(isolate); | 4270 HandleScope scope(isolate); |
4276 | 4271 |
4277 // Perform one initial GC to enable code flushing. | 4272 // Perform one initial GC to enable code flushing. |
4278 heap->CollectAllGarbage(); | 4273 heap->CollectAllGarbage(); |
4279 | 4274 |
4280 // Ensure the code ends up on an evacuation candidate. | 4275 // Ensure the code ends up on an evacuation candidate. |
4281 SimulateFullSpace(heap->code_space()); | 4276 SimulateFullSpace(heap->code_space()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4318 heap->CollectAllGarbage(); | 4313 heap->CollectAllGarbage(); |
4319 heap->CollectAllGarbage(); | 4314 heap->CollectAllGarbage(); |
4320 } | 4315 } |
4321 | 4316 |
4322 | 4317 |
4323 TEST(Regress173458) { | 4318 TEST(Regress173458) { |
4324 if (i::FLAG_never_compact) return; | 4319 if (i::FLAG_never_compact) return; |
4325 i::FLAG_always_compact = true; | 4320 i::FLAG_always_compact = true; |
4326 i::FLAG_cache_optimized_code = false; | 4321 i::FLAG_cache_optimized_code = false; |
4327 i::FLAG_allow_natives_syntax = true; | 4322 i::FLAG_allow_natives_syntax = true; |
4328 i::FLAG_flush_code_incrementally = true; | |
4329 CcTest::InitializeVM(); | 4323 CcTest::InitializeVM(); |
4330 Isolate* isolate = CcTest::i_isolate(); | 4324 Isolate* isolate = CcTest::i_isolate(); |
4331 Heap* heap = isolate->heap(); | 4325 Heap* heap = isolate->heap(); |
4332 HandleScope scope(isolate); | 4326 HandleScope scope(isolate); |
4333 | 4327 |
4334 // Perform one initial GC to enable code flushing. | 4328 // Perform one initial GC to enable code flushing. |
4335 heap->CollectAllGarbage(); | 4329 heap->CollectAllGarbage(); |
4336 | 4330 |
4337 // Ensure the code ends up on an evacuation candidate. | 4331 // Ensure the code ends up on an evacuation candidate. |
4338 SimulateFullSpace(heap->code_space()); | 4332 SimulateFullSpace(heap->code_space()); |
(...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6050 HeapObject::RawField(*array, FixedArray::kHeaderSize)); | 6044 HeapObject::RawField(*array, FixedArray::kHeaderSize)); |
6051 SlotsBuffer::RemoveObjectSlots(CcTest::i_isolate()->heap(), buffer, *array); | 6045 SlotsBuffer::RemoveObjectSlots(CcTest::i_isolate()->heap(), buffer, *array); |
6052 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) == | 6046 DCHECK(reinterpret_cast<void*>(buffer->Get(1)) == |
6053 HeapObject::RawField(heap->empty_fixed_array(), | 6047 HeapObject::RawField(heap->empty_fixed_array(), |
6054 FixedArrayBase::kLengthOffset)); | 6048 FixedArrayBase::kLengthOffset)); |
6055 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) == | 6049 DCHECK(reinterpret_cast<void*>(buffer->Get(2)) == |
6056 HeapObject::RawField(heap->empty_fixed_array(), | 6050 HeapObject::RawField(heap->empty_fixed_array(), |
6057 FixedArrayBase::kLengthOffset)); | 6051 FixedArrayBase::kLengthOffset)); |
6058 delete buffer; | 6052 delete buffer; |
6059 } | 6053 } |
OLD | NEW |