Chromium Code Reviews| 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 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1385 ASSERT(target != new_entry_point); // Why patch otherwise. | 1385 ASSERT(target != new_entry_point); // Why patch otherwise. |
| 1386 CodePatcher::PatchStaticCallAt(frame->pc(), new_entry_point); | 1386 CodePatcher::PatchStaticCallAt(frame->pc(), new_entry_point); |
| 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 |
|
Vyacheslav Egorov (Google)
2012/06/08 16:43:25
one more empty line
srdjan
2012/06/08 16:50:33
Done.
| |
| 1396 static const char* DeoptReasonToText(intptr_t deopt_id) { | |
| 1397 switch (deopt_id) { | |
| 1398 case kDeoptUnknown: return "kDeoptUnknown"; | |
|
Vyacheslav Egorov (Google)
2012/06/08 16:43:25
if deopt reasons were declared via macro-list like
srdjan
2012/06/08 16:50:33
Will do it in a next CL.
| |
| 1399 case kDeoptIncrLocal: return "kDeoptIncrLocal"; | |
| 1400 case kDeoptIncrInstance: return "kDeoptIncrInstance"; | |
| 1401 case kDeoptIncrInstanceOneClass: return "kDeoptIncrInstanceOneClass"; | |
| 1402 case kDeoptInstanceGetterSameTarget: | |
| 1403 return "kDeoptInstanceGetterSameTarget"; | |
| 1404 case kDeoptInstanceGetter: return "kDeoptInstanceGetter"; | |
| 1405 case kDeoptStoreIndexed: return "kDeoptStoreIndexed"; | |
| 1406 case kDeoptCheckedInstanceCallSmiOnly: | |
| 1407 return "kDeoptCheckedInstanceCallSmiOnly"; | |
| 1408 case kDeoptCheckedInstanceCallSmiFail: | |
| 1409 return "kDeoptCheckedInstanceCallSmiFail"; | |
| 1410 case kDeoptCheckedInstanceCallCheckFail: | |
| 1411 return "kDeoptCheckedInstanceCallCheckFail"; | |
| 1412 case kDeoptIntegerToDouble: return "kDeoptIntegerToDouble"; | |
| 1413 case kDeoptDoubleToDouble: return "kDeoptDoubleToDouble"; | |
| 1414 case kDeoptSmiBinaryOp: return "kDeoptSmiBinaryOp"; | |
| 1415 case kDeoptMintBinaryOp: return "kDeoptMintBinaryOp"; | |
| 1416 case kDeoptDoubleBinaryOp: return "kDeoptDoubleBinaryOp"; | |
| 1417 case kDeoptInstanceSetterSameTarget: | |
| 1418 return "kDeoptInstanceSetterSameTarget"; | |
| 1419 case kDeoptInstanceSetter: return "kDeoptInstanceSetter"; | |
| 1420 case kDeoptSmiEquality: return "kDeoptSmiEquality"; | |
| 1421 case kDeoptSmiCompareSmis: return "kDeoptSmiCompareSmis"; | |
| 1422 case kDeoptSmiCompareAny: return "kDeoptSmiCompareAny"; | |
| 1423 case kDeoptEqualityNoFeedback: return "kDeoptEqualityNoFeedback"; | |
| 1424 case kDeoptEqualityClassCheck: return "kDeoptEqualityClassCheck"; | |
| 1425 case kDeoptDoubleComparison: return "kDeoptDoubleComparison"; | |
| 1426 case kDeoptLoadIndexedFixedArray: return "kDeoptLoadIndexedFixedArray"; | |
| 1427 case kDeoptLoadIndexedGrowableArray: | |
| 1428 return "kDeoptLoadIndexedGrowableArray"; | |
| 1429 case kDeoptNoTypeFeedback: return "kDeoptNoTypeFeedback"; | |
| 1430 case kDeoptSAR: return "kDeoptSAR"; | |
| 1431 case kDeoptUnaryOp: return "kDeoptUnaryOp"; | |
| 1432 default: | |
| 1433 UNREACHABLE(); | |
| 1434 return ""; | |
| 1435 } | |
| 1436 } | |
| 1437 | |
| 1396 | 1438 |
| 1397 // The top Dart frame belongs to the optimized method that needs to be | 1439 // 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. | 1440 // 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 | 1441 // Find the node id of the deoptimization point and find the continuation |
| 1400 // pc in the unoptimized code. | 1442 // pc in the unoptimized code. |
| 1401 // Since both unoptimized and optimized code have the same layout, we need only | 1443 // 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. | 1444 // to patch the pc of the Dart frame and to disable/enable appropriate code. |
| 1403 DEFINE_RUNTIME_ENTRY(Deoptimize, 1) { | 1445 DEFINE_RUNTIME_ENTRY(Deoptimize, 1) { |
| 1404 ASSERT(arguments.Count() == kDeoptimizeRuntimeEntry.argument_count()); | 1446 ASSERT(arguments.Count() == kDeoptimizeRuntimeEntry.argument_count()); |
| 1405 const Smi& deoptimization_reason_id = Smi::CheckedHandle(arguments.At(0)); | 1447 const Smi& deoptimization_reason_id = Smi::CheckedHandle(arguments.At(0)); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1423 deopt_node_id = descriptors.NodeId(i); | 1465 deopt_node_id = descriptors.NodeId(i); |
| 1424 deopt_token_index = descriptors.TokenIndex(i); | 1466 deopt_token_index = descriptors.TokenIndex(i); |
| 1425 break; | 1467 break; |
| 1426 } | 1468 } |
| 1427 } | 1469 } |
| 1428 ASSERT(deopt_node_id != AstNode::kNoId); | 1470 ASSERT(deopt_node_id != AstNode::kNoId); |
| 1429 uword continue_at_pc = | 1471 uword continue_at_pc = |
| 1430 unoptimized_code.GetDeoptPcAtNodeId(deopt_node_id); | 1472 unoptimized_code.GetDeoptPcAtNodeId(deopt_node_id); |
| 1431 ASSERT(continue_at_pc != 0); | 1473 ASSERT(continue_at_pc != 0); |
| 1432 if (FLAG_trace_deopt) { | 1474 if (FLAG_trace_deopt) { |
| 1433 OS::Print("Deoptimizing (reason %d) at pc 0x%x id %d '%s' " | 1475 OS::Print("Deoptimizing (reason %d '%s') at pc 0x%x id %d '%s' " |
| 1434 "-> continue at 0x%x \n", | 1476 "-> continue at 0x%x \n", |
| 1435 deoptimization_reason_id.Value(), | 1477 deoptimization_reason_id.Value(), |
| 1478 DeoptReasonToText(deoptimization_reason_id.Value()), | |
| 1436 caller_frame->pc(), | 1479 caller_frame->pc(), |
| 1437 deopt_node_id, | 1480 deopt_node_id, |
| 1438 function.ToFullyQualifiedCString(), | 1481 function.ToFullyQualifiedCString(), |
| 1439 continue_at_pc); | 1482 continue_at_pc); |
| 1440 const Class& cls = Class::Handle(function.owner()); | 1483 const Class& cls = Class::Handle(function.owner()); |
| 1441 const Script& script = Script::Handle(cls.script()); | 1484 const Script& script = Script::Handle(cls.script()); |
| 1442 intptr_t line, column; | 1485 intptr_t line, column; |
| 1443 script.GetTokenLocation(deopt_token_index, &line, &column); | 1486 script.GetTokenLocation(deopt_token_index, &line, &column); |
| 1444 OS::Print(" Line: %d Column: %d ", line, column); | 1487 OS::Print(" Line: %d Column: %d ", line, column); |
| 1445 OS::Print(">> %s\n", String::Handle(script.GetLine(line)).ToCString()); | 1488 OS::Print(">> %s\n", String::Handle(script.GetLine(line)).ToCString()); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1555 } | 1598 } |
| 1556 } | 1599 } |
| 1557 } | 1600 } |
| 1558 // The cache is null terminated, therefore the loop above should never | 1601 // The cache is null terminated, therefore the loop above should never |
| 1559 // terminate by itself. | 1602 // terminate by itself. |
| 1560 UNREACHABLE(); | 1603 UNREACHABLE(); |
| 1561 return Code::null(); | 1604 return Code::null(); |
| 1562 } | 1605 } |
| 1563 | 1606 |
| 1564 } // namespace dart | 1607 } // namespace dart |
| OLD | NEW |