From 2ba4eeadbb816068139759957c8443565a4d795a Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 13 Feb 2017 18:16:14 +0100 Subject: [PATCH] lib: remove simd support from util.format() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upstream V8 is removing SIMD support. Be proactive and follow suit. Refs: https://bugs.chromium.org/p/v8/issues/detail?id=4124 PR-URL: https://github.com/nodejs/node/pull/11346 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Evan Lucas Reviewed-By: Ali Ijaz Sheikh Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Anna Henningsen --- lib/util.js | 41 ---------------- test/parallel/test-util-inspect-simd.js | 62 ------------------------- 2 files changed, 103 deletions(-) delete mode 100644 test/parallel/test-util-inspect-simd.js 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 280bd0b5a4b3d1..00000000000000 --- a/test/parallel/test-util-inspect-simd.js +++ /dev/null @@ -1,62 +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 ]'); - -assert.strictEqual( - inspect(SIMD.Uint16x8()), - 'Uint16x8 [ 0, 0, 0, 0, 0, 0, 0, 0 ]'); - -assert.strictEqual( - inspect(SIMD.Uint32x4()), - 'Uint32x4 [ 0, 0, 0, 0 ]'); - -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');