Skip to content

Commit f023b77

Browse files
author
Atul Katti
committed
[MERGE #5435 @atulkatti] MSFT:15450950 Remove special code to marshal TypedArray's ArrayBuffer. The default behavior does the right thing.
Merge pull request #5435 from atulkatti:Bug15450950.ArrayBufferMarshalling.1
2 parents 288d7fe + 0390398 commit f023b77

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

lib/Runtime/Library/TypedArray.h

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -221,26 +221,7 @@ namespace Js
221221
{
222222
protected:
223223
DEFINE_VTABLE_CTOR(TypedArray, TypedArrayBase);
224-
virtual void MarshalToScriptContext(Js::ScriptContext * scriptContext)
225-
{
226-
Assert(this->GetScriptContext() != scriptContext);
227-
AssertMsg(VirtualTableInfo<TypedArray>::HasVirtualTable(this), "Derived class need to define marshal to script context");
228-
229-
VirtualTableInfo<Js::CrossSiteObject<TypedArray<TypeName, clamped, virtualAllocated>>>::SetVirtualTable(this);
230-
ArrayBufferBase* arrayBuffer = this->GetArrayBuffer();
231-
if (arrayBuffer && !arrayBuffer->IsCrossSiteObject())
232-
{
233-
arrayBuffer->MarshalToScriptContext(scriptContext);
234-
}
235-
}
236-
237-
#if ENABLE_TTD
238-
virtual void MarshalCrossSite_TTDInflate()
239-
{
240-
AssertMsg(VirtualTableInfo<TypedArray>::HasVirtualTable(this), "Derived class need to define marshal");
241-
VirtualTableInfo<Js::CrossSiteObject<TypedArray<TypeName, clamped, virtualAllocated>>>::SetVirtualTable(this);
242-
}
243-
#endif
224+
DEFINE_MARSHAL_OBJECT_TO_SCRIPT_CONTEXT(TypedArray);
244225

245226
TypedArray(DynamicType *type): TypedArrayBase(nullptr, 0, 0, sizeof(TypeName), type) { buffer = nullptr; }
246227

test/typedarray/CrossSiteVirtual.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,34 @@
33
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
44
//-------------------------------------------------------------------------------------------------------
55

6-
function foo( type )
6+
function foo(type)
77
{
8-
var g = WScript.LoadScript("a = new " + type + "(16777216);", "samethread");
8+
var arrBuffer = new ArrayBuffer(16);
9+
var arr = new this[type](arrBuffer);
10+
var g = WScript.LoadScript("a = new " + type + "(16777216);" + `
11+
function arrayBufferTest1(arr2) {
12+
var buf = arr2.buffer;
13+
var name = buf.constructor.name;
14+
}` + `
15+
function arrayBufferTest2(type, arrBuffer2) {
16+
var arr2 = new this[type](arrBuffer2);
17+
var buf = arr2.buffer;
18+
var name = buf.constructor.name;
19+
}` + `
20+
function arrayBufferTest3(type, arr3) {
21+
var arrBuffer3 = new ArrayBuffer(16);
22+
arr3 = new this[type](arrBuffer3);
23+
var buf = arr3.buffer;
24+
var name = buf.constructor.name;
25+
}`, "samethread");
926
g.a[0] = 0;
1027
g.a[0];
28+
29+
// Test to make sure the TypedArray's underlying ArrayBuffer gets marshalled correctly along with it's prototype chain.
30+
g.arrayBufferTest1(arr);
31+
g.arrayBufferTest2(type, arrBuffer);
32+
var arr3;
33+
g.arrayBufferTest3(type, arr3);
1134
}
1235

1336
foo("Int8Array");

0 commit comments

Comments
 (0)