* Update to primary docs to account for console update
* fix intra-doc link
* Forgot a period
* Fixing the errors on runtime docs
* Add hidden panic to example
* Make update operations reuse the last found binding locator
* Rename opcode
* Reword opcode comments
* Change capacity of `bindings_stack`
* Use the callframe stack to store the current binding
* Fix typo
* Reuse locators on assignment deletions
* Fix binding bug
* Remove leftover comment
It was reported that the `dbg!` output of native errors was too long. This PR skips printing the `Realm` of a `JsNativeError`. It also improves the `dbg!` output of `Realm` by skipping printing `Inner` and only printing the inner fields of `Inner`.
Noticed we were using this pattern on a couple of places, so I abstracted it behind a `ContextCleanupGuard` struct.
Let me know if you remember another place where this pattern would apply.
Bumps [regress](https://github.com/ridiculousfish/regress) from 0.5.0 to 0.6.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/ridiculousfish/regress/releases">regress's releases</a>.</em></p>
<blockquote>
<h2>v0.6.0</h2>
<p>Version 0.6.0 of regress, REGex in Rust with EmcaScript Syntax.</p>
<ul>
<li>Unpaired surrogates are now properly handled in accordance with the EcmaScript spec (<a href="https://github.com/jedel1043"><code>@jedel1043</code></a> in <a href="https://redirect.github.com/ridiculousfish/regress/pull/60">ridiculousfish/regress#60</a>)</li>
<li>Invalid ranges like <code>[a-\s]</code> are now permitted in non-Unicode mode, in accordance with Annex B of EcmaScript spec (<a href="https://github.com/HalidOdat"><code>@HalidOdat</code></a> in <a href="https://redirect.github.com/ridiculousfish/regress/pull/62">ridiculousfish/regress#62</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="b0814a7435"><code>b0814a7</code></a> Release regress 0.6.0</li>
<li><a href="dcc8ab63c8"><code>dcc8ab6</code></a> Fix valid character sets in Annex-B</li>
<li><a href="e724b5c04c"><code>e724b5c</code></a> Run <code>cargo clippy</code></li>
<li><a href="701e366172"><code>701e366</code></a> Expand comments further</li>
<li><a href="79890137f8"><code>7989013</code></a> Fix surrogates parsing on regex</li>
<li>See full diff in <a href="https://github.com/ridiculousfish/regress/compare/v0.5.0...v0.6.0">compare view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=regress&package-manager=cargo&previous-version=0.5.0&new-version=0.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
</details>
This PR implements `Hidden Classes`, I named them as `Shapes` (like Spidermonkey does), calling them maps like v8 seems confusing because there already is a JS builtin, likewise with `Hidden classes` since there are already classes in JS.
There are two types of shapes: `shared` shapes that create the transition tree, and are shared between objects, this is mainly intended for user defined objects this makes more sense because shapes can create transitions trees, doing that for the builtins seems wasteful (unless users wanted to creating an object with the same property names and the same property attributes in the same order... which seems unlikely). That's why I added `unique` shapes, only one object has it. This is similar to previous solution, but this architecture enables us to use inline caching.
There will probably be a performance hit until we implement inline caching.
There still a lot of work that needs to be done, on this:
- [x] Move Property Attributes to shape
- [x] Move Prototype to shape
- [x] ~~Move extensible flag to shape~~, On further evaluation this doesn't give any benefit (at least right now), since it isn't used by inline caching also adding one more transition.
- [x] Implement delete for unique shapes.
- [x] If the chain is too long we should probably convert it into a `unique` shape
- [x] Figure out threshold ~~(maybe more that 256 properties ?)~~ curently set to an arbitrary number (`1024`)
- [x] Implement shared property table between shared shapes
- [x] Add code Document
- [x] Varying size storage for properties (get+set = 2, data = 1)
- [x] Add shapes to more object:
- [x] ordinary object
- [x] Arrays
- [x] Functions
- [x] Other builtins
- [x] Add `shapes.md` doc explaining shapes in depth with mermaid diagrams :)
- [x] Add `$boa.shape` module
- [x] `$boa.shape.id(o)`
- [x] `$boa.shape.type(o)`
- [x] `$boa.shape.same(o1, o2)`
- [x] add doc to `boa_object.md`
We have currently some bugs related to binding assignments on arithmetic operations (`+=`, `++`, `?=`, etc.), but fixing those was getting a bit complex with our current bindings APIs.
This PR refactors our binding handling APIs to be a bit easier to use.
Most of the time that we have a `ByValue` ( `[ value ]` syntax ) it is for arrays and the value is usually an index. This PR adds a fast path to the instructions (without calling `.borrow()` on the object to check if its an array)
For example, this code:
```js
let a = [1, 2, 3]
for (let i = 0 ; i < 10000000; ++i) {
a[i % 3] += a[ (i + 1) % 3 ]
}
```
Using `hyperfine`, it ran `1.38` times faster on this PR.
```bash
Benchmark 1: ./boa_main test.js
Time (mean ± σ): 16.504 s ± 0.192 s [User: 16.440 s, System: 0.020 s]
Range (min … max): 16.328 s … 16.938 s 10 runs
Benchmark 2: ./boa_direct_array_access test.js
Time (mean ± σ): 11.982 s ± 0.038 s [User: 11.939 s, System: 0.013 s]
Range (min … max): 11.914 s … 12.035 s 10 runs
Summary
'./boa_direct_array_access test.js' ran
1.38 ± 0.02 times faster than './boa_main test.js'
```
This Pull Request fixes/closes #718.
It changes the following:
- Adds a new `boa_runtime` crate, that will only include `console` for now
- Changes the `boa_cli` crate to use the new `boa_runtime` crate for the console, instead of the `console` feature of `boa_engine`
- Removes the `console` feature in `boa_engine`
- Adds a new `boa_testing` helper crate with some useful functions for testing `boa`. This part duplicates the code from `boa_engine`, but I could not make `boa_engine` work with this crate as a dependency due to circular dependencies. Maybe doing it a bit generic could work, but didn't have enough time to check it.
To be checked: wether the WASM example works as expected with the console.
This Pull Request fixes/closes #2717 and related to #2479
This was caused by an incorrect to digit conversion.
Here are two examples that always cause a panic. They have been added as a test in `number/test.rs`
```js
(0.1600057092765239).toString(36)
(0.23046743672210102).toString(36)
```
Part of ES5.
This PR allows `Date` objects to store an invalid `NativeDateTime` as a `i64` and check when `getMinutes` (or other methods) call and check if it's valid, like in the spec
This was failing some `Date` tests, when calling `new Date(8.64e15)` then calling `getTime()` it was returning `NaN` when it should return the passed value `8640000000000000` (as node does)
Part of ES5.
This was the last failing test on `Date.prototype[Symbol.primitive]` test suite :)
It changes the following:
- Fix `Date.prototype[Symbol.primitive]` incorrect attributes
This Pull Request implements [Initializers in ForIn Statement Heads](https://tc39.es/ecma262/#sec-initializers-in-forin-statement-heads) from the Annex B. This also cleans up the "annex-b" feature to be able to disable it with `--no-default-features`, since I couldn't test the error messages when the feature is disabled.
Fixes incorrect parsing of index property keys, such as:
- `"+0"` is converted to an integer index `0`, should be a string
- `"00"` is converted to an integer index `0`, should be a string
- `"01"` is converted to an integer index `1`, should be a string
We currently use `unicode_normalization` to handle the `String.prototype.normalize` method. However, the crate doesn't support UTF-16 as a first class string, so we had to do some hacks by converting the valid parts of a string to UTF-8, normalizing each one, encoding back to UTF-16 and concatenating everything with the unpaired surrogates within. All of this is obviously suboptimal for performance, which is why I leveraged the `icu_normalizer`, which does support UTF-16 input, to replace our current implementation.
Additionally, this allows users to override the default normalization data if the `intl` feature is enabled by providing the required data in the `BoaProvider` data provider.
This Pull Request changes the following:
- Creates a new `PromiseCapability` after every async function call instead of sharing the same capability for all calls of the same async function.
The new ICU4X release stabilized the `icu_segmenter` component, so this PR implements `Intl.Segmenter` using that as a base.
Also, I opted for importing `itertools` instead of copy-pasting the implementation of `TupleWindows` because its design is a lot more complex than `Intersperse`, which we copy-pasted previously. Though, I disabled all `std` features of `itertools` to make it a lot more lightweight, so it shouldn't make much difference in compilation times.
Depends on #2837.
This Pull Request changes the following:
- Fix the remaining `language/expressions/yield` tests.
- Align the sync generator execution more to the spec.
This breaks one async generator test. We can ignore that one as async generators are currently very broken. I will try to fix async generators next.
This Pull Request fixes some additional Annex B tests.
It changes the following:
- Fixes bugs related to parsing HTML closing comments (`-->`).
- Implements `RegExp::compile` behind the `annex-b` feature.
- Ignores the `legacy-regexp` feature flag, since it's still stage 3.
This PR upgrades ICU to 1.2.
Unfortunately we still have some breaking changes, so this is being handled in https://github.com/unicode-org/icu4x/issues/3332
Co-authored-by: jedel1043 <jedel0124@gmail.com>
Just some small improvements that increase the strictness of our generator state handling.
Also rollbacks the implementation of `GeneratorValidate` because I forgot to remove it after I did modifications to #2821, and it doesn't make sense to have that if it isn't used by async functions.
Bumps [num_enum](https://github.com/illicitonion/num_enum) from 0.6.0 to 0.6.1.
<details>
<summary>Commits</summary>
<ul>
<li><a href="66d22cc826"><code>66d22cc</code></a> Release 0.6.1 (<a href="https://redirect.github.com/illicitonion/num_enum/issues/118">#118</a>)</li>
<li><a href="190a93936d"><code>190a939</code></a> Have a test per type (<a href="https://redirect.github.com/illicitonion/num_enum/issues/117">#117</a>)</li>
<li><a href="f1ee727c65"><code>f1ee727</code></a> Fix is_naturally_exhaustive test for usize/isize. (<a href="https://redirect.github.com/illicitonion/num_enum/issues/116">#116</a>)</li>
<li>See full diff in <a href="https://github.com/illicitonion/num_enum/compare/0.6.0...0.6.1">compare view</a></li>
</ul>
</details>
<br />
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=num_enum&package-manager=cargo&previous-version=0.6.0&new-version=0.6.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
</details>
This Pull Request changes the following:
- Adds two new hooks to `HostHooks` to access the current UTC time and the current timezone offset.
- Replaces usages of `Local` with the host hook.
- Replaces usages of `Utc::now` and `Local::now` with the hooks.
cc @lastmjs
This fixes some more ES5 tests that were failing because the functions haven't been implemented.
It changes the following:
- Adds `String::to_locale_case`, which uses ICU4X to convert strings to uppercase or lowercase.
- Refactors `String::to_uppercase` and `String::to_lowercase` into a single `String::to_case` which uses a const generic to distinguish each case.
- Adds utility functions on `JsString` to avoid code repetition.