diff --git a/lib/util.js b/lib/util.js index 003b5e5b54073b..b16692cccfb914 100644 --- a/lib/util.js +++ b/lib/util.js @@ -18,41 +18,6 @@ const inspectDefaultOptions = Object.seal({ }); var Debug; -var simdFormatters; - -// SIMD is only available when --harmony_simd is specified on the command line -// and the set of available types differs between v5 and v6, that's why we use -// a map to look up and store the formatters. It also provides a modicum of -// protection against users monkey-patching the SIMD object. -if (typeof global.SIMD === 'object' && global.SIMD !== null) { - simdFormatters = new Map(); - - const make = - (extractLane, count) => (ctx, value, recurseTimes, visibleKeys, keys) => { - const output = new Array(count); - for (var i = 0; i < count; i += 1) - output[i] = formatPrimitive(ctx, extractLane(value, i)); - return output; - }; - - const countPerType = { - Bool16x8: 8, - Bool32x4: 4, - Bool8x16: 16, - Float32x4: 4, - Int16x8: 8, - Int32x4: 4, - Int8x16: 16, - Uint16x8: 8, - Uint32x4: 4, - Uint8x16: 16 - }; - - for (const key in countPerType) { - const type = global.SIMD[key]; - simdFormatters.set(type, make(type.extractLane, countPerType[key])); - } -} function tryStringify(arg) { try { @@ -508,7 +473,6 @@ function formatValue(ctx, value, recurseTimes) { braces = ['{', '}']; formatter = formatPromise; } else { - let maybeSimdFormatter; if (binding.isMapIterator(value)) { constructor = { name: 'MapIterator' }; braces = ['{', '}']; @@ -519,11 +483,6 @@ function formatValue(ctx, value, recurseTimes) { braces = ['{', '}']; empty = false; formatter = formatCollectionIterator; - } else if (simdFormatters && - typeof constructor === 'function' && - (maybeSimdFormatter = simdFormatters.get(constructor))) { - braces = ['[', ']']; - formatter = maybeSimdFormatter; } else { // Unset the constructor to prevent "Object {...}" for ordinary objects. if (constructor && constructor.name === 'Object') diff --git a/test/parallel/test-util-inspect-simd.js b/test/parallel/test-util-inspect-simd.js deleted file mode 100644 index 5e0a2740840c93..00000000000000 --- a/test/parallel/test-util-inspect-simd.js +++ /dev/null @@ -1,69 +0,0 @@ -// Flags: --harmony_simd -/* global SIMD */ -'use strict'; - -require('../common'); -const assert = require('assert'); -const inspect = require('util').inspect; - -assert.strictEqual( - inspect(SIMD.Bool16x8()), - 'Bool16x8 [ false, false, false, false, false, false, false, false ]'); - -assert.strictEqual( - inspect(SIMD.Bool32x4()), - 'Bool32x4 [ false, false, false, false ]'); - -assert.strictEqual( - inspect(SIMD.Bool8x16()), - 'Bool8x16 [\n false,\n false,\n false,\n false,\n false,\n' + - ' false,\n false,\n false,\n false,\n false,\n false,\n' + - ' false,\n false,\n false,\n false,\n false ]'); - -assert.strictEqual( - inspect(SIMD.Bool32x4()), - 'Bool32x4 [ false, false, false, false ]'); - -assert.strictEqual( - inspect(SIMD.Float32x4()), - 'Float32x4 [ NaN, NaN, NaN, NaN ]'); - -assert.strictEqual( - inspect(SIMD.Int16x8()), - 'Int16x8 [ 0, 0, 0, 0, 0, 0, 0, 0 ]'); - -assert.strictEqual( - inspect(SIMD.Int32x4()), - 'Int32x4 [ 0, 0, 0, 0 ]'); - -assert.strictEqual( - inspect(SIMD.Int8x16()), - 'Int8x16 [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]'); - -// The SIMD types below are not available in v5. -if (typeof SIMD.Uint16x8 === 'function') { - assert.strictEqual( - inspect(SIMD.Uint16x8()), - 'Uint16x8 [ 0, 0, 0, 0, 0, 0, 0, 0 ]'); -} - -if (typeof SIMD.Uint32x4 === 'function') { - assert.strictEqual( - inspect(SIMD.Uint32x4()), - 'Uint32x4 [ 0, 0, 0, 0 ]'); -} - -if (typeof SIMD.Uint8x16 === 'function') { - assert.strictEqual( - inspect(SIMD.Uint8x16()), - 'Uint8x16 [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]'); -} - -// Tests from test-inspect.js that should not fail with --harmony_simd. -assert.strictEqual(inspect([]), '[]'); -assert.strictEqual(inspect([0]), '[ 0 ]'); -assert.strictEqual(inspect({}), '{}'); -assert.strictEqual(inspect({foo: 42}), '{ foo: 42 }'); -assert.strictEqual(inspect(null), 'null'); -assert.strictEqual(inspect(true), 'true'); -assert.strictEqual(inspect(false), 'false');