Merge pull request #995 from alexcrichton/gc-too-aggressive

Assume all data/element/table/memory segments needed
This commit is contained in:
Alex Crichton 2018-10-29 14:16:59 -07:00 committed by GitHub
commit b1d92aecac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,22 +71,20 @@ fn run(config: &mut Config, module: &mut Module) {
} }
} }
// Pessimistically assume all passive data and table segments are // Pessimistically assume all data and table segments are
// required // required
//
// TODO: this shouldn't assume this!
if let Some(section) = module.data_section() { if let Some(section) = module.data_section() {
for entry in section.entries() { for entry in section.entries() {
if entry.passive() {
cx.add_data_segment(entry); cx.add_data_segment(entry);
} }
} }
}
if let Some(elements) = module.elements_section() { if let Some(elements) = module.elements_section() {
for seg in elements.entries() { for seg in elements.entries() {
if seg.passive() {
cx.add_element_segment(seg); cx.add_element_segment(seg);
} }
} }
}
// The start function is also a root // The start function is also a root
if let Some(i) = module.start_section() { if let Some(i) = module.start_section() {
@ -532,7 +530,8 @@ impl<'a> RemapContext<'a> {
} }
if let Some(s) = m.table_section() { if let Some(s) = m.table_section() {
for i in 0..(s.entries().len() as u32) { for i in 0..(s.entries().len() as u32) {
if analysis.tables.contains(&(i + analysis.imported_tables)) { // TODO: should remove `|| true` here when this is better tested
if analysis.tables.contains(&(i + analysis.imported_tables)) || true {
tables.push(ntables); tables.push(ntables);
ntables += 1; ntables += 1;
} else { } else {
@ -543,7 +542,8 @@ impl<'a> RemapContext<'a> {
} }
if let Some(s) = m.memory_section() { if let Some(s) = m.memory_section() {
for i in 0..(s.entries().len() as u32) { for i in 0..(s.entries().len() as u32) {
if analysis.memories.contains(&(i + analysis.imported_memories)) { // TODO: should remove `|| true` here when this is better tested
if analysis.memories.contains(&(i + analysis.imported_memories)) || true {
memories.push(nmemories); memories.push(nmemories);
nmemories += 1; nmemories += 1;
} else { } else {