Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -60489,10 +60489,22 @@ static JSValue js_typed_array_slice(JSContext *ctx, JSValueConst this_val,
if (p1 != NULL && p->class_id == p1->class_id &&
typed_array_length(p1) >= count &&
typed_array_length(p) >= start + count) {
uint8_t *src, *dst;
int nbytes;
shift = typed_array_size_log2(p->class_id);
memmove(p1->u.array.u.uint8_ptr,
p->u.array.u.uint8_ptr + (start << shift),
count << shift);
src = p->u.array.u.uint8_ptr + (start << shift);
dst = p1->u.array.u.uint8_ptr;
nbytes = count << shift;
if (dst > src && dst < src + nbytes) {
/* per spec (step 14.g) the copy is performed byte by byte
in increasing order, observable when the species
constructor returns a view over the same buffer that
overlaps the source ahead of it */
for (n = 0; n < nbytes; n++)
dst[n] = src[n];
} else {
memmove(dst, src, nbytes);
}
} else {
slow_path:
space = max_int(0, p->u.array.count - start);
Expand Down
2 changes: 1 addition & 1 deletion test262
Submodule test262 updated 94 files
+1 −1 INTERPRETING.md
+6 −24 features.txt
+1 −0 harness/assert.js
+1 −1 harness/asyncHelpers.js
+0 −1 harness/compareArray.js
+36 −0 harness/testIntlNumberFormat.js
+4 −1 test/built-ins/AsyncIteratorPrototype/Symbol.asyncDispose/invokes-return.js
+0 −32 test/built-ins/Atomics/pause/non-integral-iterationnumber-throws.js
+0 −13 test/built-ins/Atomics/pause/returns-undefined.js
+3 −0 test/built-ins/Iterator/prototype/Symbol.dispose/invokes-return.js
+43 −0 test/built-ins/Promise/allKeyed/capability-resolve-throws-reject.js
+39 −0 test/built-ins/Promise/allKeyed/get-value-not-called-for-non-enumerable.js
+39 −0 test/built-ins/Promise/allKeyed/get-value-throws-reject.js
+57 −0 test/built-ins/Promise/allKeyed/invoke-resolve-custom.js
+53 −0 test/built-ins/Promise/allKeyed/invoke-resolve-get-once.js
+46 −0 test/built-ins/Promise/allKeyed/invoke-resolve-return.js
+32 −0 test/built-ins/Promise/allKeyed/invoke-then-not-callable-reject.js
+41 −0 test/built-ins/Promise/allKeyed/non-enumerable-properties-only.js
+46 −0 test/built-ins/Promise/allKeyed/reject-first.js
+61 −0 test/built-ins/Promise/allKeyed/resolve-element-function-properties.js
+50 −0 test/built-ins/Promise/allKeyed/resolve-from-same-thenable.js
+32 −0 test/built-ins/Promise/allKeyed/resolve-missing-reject-with-typeerror.js
+40 −0 test/built-ins/Promise/allKeyed/result-property-descriptors.js
+43 −0 test/built-ins/Promise/allSettledKeyed/capability-resolve-throws-reject.js
+75 −0 test/built-ins/Promise/allSettledKeyed/element-function-properties.js
+40 −0 test/built-ins/Promise/allSettledKeyed/get-value-not-called-for-non-enumerable.js
+39 −0 test/built-ins/Promise/allSettledKeyed/get-value-throws-reject.js
+59 −0 test/built-ins/Promise/allSettledKeyed/invoke-resolve-custom.js
+53 −0 test/built-ins/Promise/allSettledKeyed/invoke-resolve-get-once.js
+46 −0 test/built-ins/Promise/allSettledKeyed/invoke-resolve-return.js
+32 −0 test/built-ins/Promise/allSettledKeyed/invoke-then-not-callable-reject.js
+41 −0 test/built-ins/Promise/allSettledKeyed/non-enumerable-properties-only.js
+52 −0 test/built-ins/Promise/allSettledKeyed/reject-from-same-thenable.js
+52 −0 test/built-ins/Promise/allSettledKeyed/resolve-from-same-thenable.js
+32 −0 test/built-ins/Promise/allSettledKeyed/resolve-missing-reject-with-typeerror.js
+85 −0 test/built-ins/Promise/allSettledKeyed/result-property-descriptors.js
+1 −1 test/built-ins/TypedArray/prototype/slice/speciesctor-return-same-buffer-with-offset.js
+1 −1 test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/index-prop-desc.js
+1 −1 test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/index-prop-desc.js
+1 −1 test/built-ins/TypedArrayConstructors/internals/Set/BigInt/null-tobigint.js
+1 −1 test/built-ins/TypedArrayConstructors/internals/Set/BigInt/number-tobigint.js
+1 −1 test/built-ins/TypedArrayConstructors/internals/Set/BigInt/string-nan-tobigint.js
+1 −1 test/built-ins/TypedArrayConstructors/internals/Set/BigInt/symbol-tobigint.js
+1 −1 test/built-ins/TypedArrayConstructors/internals/Set/BigInt/tonumber-value-throws.js
+1 −1 test/built-ins/TypedArrayConstructors/internals/Set/BigInt/undefined-tobigint.js
+1 −1 test/built-ins/TypedArrayConstructors/internals/Set/bigint-tonumber.js
+1 −1 test/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-throws.js
+35 −13 test/intl402/Locale/constructor-apply-options-canonicalizes-twice.js
+7 −7 test/intl402/Locale/likely-subtags-grandfathered.js
+10 −7 test/intl402/Locale/prototype/calendar/canonicalize.js
+66 −0 test/intl402/Locale/prototype/getCalendars/likely-subtags-region.js
+68 −0 test/intl402/Locale/prototype/getCalendars/region-override.js
+86 −0 test/intl402/Locale/prototype/getCalendars/region-priority.js
+63 −0 test/intl402/Locale/prototype/getCalendars/subdivision-region.js
+40 −0 test/intl402/Locale/prototype/getCollations/collation-keyword.js
+28 −0 test/intl402/Locale/prototype/getCollations/output-array-sorted.js
+20 −16 test/intl402/Locale/prototype/getCollations/output-array-values.js
+12 −4 test/intl402/Locale/prototype/getCollations/output-array.js
+65 −0 test/intl402/Locale/prototype/getCollations/und-language.js
+68 −0 test/intl402/Locale/prototype/getHourCycles/language-priority.js
+75 −0 test/intl402/Locale/prototype/getHourCycles/likely-subtags-region.js
+67 −0 test/intl402/Locale/prototype/getHourCycles/region-override.js
+86 −0 test/intl402/Locale/prototype/getHourCycles/region-priority.js
+62 −0 test/intl402/Locale/prototype/getHourCycles/subdivision-region.js
+75 −0 test/intl402/Locale/prototype/getWeekInfo/likely-subtags-region.js
+79 −0 test/intl402/Locale/prototype/getWeekInfo/region-override.js
+97 −0 test/intl402/Locale/prototype/getWeekInfo/region-priority.js
+72 −0 test/intl402/Locale/prototype/getWeekInfo/subdivision-region.js
+25 −19 test/intl402/NumberFormat/prototype/format/unit-ja-JP.js
+25 −19 test/intl402/NumberFormat/prototype/format/unit-zh-TW.js
+36 −52 test/intl402/NumberFormat/prototype/formatToParts/unit-ja-JP.js
+36 −51 test/intl402/NumberFormat/prototype/formatToParts/unit-zh-TW.js
+6 −0 test/language/expressions/dynamic-import/import-fulfilled-member-of-errored-cycle-a_FIXTURE.js
+8 −0 test/language/expressions/dynamic-import/import-fulfilled-member-of-errored-cycle-b_FIXTURE.js
+6 −0 test/language/expressions/dynamic-import/import-fulfilled-member-of-errored-cycle-c_FIXTURE.js
+5 −0 test/language/expressions/dynamic-import/import-fulfilled-member-of-errored-cycle-main_FIXTURE.js
+6 −0 test/language/expressions/dynamic-import/import-fulfilled-member-of-errored-cycle-x_FIXTURE.js
+82 −0 test/language/expressions/dynamic-import/import-fulfilled-member-of-errored-cycle.js
+44 −0 test/language/import/import-defer/deferred-namespace-object/json-module.js
+4 −0 test/language/import/import-defer/deferred-namespace-object/json-module_FIXTURE.json
+14 −0 test/language/statements/await-using/initializer-Symbol.asyncDispose-disposed-at-end-of-imported-module.js
+22 −0 ...nguage/statements/await-using/initializer-Symbol.asyncDispose-disposed-at-end-of-imported-module_FIXTURE.js
+22 −0 test/language/statements/await-using/initializer-Symbol.asyncDispose-disposed-at-end-of-module.js
+14 −0 test/language/statements/await-using/initializer-Symbol.dispose-disposed-at-end-of-imported-module.js
+18 −0 test/language/statements/await-using/initializer-Symbol.dispose-disposed-at-end-of-imported-module_FIXTURE.js
+22 −0 test/language/statements/await-using/initializer-Symbol.dispose-disposed-at-end-of-module.js
+14 −0 test/language/statements/using/initializer-disposed-at-end-of-imported-module.js
+18 −0 test/language/statements/using/initializer-disposed-at-end-of-imported-module_FIXTURE.js
+22 −0 test/language/statements/using/initializer-disposed-at-end-of-module.js
+1 −1 tools/lint/lib/checks/includes.py
+5 −0 tools/lint/test/fixtures/harness/noDefines.js
+8 −0 tools/lint/test/fixtures/harness/noDefinesAllowUnused.js
+13 −0 tools/lint/test/fixtures/test/includes_no_defines.js
+12 −0 tools/lint/test/fixtures/test/includes_no_defines_allow_unused.js
5 changes: 3 additions & 2 deletions test262_errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/iterator-result-reje
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/iterator-result-rejected-promise-close.js:74: strict mode: TypeError: $DONE() not called
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-result-poisoned-wrapper.js:81: TypeError: $DONE() not called
test262/test/built-ins/AsyncFromSyncIteratorPrototype/throw/throw-result-poisoned-wrapper.js:81: strict mode: TypeError: $DONE() not called
test262/test/built-ins/TypedArray/prototype/slice/speciesctor-return-same-buffer-with-offset.js:24: Test262Error: Actual [20, 30, 40, 60] and expected [20, 20, 20, 60] should have the same contents. (Testing with Float64Array and makePassthrough.)
test262/test/built-ins/TypedArray/prototype/slice/speciesctor-return-same-buffer-with-offset.js:24: strict mode: Test262Error: Actual [20, 30, 40, 60] and expected [20, 20, 20, 60] should have the same contents. (Testing with Float64Array and makePassthrough.)
test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-canonical-invalid-index-prototype-chain-set.js:35: Test262Error: value should not be coerced Expected SameValue(«22», «0») to be true
test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-canonical-invalid-index-prototype-chain-set.js:35: strict mode: Test262Error: value should not be coerced Expected SameValue(«22», «0») to be true
test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-canonical-invalid-index-reflect-set.js:35: Test262Error: value should not be coerced Expected SameValue(«32», «0») to be true
Expand Down Expand Up @@ -54,10 +52,13 @@ test262/test/language/module-code/ambiguous-export-bindings/namespace-unambiguou
test262/test/language/module-code/ambiguous-export-bindings/namespace-unambiguous-if-import-star-as-and-export.js:74: SyntaxError: export 'foo' in module 'test262/test/language/module-code/ambiguous-export-bindings/nam' is ambiguous
test262/test/language/module-code/top-level-await/module-graphs-does-not-hang.js:10: TypeError: $DONE() not called
test262/test/language/module-code/top-level-await/rejection-order.js:20: TypeError: $DONE() not called
test262/test/language/statements/await-using/initializer-Symbol.asyncDispose-disposed-at-end-of-imported-module.js:11: SyntaxError: exported variable 'resource' does not exist
test262/test/language/statements/await-using/initializer-Symbol.dispose-disposed-at-end-of-imported-module.js:11: SyntaxError: exported variable 'resource' does not exist
test262/test/language/statements/class/elements/syntax/valid/grammar-field-named-get-followed-by-generator-asi.js:40: SyntaxError: invalid property name
test262/test/language/statements/class/elements/syntax/valid/grammar-field-named-get-followed-by-generator-asi.js:40: strict mode: SyntaxError: invalid property name
test262/test/language/statements/class/elements/syntax/valid/grammar-field-named-set-followed-by-generator-asi.js:40: SyntaxError: invalid property name
test262/test/language/statements/class/elements/syntax/valid/grammar-field-named-set-followed-by-generator-asi.js:40: strict mode: SyntaxError: invalid property name
test262/test/language/statements/using/initializer-disposed-at-end-of-imported-module.js:11: SyntaxError: exported variable 'resource' does not exist
test262/test/language/statements/with/get-binding-value-call-with-proxy-env.js:39: Test262Error: Actual [has:Object, get:Symbol(Symbol.unscopables), get:Object] and expected [has:Object, get:Symbol(Symbol.unscopables), has:Object, get:Object] should have the same contents.
test262/test/language/statements/with/get-binding-value-idref-with-proxy-env.js:39: Test262Error: Actual [has:Object, get:Symbol(Symbol.unscopables), get:Object] and expected [has:Object, get:Symbol(Symbol.unscopables), has:Object, get:Object] should have the same contents.
test262/test/language/statements/with/get-mutable-binding-binding-deleted-in-get-unscopables-strict-mode.js:21: Test262Error: Expected a ReferenceError to be thrown but no exception was thrown at all
Expand Down
7 changes: 5 additions & 2 deletions tests/test_builtin.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,11 @@ function test_typed_array()
};
b = a.slice();
assert(a.buffer, b.buffer);
assert(a.toString(), "0,0,0,255");
assert(b.toString(), "0,0,255,255");
// the copy is byte by byte in increasing order, so bytes already
// copied are read back as source values when the target overlaps
// the source ahead of it
assert(a.toString(), "0,0,0,0");
assert(b.toString(), "0,0,0,0");

const TypedArray = class extends Object.getPrototypeOf(Uint8Array) {};
let caught = false;
Expand Down
48 changes: 48 additions & 0 deletions tests/typedarray-slice-overlap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { assert } from "./assert.js";

/* %TypedArray%.prototype.slice copies byte by byte in increasing order
(step 14.g). This is observable when the species constructor returns a
view over the same buffer that overlaps the source ahead of it: already
copied elements are read back as source values. */

function check(TA) {
const ta = new TA([10, 20, 30, 40, 50, 60]);
ta.constructor = {
[Symbol.species]: function() {
return new TA(ta.buffer, 2 * TA.BYTES_PER_ELEMENT);
}
};
const result = ta.slice(1, 4);
assert(result.length, 4);
assert(result[0], 20);
assert(result[1], 20);
assert(result[2], 20);
assert(result[3], 60);
}

check(Float64Array);
check(Int32Array);
check(Uint8Array);

/* target view behind the source: plain move semantics are unaffected */
{
const ta = new Int32Array([10, 20, 30, 40, 50, 60]);
ta.constructor = {
[Symbol.species]: function() {
return new Int32Array(ta.buffer, 0);
}
};
const result = ta.slice(2, 5);
assert(result[0], 30);
assert(result[1], 40);
assert(result[2], 50);
}

/* distinct buffers keep working */
{
const ta = new Int32Array([1, 2, 3, 4]);
const result = ta.slice(1, 3);
assert(result.length, 2);
assert(result[0], 2);
assert(result[1], 3);
}
Loading