Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Remove toInteger and document the string builtin #1884

Closed
wants to merge 2 commits into from

Conversation

jedel1043
Copy link
Member

The ECMAScript 2022 specification removes the toInteger method, and replaces it with toIntegerOrInfinity, which is arguably better for us since the JsValue::toInteger returns an f64, which is pretty confusing at times.

This pull request removes the JsValue::to_integer method, replaces all its calls by JsValue::to_integer_or_infinity or others per the spec and documents several methods from the string builtin.

@jedel1043 jedel1043 added builtins PRs and Issues related to builtins/intrinsics Internal Category for changelog labels Mar 2, 2022
@jedel1043 jedel1043 added this to the v0.14.0 milestone Mar 2, 2022
@github-actions
Copy link

github-actions bot commented Mar 2, 2022

Test262 conformance changes

VM implementation

Test result main count PR count difference
Total 88,342 88,342 0
Passed 43,131 43,167 +36
Ignored 21,413 21,413 0
Failed 23,798 23,762 -36
Panics 0 0 0
Conformance 48.82% 48.86% +0.04%
Fixed tests (36):
test/built-ins/DataView/prototype/setUint16/set-values-return-undefined.js [strict mode] (previously Failed)
test/built-ins/DataView/prototype/setUint16/set-values-return-undefined.js (previously Failed)
test/built-ins/DataView/prototype/setUint8/set-values-return-undefined.js [strict mode] (previously Failed)
test/built-ins/DataView/prototype/setUint8/set-values-return-undefined.js (previously Failed)
test/built-ins/DataView/prototype/setInt8/set-values-return-undefined.js [strict mode] (previously Failed)
test/built-ins/DataView/prototype/setInt8/set-values-return-undefined.js (previously Failed)
test/built-ins/DataView/prototype/setInt16/set-values-return-undefined.js [strict mode] (previously Failed)
test/built-ins/DataView/prototype/setInt16/set-values-return-undefined.js (previously Failed)
test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js [strict mode] (previously Failed)
test/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js (previously Failed)
test/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js [strict mode] (previously Failed)
test/built-ins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js (previously Failed)
test/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js [strict mode] (previously Failed)
test/built-ins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js (previously Failed)
test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations.js [strict mode] (previously Failed)
test/built-ins/TypedArray/prototype/fill/fill-values-conversion-operations.js (previously Failed)
test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation.js [strict mode] (previously Failed)
test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/conversion-operation.js (previously Failed)
test/built-ins/TypedArrayConstructors/internals/Set/conversion-operation.js [strict mode] (previously Failed)
test/built-ins/TypedArrayConstructors/internals/Set/conversion-operation.js (previously Failed)
test/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation.js [strict mode] (previously Failed)
test/built-ins/TypedArrayConstructors/ctors/object-arg/conversion-operation.js (previously Failed)
test/built-ins/String/prototype/replaceAll/searchValue-flags-null-undefined-throws.js [strict mode] (previously Failed)
test/built-ins/String/prototype/replaceAll/searchValue-flags-null-undefined-throws.js (previously Failed)
test/built-ins/String/prototype/replaceAll/searchValue-get-flags-abrupt.js [strict mode] (previously Failed)
test/built-ins/String/prototype/replaceAll/searchValue-get-flags-abrupt.js (previously Failed)
test/built-ins/String/prototype/replaceAll/searchValue-flags-toString-abrupt.js [strict mode] (previously Failed)
test/built-ins/String/prototype/replaceAll/searchValue-flags-toString-abrupt.js (previously Failed)
test/built-ins/String/prototype/replaceAll/searchValue-isRegExp-abrupt.js [strict mode] (previously Failed)
test/built-ins/String/prototype/replaceAll/searchValue-isRegExp-abrupt.js (previously Failed)
test/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-regexp-test.js [strict mode] (previously Failed)
test/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-regexp-test.js (previously Failed)
test/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring-regexp-test.js [strict mode] (previously Failed)
test/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring-regexp-test.js (previously Failed)
test/built-ins/String/prototype/includes/return-abrupt-from-searchstring-regexp-test.js [strict mode] (previously Failed)
test/built-ins/String/prototype/includes/return-abrupt-from-searchstring-regexp-test.js (previously Failed)

@github-actions
Copy link

github-actions bot commented Mar 2, 2022

Benchmark for 56d66c4

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 601.3±4.32ns 612.4±1.82ns +1.85%
Arithmetic operations (Execution) 2.4±0.03µs 2.4±0.01µs 0.00%
Arithmetic operations (Parser) 5.7±0.03µs 5.7±0.01µs 0.00%
Array access (Compiler) 1490.5±14.14ns 1490.4±4.04ns -0.01%
Array access (Execution) 11.5±0.10µs 11.6±0.06µs +0.87%
Array access (Parser) 12.7±0.03µs 12.7±0.03µs 0.00%
Array creation (Compiler) 2.1±0.02µs 2.1±0.01µs 0.00%
Array creation (Execution) 3.9±0.03ms 3.7±0.02ms -5.13%
Array creation (Parser) 14.4±0.03µs 14.3±0.03µs -0.69%
Array pop (Compiler) 4.7±0.04µs 4.6±0.02µs -2.13%
Array pop (Execution) 1680.8±12.68µs 1600.4±14.17µs -4.78%
Array pop (Parser) 148.9±0.19µs 148.9±0.70µs 0.00%
Boolean Object Access (Compiler) 1158.2±4.48ns 1163.1±9.62ns +0.42%
Boolean Object Access (Execution) 6.9±0.05µs 7.0±0.06µs +1.45%
Boolean Object Access (Parser) 15.6±0.16µs 15.5±0.19µs -0.64%
Clean js (Compiler) 3.9±0.01µs 3.9±0.01µs 0.00%
Clean js (Execution) 1325.3±10.08µs 1300.9±13.78µs -1.84%
Clean js (Parser) 31.0±0.19µs 30.7±0.05µs -0.97%
Create Realm 316.5±0.32ns 325.1±1.78ns +2.72%
Dynamic Object Property Access (Compiler) 1909.3±5.82ns 1884.7±7.44ns -1.29%
Dynamic Object Property Access (Execution) 8.0±0.04µs 8.1±0.10µs +1.25%
Dynamic Object Property Access (Parser) 11.1±0.06µs 11.2±0.02µs +0.90%
Fibonacci (Compiler) 2.6±0.02µs 2.7±0.01µs +3.85%
Fibonacci (Execution) 2.1±0.01ms 2.1±0.01ms 0.00%
Fibonacci (Parser) 17.4±0.13µs 17.4±0.04µs 0.00%
For loop (Compiler) 2.3±0.01µs 2.3±0.01µs 0.00%
For loop (Execution) 48.9±0.84µs 51.3±0.11µs +4.91%
For loop (Parser) 14.9±0.08µs 15.0±0.08µs +0.67%
Mini js (Compiler) 3.7±0.05µs 3.8±0.02µs +2.70%
Mini js (Execution) 1209.3±12.13µs 1195.0±7.70µs -1.18%
Mini js (Parser) 27.0±0.05µs 26.8±0.04µs -0.74%
Number Object Access (Compiler) 1101.4±13.56ns 1108.0±8.52ns +0.60%
Number Object Access (Execution) 5.3±0.08µs 5.5±0.05µs +3.77%
Number Object Access (Parser) 11.8±0.12µs 11.8±0.01µs 0.00%
Object Creation (Compiler) 1643.6±11.70ns 1663.3±9.75ns +1.20%
Object Creation (Execution) 7.2±0.07µs 7.2±0.07µs 0.00%
Object Creation (Parser) 9.8±0.04µs 9.9±0.06µs +1.02%
RegExp (Compiler) 1927.3±14.78ns 1935.1±4.46ns +0.40%
RegExp (Execution) 14.6±0.17µs 14.2±0.04µs -2.74%
RegExp (Parser) 10.8±0.04µs 10.7±0.02µs -0.93%
RegExp Creation (Compiler) 1666.0±7.39ns 1660.0±8.68ns -0.36%
RegExp Creation (Execution) 11.2±0.07µs 10.6±0.04µs -5.36%
RegExp Creation (Parser) 9.0±0.02µs 8.9±0.01µs -1.11%
RegExp Literal (Compiler) 1936.4±10.91ns 1950.6±5.04ns +0.73%
RegExp Literal (Execution) 14.7±0.07µs 14.3±0.05µs -2.72%
RegExp Literal (Parser) 8.7±0.02µs 8.6±0.03µs -1.15%
RegExp Literal Creation (Compiler) 1670.3±8.90ns 1655.7±8.92ns -0.87%
RegExp Literal Creation (Execution) 11.2±0.12µs 10.6±0.08µs -5.36%
RegExp Literal Creation (Parser) 6.9±0.04µs 6.8±0.02µs -1.45%
Static Object Property Access (Compiler) 1662.6±10.15ns 1672.2±14.82ns +0.58%
Static Object Property Access (Execution) 7.5±0.05µs 7.5±0.10µs 0.00%
Static Object Property Access (Parser) 10.4±0.07µs 10.6±0.03µs +1.92%
String Object Access (Compiler) 1615.0±7.55ns 1610.9±12.50ns -0.25%
String Object Access (Execution) 9.2±0.09µs 9.3±0.06µs +1.09%
String Object Access (Parser) 15.4±0.09µs 15.1±0.01µs -1.95%
String comparison (Compiler) 2.5±0.01µs 2.5±0.01µs 0.00%
String comparison (Execution) 6.9±0.09µs 7.0±0.05µs +1.45%
String comparison (Parser) 11.8±0.03µs 11.8±0.02µs 0.00%
String concatenation (Compiler) 1932.8±12.59ns 1942.2±6.42ns +0.49%
String concatenation (Execution) 6.3±0.05µs 6.3±0.04µs 0.00%
String concatenation (Parser) 8.0±0.02µs 8.0±0.02µs 0.00%
String copy (Compiler) 1552.0±8.07ns 1551.0±3.38ns -0.06%
String copy (Execution) 5.6±0.07µs 5.7±0.13µs +1.79%
String copy (Parser) 5.9±0.02µs 5.9±0.01µs 0.00%
Symbols (Compiler) 1068.5±7.42ns 1078.6±6.18ns +0.95%
Symbols (Execution) 5.3±0.02µs 5.4±0.02µs +1.89%
Symbols (Parser) 4.5±0.04µs 4.5±0.02µs 0.00%

@codecov
Copy link

codecov bot commented Mar 2, 2022

Codecov Report

Merging #1884 (38dddd7) into main (7248ed1) will decrease coverage by 0.15%.
The diff coverage is 57.69%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1884      +/-   ##
==========================================
- Coverage   46.75%   46.60%   -0.16%     
==========================================
  Files         204      205       +1     
  Lines       16755    16729      -26     
==========================================
- Hits         7834     7796      -38     
- Misses       8921     8933      +12     
Impacted Files Coverage Δ
boa_engine/src/value/integer.rs 29.41% <29.41%> (ø)
boa_engine/src/builtins/number/mod.rs 75.95% <33.33%> (-1.83%) ⬇️
boa_engine/src/symbol.rs 31.81% <50.00%> (-1.00%) ⬇️
boa_engine/src/builtins/string/mod.rs 63.09% <60.65%> (-1.86%) ⬇️
boa_engine/src/value/mod.rs 52.17% <73.68%> (+1.64%) ⬆️
boa_engine/src/builtins/console/mod.rs 25.83% <75.00%> (-1.44%) ⬇️
boa_engine/src/builtins/regexp/mod.rs 67.71% <100.00%> (ø)
boa_engine/src/builtins/string/string_iterator.rs 88.88% <100.00%> (ø)
boa_engine/src/builtins/symbol/mod.rs 59.15% <100.00%> (ø)
boa_engine/src/syntax/ast/node/await_expr/mod.rs 40.00% <0.00%> (-20.00%) ⬇️
... and 20 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7248ed1...38dddd7. Read the comment docs.

@jedel1043 jedel1043 requested review from HalidOdat, Razican and raskad and removed request for HalidOdat and Razican March 2, 2022 07:08
@github-actions
Copy link

github-actions bot commented Mar 2, 2022

Benchmark for 05a8eb6

Click to view benchmark
Test Base PR %
Arithmetic operations (Compiler) 599.6±1.73ns 615.7±4.14ns +2.69%
Arithmetic operations (Execution) 2.5±0.12µs 2.4±0.00µs -4.00%
Arithmetic operations (Parser) 5.7±0.02µs 5.7±0.01µs 0.00%
Array access (Compiler) 1527.4±8.41ns 1520.3±4.24ns -0.46%
Array access (Execution) 11.6±0.02µs 11.5±0.02µs -0.86%
Array access (Parser) 13.9±0.95µs 12.7±0.04µs -8.63%
Array creation (Compiler) 2.4±0.16µs 2.1±0.01µs -12.50%
Array creation (Execution) 4.2±0.26ms 3.7±0.02ms -11.90%
Array creation (Parser) 14.3±0.05µs 15.7±0.86µs +9.79%
Array pop (Compiler) 4.7±0.02µs 4.6±0.02µs -2.13%
Array pop (Execution) 1842.2±129.82µs 1610.6±4.35µs -12.57%
Array pop (Parser) 164.6±8.63µs 149.1±0.17µs -9.42%
Boolean Object Access (Compiler) 1269.5±82.16ns 1178.4±2.44ns -7.18%
Boolean Object Access (Execution) 7.4±0.56µs 7.9±0.55µs +6.76%
Boolean Object Access (Parser) 15.8±0.02µs 15.5±0.02µs -1.90%
Clean js (Compiler) 4.3±0.28µs 3.9±0.01µs -9.30%
Clean js (Execution) 1435.8±84.37µs 1303.5±9.45µs -9.21%
Clean js (Parser) 31.0±0.06µs 31.0±0.07µs 0.00%
Create Realm 319.9±0.90ns 341.6±18.18ns +6.78%
Dynamic Object Property Access (Compiler) 1905.0±4.36ns 1910.2±6.16ns +0.27%
Dynamic Object Property Access (Execution) 8.1±0.04µs 8.0±0.02µs -1.23%
Dynamic Object Property Access (Parser) 11.2±0.07µs 11.2±0.02µs 0.00%
Fibonacci (Compiler) 2.9±0.20µs 3.0±0.22µs +3.45%
Fibonacci (Execution) 2.3±0.15ms 2.1±0.00ms -8.70%
Fibonacci (Parser) 17.5±0.06µs 17.4±0.05µs -0.57%
For loop (Compiler) 2.3±0.01µs 2.6±0.30µs +13.04%
For loop (Execution) 50.2±0.12µs 51.0±0.13µs +1.59%
For loop (Parser) 14.9±0.04µs 15.0±0.07µs +0.67%
Mini js (Compiler) 4.2±0.32µs 4.1±0.26µs -2.38%
Mini js (Execution) 1205.1±7.50µs 1293.2±70.13µs +7.31%
Mini js (Parser) 26.9±0.02µs 27.0±0.04µs +0.37%
Number Object Access (Compiler) 1093.2±5.14ns 1161.2±88.30ns +6.22%
Number Object Access (Execution) 5.3±0.03µs 5.4±0.05µs +1.89%
Number Object Access (Parser) 12.0±0.03µs 12.5±1.06µs +4.17%
Object Creation (Compiler) 1810.9±105.89ns 1881.5±153.34ns +3.90%
Object Creation (Execution) 8.1±0.60µs 7.1±0.02µs -12.35%
Object Creation (Parser) 10.6±0.63µs 9.8±0.02µs -7.55%
RegExp (Compiler) 2.1±0.15µs 1918.5±11.58ns -8.64%
RegExp (Execution) 17.1±1.47µs 14.1±0.05µs -17.54%
RegExp (Parser) 10.8±0.03µs 11.9±0.73µs +10.19%
RegExp Creation (Compiler) 1635.3±9.62ns 1683.2±8.28ns +2.93%
RegExp Creation (Execution) 11.2±0.04µs 10.6±0.05µs -5.36%
RegExp Creation (Parser) 10.0±0.79µs 9.0±0.02µs -10.00%
RegExp Literal (Compiler) 1905.1±5.20ns 1933.7±5.77ns +1.50%
RegExp Literal (Execution) 16.5±2.12µs 14.2±0.03µs -13.94%
RegExp Literal (Parser) 9.5±0.65µs 8.6±0.02µs -9.47%
RegExp Literal Creation (Compiler) 1657.0±9.39ns 1801.7±132.95ns +8.73%
RegExp Literal Creation (Execution) 12.6±1.08µs 10.7±0.05µs -15.08%
RegExp Literal Creation (Parser) 7.4±0.61µs 6.8±0.03µs -8.11%
Static Object Property Access (Compiler) 1677.3±5.06ns 1873.8±105.94ns +11.72%
Static Object Property Access (Execution) 8.3±0.59µs 7.5±0.03µs -9.64%
Static Object Property Access (Parser) 10.6±0.03µs 11.7±0.98µs +10.38%
String Object Access (Compiler) 1597.8±8.47ns 1613.9±7.42ns +1.01%
String Object Access (Execution) 9.7±0.55µs 9.2±0.05µs -5.15%
String Object Access (Parser) 15.5±0.02µs 15.4±0.03µs -0.65%
String comparison (Compiler) 2.5±0.01µs 2.5±0.01µs 0.00%
String comparison (Execution) 7.0±0.03µs 6.9±0.04µs -1.43%
String comparison (Parser) 11.8±0.06µs 11.9±0.02µs +0.85%
String concatenation (Compiler) 1924.4±4.18ns 1950.5±11.84ns +1.36%
String concatenation (Execution) 7.1±0.52µs 6.3±0.02µs -11.27%
String concatenation (Parser) 8.8±0.47µs 8.1±0.02µs -7.95%
String copy (Compiler) 1536.5±4.85ns 1710.0±119.43ns +11.29%
String copy (Execution) 5.7±0.02µs 5.6±0.04µs -1.75%
String copy (Parser) 6.0±0.05µs 6.0±0.02µs 0.00%
Symbols (Compiler) 1068.4±2.79ns 1081.6±4.40ns +1.24%
Symbols (Execution) 5.3±0.03µs 5.3±0.02µs 0.00%
Symbols (Parser) 4.9±0.22µs 5.0±0.77µs +2.04%

Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

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

Looks good to me :)

@raskad
Copy link
Member

raskad commented Mar 2, 2022

bors r+

bors bot pushed a commit that referenced this pull request Mar 2, 2022
The ECMAScript 2022 specification removes the `toInteger` method, and replaces it with `toIntegerOrInfinity`, which is arguably better for us since the `JsValue::toInteger` returns an `f64`, which is pretty confusing at times.

This pull request removes the `JsValue::to_integer` method, replaces all its calls by `JsValue::to_integer_or_infinity` or others per the spec and documents several methods from the `string` builtin.
@bors
Copy link

bors bot commented Mar 2, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Remove toInteger and document the string builtin [Merged by Bors] - Remove toInteger and document the string builtin Mar 2, 2022
@bors bors bot closed this Mar 2, 2022
@bors bors bot deleted the no-tointeger branch March 2, 2022 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builtins PRs and Issues related to builtins/intrinsics Internal Category for changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants