Skip to content

Commit 1868f2e

Browse files
authored
Validate modules by default (AssemblyScript#1258)
1 parent 2864286 commit 1868f2e

File tree

16 files changed

+32
-36
lines changed

16 files changed

+32
-36
lines changed

bin/asinit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ function ensureGitignore() {
249249
function ensurePackageJson() {
250250
console.log("- Making sure that 'package.json' contains the build commands...")
251251
const entryPath = path.relative(projectDir, entryFile).replace(/\\/g, "/");
252-
const buildUntouched = "asc " + entryPath + " -b build/untouched.wasm -t build/untouched.wat --validate --sourceMap --debug";
253-
const buildOptimized = "asc " + entryPath + " -b build/optimized.wasm -t build/optimized.wat --validate --sourceMap --optimize";
252+
const buildUntouched = "asc " + entryPath + " -b build/untouched.wasm -t build/untouched.wat --sourceMap --debug";
253+
const buildOptimized = "asc " + entryPath + " -b build/optimized.wasm -t build/optimized.wat --sourceMap --optimize";
254254
const buildAll = "npm run asbuild:untouched && npm run asbuild:optimized";
255255
if (!fs.existsSync(packageFile)) {
256256
fs.writeFileSync(packageFile, JSON.stringify({

cli/asc.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ interface CompilerOptions {
6969
shrinkLevel?: number;
7070
/** Re-optimizes until no further improvements can be made. */
7171
converge?: boolean;
72-
/** Validates the module using Binaryen. Exits if invalid. */
73-
validate?: boolean;
7472
/** Specifies the base directory of input and output files. */
7573
baseDir?: string;
7674
/** Specifies the output file. File extension indicates format. */
@@ -119,6 +117,8 @@ interface CompilerOptions {
119117
trapMode?: "allow" | "clamp" | "js";
120118
/** Specifies additional Binaryen passes to run. */
121119
runPasses?: string | string[];
120+
/** Skips validating the module using Binaryen. */
121+
noValidate?: boolean;
122122
/** Enables WebAssembly features that are disabled by default. */
123123
enable?: string | string[];
124124
/** Disables WebAssembly features that are enabled by default. */

cli/asc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ exports.main = function main(argv, options, callback) {
638638
}
639639

640640
// Validate the module if requested
641-
if (args.validate) {
641+
if (!args.noValidate) {
642642
stats.validateCount++;
643643
stats.validateTime += measure(() => {
644644
if (!module.validate()) {

cli/asc.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,6 @@
218218
"type": "S"
219219
},
220220

221-
"validate": {
222-
"category": "Binaryen",
223-
"description": "Validates the module using Binaryen. Exits if invalid.",
224-
"type": "b",
225-
"alias": "c",
226-
"default": false
227-
},
228221
"trapMode": {
229222
"category": "Binaryen",
230223
"description": [
@@ -246,6 +239,13 @@
246239
],
247240
"type": "s"
248241
},
242+
"noValidate": {
243+
"category": "Binaryen",
244+
"description": "Skips validating the module using Binaryen.",
245+
"type": "b",
246+
"alias": "c",
247+
"default": false
248+
},
249249

250250
"baseDir": {
251251
"description": "Specifies the base directory of input and output files.",

lib/parse/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"types": "index.d.ts",
77
"scripts": {
8-
"asbuild": "asc assembly/index.ts -O3 -b build/index.wasm -t build/index.wat --importMemory --runtime none --sourceMap --validate",
8+
"asbuild": "asc assembly/index.ts -O3 -b build/index.wasm -t build/index.wat --importMemory --runtime none --sourceMap",
99
"build": "npm run asbuild && webpack --mode production --display-modules",
1010
"test": "ts-node tests/"
1111
},

lib/webpack/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ function compile() {
2323
"--baseDir", path.dirname(this.resourcePath),
2424
"--binaryFile", basePath + ".wasm",
2525
"--textFile", basePath + ".wat",
26-
"--validate",
2726
"--optimize"
2827
];
2928
if (this.sourceMap)

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
"prepublishOnly": "node scripts/prepublish",
6767
"postpublish": "node scripts/postpublish",
6868
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized",
69-
"asbuild:untouched": "node bin/asc src/glue/wasm/index.ts src/index.ts -t out/assemblyscript.untouched.wat -b out/assemblyscript.untouched.wasm -d out/assemblyscript.d.ts --validate --debug --measure --runtime stub",
70-
"asbuild:optimized": "node bin/asc src/glue/wasm/index.ts src/index.ts -t out/assemblyscript.optimized.wat -b out/assemblyscript.optimized.wasm -O3 --validate --measure --runtime stub",
69+
"asbuild:untouched": "node bin/asc src/glue/wasm/index.ts src/index.ts -t out/assemblyscript.untouched.wat -b out/assemblyscript.untouched.wasm -d out/assemblyscript.d.ts --debug --measure --runtime stub",
70+
"asbuild:optimized": "node bin/asc src/glue/wasm/index.ts src/index.ts -t out/assemblyscript.optimized.wat -b out/assemblyscript.optimized.wasm -O3 --measure --runtime stub",
7171
"astest": "ts-node tests/bootstrap"
7272
},
7373
"releaseFiles": [

tests/allocators/buddy/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"scripts": {
44
"build": "npm run build:untouched && npm run build:optimized",
5-
"build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime none --validate --sourceMap --measure",
6-
"build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime none --validate --sourceMap --measure --noAssert --optimize"
5+
"build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime none --sourceMap --measure",
6+
"build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime none --sourceMap --measure --noAssert --optimize"
77
}
88
}

tests/allocators/rt-full/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"scripts": {
44
"build": "npm run build:untouched && npm run build:optimized",
5-
"build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime full --validate --sourceMap --measure",
6-
"build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime full --validate --sourceMap --measure --noAssert --optimize"
5+
"build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime full --sourceMap --measure",
6+
"build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime full --sourceMap --measure --noAssert --optimize"
77
}
88
}

tests/allocators/rt-stub/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"scripts": {
44
"build": "npm run build:untouched && npm run build:optimized",
5-
"build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime stub --validate --sourceMap --measure",
6-
"build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime stub --validate --sourceMap --measure --noAssert --optimize"
5+
"build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime stub --sourceMap --measure",
6+
"build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime stub --sourceMap --measure --noAssert --optimize"
77
}
88
}

tests/compiler.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ function runTest(basename) {
145145
var cmd = [
146146
basename + ".ts",
147147
"--baseDir", basedir,
148-
"--validate",
149148
"--measure",
150149
"--debug",
151150
"--pedantic",
@@ -224,7 +223,6 @@ function runTest(basename) {
224223
var cmd = [
225224
basename + ".ts",
226225
"--baseDir", basedir,
227-
"--validate",
228226
"--measure",
229227
"--pedantic",
230228
"--binaryFile", // -> stdout

tests/compiler/features/simd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// hint: asc tests/compiler/simd --enable simd --validate
1+
// hint: asc tests/compiler/simd --enable simd
22

33
function test_v128(): void {
44
// equality and inequality

tests/compiler/std/simd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// hint: asc tests/compiler/std/simd --enable simd --validate
1+
// hint: asc tests/compiler/std/simd --enable simd
22

33
@final
44
class I8x16 {

tests/packages/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"scripts": {
33
"test": "npm run a && npm run b && npm run c && npm run d && npm run e && npm run f && npm run g && npm run as && npm run h",
4-
"a": "cd ./packages/a && node ../../../../bin/asc assembly/index.ts --noEmit --runtime stub --validate",
5-
"as": "cd ./packages/as && node ../../../../bin/asc as/index.ts --noEmit --runtime stub --validate",
4+
"a": "cd ./packages/a && node ../../../../bin/asc assembly/index.ts --noEmit --runtime stub",
5+
"as": "cd ./packages/as && node ../../../../bin/asc as/index.ts --noEmit --runtime stub",
66
"b": "cd ./packages/b && node ../../../../bin/asc assembly/index.ts --noEmit --runtime stub && node ../../../../bin/asc assembly/index.ts --noEmit --runtime stub --listFiles",
7-
"c": "cd ./packages/c && node ../../../../bin/asc assembly/index.ts --noEmit --runtime stub --validate",
8-
"d": "cd ./packages/d && node ../../../../bin/asc assembly/index.ts --path packages --noEmit --runtime stub --validate --traceResolution",
9-
"e": "cd ./packages/d/packages/e && node ../../../../../../bin/asc assembly/index.ts --noEmit --runtime stub --validate",
10-
"f": "cd ./packages/d/packages/e/packages/f && node ../../../../../../../../bin/asc assembly/index.ts --noEmit --runtime stub --validate",
7+
"c": "cd ./packages/c && node ../../../../bin/asc assembly/index.ts --noEmit --runtime stub",
8+
"d": "cd ./packages/d && node ../../../../bin/asc assembly/index.ts --path packages --noEmit --runtime stub --traceResolution",
9+
"e": "cd ./packages/d/packages/e && node ../../../../../../bin/asc assembly/index.ts --noEmit --runtime stub",
10+
"f": "cd ./packages/d/packages/e/packages/f && node ../../../../../../../../bin/asc assembly/index.ts --noEmit --runtime stub",
1111
"g": "cd ./packages/g && node test.js",
12-
"h": "cd ./packages/h && node ../../../../bin/asc assembly/index.ts --noEmit --runtime none --validate --traceResolution"
12+
"h": "cd ./packages/h && node ../../../../bin/asc assembly/index.ts --noEmit --runtime none --traceResolution"
1313
},
1414
"author": "Willem Wyndham",
1515
"license": "Apache-2.0"

tests/packages/packages/g/test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ let argv = [
55
"assembly/index.ts",
66
"--noEmit",
77
"--runtime", "stub",
8-
"--validate",
98
"--traceResolution"
109
];
1110

tests/runtime/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"scripts": {
44
"server": "http-server . -o -c-1",
55
"build": "npm run build:untouched && npm run build:optimized",
6-
"build:untouched": "node ../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime full --validate --sourceMap --measure",
7-
"build:optimized": "node ../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime full --validate --sourceMap --measure --noAssert --optimize"
6+
"build:untouched": "node ../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime full --sourceMap --measure",
7+
"build:optimized": "node ../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime full --sourceMap --measure --noAssert --optimize"
88
},
99
"devDependencies": {
1010
"http-server": "^0.11.1"

0 commit comments

Comments
 (0)