Skip to content
This repository was archived by the owner on Jun 22, 2023. It is now read-only.

Conversation

@rwaldron
Copy link
Contributor

This consolidates two fixes into one PR, but keeps them separate by commit


// Range checking for the index.

ia[index];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is replaced by ValidateAtomicAccess(...)

if (typeof ia != "object" || !(ia instanceof Int32Array) || !(ia.buffer instanceof SharedArrayBuffer))
throw new TypeError("Expected shared memory");
if (typeof ia != "object" ||
(!(ia instanceof Int32Array) && !(ia instanceof BigInt64Array)) ||
Copy link

Choose a reason for hiding this comment

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

The ia instanceof TypedArray line should use:

TypedArrayProto_getToStringTag(ia) !== undefined

Which is defined using:

var TypedArrayProto_getToStringTag = Function.prototype.call.bind(
	Object.getOwnPropertyDescriptor(
		Object.getPrototypeOf(Uint8Array.prototype),
		Symbol.toStringTag,
	).get,
);

Refs: https://tc39.es/ecma262/#sec-get-%typedarray%.prototype-@@tostringtag

throw new TypeError("Expected shared memory");
if (typeof ia != "object" ||
(!(ia instanceof Int32Array) && !(ia instanceof BigInt64Array)) ||
!(ia.buffer instanceof SharedArrayBuffer)) {
Copy link

Choose a reason for hiding this comment

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

And the ia.buffer instanceof SharedArrayBuffer line should instead use:

IsSharedArrayBuffer(ia.buffer)

Which is defined using:

var SharedArrayBufferProto_getByteLength = Function.prototype.call.bind(
	Object.getOwnPropertyDescriptor(
		SharedArrayBuffer.prototype,
		"byteLength",
	).get,
);

function IsSharedArrayBuffer(obj) {
	try {
		SharedArrayBufferProto_getByteLength(obj);
		return true;
	} catch (e) {
		return false;
	}
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants