Open Bug 841859 Opened 12 years ago Updated 2 months ago

BaselineCompiler: Add optimized stub for String < or > String

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect

Tracking

()

People

(Reporter: djvj, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

string-validate-input hits these 24k times in total.
Attached patch PatchSplinter Review
Patch inlines comparison of linear strings which are <64 code units in length. The vast majority of comparisons should fall into this class and the inline path should fall under the vmcall overhead for those cases. To avoid register pressure on x86, the comparison loop stores the lengths of both strings in one register, and uses some bit tricks (described in comments) to do the comparison.
Attachment #715343 - Flags: review?(jdemooij)
Comment on attachment 715343 [details] [diff] [review] Patch Review of attachment 715343 [details] [diff] [review]: ----------------------------------------------------------------- I'm not sure it's worth it. I see a <= 0.2 ms win on validate-input on x86 with --no-jm with/without parallel compilation, no other benchmarks we know need this, and the other JITs also don't specialize this case. What do you think?
I think having a stub is worth it, if only to convey the (String, String) specialization for the compare. Once we get rid of stack typesets this info will have to come from here. Maybe the fancy assembly in the stub may not be ;) OTOH, I do think the fancy assembly would be interesting to use in Ion.
Ion should be able to determine the two operands are strings, even without StackTypeSets. There shouldn't be any loss in functionality with bug 804676, it will just be restructuring things so that the types we now explicitly track and keep around in StackTypeSets are instead encoded in the MIR.
In that case we can probably leave this be for now. I'm not convinced we shouldn't have a stub, though. If for whatever reason we have string-heavy code that doesn't spend a lot of time in Ion, we'll end up taking a _really_ slow path for it every time - with stack iter, a table lookup, stub-attachment checks, the whole lot. We should try to avoid that just on principle.
Comment on attachment 715343 [details] [diff] [review] Patch Forgot to cancel this review a long time ago..
Attachment #715343 - Flags: review?(jdemooij)
Assignee: general → nobody
Severity: normal → S3

Steve, still worth doing?

Flags: needinfo?(sphink)

Anba did some of this work in bug 1538692, so we do attach and transpile stubs in this case. Right now, the only case we handle in jitcode (for relational comparison) is comparing two strings pointing to the same instance. In all other cases, we do a VM call. (There's also an Ion-only optimization to compare strings against single chars.)

We could hypothetically expand MacroAssembler::compareStrings to handle eg short linear strings. I don't remember seeing jit::StringsCompare a lot in profiles, though, so it's not clear that it's especially important.

Flags: needinfo?(sphink)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: