Skip to content

Commit 50ceab8

Browse files
committed
Stop in-lining more stuff
1 parent c1ce17c commit 50ceab8

File tree

2 files changed

+15
-30
lines changed

2 files changed

+15
-30
lines changed

jit-compiler/src/includes/field_generic_up_to_64.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,18 @@ impl std::fmt::Display for FieldElement {
1414
}
1515

1616
impl From<IntType> for FieldElement {
17-
#[inline]
1817
fn from(i: IntType) -> Self {
1918
Self(i)
2019
}
2120
}
2221
impl From<FieldElement> for IntType {
23-
#[inline]
2422
fn from(f: FieldElement) -> Self {
2523
f.0
2624
}
2725
}
2826
impl std::ops::Add for FieldElement {
2927
type Output = Self;
30-
#[inline]
28+
3129
fn add(self, b: Self) -> Self {
3230
// TODO this is inefficient.
3331
Self(
@@ -40,7 +38,7 @@ impl std::ops::Add for FieldElement {
4038
}
4139
impl std::ops::Sub for FieldElement {
4240
type Output = Self;
43-
#[inline]
41+
4442
fn sub(self, b: Self) -> Self {
4543
// TODO this is inefficient.
4644
Self(
@@ -54,7 +52,7 @@ impl std::ops::Sub for FieldElement {
5452
}
5553
impl std::ops::Neg for FieldElement {
5654
type Output = Self;
57-
#[inline]
55+
5856
fn neg(self) -> Self {
5957
if self.0 == 0 {
6058
self
@@ -65,7 +63,7 @@ impl std::ops::Neg for FieldElement {
6563
}
6664
impl std::ops::Mul<FieldElement> for FieldElement {
6765
type Output = Self;
68-
#[inline]
66+
6967
fn mul(self, b: FieldElement) -> FieldElement {
7068
// TODO this is inefficient.
7169
Self(
@@ -78,7 +76,7 @@ impl std::ops::Mul<FieldElement> for FieldElement {
7876
}
7977
impl std::ops::Div<FieldElement> for FieldElement {
8078
type Output = Self;
81-
#[inline]
79+
8280
fn div(self, b: FieldElement) -> FieldElement {
8381
if b.0 == 0 {
8482
panic!("Division by zero");
@@ -99,7 +97,7 @@ impl std::ops::Div<FieldElement> for FieldElement {
9997
}
10098
}
10199
}
102-
#[inline]
100+
103101
fn try_integer_div_without_remainder(a: IntType, b: IntType) -> Option<IntType> {
104102
(a % b == 0).then(|| a / b)
105103
}
@@ -108,20 +106,20 @@ fn full_field_div(_: FieldElement, _: FieldElement) -> FieldElement {
108106
// TODO generate the algorithm we use for goldilocks
109107
// for a generic prime field.
110108
}
111-
#[inline]
109+
112110
fn integer_div(a: FieldElement, b: FieldElement) -> FieldElement {
113111
FieldElement(a.0 / b.0)
114112
}
115113
impl std::ops::BitAnd<FieldElement> for FieldElement {
116114
type Output = Self;
117-
#[inline]
115+
118116
fn bitand(self, b: FieldElement) -> FieldElement {
119117
Self(self.0 & b.0)
120118
}
121119
}
122120
impl std::ops::BitOr<FieldElement> for FieldElement {
123121
type Output = Self;
124-
#[inline]
122+
125123
fn bitor(self, b: FieldElement) -> FieldElement {
126124
Self(self.0 | b.0)
127125
}

jit-compiler/src/includes/field_goldilocks.rs

+6-19
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,16 @@ impl GoldilocksField {
7373
res
7474
}
7575

76-
#[inline(always)]
7776
fn from_canonical_u64(n: u64) -> Self {
7877
debug_assert!(n < Self::ORDER);
7978
Self(n)
8079
}
8180

82-
#[inline]
8381
fn to_canonical_u64(self) -> u64 {
8482
self.0
8583
}
8684
}
8785

88-
#[inline]
8986
fn wrap(x: u64) -> u64 {
9087
if x >= GoldilocksField::ORDER {
9188
x - GoldilocksField::ORDER
@@ -97,7 +94,6 @@ fn wrap(x: u64) -> u64 {
9794
impl std::ops::Neg for GoldilocksField {
9895
type Output = Self;
9996

100-
#[inline]
10197
fn neg(self) -> Self {
10298
if self.0 == 0 {
10399
self
@@ -110,7 +106,6 @@ impl std::ops::Neg for GoldilocksField {
110106
impl std::ops::Add for GoldilocksField {
111107
type Output = Self;
112108

113-
#[inline]
114109
#[allow(clippy::suspicious_arithmetic_impl)]
115110
fn add(self, rhs: Self) -> Self {
116111
let (sum, over) = self.0.overflowing_add(rhs.0);
@@ -123,7 +118,6 @@ impl std::ops::Add for GoldilocksField {
123118
impl std::ops::Sub for GoldilocksField {
124119
type Output = Self;
125120

126-
#[inline]
127121
#[allow(clippy::suspicious_arithmetic_impl)]
128122
fn sub(self, rhs: Self) -> Self {
129123
let (diff, under) = self.0.overflowing_sub(rhs.0);
@@ -171,7 +165,6 @@ impl std::ops::Div for GoldilocksField {
171165
}
172166
}
173167

174-
#[inline]
175168
fn try_integer_div_without_remainder(a: u64, b: u64) -> Option<u64> {
176169
(a % b == 0).then(|| a / b)
177170
}
@@ -185,7 +178,7 @@ fn full_field_div(a: GoldilocksField, b: GoldilocksField) -> GoldilocksField {
185178
/// - It is only correct if x + y < 2**64 + ORDER = 0x1ffffffff00000001.
186179
/// - It is only faster in some circumstances. In particular, on x86 it overwrites both inputs in
187180
/// the registers, so its use is not recommended when either input will be used again.
188-
#[inline(always)]
181+
189182
#[cfg(target_arch = "x86_64")]
190183
unsafe fn add_no_canonicalize_trashing_input(x: u64, y: u64) -> u64 {
191184
let res_wrapped: u64;
@@ -212,7 +205,6 @@ unsafe fn add_no_canonicalize_trashing_input(x: u64, y: u64) -> u64 {
212205
res_wrapped + adjustment
213206
}
214207

215-
#[inline(always)]
216208
#[cfg(not(target_arch = "x86_64"))]
217209
const unsafe fn add_no_canonicalize_trashing_input(x: u64, y: u64) -> u64 {
218210
let (res_wrapped, carry) = x.overflowing_add(y);
@@ -221,7 +213,7 @@ const unsafe fn add_no_canonicalize_trashing_input(x: u64, y: u64) -> u64 {
221213
}
222214

223215
/// Reduces to a 64-bit value. The result is in canonical form.
224-
#[inline]
216+
225217
fn reduce128(x: u128) -> GoldilocksField {
226218
let (x_lo, x_hi) = split(x); // This is a no-op
227219
let x_hi_hi = x_hi >> 32;
@@ -239,17 +231,15 @@ fn reduce128(x: u128) -> GoldilocksField {
239231
}
240232

241233
/// Squares the base N number of times and multiplies the result by the tail value.
242-
#[inline(always)]
234+
243235
fn exp_acc<const N: usize>(base: GoldilocksField, tail: GoldilocksField) -> GoldilocksField {
244236
base.exp_power_of_2(N) * tail
245237
}
246238

247-
#[inline]
248239
const fn split(x: u128) -> (u64, u64) {
249240
(x as u64, (x >> 64) as u64)
250241
}
251242

252-
#[inline(always)]
253243
#[cfg(target_arch = "x86_64")]
254244
fn assume(p: bool) {
255245
debug_assert!(p);
@@ -268,7 +258,7 @@ fn assume(p: bool) {
268258
/// y = bar();
269259
/// }
270260
/// This function has no semantics. It is a hint only.
271-
#[inline(always)]
261+
272262
fn branch_hint() {
273263
// NOTE: These are the currently supported assembly architectures. See the
274264
// [nightly reference](https://doc.rust-lang.org/nightly/reference/inline-assembly.html) for
@@ -287,14 +277,12 @@ fn branch_hint() {
287277
}
288278

289279
impl From<u64> for GoldilocksField {
290-
#[inline]
291280
fn from(n: u64) -> Self {
292281
Self(wrap(n))
293282
}
294283
}
295284

296285
impl From<FieldElement> for IntType {
297-
#[inline]
298286
fn from(f: FieldElement) -> Self {
299287
f.0
300288
}
@@ -306,21 +294,20 @@ impl std::fmt::Display for GoldilocksField {
306294
}
307295
}
308296

309-
#[inline]
310297
fn integer_div(a: GoldilocksField, b: GoldilocksField) -> GoldilocksField {
311298
GoldilocksField(a.0 / b.0)
312299
}
313300

314301
impl std::ops::BitAnd<u64> for GoldilocksField {
315302
type Output = Self;
316-
#[inline]
303+
317304
fn bitand(self, b: u64) -> GoldilocksField {
318305
Self(self.0 & b)
319306
}
320307
}
321308
impl std::ops::BitOr<GoldilocksField> for GoldilocksField {
322309
type Output = Self;
323-
#[inline]
310+
324311
fn bitor(self, b: GoldilocksField) -> GoldilocksField {
325312
Self(self.0 | b.0)
326313
}

0 commit comments

Comments
 (0)