| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/code_generator.h" | 5 #include "vm/code_generator.h" |
| 6 | 6 |
| 7 #include "vm/assembler_macros.h" | 7 #include "vm/assembler_macros.h" |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 if (FLAG_trace_patching) { | 1387 if (FLAG_trace_patching) { |
| 1388 OS::Print("FixCallersTarget: patching from 0x%x to '%s' 0x%x\n", | 1388 OS::Print("FixCallersTarget: patching from 0x%x to '%s' 0x%x\n", |
| 1389 frame->pc(), | 1389 frame->pc(), |
| 1390 target_function.ToFullyQualifiedCString(), | 1390 target_function.ToFullyQualifiedCString(), |
| 1391 new_entry_point); | 1391 new_entry_point); |
| 1392 } | 1392 } |
| 1393 } | 1393 } |
| 1394 } | 1394 } |
| 1395 | 1395 |
| 1396 | 1396 |
| 1397 static const char* DeoptReasonToText(intptr_t deopt_id) { |
| 1398 switch (deopt_id) { |
| 1399 case kDeoptUnknown: return "kDeoptUnknown"; |
| 1400 case kDeoptIncrLocal: return "kDeoptIncrLocal"; |
| 1401 case kDeoptIncrInstance: return "kDeoptIncrInstance"; |
| 1402 case kDeoptIncrInstanceOneClass: return "kDeoptIncrInstanceOneClass"; |
| 1403 case kDeoptInstanceGetterSameTarget: |
| 1404 return "kDeoptInstanceGetterSameTarget"; |
| 1405 case kDeoptInstanceGetter: return "kDeoptInstanceGetter"; |
| 1406 case kDeoptStoreIndexed: return "kDeoptStoreIndexed"; |
| 1407 case kDeoptCheckedInstanceCallSmiOnly: |
| 1408 return "kDeoptCheckedInstanceCallSmiOnly"; |
| 1409 case kDeoptCheckedInstanceCallSmiFail: |
| 1410 return "kDeoptCheckedInstanceCallSmiFail"; |
| 1411 case kDeoptCheckedInstanceCallCheckFail: |
| 1412 return "kDeoptCheckedInstanceCallCheckFail"; |
| 1413 case kDeoptIntegerToDouble: return "kDeoptIntegerToDouble"; |
| 1414 case kDeoptDoubleToDouble: return "kDeoptDoubleToDouble"; |
| 1415 case kDeoptSmiBinaryOp: return "kDeoptSmiBinaryOp"; |
| 1416 case kDeoptMintBinaryOp: return "kDeoptMintBinaryOp"; |
| 1417 case kDeoptDoubleBinaryOp: return "kDeoptDoubleBinaryOp"; |
| 1418 case kDeoptInstanceSetterSameTarget: |
| 1419 return "kDeoptInstanceSetterSameTarget"; |
| 1420 case kDeoptInstanceSetter: return "kDeoptInstanceSetter"; |
| 1421 case kDeoptSmiEquality: return "kDeoptSmiEquality"; |
| 1422 case kDeoptSmiCompareSmis: return "kDeoptSmiCompareSmis"; |
| 1423 case kDeoptSmiCompareAny: return "kDeoptSmiCompareAny"; |
| 1424 case kDeoptEqualityNoFeedback: return "kDeoptEqualityNoFeedback"; |
| 1425 case kDeoptEqualityClassCheck: return "kDeoptEqualityClassCheck"; |
| 1426 case kDeoptDoubleComparison: return "kDeoptDoubleComparison"; |
| 1427 case kDeoptLoadIndexedFixedArray: return "kDeoptLoadIndexedFixedArray"; |
| 1428 case kDeoptLoadIndexedGrowableArray: |
| 1429 return "kDeoptLoadIndexedGrowableArray"; |
| 1430 case kDeoptNoTypeFeedback: return "kDeoptNoTypeFeedback"; |
| 1431 case kDeoptSAR: return "kDeoptSAR"; |
| 1432 case kDeoptUnaryOp: return "kDeoptUnaryOp"; |
| 1433 default: |
| 1434 UNREACHABLE(); |
| 1435 return ""; |
| 1436 } |
| 1437 } |
| 1438 |
| 1439 |
| 1397 // The top Dart frame belongs to the optimized method that needs to be | 1440 // The top Dart frame belongs to the optimized method that needs to be |
| 1398 // deoptimized. The pc of the Dart frame points to the deoptimization point. | 1441 // deoptimized. The pc of the Dart frame points to the deoptimization point. |
| 1399 // Find the node id of the deoptimization point and find the continuation | 1442 // Find the node id of the deoptimization point and find the continuation |
| 1400 // pc in the unoptimized code. | 1443 // pc in the unoptimized code. |
| 1401 // Since both unoptimized and optimized code have the same layout, we need only | 1444 // Since both unoptimized and optimized code have the same layout, we need only |
| 1402 // to patch the pc of the Dart frame and to disable/enable appropriate code. | 1445 // to patch the pc of the Dart frame and to disable/enable appropriate code. |
| 1403 DEFINE_RUNTIME_ENTRY(Deoptimize, 1) { | 1446 DEFINE_RUNTIME_ENTRY(Deoptimize, 1) { |
| 1404 ASSERT(arguments.Count() == kDeoptimizeRuntimeEntry.argument_count()); | 1447 ASSERT(arguments.Count() == kDeoptimizeRuntimeEntry.argument_count()); |
| 1405 const Smi& deoptimization_reason_id = Smi::CheckedHandle(arguments.At(0)); | 1448 const Smi& deoptimization_reason_id = Smi::CheckedHandle(arguments.At(0)); |
| 1406 DartFrameIterator iterator; | 1449 DartFrameIterator iterator; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1423 deopt_node_id = descriptors.NodeId(i); | 1466 deopt_node_id = descriptors.NodeId(i); |
| 1424 deopt_token_index = descriptors.TokenIndex(i); | 1467 deopt_token_index = descriptors.TokenIndex(i); |
| 1425 break; | 1468 break; |
| 1426 } | 1469 } |
| 1427 } | 1470 } |
| 1428 ASSERT(deopt_node_id != AstNode::kNoId); | 1471 ASSERT(deopt_node_id != AstNode::kNoId); |
| 1429 uword continue_at_pc = | 1472 uword continue_at_pc = |
| 1430 unoptimized_code.GetDeoptPcAtNodeId(deopt_node_id); | 1473 unoptimized_code.GetDeoptPcAtNodeId(deopt_node_id); |
| 1431 ASSERT(continue_at_pc != 0); | 1474 ASSERT(continue_at_pc != 0); |
| 1432 if (FLAG_trace_deopt) { | 1475 if (FLAG_trace_deopt) { |
| 1433 OS::Print("Deoptimizing (reason %d) at pc 0x%x id %d '%s' " | 1476 OS::Print("Deoptimizing (reason %d '%s') at pc 0x%x id %d '%s' " |
| 1434 "-> continue at 0x%x \n", | 1477 "-> continue at 0x%x \n", |
| 1435 deoptimization_reason_id.Value(), | 1478 deoptimization_reason_id.Value(), |
| 1479 DeoptReasonToText(deoptimization_reason_id.Value()), |
| 1436 caller_frame->pc(), | 1480 caller_frame->pc(), |
| 1437 deopt_node_id, | 1481 deopt_node_id, |
| 1438 function.ToFullyQualifiedCString(), | 1482 function.ToFullyQualifiedCString(), |
| 1439 continue_at_pc); | 1483 continue_at_pc); |
| 1440 const Class& cls = Class::Handle(function.owner()); | 1484 const Class& cls = Class::Handle(function.owner()); |
| 1441 const Script& script = Script::Handle(cls.script()); | 1485 const Script& script = Script::Handle(cls.script()); |
| 1442 intptr_t line, column; | 1486 intptr_t line, column; |
| 1443 script.GetTokenLocation(deopt_token_index, &line, &column); | 1487 script.GetTokenLocation(deopt_token_index, &line, &column); |
| 1444 OS::Print(" Line: %d Column: %d ", line, column); | 1488 OS::Print(" Line: %d Column: %d ", line, column); |
| 1445 OS::Print(">> %s\n", String::Handle(script.GetLine(line)).ToCString()); | 1489 OS::Print(">> %s\n", String::Handle(script.GetLine(line)).ToCString()); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 } | 1599 } |
| 1556 } | 1600 } |
| 1557 } | 1601 } |
| 1558 // The cache is null terminated, therefore the loop above should never | 1602 // The cache is null terminated, therefore the loop above should never |
| 1559 // terminate by itself. | 1603 // terminate by itself. |
| 1560 UNREACHABLE(); | 1604 UNREACHABLE(); |
| 1561 return Code::null(); | 1605 return Code::null(); |
| 1562 } | 1606 } |
| 1563 | 1607 |
| 1564 } // namespace dart | 1608 } // namespace dart |
| OLD | NEW |