Commit 766cd463 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by V8 LUCI CQ

[bigint][ia32] Make bigint::Compare inlineable

Due to the limits of ia32's calling convention, being able to
avoid construction of "Digits" objects (thanks to inlining)
helps a lot for microbenchmarks.

Fixed: chromium:1192133
Change-Id: I5676640d96a99dc6422f3946c608bcc93ef222ba
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2947410
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75028}
parent c0f90e59
......@@ -206,7 +206,18 @@ class Platform {
// mechanism when it takes too long. These functions return a {Status} value.
// Returns r such that r < 0 if A < B; r > 0 if A > B; r == 0 if A == B.
int Compare(Digits A, Digits B);
// Defined here to be inlineable, which helps ia32 a lot (64-bit platforms
// don't care).
inline int Compare(Digits A, Digits B) {
A.Normalize();
B.Normalize();
int diff = A.len() - B.len();
if (diff != 0) return diff;
int i = A.len() - 1;
while (i >= 0 && A[i] == B[i]) i--;
if (i < 0) return 0;
return A[i] > B[i] ? 1 : -1;
}
enum class Status { kOk, kInterrupted };
......
......@@ -34,16 +34,5 @@ void SubAt(RWDigits Z, Digits X) {
}
}
int Compare(Digits A, Digits B) {
A.Normalize();
B.Normalize();
int diff = A.len() - B.len();
if (diff != 0) return diff;
int i = A.len() - 1;
while (i >= 0 && A[i] == B[i]) i--;
if (i < 0) return 0;
return A[i] > B[i] ? 1 : -1;
}
} // namespace bigint
} // namespace v8
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