| 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 // Class for intrinsifying functions. | 4 // Class for intrinsifying functions. |
| 5 | 5 |
| 6 #include "vm/assembler.h" | 6 #include "vm/assembler.h" |
| 7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
| 8 #include "vm/cpu.h" | 8 #include "vm/cpu.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/flow_graph.h" | 10 #include "vm/flow_graph.h" |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 Thread::kNoDeoptId, | 581 Thread::kNoDeoptId, |
| 582 builder.TokenPos())); | 582 builder.TokenPos())); |
| 583 Definition* result = builder.AddDefinition( | 583 Definition* result = builder.AddDefinition( |
| 584 BoxInstr::Create(kUnboxedUint32, new Value(unboxed_value))); | 584 BoxInstr::Create(kUnboxedUint32, new Value(unboxed_value))); |
| 585 builder.AddIntrinsicReturn(new Value(result)); | 585 builder.AddIntrinsicReturn(new Value(result)); |
| 586 return true; | 586 return true; |
| 587 } | 587 } |
| 588 | 588 |
| 589 | 589 |
| 590 bool Intrinsifier::Build_Float64ArraySetIndexed(FlowGraph* flow_graph) { | 590 bool Intrinsifier::Build_Float64ArraySetIndexed(FlowGraph* flow_graph) { |
| 591 if (!FlowGraphCompiler::SupportsUnboxedDoubles()) return false; | 591 if (!FlowGraphCompiler::SupportsUnboxedDoubles()) { |
| 592 return false; |
| 593 } |
| 592 | 594 |
| 593 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); | 595 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); |
| 594 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); | 596 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); |
| 595 BlockBuilder builder(flow_graph, normal_entry); | 597 BlockBuilder builder(flow_graph, normal_entry); |
| 596 | 598 |
| 597 Definition* value = builder.AddParameter(1); | 599 Definition* value = builder.AddParameter(1); |
| 598 Definition* index = builder.AddParameter(2); | 600 Definition* index = builder.AddParameter(2); |
| 599 Definition* array = builder.AddParameter(3); | 601 Definition* array = builder.AddParameter(3); |
| 600 | 602 |
| 601 PrepareIndexedOp(&builder, array, index, TypedData::length_offset()); | 603 PrepareIndexedOp(&builder, array, index, TypedData::length_offset()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 627 Thread::kNoDeoptId, | 629 Thread::kNoDeoptId, |
| 628 builder.TokenPos())); | 630 builder.TokenPos())); |
| 629 // Return null. | 631 // Return null. |
| 630 Definition* null_def = builder.AddNullDefinition(); | 632 Definition* null_def = builder.AddNullDefinition(); |
| 631 builder.AddIntrinsicReturn(new Value(null_def)); | 633 builder.AddIntrinsicReturn(new Value(null_def)); |
| 632 return true; | 634 return true; |
| 633 } | 635 } |
| 634 | 636 |
| 635 | 637 |
| 636 bool Intrinsifier::Build_Float64ArrayGetIndexed(FlowGraph* flow_graph) { | 638 bool Intrinsifier::Build_Float64ArrayGetIndexed(FlowGraph* flow_graph) { |
| 637 if (!FlowGraphCompiler::SupportsUnboxedDoubles()) return false; | 639 if (!FlowGraphCompiler::SupportsUnboxedDoubles()) { |
| 640 return false; |
| 641 } |
| 638 | 642 |
| 639 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); | 643 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); |
| 640 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); | 644 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); |
| 641 BlockBuilder builder(flow_graph, normal_entry); | 645 BlockBuilder builder(flow_graph, normal_entry); |
| 642 | 646 |
| 643 Definition* index = builder.AddParameter(1); | 647 Definition* index = builder.AddParameter(1); |
| 644 Definition* array = builder.AddParameter(2); | 648 Definition* array = builder.AddParameter(2); |
| 645 | 649 |
| 646 PrepareIndexedOp(&builder, array, index, TypedData::length_offset()); | 650 PrepareIndexedOp(&builder, array, index, TypedData::length_offset()); |
| 647 | 651 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 } | 780 } |
| 777 | 781 |
| 778 | 782 |
| 779 bool Intrinsifier::Build_Float32x4Add(FlowGraph* flow_graph) { | 783 bool Intrinsifier::Build_Float32x4Add(FlowGraph* flow_graph) { |
| 780 return BuildBinaryFloat32x4Op(flow_graph, Token::kADD); | 784 return BuildBinaryFloat32x4Op(flow_graph, Token::kADD); |
| 781 } | 785 } |
| 782 | 786 |
| 783 | 787 |
| 784 static bool BuildFloat32x4Shuffle(FlowGraph* flow_graph, | 788 static bool BuildFloat32x4Shuffle(FlowGraph* flow_graph, |
| 785 MethodRecognizer::Kind kind) { | 789 MethodRecognizer::Kind kind) { |
| 786 if (!FlowGraphCompiler::SupportsUnboxedSimd128()) return false; | 790 if (!FlowGraphCompiler::SupportsUnboxedDoubles() || |
| 791 !FlowGraphCompiler::SupportsUnboxedSimd128()) { |
| 792 return false; |
| 793 } |
| 787 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); | 794 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); |
| 788 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); | 795 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); |
| 789 BlockBuilder builder(flow_graph, normal_entry); | 796 BlockBuilder builder(flow_graph, normal_entry); |
| 790 | 797 |
| 791 Definition* receiver = builder.AddParameter(1); | 798 Definition* receiver = builder.AddParameter(1); |
| 792 | 799 |
| 793 Definition* unboxed_receiver = | 800 Definition* unboxed_receiver = |
| 794 builder.AddUnboxInstr(kUnboxedFloat32x4, | 801 builder.AddUnboxInstr(kUnboxedFloat32x4, |
| 795 new Value(receiver), | 802 new Value(receiver), |
| 796 /* is_checked = */ true); | 803 /* is_checked = */ true); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 new Value(length), | 1021 new Value(length), |
| 1015 kNoStoreBarrier, | 1022 kNoStoreBarrier, |
| 1016 builder.TokenPos())); | 1023 builder.TokenPos())); |
| 1017 Definition* null_def = builder.AddNullDefinition(); | 1024 Definition* null_def = builder.AddNullDefinition(); |
| 1018 builder.AddIntrinsicReturn(new Value(null_def)); | 1025 builder.AddIntrinsicReturn(new Value(null_def)); |
| 1019 return true; | 1026 return true; |
| 1020 } | 1027 } |
| 1021 | 1028 |
| 1022 | 1029 |
| 1023 bool Intrinsifier::Build_DoubleFlipSignBit(FlowGraph* flow_graph) { | 1030 bool Intrinsifier::Build_DoubleFlipSignBit(FlowGraph* flow_graph) { |
| 1031 if (!FlowGraphCompiler::SupportsUnboxedDoubles()) { |
| 1032 return false; |
| 1033 } |
| 1024 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); | 1034 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); |
| 1025 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); | 1035 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); |
| 1026 BlockBuilder builder(flow_graph, normal_entry); | 1036 BlockBuilder builder(flow_graph, normal_entry); |
| 1027 | 1037 |
| 1028 Definition* receiver = builder.AddParameter(1); | 1038 Definition* receiver = builder.AddParameter(1); |
| 1029 Definition* unboxed_value = | 1039 Definition* unboxed_value = |
| 1030 builder.AddUnboxInstr(kUnboxedDouble, | 1040 builder.AddUnboxInstr(kUnboxedDouble, |
| 1031 new Value(receiver), | 1041 new Value(receiver), |
| 1032 /* is_checked = */ true); | 1042 /* is_checked = */ true); |
| 1033 Definition* unboxed_result = builder.AddDefinition( | 1043 Definition* unboxed_result = builder.AddDefinition( |
| 1034 new UnaryDoubleOpInstr(Token::kNEGATE, | 1044 new UnaryDoubleOpInstr(Token::kNEGATE, |
| 1035 new Value(unboxed_value), | 1045 new Value(unboxed_value), |
| 1036 Thread::kNoDeoptId)); | 1046 Thread::kNoDeoptId)); |
| 1037 Definition* result = builder.AddDefinition( | 1047 Definition* result = builder.AddDefinition( |
| 1038 BoxInstr::Create(kUnboxedDouble, new Value(unboxed_result))); | 1048 BoxInstr::Create(kUnboxedDouble, new Value(unboxed_result))); |
| 1039 builder.AddIntrinsicReturn(new Value(result)); | 1049 builder.AddIntrinsicReturn(new Value(result)); |
| 1040 return true; | 1050 return true; |
| 1041 } | 1051 } |
| 1042 | 1052 |
| 1043 | 1053 |
| 1044 static bool BuildInvokeMathCFunction(BlockBuilder* builder, | 1054 static bool BuildInvokeMathCFunction(BlockBuilder* builder, |
| 1045 MethodRecognizer::Kind kind, | 1055 MethodRecognizer::Kind kind, |
| 1046 intptr_t num_parameters = 1) { | 1056 intptr_t num_parameters = 1) { |
| 1057 if (!FlowGraphCompiler::SupportsUnboxedDoubles()) { |
| 1058 return false; |
| 1059 } |
| 1047 ZoneGrowableArray<Value*>* args = | 1060 ZoneGrowableArray<Value*>* args = |
| 1048 new ZoneGrowableArray<Value*>(num_parameters); | 1061 new ZoneGrowableArray<Value*>(num_parameters); |
| 1049 | 1062 |
| 1050 for (intptr_t i = 0; i < num_parameters; i++) { | 1063 for (intptr_t i = 0; i < num_parameters; i++) { |
| 1051 const intptr_t parameter_index = (num_parameters - i); | 1064 const intptr_t parameter_index = (num_parameters - i); |
| 1052 Definition* value = builder->AddParameter(parameter_index); | 1065 Definition* value = builder->AddParameter(parameter_index); |
| 1053 Definition* unboxed_value = | 1066 Definition* unboxed_value = |
| 1054 builder->AddUnboxInstr(kUnboxedDouble, value, /* is_checked = */ false); | 1067 builder->AddUnboxInstr(kUnboxedDouble, value, /* is_checked = */ false); |
| 1055 args->Add(new Value(unboxed_value)); | 1068 args->Add(new Value(unboxed_value)); |
| 1056 } | 1069 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); | 1230 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); |
| 1218 BlockBuilder builder(flow_graph, normal_entry); | 1231 BlockBuilder builder(flow_graph, normal_entry); |
| 1219 | 1232 |
| 1220 return BuildInvokeMathCFunction(&builder, | 1233 return BuildInvokeMathCFunction(&builder, |
| 1221 MethodRecognizer::kDoubleRound); | 1234 MethodRecognizer::kDoubleRound); |
| 1222 } | 1235 } |
| 1223 #endif // !defined(TARGET_ARCH_DBC) | 1236 #endif // !defined(TARGET_ARCH_DBC) |
| 1224 | 1237 |
| 1225 | 1238 |
| 1226 } // namespace dart | 1239 } // namespace dart |
| OLD | NEW |