Skip to content
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

Finalize signatures & names when no function bodies #669

Merged
merged 2 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions lib/runtime-core/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ pub fn read_module<

let mut namespace_builder = Some(StringTableBuilder::new());
let mut name_builder = Some(StringTableBuilder::new());
let mut func_count: usize = ::std::usize::MAX;
let mut func_count: usize = 0;
let mut mcg_info_fed = false;

loop {
use wasmparser::ParserState;
Expand Down Expand Up @@ -196,9 +197,9 @@ pub fn read_module<
info.write().unwrap().start_func = Some(FuncIndex::new(start_index as usize));
}
ParserState::BeginFunctionBody { .. } => {
let id = func_count.wrapping_add(1);
func_count = id;
if func_count == 0 {
let id = func_count;
if !mcg_info_fed {
mcg_info_fed = true;
info.write().unwrap().namespace_table =
namespace_builder.take().unwrap().finish();
info.write().unwrap().name_table = name_builder.take().unwrap().finish();
Expand Down Expand Up @@ -279,6 +280,7 @@ pub fn read_module<
.map_err(|x| LoadError::Codegen(x))?;
fcg.finalize()
.map_err(|x| LoadError::Codegen(format!("{:?}", x)))?;
func_count = func_count.wrapping_add(1);
}
ParserState::BeginActiveElementSectionEntry(table_index) => {
let table_index = TableIndex::new(table_index as usize);
Expand Down Expand Up @@ -369,12 +371,17 @@ pub fn read_module<
info.write().unwrap().globals.push(global_init);
}
ParserState::EndWasm => {
if namespace_builder.is_some() {
// TODO Consolidate with BeginFunction body if possible
if !mcg_info_fed {
info.write().unwrap().namespace_table =
namespace_builder.take().unwrap().finish();
}
if name_builder.is_some() {
info.write().unwrap().name_table = name_builder.take().unwrap().finish();
mcg.feed_signatures(info.read().unwrap().signatures.clone())
.map_err(|x| LoadError::Codegen(format!("{:?}", x)))?;
mcg.feed_function_signatures(info.read().unwrap().func_assoc.clone())
.map_err(|x| LoadError::Codegen(format!("{:?}", x)))?;
mcg.check_precondition(&info.read().unwrap())
.map_err(|x| LoadError::Codegen(format!("{:?}", x)))?;
}
break;
}
Expand Down
56 changes: 6 additions & 50 deletions lib/spectests/tests/excludes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -827,58 +827,16 @@ llvm:skip:skip-stack-guard-page.wast:* # Spec running forever or (signal: 4, SIG
llvm:skip:linking.wast:236 # terminating with uncaught exception of type WasmTrap
llvm:skip:linking.wast:248 # terminating with uncaught exception of type WasmTrap

llvm:fail:binary-leb128.wast:56 # Module - caught panic Any
llvm:fail:binary-leb128.wast:65 # Module - caught panic Any
llvm:fail:binary-leb128.wast:74 # Module - caught panic Any
llvm:fail:binary-leb128.wast:86 # Module - caught panic Any
llvm:fail:binary-leb128.wast:98 # Module - caught panic Any
llvm:fail:binary.wast:446 # Module - caught panic Any
llvm:fail:globals.wast:243 # AssertInvalid - caught panic Any
llvm:fail:i32.wast:243 # AssertReturn - result I32(205242703) ("0xc3bc14f") does not match expected I32(32) ("0x20")
llvm:fail:i32.wast:252 # AssertReturn - result I32(205242720) ("0xc3bc160") does not match expected I32(32) ("0x20")
llvm:fail:i64.wast:243 # AssertReturn - result I64(4500210159) ("0x10c3bc1ef") does not match expected I64(64) ("0x40")
llvm:fail:i64.wast:252 # AssertReturn - result I64(4500210144) ("0x10c3bc1e0") does not match expected I64(64) ("0x40")
llvm:fail:imports.wast:98 # Module - caught panic Any
llvm:fail:imports.wast:99 # Module - caught panic Any
llvm:fail:imports.wast:100 # Module - caught panic Any
llvm:fail:imports.wast:101 # Module - caught panic Any
llvm:fail:imports.wast:102 # Module - caught panic Any
llvm:fail:imports.wast:103 # Module - caught panic Any
llvm:fail:imports.wast:104 # Module - caught panic Any
llvm:fail:imports.wast:107 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:111 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:116 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:120 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:124 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:128 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:132 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:136 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:140 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:144 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:148 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:152 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:156 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:160 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:164 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:168 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:172 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:176 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:181 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:185 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:189 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:193 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:197 # AssertUnlinkable - caught panic Any
llvm:fail:imports.wast:201 # AssertUnlinkable - caught panic Any
llvm:fail:i32.wast:243 # AssertReturn - result I32(61374799) ("0x3a8814f") does not match expected I32(32) ("0x20")
llvm:fail:i32.wast:252 # AssertReturn - result I32(61374816) ("0x3a88160") does not match expected I32(32) ("0x20")
llvm:fail:i64.wast:243 # AssertReturn - result I64(4356342255) ("0x103a881ef") does not match expected I64(64) ("0x40")
llvm:fail:i64.wast:252 # AssertReturn - result I64(4356342240) ("0x103a881e0") does not match expected I64(64) ("0x40")
llvm:fail:imports.wast:491 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" }
llvm:fail:imports.wast:492 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" }
llvm:fail:imports.wast:493 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" }
llvm:fail:imports.wast:494 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" }
llvm:fail:imports.wast:495 # AssertReturn - Call failed ResolveError: ExportNotFound { name: "grow" }
llvm:fail:imports.wast:574 # AssertUnlinkable - caught panic Any
llvm:fail:linking.wast:22 # Module - caught panic Any
llvm:fail:linking.wast:26 # Register - No instance available
llvm:fail:linking.wast:28 # AssertUnlinkable - caught panic Any
llvm:fail:linking.wast:32 # AssertUnlinkable - caught panic Any
llvm:fail:linking.wast:314 # AssertReturn - No instance available: Some("$Pm")
llvm:fail:linking.wast:315 # AssertReturn - No instance available: Some("$Pm")
llvm:fail:linking.wast:316 # AssertReturn - No instance available: Some("$Pm")
Expand All @@ -887,12 +845,10 @@ llvm:fail:linking.wast:318 # AssertReturn - No instance available: Some("$Pm")
llvm:fail:linking.wast:319 # AssertReturn - No instance available: Some("$Pm")
llvm:fail:linking.wast:320 # AssertReturn - No instance available: Some("$Pm")
llvm:fail:linking.wast:321 # AssertReturn - No instance available: Some("$Pm")
llvm:fail:linking.wast:324 # AssertUnlinkable - caught panic Any
llvm:fail:linking.wast:387 # AssertReturn - result I32(0) ("0x0") does not match expected I32(104) ("0x68")
llvm:fail:linking.wast:388 # AssertReturn - Call failed RuntimeError: WebAssembly trap occurred during runtime: incorrect `call_indirect` signature
llvm:fail:load.wast:201 # AssertReturn - result I32(205795359) ("0xc44301f") does not match expected I32(32) ("0x20")
llvm:fail:start.wast:92 # Module - caught panic Any
llvm:fail:type.wast:3 # Module - caught panic Any
llvm:fail:load.wast:201 # AssertReturn - result I32(66175007) ("0x3f1c01f") does not match expected I32(32) ("0x20")


# LLVM Windows
llvm:skip:address.wast:*:windows
Expand Down