boa icon indicating copy to clipboard operation
boa copied to clipboard

Replace all u64/i64 for length, index or offsets into usize/isize

Open hansl opened this issue 1 year ago • 9 comments

On platforms that are 32-bits (or 128?) this should make array and iterations faster in general. On platforms that are 64-bits, this will have no effect.

hansl avatar Dec 11 '24 22:12 hansl

Codecov Report

Attention: Patch coverage is 43.57143% with 79 lines in your changes missing coverage. Please review.

Project coverage is 53.34%. Comparing base (6ddc2b4) to head (442bc60). Report is 319 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/builtins/typed_array/builtin.rs 12.90% 27 Missing :warning:
core/engine/src/builtins/regexp/mod.rs 41.17% 10 Missing :warning:
core/engine/src/builtins/array/mod.rs 73.33% 8 Missing :warning:
core/engine/src/builtins/dataview/mod.rs 0.00% 7 Missing :warning:
core/engine/src/builtins/array_buffer/mod.rs 0.00% 6 Missing :warning:
core/engine/src/object/builtins/jsdataview.rs 0.00% 5 Missing :warning:
core/engine/src/builtins/array_buffer/shared.rs 0.00% 4 Missing :warning:
core/engine/src/builtins/string/mod.rs 66.66% 3 Missing :warning:
core/engine/src/builtins/atomics/mod.rs 0.00% 2 Missing :warning:
core/engine/src/object/builtins/jsarray.rs 0.00% 2 Missing :warning:
... and 5 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4083      +/-   ##
==========================================
+ Coverage   47.24%   53.34%   +6.09%     
==========================================
  Files         476      484       +8     
  Lines       46892    48196    +1304     
==========================================
+ Hits        22154    25709    +3555     
+ Misses      24738    22487    -2251     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Dec 11 '24 23:12 codecov[bot]

Test262 conformance changes

Test result main count PR count difference
Total 48,625 48,625 0
Passed 43,616 43,607 -9
Ignored 1,471 1,471 0
Failed 3,538 3,547 +9
Panics 0 0 0
Conformance 89.70% 89.68% -0.02%
Broken tests (9):
test/built-ins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js (previously Passed)
test/built-ins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js (previously Passed)
test/built-ins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js (previously Passed)
test/built-ins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js (previously Passed)
test/built-ins/TypedArray/prototype/lastIndexOf/resizable-buffer.js (previously Passed)
test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js (previously Passed)
test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js (previously Passed)
test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js (previously Passed)
test/built-ins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js (previously Passed)

jedel1043 avatar Dec 12 '24 02:12 jedel1043

Hmm, there were some test regressions. Can you investigate them? Maybe it was just a typo somewhere.

jedel1043 avatar Dec 12 '24 02:12 jedel1043

@jedel1043 I don't know how to manually re-run the test262 on this project, so I'll leave that to you as a reviewer. Thanks!

hansl avatar Dec 13 '24 04:12 hansl

@hansl tests already ran, it's just on the output of the "Update comment / Write a new comment" steps for the Test262 action. We really need to setup something so that this thing works on external repos 😅

jedel1043 avatar Dec 13 '24 04:12 jedel1043

Test262 conformance changes

Test result main count PR count difference
Total 48,625 48,625 0
Passed 43,616 43,616 0
Ignored 1,471 1,471 0
Failed 3,538 3,538 0
Panics 0 0 0
Conformance 89.70% 89.70% 0.00%

jedel1043 avatar Dec 13 '24 04:12 jedel1043

~~Sounds good. Let me test the test262 on my embedded platform before merging. Will have to wait to Monday.~~

Scratch that. I won't be able to easily run test262, but I'll run the integration tests and the unit tests tonight and report back. Will also create an issue.

hansl avatar Dec 14 '24 02:12 hansl

At least 3 tests are failing in boa_engine, will investigate Monday.

CleanShot 2024-12-13 at 19 12 58@2x

To be fair, they're likely wrong test expectations based on overflow/underflow, but I still want to make sure.

hansl avatar Dec 14 '24 03:12 hansl

Okay so after running test262 a bunch, and testing in browsers and Deno, I would still like to build this PR the right way but will need to move to a different approach:

  • isize/usize will be used internally for sizes, indices and offsets of strings.
  • i64/u64 will be used for array.

This should still result in performance improvements on 32-bits platforms (e.g. in wasm32).

I may type the new sizes StringUSize / StringISize and ArrayUSize / ArrayISize so it becomes more clear in the code which we're dealing with.

For now this PR will be back to draft.

hansl avatar Dec 19 '24 01:12 hansl