Socket
Socket
Sign inDemoInstall

webassemblyjs

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webassemblyjs - npm Package Compare versions

Comparing version 1.2.5 to 1.2.6

12

lib/compiler/validation/func-result-type.js

@@ -8,2 +8,4 @@ "use strict";

var _errors = require("../../errors");
var _ast = require("@webassemblyjs/ast");

@@ -30,5 +32,11 @@

var node = _ref.node;
// Since only one return is allowed at the moment, we don't need to check
if (node.signature.type !== "Signature") {
throw new _errors.RuntimeError("Function signatures must be denormalised before execution");
}
var signature = node.signature; // Since only one return is allowed at the moment, we don't need to check
// them all.
var resultType = node.result;
var resultType = signature.results;
var inferedResultType = getType(node.body); // Type is unknown, we can not verify the result type

@@ -35,0 +43,0 @@

11

lib/interpreter/host-func.js

@@ -28,3 +28,4 @@ "use strict";

function createHostfunc(moduleinst, exportinst, allocator, _ref) {
var checkForI64InSignature = _ref.checkForI64InSignature;
var checkForI64InSignature = _ref.checkForI64InSignature,
returnStackLocal = _ref.returnStackLocal;
return function hostfunc() {

@@ -130,10 +131,14 @@ var exportinstAddr = exportinst.value.addr;

return executeStackFrameAndGetResult(stackFrame);
return executeStackFrameAndGetResult(stackFrame, returnStackLocal);
};
}
function executeStackFrameAndGetResult(stackFrame) {
function executeStackFrameAndGetResult(stackFrame, returnStackLocal) {
try {
var res = executeStackFrame(stackFrame);
if (returnStackLocal === true) {
return res;
}
if (res != null && res.value != null) {

@@ -140,0 +145,0 @@ return res.value.toNumber();

@@ -65,3 +65,4 @@ "use strict";

var internalInstanceOptions = {
checkForI64InSignature: true
checkForI64InSignature: true,
returnStackLocal: false
};

@@ -107,3 +108,7 @@

_this.exports[exportinst.name] = globalinst.value.toNumber();
if (internalInstanceOptions.returnStackLocal === true) {
_this.exports[exportinst.name] = globalinst;
} else {
_this.exports[exportinst.name] = globalinst.value.toNumber();
}
}

@@ -152,3 +157,5 @@

(0, _hostFunc.executeStackFrameAndGetResult)(stackFrame);
(0, _hostFunc.executeStackFrameAndGetResult)(stackFrame,
/* returnStackLocal */
true);
}

@@ -155,0 +162,0 @@ }]);

@@ -307,5 +307,9 @@ "use strict";

if (func.name.type === "Identifier") {
if (func.signature.type !== "Signature") {
throw newRuntimeError("Function signatures must be denormalised before execution");
}
frame.labels.push({
value: func,
arity: func.params.length,
arity: func.signature.params.length,
id: func.name

@@ -312,0 +316,0 @@ });

@@ -0,8 +1,18 @@

"use strict";
var _errors = require("../../../errors");
function createInstance(n, fromModule) {
// [param*, result*]
var type = [[], []];
n.params.forEach(function (param) {
if (n.signature.type !== "Signature") {
throw new _errors.RuntimeError("Function signatures must be denormalised before execution");
}
var signature = n.signature;
signature.params.forEach(function (param) {
type[0].push(param.valtype);
});
n.result.forEach(function (result) {
signature.results.forEach(function (result) {
type[1].push(result);

@@ -9,0 +19,0 @@ });

@@ -51,4 +51,4 @@ "use strict";

var element = getExternalElementOrThrow(node.module, node.name);
var params = descr.params != null ? descr.params : [];
var results = descr.results != null ? descr.results : [];
var params = descr.signature.params != null ? descr.signature.params : [];
var results = descr.signature.results != null ? descr.signature.results : [];
var externFuncinstance = externvalue.createFuncInstance(element, // $FlowIgnore

@@ -55,0 +55,0 @@ params, results);

{
"name": "webassemblyjs",
"version": "1.2.5",
"version": "1.2.6",
"keywords": [

@@ -21,9 +21,9 @@ "webassembly",

"dependencies": {
"@webassemblyjs/ast": "1.2.5",
"@webassemblyjs/wasm-parser": "1.2.5",
"@webassemblyjs/wast-parser": "1.2.5",
"@webassemblyjs/ast": "1.2.6",
"@webassemblyjs/wasm-parser": "1.2.6",
"@webassemblyjs/wast-parser": "1.2.6",
"long": "^3.2.0"
},
"devDependencies": {
"@webassemblyjs/floating-point-hex-parser": "1.2.5"
"@webassemblyjs/floating-point-hex-parser": "1.2.6"
},

@@ -30,0 +30,0 @@ "repository": {

// @flow
import { RuntimeError } from "../../errors";
import { traverse } from "@webassemblyjs/ast";

@@ -11,5 +11,12 @@ const { getType, typeEq } = require("./type-inference");

Func({ node }: NodePath<Func>) {
if (node.signature.type !== "Signature") {
throw new RuntimeError(
"Function signatures must be denormalised before execution"
);
}
const signature = (node.signature: Signature);
// Since only one return is allowed at the moment, we don't need to check
// them all.
const resultType = node.result;
const resultType = signature.results;

@@ -16,0 +23,0 @@ const inferedResultType = getType(node.body);

@@ -18,3 +18,3 @@ // @flow

allocator: Allocator,
{ checkForI64InSignature }: InternalInstanceOptions
{ checkForI64InSignature, returnStackLocal }: InternalInstanceOptions
): Hostfunc {

@@ -154,10 +154,17 @@ return function hostfunc(...args): ?any {

return executeStackFrameAndGetResult(stackFrame);
return executeStackFrameAndGetResult(stackFrame, returnStackLocal);
};
}
export function executeStackFrameAndGetResult(stackFrame: StackFrame): any {
export function executeStackFrameAndGetResult(
stackFrame: StackFrame,
returnStackLocal: boolean
): any {
try {
const res = executeStackFrame(stackFrame);
if (returnStackLocal === true) {
return res;
}
if (res != null && res.value != null) {

@@ -164,0 +171,0 @@ return res.value.toNumber();

@@ -45,3 +45,4 @@ // @flow

let internalInstanceOptions: InternalInstanceOptions = {
checkForI64InSignature: true
checkForI64InSignature: true,
returnStackLocal: false
};

@@ -98,3 +99,7 @@

this.exports[exportinst.name] = globalinst.value.toNumber();
if (internalInstanceOptions.returnStackLocal === true) {
this.exports[exportinst.name] = globalinst;
} else {
this.exports[exportinst.name] = globalinst.value.toNumber();
}
}

@@ -148,3 +153,3 @@

// Ignore the result
executeStackFrameAndGetResult(stackFrame);
executeStackFrameAndGetResult(stackFrame, /* returnStackLocal */ true);
}

@@ -151,0 +156,0 @@ }

@@ -306,5 +306,10 @@ // @flow

if (func.name.type === "Identifier") {
if (func.signature.type !== "Signature") {
throw newRuntimeError(
"Function signatures must be denormalised before execution"
);
}
frame.labels.push({
value: func,
arity: func.params.length,
arity: func.signature.params.length,
id: func.name

@@ -311,0 +316,0 @@ });

// @flow
import { RuntimeError } from "../../../errors";

@@ -7,7 +8,14 @@ function createInstance(n: Func, fromModule: ModuleInstance): FuncInstance {

n.params.forEach(param => {
if (n.signature.type !== "Signature") {
throw new RuntimeError(
"Function signatures must be denormalised before execution"
);
}
const signature = (n.signature: Signature);
signature.params.forEach(param => {
type[0].push(param.valtype);
});
n.result.forEach(result => {
signature.results.forEach(result => {
type[1].push(result);

@@ -14,0 +22,0 @@ });

@@ -41,4 +41,5 @@ // @flow

const params = descr.params != null ? descr.params : [];
const results = descr.results != null ? descr.results : [];
const params = descr.signature.params != null ? descr.signature.params : [];
const results =
descr.signature.results != null ? descr.signature.results : [];

@@ -45,0 +46,0 @@ const externFuncinstance = externvalue.createFuncInstance(

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc