Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
hansl wants to merge6 commits intoboa-dev:main
base:main
Choose a base branch
Loading
fromhansl:bytesarray-array-length

Conversation

@hansl
Copy link
Contributor

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.

On platforms that are 32-bits (or 128?) this should make array anditerations faster in general. On platforms that are 64-bits, thiswill have no effect.
@codecov
Copy link

codecovbot commentedDec 11, 2024
edited
Loading

Codecov Report

Attention: Patch coverage is43.57143% with79 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 linesPatch %Lines
core/engine/src/builtins/typed_array/builtin.rs12.90%27 Missing⚠️
core/engine/src/builtins/regexp/mod.rs41.17%10 Missing⚠️
core/engine/src/builtins/array/mod.rs73.33%8 Missing⚠️
core/engine/src/builtins/dataview/mod.rs0.00%7 Missing⚠️
core/engine/src/builtins/array_buffer/mod.rs0.00%6 Missing⚠️
core/engine/src/object/builtins/jsdataview.rs0.00%5 Missing⚠️
core/engine/src/builtins/array_buffer/shared.rs0.00%4 Missing⚠️
core/engine/src/builtins/string/mod.rs66.66%3 Missing⚠️
core/engine/src/builtins/atomics/mod.rs0.00%2 Missing⚠️
core/engine/src/object/builtins/jsarray.rs0.00%2 Missing⚠️
... and5 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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

@jedel1043
Copy link
Member

Test262 conformance changes

Test resultmain countPR countdifference
Total48,62548,6250
Passed43,61643,607-9
Ignored1,4711,4710
Failed3,5383,547+9
Panics000
Conformance89.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
Copy link
Member

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

@hansl
Copy link
ContributorAuthor

@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!

@jedel1043
Copy link
Member

jedel1043 commentedDec 13, 2024
edited
Loading

@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
Copy link
Member

Test262 conformance changes

Test resultmain countPR countdifference
Total48,62548,6250
Passed43,61643,6160
Ignored1,4711,4710
Failed3,5383,5380
Panics000
Conformance89.70%89.70%0.00%

Copy link
Member

@jedel1043jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks great!

Approving this, but can you open an issue to add CI tests for a 32-bit architecture? I'd really like to potentially test that just to avoid introducing platform-dependent regressions.

@hansl
Copy link
ContributorAuthor

hansl commentedDec 14, 2024
edited
Loading

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
Copy link
ContributorAuthor

hansl commentedDec 14, 2024
edited
Loading

At least 3 tests are failing inboa_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.

Comment on lines 899 to 902
pubfnto_length(&self,context:&mutContext) ->JsResult<usize>{
// 1. Let len be ? ToInteger(argument).
// 2. If len ≤ +0, return +0.
// 3. Return min(len, 2^53 - 1).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We used to have it beusize, but we changed it because on32-bit systems it does not capture the full range that a JavaScript length can be. (for arrays it's fine to put it asusize since it's between0..2^32-1, but for strings and typed arrays, the upper bound is2^53-1 (max safe representable integer in af64).

Setting it tousize truncates the values on 32-bit platforms giving wrong results.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

For example, one place thatto_length is used isString.padEnd() on themaxLength parameter, putting2^32-1 would work on 32-bit platform anything greater will be truncated (i.e.2^32 will be truncated to0), on 64-bit platform this would be fine.

Copy link
ContributorAuthor

@hanslhanslDec 14, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

MAX_STRING_LENGTH is 2^32-1.

From the MDN:

The language specification requires strings to have a maximum length of 253 - 1 elements, which is the upper limit for precise integers. However, a string with this length needs 16384TiB of storage, which cannot fit in any reasonable device's memory, so implementations tend to lower the threshold, which allows the string's length to be conveniently stored in a 32-bit integer.

In V8 (used by Chrome and Node), the maximum length is 229 - 24 (~1GiB). On 32-bit systems, the maximum length is 228 - 16 (~512MiB).
In Firefox, the maximum length is 230 - 2 (~2GiB). Before Firefox 65, the maximum length was 228 - 1 (~512MiB).
In Safari, the maximum length is 231 - 1 (~4GiB).

Copy link
Member

@HalidOdatHalidOdatDec 15, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The issue isn't with allocation of the strings, rather that it breaks the math and checks in many places.

EDIT: What I mean is that even if the allocation is limited, the spec still assumes at the length is the full range, and all the math and checks before the final allocation should be able to hold that range.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

That's all fine. If there's a bug with math being broken, then we need to fix it.

I would assume test262 and/or our tests would find any discrepancies, and I'd consider any issue a blocker for this PR. I'm currently running the full test262 suite on a Rasp Pi 2 equivalent. Everything works locally on my aarch64 Mac.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If you can provide me with a valid JavaScript snippet that works on other implementations but doesn't work on this PR, I'll be more than happy to add it to tests and fix this PR.

@hansl
Copy link
ContributorAuthor

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 sizesStringUSize /StringISize andArrayUSize /ArrayISize so it becomes more clear in the code which we're dealing with.

For now this PR will be back to draft.

@hanslhansl marked this pull request as draftDecember 19, 2024 01:49
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@HalidOdatHalidOdatHalidOdat left review comments

@jedel1043jedel1043jedel1043 approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@hansl@jedel1043@HalidOdat

[8]ページ先頭

©2009-2025 Movatter.jp