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

Unified Diff: runtime/vm/flow_graph_inliner.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/constant_propagator.cc ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_inliner.cc
diff --git a/runtime/vm/flow_graph_inliner.cc b/runtime/vm/flow_graph_inliner.cc
index 471c5118483b1c8f9ee30237a6e2ecad38d9dc90..c360c983e6727aec6420166e7b79d75fd2cf6433 100644
--- a/runtime/vm/flow_graph_inliner.cc
+++ b/runtime/vm/flow_graph_inliner.cc
@@ -2803,6 +2803,25 @@ static Definition* PrepareInlineStringIndexOp(
call->env(),
FlowGraph::kEffect);
+ // For external strings: Load backing store.
+ if (cid == kExternalOneByteStringCid) {
+ str = new LoadUntaggedInstr(new Value(str),
+ ExternalOneByteString::external_data_offset());
+ cursor = flow_graph->AppendTo(cursor, str, NULL, FlowGraph::kValue);
+ str = new LoadUntaggedInstr(
+ new Value(str),
+ RawExternalOneByteString::ExternalData::data_offset());
+ cursor = flow_graph->AppendTo(cursor, str, NULL, FlowGraph::kValue);
+ } else if (cid == kExternalTwoByteStringCid) {
+ str = new LoadUntaggedInstr(new Value(str),
+ ExternalTwoByteString::external_data_offset());
+ cursor = flow_graph->AppendTo(cursor, str, NULL, FlowGraph::kValue);
+ str = new LoadUntaggedInstr(
+ new Value(str),
+ RawExternalTwoByteString::ExternalData::data_offset());
+ cursor = flow_graph->AppendTo(cursor, str, NULL, FlowGraph::kValue);
+ }
+
LoadIndexedInstr* load_indexed = new(Z) LoadIndexedInstr(
new(Z) Value(str),
new(Z) Value(index),
@@ -2823,8 +2842,7 @@ static bool InlineStringBaseCharAt(
intptr_t cid,
TargetEntryInstr** entry,
Definition** last) {
- // TODO(johnmccutchan): Handle external strings in PrepareInlineStringIndexOp.
- if (RawObject::IsExternalStringClassId(cid) || cid != kOneByteStringCid) {
+ if ((cid != kOneByteStringCid) && (cid != kExternalOneByteStringCid)) {
return false;
}
Definition* str = call->ArgumentAt(0);
@@ -2836,8 +2854,8 @@ static bool InlineStringBaseCharAt(
*last = PrepareInlineStringIndexOp(flow_graph, call, cid, str, index, *entry);
- StringFromCharCodeInstr* char_at = new(Z) StringFromCharCodeInstr(
- new(Z) Value(*last), cid);
+ OneByteStringFromCharCodeInstr* char_at =
+ new(Z) OneByteStringFromCharCodeInstr(new(Z) Value(*last));
flow_graph->AppendTo(*last, char_at, NULL, FlowGraph::kValue);
*last = char_at;
@@ -2852,11 +2870,6 @@ static bool InlineStringCodeUnitAt(
intptr_t cid,
TargetEntryInstr** entry,
Definition** last) {
- // TODO(johnmccutchan): Handle external strings in PrepareInlineStringIndexOp.
- if (RawObject::IsExternalStringClassId(cid)) {
- return false;
- }
-
Definition* str = call->ArgumentAt(0);
Definition* index = call->ArgumentAt(1);
@@ -3097,7 +3110,10 @@ bool FlowGraphInliner::TryInlineRecognizedMethod(FlowGraph* flow_graph,
receiver_cid,
kTypedDataInt32x4ArrayCid,
entry, last);
- case MethodRecognizer::kStringBaseCodeUnitAt:
+ case MethodRecognizer::kOneByteStringCodeUnitAt:
+ case MethodRecognizer::kTwoByteStringCodeUnitAt:
+ case MethodRecognizer::kExternalOneByteStringCodeUnitAt:
+ case MethodRecognizer::kExternalTwoByteStringCodeUnitAt:
return InlineStringCodeUnitAt(
flow_graph, call, receiver_cid, entry, last);
case MethodRecognizer::kStringBaseCharAt:
« no previous file with comments | « runtime/vm/constant_propagator.cc ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698