Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: remove simd support from util.format() #11346

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -508,7 +473,6 @@ function formatValue(ctx, value, recurseTimes) {
braces = ['{', '}'];
formatter = formatPromise;
} else {
let maybeSimdFormatter;
if (binding.isMapIterator(value)) {
constructor = { name: 'MapIterator' };
braces = ['{', '}'];
Expand All @@ -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')
Expand Down
69 changes: 0 additions & 69 deletions test/parallel/test-util-inspect-simd.js

This file was deleted.