Skip to content

Commit

Permalink
Revert "[gc] Fix typecheck for element initializations"
Browse files Browse the repository at this point in the history
This reverts commit 3328e73.
  • Loading branch information
titzer committed Sep 18, 2024
1 parent 3328e73 commit 0a1a32e
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 51 deletions.
1 change: 1 addition & 0 deletions issues.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Prio Component Issue
gc Final types
gc tests for binary iso-rec canonicalization
gc tests for verifying supertype decls
gc implement array.new_data, array.new_elem in init expressions
fast-int non-final subtyping check for call_indirect
spc non-final subtyping check for call_indirect

Expand Down
10 changes: 5 additions & 5 deletions src/engine/BinParser.v3
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,7 @@ class BinParser(extensions: Extension.set, limits: Limits, filename: string) ext
var t = parser.checkTableIndex(pt, 0);
var offset = readI32Expr("elements offset");
mode = SegmentMode.Active(t.1, offset);
var vt = ValueTypes.FUNCREF;
checkElemsType(pt, t.0, vt);
var vt = if(t.0 != null, t.0.elemtype, ValueTypes.FUNCREF);
details = readElemInitExprs(vt);
}
5 => {
Expand Down Expand Up @@ -755,9 +754,10 @@ class BpFsm extends WasmParser {
}
private def advance() {
current_pos = decoder.pos;
if (Debug.binparse) {
Trace.OUT.put3("@+%d [%d bytes] BpFsm.state=%s", decoder.addr(),
decoder.available(), state.name).ln();
if (Trace.binparse) {
// TODO: this is debug code, not tracing code
// Trace.OUT.put3("@+%d [%d bytes] BpFsm.state=%s", decoder.addr(),
// decoder.available(), state.name).ln();
}
match (state) {
MAGIC => {
Expand Down
6 changes: 4 additions & 2 deletions src/engine/CodeValidator.v3
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ class CodeValidator(extensions: Extension.set, limits: Limits, module: Module, e
}
STRUCT_NEW => {
if (noGC(opcode)) return;
constExpr = true;
constExpr = true; // TODO: only if fields are immutable?
var st = parser.readStructType();
if (st == null) return;
checkAndPopFields(st.field_types);
Expand All @@ -637,7 +637,7 @@ class CodeValidator(extensions: Extension.set, limits: Limits, module: Module, e
}
STRUCT_NEW_DEFAULT => {
if (noGC(opcode)) return;
constExpr = true;
constExpr = true; // TODO: only if fields are immutable?
var st = parser.readStructType();
if (st == null) return;
var stt = ValueTypes.RefStruct(false, st);
Expand Down Expand Up @@ -815,6 +815,7 @@ class CodeValidator(extensions: Extension.set, limits: Limits, module: Module, e
}
ARRAY_NEW_DATA => {
if (noGC(opcode)) return;
constExpr = true; // TODO: only if elem is immutable?
var at = parser.readArrayType();
if (at == null) return;
var index = parser.readDataIndex();
Expand All @@ -830,6 +831,7 @@ class CodeValidator(extensions: Extension.set, limits: Limits, module: Module, e
}
ARRAY_NEW_ELEM => {
if (noGC(opcode)) return;
constExpr = true; // TODO: only if elem is immutable?
var at = parser.readArrayType();
if (at == null) return;
var elem = parser.readElemRef();
Expand Down
1 change: 0 additions & 1 deletion src/engine/Debug.v3
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ component Debug {
def paranoid = false;
def verbose = false;
def interpreter = false;
def binparse = false;
def runtime = false;
def compiler = false;
def pregen = false;
Expand Down
10 changes: 0 additions & 10 deletions test/regress/ext:gc/elem0.bin.wast

This file was deleted.

8 changes: 0 additions & 8 deletions test/regress/ext:gc/elem0.wast

This file was deleted.

36 changes: 18 additions & 18 deletions test/regress/ext:gc/type-subtyping.bin.wast
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
"\03\05\66\61\69\6c\31\00\04\05\66\61\69\6c\32\00"
"\05\05\66\61\69\6c\33\00\06\05\66\61\69\6c\34\00"
"\07\05\66\61\69\6c\35\00\08\05\66\61\69\6c\36\00"
"\09\09\8f\80\80\80\00\01\04\41\00\0b\03\d2\00\0b"
"\d2\01\0b\d2\02\0b\0a\80\82\80\80\00\0a\84\80\80"
"\80\00\00\d0\70\0b\84\80\80\80\00\00\d0\01\0b\84"
"\80\80\80\00\00\d0\02\0b\f9\80\80\80\00\00\02\70"
"\41\00\11\00\00\0b\02\70\41\01\11\00\00\0b\02\70"
"\41\02\11\00\00\0b\02\63\01\41\01\11\01\00\0b\02"
"\63\01\41\02\11\01\00\0b\02\63\02\41\02\11\02\00"
"\0b\02\63\00\41\00\25\00\fb\16\00\0b\02\63\00\41"
"\01\25\00\fb\16\00\0b\02\63\00\41\02\25\00\fb\16"
"\00\0b\02\63\01\41\01\25\00\fb\16\01\0b\02\63\01"
"\41\02\25\00\fb\16\01\0b\02\63\02\41\02\25\00\fb"
"\16\02\0b\0c\00\0b\8d\80\80\80\00\00\02\63\01\41"
"\00\11\01\00\0b\0c\00\0b\8d\80\80\80\00\00\02\63"
"\01\41\00\11\02\00\0b\0c\00\0b\8d\80\80\80\00\00"
"\02\63\01\41\01\11\02\00\0b\0c\00\0b\8b\80\80\80"
"\00\00\41\00\25\00\fb\16\01\0c\00\0b\8b\80\80\80"
"\00\00\41\00\25\00\fb\16\02\0c\00\0b\8b\80\80\80"
"\00\00\41\01\25\00\fb\16\02\0c\00\0b"
"\09\09\91\80\80\80\00\01\06\00\41\00\0b\70\03\d2"
"\00\0b\d2\01\0b\d2\02\0b\0a\80\82\80\80\00\0a\84"
"\80\80\80\00\00\d0\70\0b\84\80\80\80\00\00\d0\01"
"\0b\84\80\80\80\00\00\d0\02\0b\f9\80\80\80\00\00"
"\02\70\41\00\11\00\00\0b\02\70\41\01\11\00\00\0b"
"\02\70\41\02\11\00\00\0b\02\63\01\41\01\11\01\00"
"\0b\02\63\01\41\02\11\01\00\0b\02\63\02\41\02\11"
"\02\00\0b\02\63\00\41\00\25\00\fb\16\00\0b\02\63"
"\00\41\01\25\00\fb\16\00\0b\02\63\00\41\02\25\00"
"\fb\16\00\0b\02\63\01\41\01\25\00\fb\16\01\0b\02"
"\63\01\41\02\25\00\fb\16\01\0b\02\63\02\41\02\25"
"\00\fb\16\02\0b\0c\00\0b\8d\80\80\80\00\00\02\63"
"\01\41\00\11\01\00\0b\0c\00\0b\8d\80\80\80\00\00"
"\02\63\01\41\00\11\02\00\0b\0c\00\0b\8d\80\80\80"
"\00\00\02\63\01\41\01\11\02\00\0b\0c\00\0b\8b\80"
"\80\80\00\00\41\00\25\00\fb\16\01\0c\00\0b\8b\80"
"\80\80\00\00\41\00\25\00\fb\16\02\0c\00\0b\8b\80"
"\80\80\00\00\41\01\25\00\fb\16\02\0c\00\0b"
)
(assert_return (invoke "run"))
(assert_trap (invoke "fail1") "indirect call")
Expand Down
14 changes: 7 additions & 7 deletions test/regress/ext:gc/type-subtyping1.bin.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"\01\01\01\01\04\85\80\80\80\00\01\70\01\02\02\07"
"\a1\80\80\80\00\04\05\66\61\69\6c\31\00\02\05\66"
"\61\69\6c\32\00\03\05\66\61\69\6c\33\00\04\05\66"
"\61\69\6c\34\00\05\09\8c\80\80\80\00\01\04\41\00"
"\0b\02\d2\00\0b\d2\01\0b\0a\cb\80\80\80\00\06\82"
"\80\80\80\00\00\0b\82\80\80\80\00\00\0b\8a\80\80"
"\80\00\00\02\40\41\01\11\00\00\0b\0b\8a\80\80\80"
"\00\00\02\40\41\00\11\01\00\0b\0b\8a\80\80\80\00"
"\00\41\01\25\00\fb\16\00\1a\0b\8a\80\80\80\00\00"
"\41\00\25\00\fb\16\01\1a\0b"
"\61\69\6c\34\00\05\09\8e\80\80\80\00\01\06\00\41"
"\00\0b\70\02\d2\00\0b\d2\01\0b\0a\cb\80\80\80\00"
"\06\82\80\80\80\00\00\0b\82\80\80\80\00\00\0b\8a"
"\80\80\80\00\00\02\40\41\01\11\00\00\0b\0b\8a\80"
"\80\80\00\00\02\40\41\00\11\01\00\0b\0b\8a\80\80"
"\80\00\00\41\01\25\00\fb\16\00\1a\0b\8a\80\80\80"
"\00\00\41\00\25\00\fb\16\01\1a\0b"
)
(assert_trap (invoke "fail1") "indirect call")
(assert_trap (invoke "fail2") "indirect call")
Expand Down

0 comments on commit 0a1a32e

Please sign in to comment.