-
Notifications
You must be signed in to change notification settings - Fork 780
Fix v8 validation error in -O0 builds #897
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
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Module["asm"] = (function(global, env, buffer) { | ||
'almost asm'; | ||
|
||
var HEAP8 = new global.Int8Array(buffer); | ||
var HEAP16 = new global.Int16Array(buffer); | ||
var HEAP32 = new global.Int32Array(buffer); | ||
var HEAPU8 = new global.Uint8Array(buffer); | ||
var HEAPU16 = new global.Uint16Array(buffer); | ||
var HEAPU32 = new global.Uint32Array(buffer); | ||
var HEAPF32 = new global.Float32Array(buffer); | ||
var HEAPF64 = new global.Float64Array(buffer); | ||
|
||
var STACKTOP=env.STACKTOP|0; | ||
var STACK_MAX=env.STACK_MAX|0; | ||
|
||
var abortStackOverflow=env.abortStackOverflow; | ||
|
||
// when printing the full ast, we should see a |block i32| that | ||
// normal printing hides, but is crucial for validation | ||
function stackAlloc(size) { | ||
size = size|0; | ||
var ret = 0; | ||
ret = STACKTOP; | ||
STACKTOP = (STACKTOP + size)|0; | ||
STACKTOP = (STACKTOP + 15)&-16; | ||
if ((STACKTOP|0) >= (STACK_MAX|0)) abortStackOverflow(size|0); | ||
return ret|0; | ||
} | ||
|
||
return { stackAlloc: stackAlloc }; | ||
}) | ||
; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
(module | ||
(type $FUNCSIG$vi (func (param i32))) | ||
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) | ||
(import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32)) | ||
(import "env" "abortStackOverflow" (func $abortStackOverflow (param i32))) | ||
(import "env" "memory" (memory $0 256 256)) | ||
(import "env" "table" (table 0 0 anyfunc)) | ||
(import "env" "memoryBase" (global $memoryBase i32)) | ||
(import "env" "tableBase" (global $tableBase i32)) | ||
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import)) | ||
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import)) | ||
(data (get_global $memoryBase) "PRINT_FULL.asm.js") | ||
(export "stackAlloc" (func $stackAlloc)) | ||
(func $stackAlloc (param $0 i32) (result i32) | ||
(local $1 i32) | ||
[i32] [i32] (block i32 | ||
[none] (set_local $1 | ||
[i32] (get_global $STACKTOP) | ||
) | ||
[none] (set_global $STACKTOP | ||
[i32] (i32.add | ||
[i32] (get_global $STACKTOP) | ||
[i32] (get_local $0) | ||
) | ||
) | ||
[none] (set_global $STACKTOP | ||
[i32] (i32.and | ||
[i32] (i32.add | ||
[i32] (get_global $STACKTOP) | ||
[i32] (i32.const 15) | ||
) | ||
[i32] (i32.const -16) | ||
) | ||
) | ||
[none] (if | ||
[i32] (i32.ge_s | ||
[i32] (get_global $STACKTOP) | ||
[i32] (get_global $STACK_MAX) | ||
) | ||
[none] (call $abortStackOverflow | ||
[i32] (get_local $0) | ||
) | ||
) | ||
[i32] (get_local $1) | ||
) | ||
) | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
(module | ||
(type $FUNCSIG$vi (func (param i32))) | ||
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) | ||
(import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32)) | ||
(import "env" "abortStackOverflow" (func $abortStackOverflow (param i32))) | ||
(import "env" "memory" (memory $0 256 256)) | ||
(import "env" "table" (table 0 0 anyfunc)) | ||
(import "env" "memoryBase" (global $memoryBase i32)) | ||
(import "env" "tableBase" (global $tableBase i32)) | ||
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import)) | ||
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import)) | ||
(export "stackAlloc" (func $stackAlloc)) | ||
(func $stackAlloc (param $0 i32) (result i32) | ||
(local $1 i32) | ||
[i32] [i32] (block i32 | ||
[none] (set_local $1 | ||
[i32] (get_global $STACKTOP) | ||
) | ||
[none] (set_global $STACKTOP | ||
[i32] (i32.add | ||
[i32] (get_global $STACKTOP) | ||
[i32] (get_local $0) | ||
) | ||
) | ||
[none] (set_global $STACKTOP | ||
[i32] (i32.and | ||
[i32] (i32.add | ||
[i32] (get_global $STACKTOP) | ||
[i32] (i32.const 15) | ||
) | ||
[i32] (i32.const -16) | ||
) | ||
) | ||
[none] (if | ||
[i32] (i32.ge_s | ||
[i32] (get_global $STACKTOP) | ||
[i32] (get_global $STACK_MAX) | ||
) | ||
[none] (call $abortStackOverflow | ||
[i32] (get_local $0) | ||
) | ||
) | ||
[i32] (get_local $1) | ||
) | ||
) | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
(module | ||
(type $FUNCSIG$vi (func (param i32))) | ||
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) | ||
(import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32)) | ||
(import "env" "abortStackOverflow" (func $abortStackOverflow (param i32))) | ||
(import "env" "memory" (memory $0 256 256)) | ||
(import "env" "table" (table 0 0 anyfunc)) | ||
(import "env" "memoryBase" (global $memoryBase i32)) | ||
(import "env" "tableBase" (global $tableBase i32)) | ||
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import)) | ||
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import)) | ||
(export "stackAlloc" (func $stackAlloc)) | ||
(func $stackAlloc (param $size i32) (result i32) | ||
(local $ret i32) | ||
[i32] [i32] (block i32 | ||
[none] (set_local $ret | ||
[i32] (get_global $STACKTOP) | ||
) | ||
[none] (set_global $STACKTOP | ||
[i32] (i32.add | ||
[i32] (get_global $STACKTOP) | ||
[i32] (get_local $size) | ||
) | ||
) | ||
[none] (set_global $STACKTOP | ||
[i32] (i32.and | ||
[i32] (i32.add | ||
[i32] (get_global $STACKTOP) | ||
[i32] (i32.const 15) | ||
) | ||
[i32] (i32.const -16) | ||
) | ||
) | ||
[none] (if | ||
[i32] (i32.ge_s | ||
[i32] (get_global $STACKTOP) | ||
[i32] (get_global $STACK_MAX) | ||
) | ||
[none] (call $abortStackOverflow | ||
[i32] (get_local $size) | ||
) | ||
) | ||
[unreachable] (return | ||
[i32] (get_local $ret) | ||
) | ||
) | ||
) | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
(module | ||
(type $FUNCSIG$vi (func (param i32))) | ||
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) | ||
(import "env" "STACK_MAX" (global $STACK_MAX$asm2wasm$import i32)) | ||
(import "env" "abortStackOverflow" (func $abortStackOverflow (param i32))) | ||
(import "env" "memory" (memory $0 256 256)) | ||
(import "env" "table" (table 0 0 anyfunc)) | ||
(import "env" "memoryBase" (global $memoryBase i32)) | ||
(import "env" "tableBase" (global $tableBase i32)) | ||
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import)) | ||
(global $STACK_MAX (mut i32) (get_global $STACK_MAX$asm2wasm$import)) | ||
(export "stackAlloc" (func $stackAlloc)) | ||
(func $stackAlloc (param $size i32) (result i32) | ||
(local $ret i32) | ||
[i32] [i32] (block i32 | ||
[none] (set_local $ret | ||
[i32] (get_global $STACKTOP) | ||
) | ||
[none] (set_global $STACKTOP | ||
[i32] (i32.add | ||
[i32] (get_global $STACKTOP) | ||
[i32] (get_local $size) | ||
) | ||
) | ||
[none] (set_global $STACKTOP | ||
[i32] (i32.and | ||
[i32] (i32.add | ||
[i32] (get_global $STACKTOP) | ||
[i32] (i32.const 15) | ||
) | ||
[i32] (i32.const -16) | ||
) | ||
) | ||
[none] (if | ||
[i32] (i32.ge_s | ||
[i32] (get_global $STACKTOP) | ||
[i32] (get_global $STACK_MAX) | ||
) | ||
[none] (call $abortStackOverflow | ||
[i32] (get_local $size) | ||
) | ||
) | ||
[unreachable] (return | ||
[i32] (get_local $ret) | ||
) | ||
) | ||
) | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is adding a class of tests that can be ran with
BINARYEN_PRINT_FULL
set, then the test that this PR adds should have a name besides justPRINT_FULL.asm
, something likePRINT_FULL.unreachable_function_block_type.asm.js
I'd thinkThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I considered that, but instead I documented this in more detail in the test itself. i.e., we might have just one
PRINT_FULL
file with multiple small unit tests inside it eventually, with some text describing each one in the file. I prefer that because a filename isn't much room to go into detail. if i'm in the minority though i can change that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case why not have the test script only set this
if asm == 'PRINT_FULL.asm.js'
? That way the intent of multiple small tests in this one special file is documented by the code itself.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point, I wanted to keep my options open ;) In case we do want multiple files, this would mean we don't need to change anything.
Anyhow, I don't feel strongly about any of it. If you do, let me know what you'd prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't feel strongly enough about it to block
Actually a best-of-both-worlds thing would be to leave the
PRINT_FULL
substring check, and rename the test toPRINT_FULL_generic.asm.js
or something. That way both are reasonably-well supported, and it's more clear that generic tests go there.