Bladeren bron

Replaced ArrayBuffer.transfer with ArrayBuffer.detach in test builds.

Michael Ferris 8 jaren geleden
bovenliggende
commit
3ad6f7270b

+ 0 - 12
lib/Common/ConfigFlagsList.h

@@ -587,12 +587,6 @@ PHASE(All)
     #define DEFAULT_CONFIG_ES6RegExSymbols         (false)
 #endif
 #define DEFAULT_CONFIG_ES6HasInstance          (true)
-#ifdef COMPILE_DISABLE_ArrayBufferTransfer
-    // If ArrayBufferTransfer needs to be disabled by compile flag, DEFAULT_CONFIG_ArrayBufferTransfer should be false
-    #define DEFAULT_CONFIG_ArrayBufferTransfer     (false)
-#else
-    #define DEFAULT_CONFIG_ArrayBufferTransfer     (false)
-#endif
 #define DEFAULT_CONFIG_ES7AsyncAwait           (true)
 #define DEFAULT_CONFIG_ES7ExponentionOperator  (true)
 #define DEFAULT_CONFIG_ES7TrailingComma        (true)
@@ -1061,12 +1055,6 @@ FLAGPR_REGOVR_EXP(Boolean, ES6, ES6RegExSymbols        , "Enable ES6 RegExp symb
 
 FLAGPR           (Boolean, ES6, ES6HasInstance         , "Enable ES6 @@hasInstance symbol"                          , DEFAULT_CONFIG_ES6HasInstance)
 FLAGPR           (Boolean, ES6, ES6Verbose             , "Enable ES6 verbose trace"                                 , DEFAULT_CONFIG_ES6Verbose)
-
-#ifndef COMPILE_DISABLE_ArrayBufferTransfer
-    #define COMPILE_DISABLE_ArrayBufferTransfer 0
-#endif
-FLAGPR_REGOVR_EXP(Boolean, ES6, ArrayBufferTransfer    , "Enable ArrayBuffer.transfer"                              , DEFAULT_CONFIG_ArrayBufferTransfer)
-
 FLAGPR           (Boolean, ES6, ESObjectGetOwnPropertyDescriptors, "Enable Object.getOwnPropertyDescriptors"        , DEFAULT_CONFIG_ESObjectGetOwnPropertyDescriptors)
 
 #ifndef COMPILE_DISABLE_ESSharedArrayBuffer

+ 1 - 1
lib/Runtime/Base/JnDirectFields.h

@@ -186,6 +186,7 @@ ENTRY2(delete_, _u("delete")) // "delete" cannot be an identifier in C++ so usin
 ENTRY2(star_, _u("*"))
 ENTRY(deleteProperty)
 ENTRY(description)
+ENTRY(detach)
 ENTRY(done)
 ENTRY(E)
 ENTRY(encodeURI)
@@ -448,7 +449,6 @@ ENTRY(toStringTag)
 ENTRY(toTimeString)
 ENTRY(toUpperCase)
 ENTRY(toUTCString)
-ENTRY(transfer)
 ENTRY(trim)
 ENTRY(trimLeft)
 ENTRY(trimRight)

+ 0 - 1
lib/Runtime/Base/ThreadConfigFlagsList.h

@@ -44,7 +44,6 @@ FLAG_RELEASE(IsES6RegExSymbolsEnabled, ES6RegExSymbols)
 FLAG_RELEASE(IsES6HasInstanceEnabled, ES6HasInstance)
 FLAG_RELEASE(SkipSplitOnNoResult, SkipSplitOnNoResult)
 FLAG_RELEASE(IsES7AsyncAndAwaitEnabled, ES7AsyncAwait)
-FLAG_RELEASE(IsArrayBufferTransferEnabled, ArrayBufferTransfer)
 FLAG_RELEASE(IsESObjectGetOwnPropertyDescriptorsEnabled, ESObjectGetOwnPropertyDescriptors)
 FLAG_RELEASE(IsESSharedArrayBufferEnabled, ESSharedArrayBuffer)
 #ifdef ENABLE_PROJECTION

+ 9 - 189
lib/Runtime/Library/ArrayBuffer.cpp

@@ -407,8 +407,8 @@ namespace Js
         return library->GetFalse();
     }
 
-    // ArrayBuffer.transfer as described in Luke Wagner's proposal: https://gist.github.com/lukewagner/2735af7eea411e18cf20
-    Var ArrayBuffer::EntryTransfer(RecyclableObject* function, CallInfo callInfo, ...)
+#if ENABLE_DEBUG_CONFIG_OPTIONS
+    Var ArrayBuffer::EntryDetach(RecyclableObject* function, CallInfo callInfo, ...)
     {
         ScriptContext* scriptContext = function->GetScriptContext();
 
@@ -416,9 +416,9 @@ namespace Js
 
         ARGUMENTS(args, callInfo);
 
-        Assert(!(callInfo.Flags & CallFlags_New));
+        AssertMsg(args.Info.Count > 0, "Should always have implicit 'this'");
 
-        CHAKRATEL_LANGSTATS_INC_BUILTINCOUNT(ArrayBuffer_Constructor_transfer);
+        Assert(!(callInfo.Flags & CallFlags_New));
 
         if (args.Info.Count < 2 || !ArrayBuffer::Is(args[1]))
         {
@@ -429,23 +429,14 @@ namespace Js
 
         if (arrayBuffer->IsDetached())
         {
-            JavascriptError::ThrowTypeError(scriptContext, JSERR_DetachedTypedArray, _u("ArrayBuffer.transfer"));
-        }
-
-        uint32 newBufferLength = arrayBuffer->bufferLength;
-        if (args.Info.Count >= 3)
-        {
-            newBufferLength = ToIndex(args[2], JSERR_ArrayLengthConstructIncorrect, scriptContext, MaxArrayBufferLength);
-
-            // ToIndex above can call user script (valueOf) which can detach the buffer
-            if (arrayBuffer->IsDetached())
-            {
-                JavascriptError::ThrowTypeError(scriptContext, JSERR_DetachedTypedArray, _u("ArrayBuffer.transfer"));
-            }
+            JavascriptError::ThrowTypeError(scriptContext, JSERR_DetachedTypedArray, _u("ArrayBuffer.detach"));
         }
 
-        return arrayBuffer->TransferInternal(newBufferLength);
+        // Discard the buffer
+        AutoDiscardPTR<DetachedStateBase>(arrayBuffer->DetachAndGetState());
+        return scriptContext->GetLibrary()->GetUndefined();
     }
+#endif
 
     // ArrayBuffer.prototype.slice as described in ES6 draft #19 section 24.1.4.3.
     Var ArrayBuffer::EntrySlice(RecyclableObject* function, CallInfo callInfo, ...)
@@ -785,18 +776,6 @@ namespace Js
         /* See JavascriptArrayBuffer::Finalize */
     }
 
-    // Copy memory from src to dst, truncate if dst smaller, zero extra memory
-    // if dst larger
-    static void MemCpyZero(__bcount(dstSize) BYTE* dst, size_t dstSize,
-        __in_bcount(count) const BYTE* src, size_t count)
-    {
-        js_memcpy_s(dst, dstSize, src, min(dstSize, count));
-        if (dstSize > count)
-        {
-            ZeroMemory(dst + count, dstSize - count);
-        }
-    }
-
     // Same as realloc but zero newly allocated portion if newSize > oldSize
     static BYTE* ReallocZero(BYTE* ptr, size_t oldSize, size_t newSize)
     {
@@ -808,137 +787,6 @@ namespace Js
         return ptrNew;
     }
 
-    ArrayBuffer * JavascriptArrayBuffer::TransferInternal(uint32 newBufferLength)
-    {
-        ArrayBuffer* newArrayBuffer;
-        Recycler* recycler = this->GetRecycler();
-
-        if (this->bufferLength > 0)
-        {
-            ReportDifferentialAllocation(newBufferLength);
-        }
-
-        if (newBufferLength == 0 || this->bufferLength == 0)
-        {
-            newArrayBuffer = GetLibrary()->CreateArrayBuffer(newBufferLength);
-            if (newBufferLength > 0 && !newArrayBuffer->GetByteLength())
-            {
-                JavascriptError::ThrowOutOfMemoryError(GetScriptContext());
-            }
-        }
-        else
-        {
-            BYTE * newBuffer = nullptr;
-            if (IsValidVirtualBufferLength(this->bufferLength))
-            {
-                if (IsValidVirtualBufferLength(newBufferLength))
-                {
-                    // we are transferring between an optimized buffer using a length that can be optimized
-                    if (newBufferLength < this->bufferLength)
-                    {
-#pragma prefast(suppress:6250, "Calling 'VirtualFree' without the MEM_RELEASE flag might free memory but not address descriptors (VADs).")
-                        VirtualFree(this->buffer + newBufferLength, this->bufferLength - newBufferLength, MEM_DECOMMIT);
-                    }
-                    else if (newBufferLength > this->bufferLength)
-                    {
-                        LPVOID newMem = VirtualAlloc(this->buffer + this->bufferLength, newBufferLength - this->bufferLength, MEM_COMMIT, PAGE_READWRITE);
-                        if (!newMem)
-                        {
-                            recycler->ReportExternalMemoryFailure(newBufferLength - this->bufferLength);
-                            JavascriptError::ThrowOutOfMemoryError(GetScriptContext());
-                        }
-                    }
-                    newBuffer = this->buffer;
-                }
-                else
-                {
-                    // we are transferring from an optimized buffer, but the new length isn't compatible, so start over and copy to new memory
-                    newBuffer = (BYTE*)malloc(newBufferLength);
-                    if (!newBuffer)
-                    {
-                        recycler->ReportExternalMemoryFailure(newBufferLength - this->bufferLength);
-                        JavascriptError::ThrowOutOfMemoryError(GetScriptContext());
-                    }
-                    MemCpyZero(newBuffer, newBufferLength, this->buffer, this->bufferLength);
-                }
-            }
-            else
-            {
-                if (IsValidVirtualBufferLength(newBufferLength))
-                {
-                    // we are transferring from an unoptimized buffer, but new length can be optimized, so move to that
-                    newBuffer = (BYTE*)AsmJsVirtualAllocator(newBufferLength);
-                    if (!newBuffer)
-                    {
-                        recycler->ReportExternalMemoryFailure(newBufferLength - this->bufferLength);
-                        JavascriptError::ThrowOutOfMemoryError(GetScriptContext());
-                    }
-                    MemCpyZero(newBuffer, newBufferLength, this->buffer, this->bufferLength);
-                }
-                else if (newBufferLength != this->bufferLength)
-                {
-                    // both sides will just be regular ArrayBuffer, so realloc
-                    newBuffer = ReallocZero(this->buffer, this->bufferLength, newBufferLength);
-                    if (!newBuffer)
-                    {
-                        recycler->ReportExternalMemoryFailure(newBufferLength - this->bufferLength);
-                        JavascriptError::ThrowOutOfMemoryError(GetScriptContext());
-                    }
-                }
-                else
-                {
-                    newBuffer = this->buffer;
-                }
-            }
-            newArrayBuffer = GetLibrary()->CreateArrayBuffer(newBuffer, newBufferLength);
-
-        }
-        AutoDiscardPTR<Js::ArrayBufferDetachedStateBase> state(DetachAndGetState());
-        state->MarkAsClaimed();
-
-        return newArrayBuffer;
-    }
-
-
-    template<typename Func>
-    void Js::JavascriptArrayBuffer::ReportDifferentialAllocation(uint32 newBufferLength, Func reportFailureFn)
-    {
-        Recycler* recycler = this->GetRecycler();
-
-        // Report differential external memory allocation.
-        // If current bufferLength == 0, new ArrayBuffer creation records the allocation
-        // so no need to do it here.
-        if (newBufferLength != this->bufferLength)
-        {
-            // Expanding buffer
-            if (newBufferLength > this->bufferLength)
-            {
-                if (!recycler->RequestExternalMemoryAllocation(newBufferLength - this->bufferLength))
-                {
-                    recycler->CollectNow<CollectOnTypedArrayAllocation>();
-                    if (!recycler->RequestExternalMemoryAllocation(newBufferLength - this->bufferLength))
-                    {
-                        reportFailureFn();
-                    }
-                }
-            }
-            // Contracting buffer
-            else
-            {
-                recycler->ReportExternalMemoryFree(this->bufferLength - newBufferLength);
-            }
-        }
-    }
-
-
-    void JavascriptArrayBuffer::ReportDifferentialAllocation(uint32 newBufferLength)
-    {
-        ScriptContext* scriptContext = GetScriptContext();
-        ReportDifferentialAllocation(newBufferLength, [scriptContext] {
-            JavascriptError::ThrowOutOfMemoryError(scriptContext);
-        });
-    }
-
 #if ENABLE_TTD
     TTD::NSSnapObjects::SnapObjectType JavascriptArrayBuffer::GetSnapTag_TTD() const
     {
@@ -1121,11 +969,6 @@ namespace Js
         }
     }
 
-    ArrayBuffer * WebAssemblyArrayBuffer::TransferInternal(uint32 newBufferLength)
-    {
-        JavascriptError::ThrowTypeError(GetScriptContext(), WASMERR_CantDetach);
-    }
-
     ProjectionArrayBuffer::ProjectionArrayBuffer(uint32 length, DynamicType * type) :
         ArrayBuffer(length, type, CoTaskMemAlloc)
     {
@@ -1157,29 +1000,6 @@ namespace Js
         CoTaskMemFree(buffer);
     }
 
-    ArrayBuffer * ProjectionArrayBuffer::TransferInternal(uint32 newBufferLength)
-    {
-        ArrayBuffer* newArrayBuffer;
-        if (newBufferLength == 0 || this->bufferLength == 0)
-        {
-            newArrayBuffer = GetLibrary()->CreateProjectionArraybuffer(newBufferLength);
-        }
-        else
-        {
-            BYTE * newBuffer = (BYTE*)CoTaskMemRealloc(this->buffer, newBufferLength);
-            if (!newBuffer)
-            {
-                JavascriptError::ThrowOutOfMemoryError(GetScriptContext());
-            }
-            newArrayBuffer = GetLibrary()->CreateProjectionArraybuffer(newBuffer, newBufferLength);
-        }
-
-        AutoDiscardPTR<Js::ArrayBufferDetachedStateBase> state(DetachAndGetState());
-        state->MarkAsClaimed();
-
-        return newArrayBuffer;
-    }
-
     ExternalArrayBuffer::ExternalArrayBuffer(byte *buffer, uint32 length, DynamicType *type)
         : ArrayBuffer(buffer, length, type)
     {

+ 6 - 14
lib/Runtime/Library/ArrayBuffer.h

@@ -142,7 +142,9 @@ namespace Js
             static FunctionInfo IsView;
             static FunctionInfo GetterByteLength;
             static FunctionInfo GetterSymbolSpecies;
-            static FunctionInfo Transfer;
+#if ENABLE_DEBUG_CONFIG_OPTIONS
+            static FunctionInfo Detach;
+#endif
         };
 
         static Var NewInstance(RecyclableObject* function, CallInfo callInfo, ...);
@@ -150,7 +152,9 @@ namespace Js
         static Var EntryIsView(RecyclableObject* function, CallInfo callInfo, ...);
         static Var EntryGetterByteLength(RecyclableObject* function, CallInfo callInfo, ...);
         static Var EntryGetterSymbolSpecies(RecyclableObject* function, CallInfo callInfo, ...);
-        static Var EntryTransfer(RecyclableObject* function, CallInfo callInfo, ...);
+#if ENABLE_DEBUG_CONFIG_OPTIONS
+        static Var EntryDetach(RecyclableObject* function, CallInfo callInfo, ...);
+#endif
 
         static bool Is(Var aValue);
         static ArrayBuffer* NewFromDetachedState(DetachedStateBase* state, JavascriptLibrary *library);
@@ -183,15 +187,12 @@ namespace Js
 
         static uint32 ToIndex(Var value, int32 errorCode, ScriptContext *scriptContext, uint32 MaxAllowedLength, bool checkSameValueZero = true);
 
-        virtual ArrayBuffer * TransferInternal(DECLSPEC_GUARD_OVERFLOW uint32 newBufferLength) = 0;
     protected:
         void Detach();
 
         typedef void __cdecl FreeFn(void* ptr);
         virtual ArrayBufferDetachedStateBase* CreateDetachedState(BYTE* buffer, DECLSPEC_GUARD_OVERFLOW uint32 bufferLength) = 0;
 
-        static uint32 GetIndexFromVar(Js::Var arg, uint32 length, ScriptContext* scriptContext);
-
         //In most cases, the ArrayBuffer will only have one parent
         Field(RecyclerWeakReference<ArrayBufferParent>*) primaryParent;
 
@@ -259,12 +260,6 @@ namespace Js
         virtual bool IsValidAsmJsBufferLength(uint length, bool forceCheck = false) override;
         virtual bool IsValidVirtualBufferLength(uint length) const override;
 
-        virtual ArrayBuffer * TransferInternal(DECLSPEC_GUARD_OVERFLOW uint32 newBufferLength) override;
-
-        template<typename Func>
-        void ReportDifferentialAllocation(uint32 newBufferLength, Func reportFailureFn);
-        void ReportDifferentialAllocation(uint32 newBufferLength);
-
     protected:
         JavascriptArrayBuffer(DynamicType * type);
         virtual ArrayBufferDetachedStateBase* CreateDetachedState(BYTE* buffer, DECLSPEC_GUARD_OVERFLOW uint32 bufferLength) override;
@@ -295,7 +290,6 @@ namespace Js
         WebAssemblyArrayBuffer* GrowMemory(DECLSPEC_GUARD_OVERFLOW uint32 newBufferLength);
 
         virtual bool IsValidVirtualBufferLength(uint length) const override;
-        virtual ArrayBuffer * TransferInternal(DECLSPEC_GUARD_OVERFLOW uint32 newBufferLength) override;
         virtual bool IsWebAssemblyArrayBuffer() override { return true; }
 
     protected:
@@ -322,7 +316,6 @@ namespace Js
         static ProjectionArrayBuffer* Create(byte* buffer, DECLSPEC_GUARD_OVERFLOW uint32 length, DynamicType * type);
         virtual void Dispose(bool isShutdown) override;
         virtual void Finalize(bool isShutdown) override {};
-        virtual ArrayBuffer * TransferInternal(DECLSPEC_GUARD_OVERFLOW uint32 newBufferLength) override;
     private:
         ProjectionArrayBuffer(uint32 length, DynamicType * type);
         ProjectionArrayBuffer(byte* buffer, uint32 length, DynamicType * type);
@@ -336,7 +329,6 @@ namespace Js
         DEFINE_MARSHAL_OBJECT_TO_SCRIPT_CONTEXT(ExternalArrayBuffer);
     public:
         ExternalArrayBuffer(byte *buffer, DECLSPEC_GUARD_OVERFLOW uint32 length, DynamicType *type);
-        virtual ArrayBuffer * TransferInternal(DECLSPEC_GUARD_OVERFLOW uint32 newBufferLength) override { Assert(UNREACHED); Throw::InternalError(); };
     protected:
         virtual ArrayBufferDetachedStateBase* CreateDetachedState(BYTE* buffer, DECLSPEC_GUARD_OVERFLOW uint32 bufferLength) override { Assert(UNREACHED); Throw::InternalError(); };
 

+ 3 - 1
lib/Runtime/Library/JavascriptBuiltInFunctionList.h

@@ -910,7 +910,9 @@ BUILTIN(ArrayBuffer, Slice, EntrySlice, FunctionInfo::ErrorOnNew)
 BUILTIN(ArrayBuffer, IsView, EntryIsView, FunctionInfo::ErrorOnNew)
 BUILTIN(ArrayBuffer, GetterByteLength, EntryGetterByteLength, FunctionInfo::ErrorOnNew | FunctionInfo::HasNoSideEffect)
 BUILTIN(ArrayBuffer, GetterSymbolSpecies, EntryGetterSymbolSpecies, FunctionInfo::ErrorOnNew)
-BUILTIN(ArrayBuffer, Transfer, EntryTransfer, FunctionInfo::ErrorOnNew)
+#if ENABLE_DEBUG_CONFIG_OPTIONS
+BUILTIN(ArrayBuffer, Detach, EntryDetach, FunctionInfo::ErrorOnNew)
+#endif
 BUILTIN(DataView, NewInstance, NewInstance, FunctionInfo::SkipDefaultNewObject)
 BUILTIN(DataView, SetInt8, EntrySetInt8, FunctionInfo::ErrorOnNew)
 BUILTIN(DataView, SetUint8, EntrySetUint8, FunctionInfo::ErrorOnNew)

+ 3 - 5
lib/Runtime/Library/JavascriptLibrary.cpp

@@ -1829,11 +1829,9 @@ namespace Js
         }
         library->AddFunctionToLibraryObject(arrayBufferConstructor, PropertyIds::isView, &ArrayBuffer::EntryInfo::IsView, 1);
 
-        if (scriptContext->GetConfig()->IsArrayBufferTransferEnabled())
-        {
-            library->AddFunctionToLibraryObject(arrayBufferConstructor, PropertyIds::transfer, &ArrayBuffer::EntryInfo::Transfer, 2);
-        }
-
+#if ENABLE_DEBUG_CONFIG_OPTIONS
+        library->AddFunctionToLibraryObject(arrayBufferConstructor, PropertyIds::detach, &ArrayBuffer::EntryInfo::Detach, 1);
+#endif
         arrayBufferConstructor->SetHasNoEnumerableProperties(true);
 
         return true;

+ 0 - 37
test/es7/arraybuffer_transfer.js

@@ -1,37 +0,0 @@
-//-------------------------------------------------------------------------------------------------------
-// Copyright (C) Microsoft Corporation and contributors. All rights reserved.
-// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
-//-------------------------------------------------------------------------------------------------------
-
-function assertEquals(expected, actual) {
-    if (expected != actual) {
-        throw `Expected ${expected}, received ${actual}`;
-    }
-}
-
-function arrayBufferAllocAndTransfer(initSize) {
-
-    const UNDER_1GB = 0x3FFF0000;
-    let buffers = [];
-    const n = 10;
-
-    for (let i = 0; i < n; i++) {
-        try {
-            const b = new Uint8Array(initSize);
-            ArrayBuffer.transfer(b.buffer, UNDER_1GB);
-            buffers.push(b);
-        } catch (e) {
-            return e;
-        }
-    }
-
-    return new Error('OOM Expected');
-}
-
-assertEquals(1, WScript.Arguments.length);
-const INITIAL_SIZE = parseInt(WScript.Arguments[0]);
-
-let {name, message } = arrayBufferAllocAndTransfer(INITIAL_SIZE);
-assertEquals("Out of memory", message); //message check comes first to render test failures more intuitive
-assertEquals("Error", name);
-print ("PASSED");

+ 0 - 14
test/es7/rlexe.xml

@@ -92,18 +92,4 @@
       <tags>exclude_xplat</tags>
     </default>
   </test>
-  <test>
-    <default>
-      <files>arraybuffer_transfer.js</files>
-      <compile-flags>-es6experimental -args 0x1000 -endargs</compile-flags>
-      <tags>exclude_amd64</tags>
-    </default>
-  </test>
-  <test>
-    <default>
-      <files>arraybuffer_transfer.js</files>
-      <compile-flags>-es6experimental -args 0 -endargs</compile-flags>
-      <tags>exclude_amd64</tags>
-    </default>
-  </test>
 </regress-exe>

+ 0 - 15
test/typedarray/rlexe.xml

@@ -295,21 +295,6 @@ Below test fails with difference in space. Investigate the cause and re-enable t
       <tags>typedarray,BUG</tags>
     </default>
   </test>
-  <test>
-    <default>
-      <files>transfer.js</files>
-      <baseline>transfer.baseline</baseline>
-      <compile-flags>-ArrayBufferTransfer</compile-flags>
-      <tags>typedarray</tags>
-    </default>
-  </test>
-  <test>
-    <default>
-      <files>transferdetach.js</files>
-      <compile-flags>-ArrayBufferTransfer</compile-flags>
-      <tags>typedarray</tags>
-    </default>
-  </test>
   <test>
     <default>
       <files>memset.js</files>

+ 0 - 18
test/typedarray/transfer.baseline

@@ -1,18 +0,0 @@
-0
-4194304
-43
-42
-44
-0
-1048576
-undefined
-42
-0
-80
-42
-0
-0
-0
-2097152
-0
-0

+ 0 - 47
test/typedarray/transfer.js

@@ -1,47 +0,0 @@
-//-------------------------------------------------------------------------------------------------------
-// Copyright (C) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
-//-------------------------------------------------------------------------------------------------------
-if (this.WScript && this.WScript.LoadScriptFile) { // Check for running in ch
-    this.WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
-}
-
-var buf1 = new ArrayBuffer(1<<21);
-new Int8Array(buf1)[0] = 42;
-new Int8Array(buf1)[1<<21-1] = 43;
-
-var buf2 = ArrayBuffer.transfer(buf1, 1<<22);
-print(buf1.byteLength);
-print(buf2.byteLength);
-print(new Int8Array(buf2)[1<<21-1]);
-print(new Int8Array(buf2)[0]);
-new Int8Array(buf2)[1<<22-1] = 44;
-print(new Int8Array(buf2)[1<<22-1]);
-var buf3 = ArrayBuffer.transfer(buf2, 1<<20);
-print(buf2.byteLength);
-print(buf3.byteLength);
-print(new Int8Array(buf3)[1<<21-1]);
-print(new Int8Array(buf3)[0]);
-var buf4 = ArrayBuffer.transfer(buf3, 80);
-print(buf3.byteLength);
-print(buf4.byteLength);
-print(new Int8Array(buf4)[0]);
-var buf5 = ArrayBuffer.transfer(buf4, 0);
-print(buf4.byteLength);
-print(buf5.byteLength);
-var buf6 = ArrayBuffer.transfer(buf5, 1<<21);
-print(buf5.byteLength);
-print(buf6.byteLength);
-var buf7 = ArrayBuffer.transfer(buf6, 0);
-print(buf6.byteLength);
-print(buf7.byteLength);
-
-// Test the DataView constructor with a detached buffer.
-function TestDataViewCostructorDetachedBuffer()
-{
-    var arrayBufferToDetach = new ArrayBuffer(16);
-    var arrayBufferNew = ArrayBuffer.transfer(arrayBufferToDetach, 0);
-    var dataView8 = new DataView(arrayBufferToDetach);
-}
-
-assert.throws(TestDataViewCostructorDetachedBuffer, TypeError, "", "The ArrayBuffer is detached.");

+ 0 - 30
test/typedarray/transferdetach.js

@@ -1,30 +0,0 @@
-//-------------------------------------------------------------------------------------------------------
-// Copyright (C) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
-//-------------------------------------------------------------------------------------------------------
-if (this.WScript && this.WScript.LoadScriptFile) { // Check for running in ch
-  this.WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
-}
-
-var a = new ArrayBuffer(0x10);
-
-function foo() {
-  detach(a);
-  return 6;
-};
-
-function detach(ab) {
-  var c = ArrayBuffer.transfer(a, 0x10);
-};
-
-var obj = {
-  valueOf: foo
-};
-
-function test() {
-  ArrayBuffer.transfer(a, obj);
-}
-
-assert.throws(test, TypeError, "", "ArrayBuffer.transfer: The ArrayBuffer is detached.");
-
-print("pass");

+ 11 - 15
test/wasm/memory.js

@@ -21,18 +21,14 @@ while (true) {
   ++verbose;
 }
 
-function testTransfer(buffer) {
-  if (ArrayBuffer.transfer) {
-    try {
-      ArrayBuffer.transfer(buffer);
-      print("Failed. Expected an error when trying to transfer ");
-    } catch (e) {
-      if (verbose > 1) {
-        print(`Passed. Expected error: ${e.message}`);
-      }
+function testDetach(buffer) {
+  try {
+    ArrayBuffer.detach(buffer);
+    print("Failed. Expected an error when trying to transfer ");
+  } catch (e) {
+    if (verbose > 1) {
+      print(`Passed. Expected error: ${e.message}`);
     }
-  } else {
-    print("ArrayBuffer.tranfer is missing");
   }
 }
 
@@ -105,7 +101,7 @@ function test({init, max, checkOOM} = {}) {
     }
   }
   function run(delta) {
-    testTransfer(mem.buffer);
+    testDetach(mem.buffer);
     const beforePages = current();
     const growRes = grow(delta);
     if (growRes !== -1 && growRes !== beforePages) {
@@ -124,16 +120,16 @@ function test({init, max, checkOOM} = {}) {
     testReadWrite(-2, -2, currentSize);
     testReadWrite(-1, -1, currentSize);
     testReadWrite(0, 6, currentSize);
-    testTransfer(mem.buffer);
+    testDetach(mem.buffer);
     testReadWrite(1, 7, currentSize);
-    testTransfer(mem.buffer);
+    testDetach(mem.buffer);
     testReadWrite(1, 7, currentSize);
     testReadWrite(currentSize - 4, 457, currentSize);
     testReadWrite(currentSize - 3, -98745, currentSize);
     testReadWrite(currentSize - 2, 786452, currentSize);
     testReadWrite(currentSize - 1, -1324, currentSize);
     testReadWrite(currentSize, 123, currentSize);
-    testTransfer(mem.buffer);
+    testDetach(mem.buffer);
   }
   run(0);
   run(3);

+ 2 - 2
test/wasm/rlexe.xml

@@ -270,14 +270,14 @@
 <test>
   <default>
     <files>memory.js</files>
-    <compile-flags>-wasm -ArrayBufferTransfer</compile-flags>
+    <compile-flags>-wasm</compile-flags>
     <tags>exclude_jshost,exclude_win7,exclude_xplat</tags>
   </default>
 </test>
 <test>
   <default>
     <files>memory.js</files>
-    <compile-flags>-wasm -ArrayBufferTransfer -wasmfastarray-</compile-flags>
+    <compile-flags>-wasm -wasmfastarray-</compile-flags>
     <tags>exclude_jshost,exclude_win7,exclude_xplat</tags>
   </default>
 </test>