| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/globals.h" // Needed here to get TARGET_ARCH_XXX. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX. |
| 6 | 6 |
| 7 #include "vm/flow_graph_compiler.h" | 7 #include "vm/flow_graph_compiler.h" |
| 8 | 8 |
| 9 #include "vm/cha.h" | 9 #include "vm/cha.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 | 495 |
| 496 void FlowGraphCompiler::FinalizeStaticCallTargetsTable(const Code& code) { | 496 void FlowGraphCompiler::FinalizeStaticCallTargetsTable(const Code& code) { |
| 497 ASSERT(code.static_calls_target_table() == Array::null()); | 497 ASSERT(code.static_calls_target_table() == Array::null()); |
| 498 code.set_static_calls_target_table( | 498 code.set_static_calls_target_table( |
| 499 Array::Handle(Array::MakeArray(static_calls_target_table_))); | 499 Array::Handle(Array::MakeArray(static_calls_target_table_))); |
| 500 } | 500 } |
| 501 | 501 |
| 502 | 502 |
| 503 // Returns 'true' if code generation for this function is complete, i.e., | 503 // Returns 'true' if code generation for this function is complete, i.e., |
| 504 // no fall-through to regular code is needed. | 504 // no fall-through to regular code is needed. |
| 505 bool FlowGraphCompiler::TryIntrinsify() { | 505 void FlowGraphCompiler::TryIntrinsify() { |
| 506 if (!CanOptimizeFunction()) return false; | 506 if (!CanOptimizeFunction()) return; |
| 507 // Intrinsification skips arguments checks, therefore disable if in checked | 507 // Intrinsification skips arguments checks, therefore disable if in checked |
| 508 // mode. | 508 // mode. |
| 509 if (FLAG_intrinsify && !FLAG_enable_type_checks) { | 509 if (FLAG_intrinsify && !FLAG_enable_type_checks) { |
| 510 if (parsed_function().function().kind() == RawFunction::kImplicitGetter) { | 510 if (parsed_function().function().kind() == RawFunction::kImplicitGetter) { |
| 511 // An implicit getter must have a specific AST structure. | 511 // An implicit getter must have a specific AST structure. |
| 512 const SequenceNode& sequence_node = *parsed_function().node_sequence(); | 512 const SequenceNode& sequence_node = *parsed_function().node_sequence(); |
| 513 ASSERT(sequence_node.length() == 1); | 513 ASSERT(sequence_node.length() == 1); |
| 514 ASSERT(sequence_node.NodeAt(0)->IsReturnNode()); | 514 ASSERT(sequence_node.NodeAt(0)->IsReturnNode()); |
| 515 const ReturnNode& return_node = *sequence_node.NodeAt(0)->AsReturnNode(); | 515 const ReturnNode& return_node = *sequence_node.NodeAt(0)->AsReturnNode(); |
| 516 ASSERT(return_node.value()->IsLoadInstanceFieldNode()); | 516 ASSERT(return_node.value()->IsLoadInstanceFieldNode()); |
| 517 const LoadInstanceFieldNode& load_node = | 517 const LoadInstanceFieldNode& load_node = |
| 518 *return_node.value()->AsLoadInstanceFieldNode(); | 518 *return_node.value()->AsLoadInstanceFieldNode(); |
| 519 GenerateInlinedGetter(load_node.field().Offset()); | 519 GenerateInlinedGetter(load_node.field().Offset()); |
| 520 return true; | 520 return; |
| 521 } | 521 } |
| 522 if (parsed_function().function().kind() == RawFunction::kImplicitSetter) { | 522 if (parsed_function().function().kind() == RawFunction::kImplicitSetter) { |
| 523 // An implicit setter must have a specific AST structure. | 523 // An implicit setter must have a specific AST structure. |
| 524 // Sequence node has one store node and one return NULL node. | 524 // Sequence node has one store node and one return NULL node. |
| 525 const SequenceNode& sequence_node = *parsed_function().node_sequence(); | 525 const SequenceNode& sequence_node = *parsed_function().node_sequence(); |
| 526 ASSERT(sequence_node.length() == 2); | 526 ASSERT(sequence_node.length() == 2); |
| 527 ASSERT(sequence_node.NodeAt(0)->IsStoreInstanceFieldNode()); | 527 ASSERT(sequence_node.NodeAt(0)->IsStoreInstanceFieldNode()); |
| 528 ASSERT(sequence_node.NodeAt(1)->IsReturnNode()); | 528 ASSERT(sequence_node.NodeAt(1)->IsReturnNode()); |
| 529 const StoreInstanceFieldNode& store_node = | 529 const StoreInstanceFieldNode& store_node = |
| 530 *sequence_node.NodeAt(0)->AsStoreInstanceFieldNode(); | 530 *sequence_node.NodeAt(0)->AsStoreInstanceFieldNode(); |
| 531 if (store_node.field().guarded_cid() == kDynamicCid) { | 531 if (store_node.field().guarded_cid() == kDynamicCid) { |
| 532 GenerateInlinedSetter(store_node.field().Offset()); | 532 GenerateInlinedSetter(store_node.field().Offset()); |
| 533 return true; | 533 return; |
| 534 } | 534 } |
| 535 } | 535 } |
| 536 } | 536 } |
| 537 // Even if an intrinsified version of the function was successfully | 537 // Even if an intrinsified version of the function was successfully |
| 538 // generated, it may fall through to the non-intrinsified method body. | 538 // generated, it may fall through to the non-intrinsified method body. |
| 539 return Intrinsifier::Intrinsify(parsed_function().function(), assembler()); | 539 return Intrinsifier::Intrinsify(parsed_function().function(), assembler()); |
| 540 } | 540 } |
| 541 | 541 |
| 542 | 542 |
| 543 void FlowGraphCompiler::GenerateInstanceCall( | 543 void FlowGraphCompiler::GenerateInstanceCall( |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 | 1138 |
| 1139 for (int i = 0; i < len; i++) { | 1139 for (int i = 0; i < len; i++) { |
| 1140 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), | 1140 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), |
| 1141 &Function::ZoneHandle(ic_data.GetTargetAt(i)), | 1141 &Function::ZoneHandle(ic_data.GetTargetAt(i)), |
| 1142 ic_data.GetCountAt(i))); | 1142 ic_data.GetCountAt(i))); |
| 1143 } | 1143 } |
| 1144 sorted->Sort(HighestCountFirst); | 1144 sorted->Sort(HighestCountFirst); |
| 1145 } | 1145 } |
| 1146 | 1146 |
| 1147 } // namespace dart | 1147 } // namespace dart |
| OLD | NEW |