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

Backport typed array related fixes #1913

Merged
merged 1 commit into from
Jul 13, 2024
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
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="SharpZipLib" Version="1.4.0" />
<PackageVersion Include="Spectre.Console.Cli" Version="0.45.0" />
<PackageVersion Include="System.Text.Json" Version="8.0.3" />
<PackageVersion Include="System.Text.Json" Version="8.0.4" />
<PackageVersion Include="Test262Harness" Version="1.0.0" />
<PackageVersion Include="xunit" Version="2.7.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.7" PrivateAssets="all" />
Expand Down
8 changes: 6 additions & 2 deletions Jint.Tests.Test262/Test262Harness.settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"SuiteGitSha": "c3a326ace810e7c80a4e1b8df8c8b704ed223c28",
"SuiteGitSha": "694fae5b10fa760951dbc9c2fe22a2fa38383c66",
//"SuiteDirectory": "//mnt/c/work/test262",
"TargetPath": "./Generated",
"Namespace": "Jint.Tests.Test262",
Expand All @@ -8,18 +8,22 @@
"Array.fromAsync",
"async-iteration",
"Atomics",
"Atomics.pause",
"Float16Array",
"import-assertions",
"iterator-helpers",
"Math.sumPrecise",
"promise-try",
"regexp-duplicate-named-groups",
"regexp-lookbehind",
"regexp-modifiers",
"regexp-unicode-property-escapes",
"regexp-v-flag",
"source-phase-imports",
"tail-call-optimization",
"Temporal",
"u180e"
"u180e",
"uint8array-base64"
],
"ExcludedFlags": [
],
Expand Down
2 changes: 1 addition & 1 deletion Jint/Native/Array/ArrayOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public override void EnsureCapacity(ulong capacity)

public override bool TryGetValue(ulong index, out JsValue value)
{
if (index < _target.GetLength())
if (_target.IsValidIntegerIndex(index))
{
value = _target[(int) index];
return true;
Expand Down
6 changes: 5 additions & 1 deletion Jint/Native/JsTypedArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ public JsValue this[uint index]

public uint Length => GetLength();

internal override uint GetLength() => IntrinsicTypedArrayPrototype.MakeTypedArrayWithBufferWitnessRecord(this, ArrayBufferOrder.Unordered).TypedArrayLength;
internal override uint GetLength()
{
var record = IntrinsicTypedArrayPrototype.MakeTypedArrayWithBufferWitnessRecord(this, ArrayBufferOrder.Unordered);
return record.IsTypedArrayOutOfBounds ? 0 : record.TypedArrayLength;
}

internal override bool IsArrayLike => true;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Jint.Native;
using Jint.Native.Function;
using Jint.Native.Object;

namespace Jint.Runtime.Interpreter.Expressions;

Expand All @@ -18,8 +19,12 @@ protected override object EvaluateInternal(EvaluationContext context)
var env = engine.ExecutionContext.LexicalEnvironment;
var privateEnv = engine.ExecutionContext.PrivateEnvironment;

ObjectInstance prototype = _function.Function.Async
? engine.Realm.Intrinsics.AsyncFunction.PrototypeObject
: engine.Realm.Intrinsics.Function.PrototypeObject;

var closure = engine.Realm.Intrinsics.Function.OrdinaryFunctionCreate(
engine.Realm.Intrinsics.Function.PrototypeObject,
prototype,
_function,
FunctionThisMode.Lexical,
env,
Expand Down