diff --git a/Makefile b/Makefile index 44bcae0b..f2c65a22 100644 --- a/Makefile +++ b/Makefile @@ -96,7 +96,6 @@ MAIN_JS_SRCS = \ polyfill/find.js \ polyfill/findIndex.js \ polyfill/fround.js \ - polyfill/TypedArray.js \ blackBox.js \ timer.js \ util.js \ diff --git a/polyfill/TypedArray.js b/polyfill/TypedArray.js deleted file mode 100644 index 457fcb84..00000000 --- a/polyfill/TypedArray.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; - -(function () { - // Per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray, - // "all typed array prototypes (TypedArray.prototype) have %TypedArray%.prototype as their [[Prototype]]." - // So it doesn't matter which TypedArray constructor we use to dereference - // the prototype. - var proto = Object.getPrototypeOf(Int8Array.prototype); - - if (!("fill" in proto)) { - proto.fill = function(value, start, end) { - if ((typeof start) === "undefined") { - start = 0; - } - - if ((typeof end) === "undefined") { - end = this.length; - } - - for (var i = start; i < end; i++) { - this[i] = value; - } - - return this; - }; - } - -})(); diff --git a/tests/gctests.js b/tests/gctests.js index 4b1e7c15..4681cdd8 100755 --- a/tests/gctests.js +++ b/tests/gctests.js @@ -299,7 +299,7 @@ tests.push(function() { ASM._forceCollection(); } - ok(!zeroedOut, "gcMallocAtomic doesn't zero-out allocated memory"); + ok(zeroedOut, "gcMallocAtomic does zero-out allocated memory"); next(); }); @@ -326,7 +326,7 @@ tests.push(function() { ASM._forceCollection(); } - ok(zeroedOut, "newArray does zero-out allocated memory"); + ok(zeroedOut, "newIntArray does zero-out allocated memory"); next(); }); diff --git a/tools/lib.d.ts b/tools/lib.d.ts index bfbf8460..1e297073 100644 --- a/tools/lib.d.ts +++ b/tools/lib.d.ts @@ -1227,8 +1227,6 @@ interface Int8Array extends ArrayBufferView { * @param end The index of the end of the array. */ subarray(begin: number, end?: number): Int8Array; - - fill(value: number, start?: number, end?: number): void; } declare var Int8Array: { prototype: Int8Array; diff --git a/vm/native/native.cpp b/vm/native/native.cpp index 1be9b0fa..fa92b320 100644 --- a/vm/native/native.cpp +++ b/vm/native/native.cpp @@ -8,6 +8,7 @@ #include #include #include +#include // Formatting: Printing longs. // printf("L: %" PRId64 ", R: %" PRId64, *l, *r); @@ -69,7 +70,9 @@ extern "C" { } uintptr_t gcMallocAtomic(int32_t size) { - return (uintptr_t)GC_MALLOC_ATOMIC(size); + uintptr_t ptr = (uintptr_t)GC_MALLOC_ATOMIC(size); + memset((void*)ptr, 0, size); + return ptr; } void gcRegisterDisappearingLink(uintptr_t p, uintptr_t objAddr) { diff --git a/vm/runtime.ts b/vm/runtime.ts index 2e1e4a75..b95fa15a 100644 --- a/vm/runtime.ts +++ b/vm/runtime.ts @@ -1346,11 +1346,6 @@ module J2ME { if (elementClassInfo instanceof PrimitiveClassInfo) { addr = ASM._gcMallocAtomic(Constants.ARRAY_HDR_SIZE + size * (arrayClassInfo).bytesPerElement); - - // Zero-out memory because GC_MALLOC_ATOMIC doesn't do it automatically. - var off = Constants.ARRAY_HDR_SIZE + addr; - var end = off + size * (arrayClassInfo).bytesPerElement; - i8.fill(0, off, end); } else { // We need to hold an integer to define the length of the array // and *size* references.