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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intrinsifier.cc
diff --git a/runtime/vm/intrinsifier.cc b/runtime/vm/intrinsifier.cc
index 5615e58a699678252d77386790ad6c8f537160c8..27631b37e96115b59d928c326b3499141fa1319f 100644
--- a/runtime/vm/intrinsifier.cc
+++ b/runtime/vm/intrinsifier.cc
@@ -659,6 +659,68 @@ bool Intrinsifier::Build_Float64ArrayGetIndexed(FlowGraph* flow_graph) {
}
+static bool BuildCodeUnitAt(FlowGraph* flow_graph, intptr_t cid) {
+ GraphEntryInstr* graph_entry = flow_graph->graph_entry();
+ TargetEntryInstr* normal_entry = graph_entry->normal_entry();
+ BlockBuilder builder(flow_graph, normal_entry);
+
+ Definition* index = builder.AddParameter(1);
+ Definition* str = builder.AddParameter(2);
+ PrepareIndexedOp(&builder, str, index, String::length_offset());
+
+ // For external strings: Load external data.
+ if (cid == kExternalOneByteStringCid) {
+ str = builder.AddDefinition(
+ new LoadUntaggedInstr(new Value(str),
+ ExternalOneByteString::external_data_offset()));
+ str = builder.AddDefinition(
+ new LoadUntaggedInstr(
+ new Value(str),
+ RawExternalOneByteString::ExternalData::data_offset()));
+ } else if (cid == kExternalTwoByteStringCid) {
+ str = builder.AddDefinition(
+ new LoadUntaggedInstr(new Value(str),
+ ExternalTwoByteString::external_data_offset()));
+ str = builder.AddDefinition(
+ new LoadUntaggedInstr(
+ new Value(str),
+ RawExternalTwoByteString::ExternalData::data_offset()));
+ }
+
+ Definition* result = builder.AddDefinition(
+ new LoadIndexedInstr(new Value(str),
+ new Value(index),
+ Instance::ElementSizeFor(cid),
+ cid,
+ Thread::kNoDeoptId,
+ builder.TokenPos()));
+ builder.AddIntrinsicReturn(new Value(result));
+ return true;
+}
+
+
+bool Intrinsifier::Build_OneByteStringCodeUnitAt(FlowGraph* flow_graph) {
+ return BuildCodeUnitAt(flow_graph, kOneByteStringCid);
+}
+
+
+bool Intrinsifier::Build_TwoByteStringCodeUnitAt(FlowGraph* flow_graph) {
+ return BuildCodeUnitAt(flow_graph, kTwoByteStringCid);
+}
+
+
+bool Intrinsifier::Build_ExternalOneByteStringCodeUnitAt(
+ FlowGraph* flow_graph) {
+ return BuildCodeUnitAt(flow_graph, kExternalOneByteStringCid);
+}
+
+
+bool Intrinsifier::Build_ExternalTwoByteStringCodeUnitAt(
+ FlowGraph* flow_graph) {
+ return BuildCodeUnitAt(flow_graph, kExternalTwoByteStringCid);
+}
+
+
static bool BuildBinaryFloat32x4Op(FlowGraph* flow_graph, Token::Kind kind) {
if (!FlowGraphCompiler::SupportsUnboxedSimd128()) return false;
« 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