diff options
Diffstat (limited to 'node_modules/@webassemblyjs/wasm-opt')
-rw-r--r-- | node_modules/@webassemblyjs/wasm-opt/LICENSE | 21 | ||||
-rw-r--r-- | node_modules/@webassemblyjs/wasm-opt/esm/index.js | 41 | ||||
-rw-r--r-- | node_modules/@webassemblyjs/wasm-opt/esm/leb128.js | 47 | ||||
-rw-r--r-- | node_modules/@webassemblyjs/wasm-opt/lib/index.js | 50 | ||||
-rw-r--r-- | node_modules/@webassemblyjs/wasm-opt/lib/leb128.js | 56 | ||||
-rw-r--r-- | node_modules/@webassemblyjs/wasm-opt/package.json | 58 |
6 files changed, 273 insertions, 0 deletions
diff --git a/node_modules/@webassemblyjs/wasm-opt/LICENSE b/node_modules/@webassemblyjs/wasm-opt/LICENSE new file mode 100644 index 0000000..87e7e1f --- /dev/null +++ b/node_modules/@webassemblyjs/wasm-opt/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/@webassemblyjs/wasm-opt/esm/index.js b/node_modules/@webassemblyjs/wasm-opt/esm/index.js new file mode 100644 index 0000000..f9d9232 --- /dev/null +++ b/node_modules/@webassemblyjs/wasm-opt/esm/index.js @@ -0,0 +1,41 @@ +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +import { decode } from "@webassemblyjs/wasm-parser"; +import { shrinkPaddedLEB128 as makeShrinkPaddedLEB128 } from "./leb128.js"; + +var OptimizerError = +/*#__PURE__*/ +function (_Error) { + _inherits(OptimizerError, _Error); + + function OptimizerError(name, initalError) { + var _this; + + _classCallCheck(this, OptimizerError); + + _this = _possibleConstructorReturn(this, (OptimizerError.__proto__ || Object.getPrototypeOf(OptimizerError)).call(this, "Error while optimizing: " + name + ": " + initalError.message)); + _this.stack = initalError.stack; + return _this; + } + + return OptimizerError; +}(Error); + +var decoderOpts = { + ignoreCodeSection: true, + ignoreDataSection: true +}; +export function shrinkPaddedLEB128(uint8Buffer) { + try { + var ast = decode(uint8Buffer.buffer, decoderOpts); + return makeShrinkPaddedLEB128(ast, uint8Buffer); + } catch (e) { + throw new OptimizerError("shrinkPaddedLEB128", e); + } +}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-opt/esm/leb128.js b/node_modules/@webassemblyjs/wasm-opt/esm/leb128.js new file mode 100644 index 0000000..3150c9e --- /dev/null +++ b/node_modules/@webassemblyjs/wasm-opt/esm/leb128.js @@ -0,0 +1,47 @@ +import { traverse, shiftSection } from "@webassemblyjs/ast"; +import { encodeU32 } from "@webassemblyjs/wasm-gen/lib/encoder"; +import { overrideBytesInBuffer } from "@webassemblyjs/helper-buffer"; + +function shiftFollowingSections(ast, _ref, deltaInSizeEncoding) { + var section = _ref.section; + // Once we hit our section every that is after needs to be shifted by the delta + var encounteredSection = false; + traverse(ast, { + SectionMetadata: function SectionMetadata(path) { + if (path.node.section === section) { + encounteredSection = true; + return; + } + + if (encounteredSection === true) { + shiftSection(ast, path.node, deltaInSizeEncoding); + } + } + }); +} + +export function shrinkPaddedLEB128(ast, uint8Buffer) { + traverse(ast, { + SectionMetadata: function SectionMetadata(_ref2) { + var node = _ref2.node; + + /** + * Section size + */ + { + var newu32Encoded = encodeU32(node.size.value); + var newu32EncodedLen = newu32Encoded.length; + var start = node.size.loc.start.column; + var end = node.size.loc.end.column; + var oldu32EncodedLen = end - start; + + if (newu32EncodedLen !== oldu32EncodedLen) { + var deltaInSizeEncoding = oldu32EncodedLen - newu32EncodedLen; + uint8Buffer = overrideBytesInBuffer(uint8Buffer, start, end, newu32Encoded); + shiftFollowingSections(ast, node, -deltaInSizeEncoding); + } + } + } + }); + return uint8Buffer; +}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-opt/lib/index.js b/node_modules/@webassemblyjs/wasm-opt/lib/index.js new file mode 100644 index 0000000..4355961 --- /dev/null +++ b/node_modules/@webassemblyjs/wasm-opt/lib/index.js @@ -0,0 +1,50 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.shrinkPaddedLEB128 = shrinkPaddedLEB128; + +var _wasmParser = require("@webassemblyjs/wasm-parser"); + +var _leb = require("./leb128.js"); + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var OptimizerError = +/*#__PURE__*/ +function (_Error) { + _inherits(OptimizerError, _Error); + + function OptimizerError(name, initalError) { + var _this; + + _classCallCheck(this, OptimizerError); + + _this = _possibleConstructorReturn(this, (OptimizerError.__proto__ || Object.getPrototypeOf(OptimizerError)).call(this, "Error while optimizing: " + name + ": " + initalError.message)); + _this.stack = initalError.stack; + return _this; + } + + return OptimizerError; +}(Error); + +var decoderOpts = { + ignoreCodeSection: true, + ignoreDataSection: true +}; + +function shrinkPaddedLEB128(uint8Buffer) { + try { + var ast = (0, _wasmParser.decode)(uint8Buffer.buffer, decoderOpts); + return (0, _leb.shrinkPaddedLEB128)(ast, uint8Buffer); + } catch (e) { + throw new OptimizerError("shrinkPaddedLEB128", e); + } +}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js b/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js new file mode 100644 index 0000000..e4a0e85 --- /dev/null +++ b/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js @@ -0,0 +1,56 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.shrinkPaddedLEB128 = shrinkPaddedLEB128; + +var _ast = require("@webassemblyjs/ast"); + +var _encoder = require("@webassemblyjs/wasm-gen/lib/encoder"); + +var _helperBuffer = require("@webassemblyjs/helper-buffer"); + +function shiftFollowingSections(ast, _ref, deltaInSizeEncoding) { + var section = _ref.section; + // Once we hit our section every that is after needs to be shifted by the delta + var encounteredSection = false; + (0, _ast.traverse)(ast, { + SectionMetadata: function SectionMetadata(path) { + if (path.node.section === section) { + encounteredSection = true; + return; + } + + if (encounteredSection === true) { + (0, _ast.shiftSection)(ast, path.node, deltaInSizeEncoding); + } + } + }); +} + +function shrinkPaddedLEB128(ast, uint8Buffer) { + (0, _ast.traverse)(ast, { + SectionMetadata: function SectionMetadata(_ref2) { + var node = _ref2.node; + + /** + * Section size + */ + { + var newu32Encoded = (0, _encoder.encodeU32)(node.size.value); + var newu32EncodedLen = newu32Encoded.length; + var start = node.size.loc.start.column; + var end = node.size.loc.end.column; + var oldu32EncodedLen = end - start; + + if (newu32EncodedLen !== oldu32EncodedLen) { + var deltaInSizeEncoding = oldu32EncodedLen - newu32EncodedLen; + uint8Buffer = (0, _helperBuffer.overrideBytesInBuffer)(uint8Buffer, start, end, newu32Encoded); + shiftFollowingSections(ast, node, -deltaInSizeEncoding); + } + } + } + }); + return uint8Buffer; +}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-opt/package.json b/node_modules/@webassemblyjs/wasm-opt/package.json new file mode 100644 index 0000000..b22e943 --- /dev/null +++ b/node_modules/@webassemblyjs/wasm-opt/package.json @@ -0,0 +1,58 @@ +{ + "_from": "@webassemblyjs/wasm-opt@1.9.0", + "_id": "@webassemblyjs/wasm-opt@1.9.0", + "_inBundle": false, + "_integrity": "sha512-Qkjgm6Anhm+OMbIL0iokO7meajkzQD71ioelnfPEj6r4eOFuqm4YC3VBPqXjFyyNwowzbMD+hizmprP/Fwkl2A==", + "_location": "/@webassemblyjs/wasm-opt", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "@webassemblyjs/wasm-opt@1.9.0", + "name": "@webassemblyjs/wasm-opt", + "escapedName": "@webassemblyjs%2fwasm-opt", + "scope": "@webassemblyjs", + "rawSpec": "1.9.0", + "saveSpec": null, + "fetchSpec": "1.9.0" + }, + "_requiredBy": [ + "/@webassemblyjs/wasm-edit" + ], + "_resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.9.0.tgz", + "_shasum": "2211181e5b31326443cc8112eb9f0b9028721a61", + "_spec": "@webassemblyjs/wasm-opt@1.9.0", + "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/wasm-edit", + "author": { + "name": "Sven Sauleau" + }, + "bugs": { + "url": "https://github.com/xtuc/webassemblyjs/issues" + }, + "bundleDependencies": false, + "dependencies": { + "@webassemblyjs/ast": "1.9.0", + "@webassemblyjs/helper-buffer": "1.9.0", + "@webassemblyjs/wasm-gen": "1.9.0", + "@webassemblyjs/wasm-parser": "1.9.0" + }, + "deprecated": false, + "description": "", + "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", + "homepage": "https://github.com/xtuc/webassemblyjs#readme", + "license": "MIT", + "main": "lib/index.js", + "module": "esm/index.js", + "name": "@webassemblyjs/wasm-opt", + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/xtuc/webassemblyjs.git" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "version": "1.9.0" +} |