Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: runtime/vm/intrinsifier.cc

Issue 1961393002: VM: Optimized code for all of [External]{One|Two}ByteString::codeUnitAt. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | runtime/vm/intrinsifier_arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 kTypedDataFloat64ArrayCid, 652 kTypedDataFloat64ArrayCid,
653 Thread::kNoDeoptId, 653 Thread::kNoDeoptId,
654 builder.TokenPos())); 654 builder.TokenPos()));
655 Definition* result = builder.AddDefinition( 655 Definition* result = builder.AddDefinition(
656 BoxInstr::Create(kUnboxedDouble, new Value(unboxed_value))); 656 BoxInstr::Create(kUnboxedDouble, new Value(unboxed_value)));
657 builder.AddIntrinsicReturn(new Value(result)); 657 builder.AddIntrinsicReturn(new Value(result));
658 return true; 658 return true;
659 } 659 }
660 660
661 661
662 static bool BuildCodeUnitAt(FlowGraph* flow_graph, intptr_t cid) {
663 GraphEntryInstr* graph_entry = flow_graph->graph_entry();
664 TargetEntryInstr* normal_entry = graph_entry->normal_entry();
665 BlockBuilder builder(flow_graph, normal_entry);
666
667 Definition* index = builder.AddParameter(1);
668 Definition* str = builder.AddParameter(2);
669 PrepareIndexedOp(&builder, str, index, String::length_offset());
670
671 // For external strings: Load external data.
672 if (cid == kExternalOneByteStringCid) {
673 str = builder.AddDefinition(
674 new LoadUntaggedInstr(new Value(str),
675 ExternalOneByteString::external_data_offset()));
676 str = builder.AddDefinition(
677 new LoadUntaggedInstr(
678 new Value(str),
679 RawExternalOneByteString::ExternalData::data_offset()));
680 } else if (cid == kExternalTwoByteStringCid) {
681 str = builder.AddDefinition(
682 new LoadUntaggedInstr(new Value(str),
683 ExternalTwoByteString::external_data_offset()));
684 str = builder.AddDefinition(
685 new LoadUntaggedInstr(
686 new Value(str),
687 RawExternalTwoByteString::ExternalData::data_offset()));
688 }
689
690 Definition* result = builder.AddDefinition(
691 new LoadIndexedInstr(new Value(str),
692 new Value(index),
693 Instance::ElementSizeFor(cid),
694 cid,
695 Thread::kNoDeoptId,
696 builder.TokenPos()));
697 builder.AddIntrinsicReturn(new Value(result));
698 return true;
699 }
700
701
702 bool Intrinsifier::Build_OneByteStringCodeUnitAt(FlowGraph* flow_graph) {
703 return BuildCodeUnitAt(flow_graph, kOneByteStringCid);
704 }
705
706
707 bool Intrinsifier::Build_TwoByteStringCodeUnitAt(FlowGraph* flow_graph) {
708 return BuildCodeUnitAt(flow_graph, kTwoByteStringCid);
709 }
710
711
712 bool Intrinsifier::Build_ExternalOneByteStringCodeUnitAt(
713 FlowGraph* flow_graph) {
714 return BuildCodeUnitAt(flow_graph, kExternalOneByteStringCid);
715 }
716
717
718 bool Intrinsifier::Build_ExternalTwoByteStringCodeUnitAt(
719 FlowGraph* flow_graph) {
720 return BuildCodeUnitAt(flow_graph, kExternalTwoByteStringCid);
721 }
722
723
662 static bool BuildBinaryFloat32x4Op(FlowGraph* flow_graph, Token::Kind kind) { 724 static bool BuildBinaryFloat32x4Op(FlowGraph* flow_graph, Token::Kind kind) {
663 if (!FlowGraphCompiler::SupportsUnboxedSimd128()) return false; 725 if (!FlowGraphCompiler::SupportsUnboxedSimd128()) return false;
664 726
665 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); 727 GraphEntryInstr* graph_entry = flow_graph->graph_entry();
666 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); 728 TargetEntryInstr* normal_entry = graph_entry->normal_entry();
667 BlockBuilder builder(flow_graph, normal_entry); 729 BlockBuilder builder(flow_graph, normal_entry);
668 730
669 Definition* right = builder.AddParameter(1); 731 Definition* right = builder.AddParameter(1);
670 Definition* left = builder.AddParameter(2); 732 Definition* left = builder.AddParameter(2);
671 733
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); 1217 TargetEntryInstr* normal_entry = graph_entry->normal_entry();
1156 BlockBuilder builder(flow_graph, normal_entry); 1218 BlockBuilder builder(flow_graph, normal_entry);
1157 1219
1158 return BuildInvokeMathCFunction(&builder, 1220 return BuildInvokeMathCFunction(&builder,
1159 MethodRecognizer::kDoubleRound); 1221 MethodRecognizer::kDoubleRound);
1160 } 1222 }
1161 #endif // !defined(TARGET_ARCH_DBC) 1223 #endif // !defined(TARGET_ARCH_DBC)
1162 1224
1163 1225
1164 } // namespace dart 1226 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | runtime/vm/intrinsifier_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698