OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/isolate_reload.h" | 5 #include "vm/isolate_reload.h" |
6 | 6 |
7 #include "vm/become.h" | 7 #include "vm/become.h" |
8 #include "vm/bit_vector.h" | 8 #include "vm/bit_vector.h" |
9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 } | 1359 } |
1360 } | 1360 } |
1361 | 1361 |
1362 | 1362 |
1363 ObjectStore* IsolateReloadContext::object_store() { | 1363 ObjectStore* IsolateReloadContext::object_store() { |
1364 return isolate_->object_store(); | 1364 return isolate_->object_store(); |
1365 } | 1365 } |
1366 | 1366 |
1367 | 1367 |
1368 void IsolateReloadContext::ResetUnoptimizedICsOnStack() { | 1368 void IsolateReloadContext::ResetUnoptimizedICsOnStack() { |
1369 Code& code = Code::Handle(); | 1369 Thread* thread = Thread::Current(); |
1370 Function& function = Function::Handle(); | 1370 StackZone stack_zone(thread); |
| 1371 Zone* zone = stack_zone.GetZone(); |
| 1372 |
| 1373 Code& code = Code::Handle(zone); |
| 1374 Function& function = Function::Handle(zone); |
1371 DartFrameIterator iterator; | 1375 DartFrameIterator iterator; |
1372 StackFrame* frame = iterator.NextFrame(); | 1376 StackFrame* frame = iterator.NextFrame(); |
1373 while (frame != NULL) { | 1377 while (frame != NULL) { |
1374 code = frame->LookupDartCode(); | 1378 code = frame->LookupDartCode(); |
1375 if (code.is_optimized()) { | 1379 if (code.is_optimized()) { |
1376 // If this code is optimized, we need to reset the ICs in the | 1380 // If this code is optimized, we need to reset the ICs in the |
1377 // corresponding unoptimized code, which will be executed when the stack | 1381 // corresponding unoptimized code, which will be executed when the stack |
1378 // unwinds to the the optimized code. | 1382 // unwinds to the the optimized code. |
1379 function = code.function(); | 1383 function = code.function(); |
1380 code = function.unoptimized_code(); | 1384 code = function.unoptimized_code(); |
1381 ASSERT(!code.IsNull()); | 1385 ASSERT(!code.IsNull()); |
1382 code.ResetICDatas(); | 1386 code.ResetICDatas(zone); |
1383 } else { | 1387 } else { |
1384 code.ResetICDatas(); | 1388 code.ResetICDatas(zone); |
1385 } | 1389 } |
1386 frame = iterator.NextFrame(); | 1390 frame = iterator.NextFrame(); |
1387 } | 1391 } |
1388 } | 1392 } |
1389 | 1393 |
1390 | 1394 |
1391 void IsolateReloadContext::ResetMegamorphicCaches() { | 1395 void IsolateReloadContext::ResetMegamorphicCaches() { |
1392 object_store()->set_megamorphic_cache_table(GrowableObjectArray::Handle()); | 1396 object_store()->set_megamorphic_cache_table(GrowableObjectArray::Handle()); |
1393 // Since any current optimized code will not make any more calls, it may be | 1397 // Since any current optimized code will not make any more calls, it may be |
1394 // better to clear the table instead of clearing each of the caches, allow | 1398 // better to clear the table instead of clearing each of the caches, allow |
1395 // the current megamorphic caches get GC'd and any new optimized code allocate | 1399 // the current megamorphic caches get GC'd and any new optimized code allocate |
1396 // new ones. | 1400 // new ones. |
1397 } | 1401 } |
1398 | 1402 |
1399 | 1403 |
1400 class MarkFunctionsForRecompilation : public ObjectVisitor { | 1404 class MarkFunctionsForRecompilation : public ObjectVisitor { |
1401 public: | 1405 public: |
1402 MarkFunctionsForRecompilation(Isolate* isolate, | 1406 MarkFunctionsForRecompilation(Isolate* isolate, |
1403 IsolateReloadContext* reload_context) | 1407 IsolateReloadContext* reload_context, |
| 1408 Zone* zone) |
1404 : ObjectVisitor(), | 1409 : ObjectVisitor(), |
1405 handle_(Object::Handle()), | 1410 handle_(Object::Handle(zone)), |
1406 owning_class_(Class::Handle()), | 1411 owning_class_(Class::Handle(zone)), |
1407 owning_lib_(Library::Handle()), | 1412 owning_lib_(Library::Handle(zone)), |
1408 code_(Code::Handle()), | 1413 code_(Code::Handle(zone)), |
1409 reload_context_(reload_context) { | 1414 reload_context_(reload_context), |
| 1415 zone_(zone) { |
1410 } | 1416 } |
1411 | 1417 |
1412 virtual void VisitObject(RawObject* obj) { | 1418 virtual void VisitObject(RawObject* obj) { |
1413 if (obj->IsPseudoObject()) { | 1419 if (obj->IsPseudoObject()) { |
1414 // Cannot even be wrapped in handles. | 1420 // Cannot even be wrapped in handles. |
1415 return; | 1421 return; |
1416 } | 1422 } |
1417 handle_ = obj; | 1423 handle_ = obj; |
1418 if (handle_.IsFunction()) { | 1424 if (handle_.IsFunction()) { |
1419 const Function& func = Function::Cast(handle_); | 1425 const Function& func = Function::Cast(handle_); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1453 // Null out the ICData array and code. | 1459 // Null out the ICData array and code. |
1454 func.ClearICDataArray(); | 1460 func.ClearICDataArray(); |
1455 func.ClearCode(); | 1461 func.ClearCode(); |
1456 func.set_was_compiled(false); | 1462 func.set_was_compiled(false); |
1457 } | 1463 } |
1458 | 1464 |
1459 void PreserveUnoptimizedCode() { | 1465 void PreserveUnoptimizedCode() { |
1460 ASSERT(!code_.IsNull()); | 1466 ASSERT(!code_.IsNull()); |
1461 // We are preserving the unoptimized code, fill all ICData arrays with | 1467 // We are preserving the unoptimized code, fill all ICData arrays with |
1462 // the sentinel values so that we have no stale type feedback. | 1468 // the sentinel values so that we have no stale type feedback. |
1463 code_.ResetICDatas(); | 1469 code_.ResetICDatas(zone_); |
1464 } | 1470 } |
1465 | 1471 |
1466 bool IsFromDirtyLibrary(const Function& func) { | 1472 bool IsFromDirtyLibrary(const Function& func) { |
1467 owning_class_ = func.Owner(); | 1473 owning_class_ = func.Owner(); |
1468 owning_lib_ = owning_class_.library(); | 1474 owning_lib_ = owning_class_.library(); |
1469 return reload_context_->IsDirty(owning_lib_); | 1475 return reload_context_->IsDirty(owning_lib_); |
1470 } | 1476 } |
1471 | 1477 |
1472 Object& handle_; | 1478 Object& handle_; |
1473 Class& owning_class_; | 1479 Class& owning_class_; |
1474 Library& owning_lib_; | 1480 Library& owning_lib_; |
1475 Code& code_; | 1481 Code& code_; |
1476 IsolateReloadContext* reload_context_; | 1482 IsolateReloadContext* reload_context_; |
| 1483 Zone* zone_; |
1477 }; | 1484 }; |
1478 | 1485 |
1479 | 1486 |
1480 void IsolateReloadContext::MarkAllFunctionsForRecompilation() { | 1487 void IsolateReloadContext::MarkAllFunctionsForRecompilation() { |
1481 TIMELINE_SCOPE(MarkAllFunctionsForRecompilation); | 1488 TIMELINE_SCOPE(MarkAllFunctionsForRecompilation); |
1482 TIR_Print("---- MARKING ALL FUNCTIONS FOR RECOMPILATION\n"); | 1489 TIR_Print("---- MARKING ALL FUNCTIONS FOR RECOMPILATION\n"); |
| 1490 Thread* thread = Thread::Current(); |
| 1491 StackZone stack_zone(thread); |
| 1492 Zone* zone = stack_zone.GetZone(); |
1483 NoSafepointScope no_safepoint; | 1493 NoSafepointScope no_safepoint; |
1484 HeapIterationScope heap_iteration_scope; | 1494 HeapIterationScope heap_iteration_scope; |
1485 MarkFunctionsForRecompilation visitor(isolate_, this); | 1495 MarkFunctionsForRecompilation visitor(isolate_, this, zone); |
1486 isolate_->heap()->VisitObjects(&visitor); | 1496 isolate_->heap()->VisitObjects(&visitor); |
1487 } | 1497 } |
1488 | 1498 |
1489 | 1499 |
1490 void IsolateReloadContext::InvalidateWorld() { | 1500 void IsolateReloadContext::InvalidateWorld() { |
1491 TIR_Print("---- INVALIDATING WORLD\n"); | 1501 TIR_Print("---- INVALIDATING WORLD\n"); |
1492 ResetMegamorphicCaches(); | 1502 ResetMegamorphicCaches(); |
1493 DeoptimizeFunctionsOnStack(); | 1503 DeoptimizeFunctionsOnStack(); |
1494 ResetUnoptimizedICsOnStack(); | 1504 ResetUnoptimizedICsOnStack(); |
1495 MarkAllFunctionsForRecompilation(); | 1505 MarkAllFunctionsForRecompilation(); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 ASSERT(!super_cls.IsNull()); | 1661 ASSERT(!super_cls.IsNull()); |
1652 super_cls.AddDirectSubclass(cls); | 1662 super_cls.AddDirectSubclass(cls); |
1653 } | 1663 } |
1654 } | 1664 } |
1655 } | 1665 } |
1656 } | 1666 } |
1657 | 1667 |
1658 #endif // !PRODUCT | 1668 #endif // !PRODUCT |
1659 | 1669 |
1660 } // namespace dart | 1670 } // namespace dart |
OLD | NEW |