Permalink
Browse files

lib: remove simd support from util.format()

Upstream V8 is removing SIMD support.  Be proactive and follow suit.

Refs: https://bugs.chromium.org/p/v8/issues/detail?id=4124
PR-URL: #11346
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information...
bnoordhuis authored and jasnell committed Feb 13, 2017
1 parent c5d1851 commit 2ba4eeadbb816068139759957c8443565a4d795a
Showing with 0 additions and 103 deletions.
  1. +0 −41 lib/util.js
  2. +0 −62 test/parallel/test-util-inspect-simd.js
View
@@ -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')
@@ -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');

0 comments on commit 2ba4eea

Please sign in to comment.