Commit e4e0d1c6 authored by Jun Lim's avatar Jun Lim Committed by Commit Bot

[turbo]Partition search space in StringCharCodeAt

Instead of using sequential search for each string type,
this CL partition the search space into two groups.

In arm64, observed about 10% speedup in the benchmark posted in bug7326.

Bug: v8:7326
Change-Id: I42d4580eddf7bde7b9eb2225b08c8e26989f14e8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1605355Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61463}
parent 0dc3ffc5
......@@ -3639,18 +3639,28 @@ Node* EffectControlLinearizer::LowerStringCharCodeAt(Node* node) {
receiver_instance_type, __ Int32Constant(kStringRepresentationMask));
// Dispatch on the current {receiver}s string representation.
auto if_lessthanoreq_cons = __ MakeLabel();
auto if_greaterthan_cons = __ MakeLabel();
auto if_seqstring = __ MakeLabel();
auto if_consstring = __ MakeLabel();
auto if_thinstring = __ MakeLabel();
auto if_externalstring = __ MakeLabel();
auto if_slicedstring = __ MakeLabel();
auto if_runtime = __ MakeDeferredLabel();
__ GotoIf(__ Word32Equal(receiver_representation,
__ Int32Constant(kSeqStringTag)),
&if_seqstring);
__ GotoIf(__ Word32Equal(receiver_representation,
__ Branch(__ Int32LessThanOrEqual(receiver_representation,
__ Int32Constant(kConsStringTag)),
&if_lessthanoreq_cons, &if_greaterthan_cons);
__ Bind(&if_lessthanoreq_cons);
{
__ Branch(__ Word32Equal(receiver_representation,
__ Int32Constant(kConsStringTag)),
&if_consstring);
&if_consstring, &if_seqstring);
}
__ Bind(&if_greaterthan_cons);
{
__ GotoIf(__ Word32Equal(receiver_representation,
__ Int32Constant(kThinStringTag)),
&if_thinstring);
......@@ -3660,6 +3670,7 @@ Node* EffectControlLinearizer::LowerStringCharCodeAt(Node* node) {
__ Branch(__ Word32Equal(receiver_representation,
__ Int32Constant(kSlicedStringTag)),
&if_slicedstring, &if_runtime);
}
__ Bind(&if_seqstring);
{
......@@ -3672,13 +3683,6 @@ Node* EffectControlLinearizer::LowerStringCharCodeAt(Node* node) {
__ Goto(&loop_done, result);
}
__ Bind(&if_thinstring);
{
Node* receiver_actual =
__ LoadField(AccessBuilder::ForThinStringActual(), receiver);
__ Goto(&loop_next, receiver_actual, position);
}
__ Bind(&if_consstring);
{
Node* receiver_second =
......@@ -3690,6 +3694,13 @@ Node* EffectControlLinearizer::LowerStringCharCodeAt(Node* node) {
__ Goto(&loop_next, receiver_first, position);
}
__ Bind(&if_thinstring);
{
Node* receiver_actual =
__ LoadField(AccessBuilder::ForThinStringActual(), receiver);
__ Goto(&loop_next, receiver_actual, position);
}
__ Bind(&if_externalstring);
{
// We need to bailout to the runtime for uncached external strings.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment