Skip to content

Add string_normalize intrinsic#1023

Merged
jeffcharles merged 3 commits into
mainfrom
jc.add-string-normalize
Oct 6, 2025
Merged

Add string_normalize intrinsic#1023
jeffcharles merged 3 commits into
mainfrom
jc.add-string-normalize

Conversation

@jeffcharles

@jeffcharles jeffcharles commented Oct 3, 2025

Copy link
Copy Markdown
Collaborator

Description of the change

Adds the string_normalize RQuickJS intrinsic and a method on Config to make it available or unavailable. It defaults to available similar to how we handle other RQuickJS intrinsics.

Also lowers the fuel consumed amount for the empty test because that test was failing for me and increases the threshold to 3% since I can't get the tests to pass on both MacOS and Linux at 2%.

Why am I making this change?

Someone tried to use the normalize method on strings and it didn't exist.

Checklist

  • I've updated the relevant CHANGELOG files if necessary. Changes to javy-cli, javy-plugin, and javy-plugin-processing do not require updating CHANGELOG files.
  • I've updated the relevant crate versions if necessary. Versioning policy for library crates
  • I've updated documentation including crate documentation if necessary.

let target_fuel = target_fuel as f64;
let fuel_consumed = fuel_consumed as f64;
let threshold = 2.0;
let threshold = 3.0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's not totally clear why this change is needed, but perhaps I'm missing something?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If I don't make this change, the test_empty test will always fail on one of Linux or MacOS because the difference between the fuel counts on the different operating systems is 2.3% apart with this change.

}

if intrinsics.contains(JSIntrinsics::STRING_NORMALIZE) {
unsafe { intrinsic::StringNormalize::add_intrinsic(ctx.as_raw()) }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add an entry here? https://github.com/bytecodealliance/javy/blob/main/docs/docs-using-js-api-support.md -- I guess that page needs a general update, so might be worth doing while you're there, if you feel like it.

@jeffcharles
jeffcharles merged commit d00f4d7 into main Oct 6, 2025
5 checks passed
@jeffcharles
jeffcharles deleted the jc.add-string-normalize branch October 6, 2025 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants