diff options
author | Heejin Ahn <aheejin@gmail.com> | 2018-11-14 02:46:21 +0000 |
---|---|---|
committer | Heejin Ahn <aheejin@gmail.com> | 2018-11-14 02:46:21 +0000 |
commit | da419bdb5e3e167ea90c6923660059f35fa17d67 (patch) | |
tree | 0264ae56ecdddf59399c2b355e1dee8eeffafb63 /llvm/lib/ObjectYAML/WasmYAML.cpp | |
parent | 6a3c279d1cdcd4205a233952b4bacd5941cd355e (diff) | |
download | bcm5719-llvm-da419bdb5e3e167ea90c6923660059f35fa17d67.tar.gz bcm5719-llvm-da419bdb5e3e167ea90c6923660059f35fa17d67.zip |
[WebAssembly] Add support for the event section
Summary:
This adds support for the 'event section' specified in the exception
handling proposal. (This was named 'exception section' first, but later
renamed to 'event section' to take possibilities of other kinds of
events into consideration. But currently we only store exception info in
this section.)
The event section is added between the global section and the export
section. This is for ease of validation per request of the V8 team.
This patch:
- Creates the event symbol type, which is a weak symbol
- Makes 'throw' instruction take the event symbol '__cpp_exception'
- Adds relocation support for events
- Adds WasmObjectWriter / WasmObjectFile (Reader) support
- Adds obj2yaml / yaml2obj support
- Adds '.eventtype' printing support
Reviewers: dschuff, sbc100, aardappel
Subscribers: jgravelle-google, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D54096
llvm-svn: 346825
Diffstat (limited to 'llvm/lib/ObjectYAML/WasmYAML.cpp')
-rw-r--r-- | llvm/lib/ObjectYAML/WasmYAML.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/ObjectYAML/WasmYAML.cpp b/llvm/lib/ObjectYAML/WasmYAML.cpp index dba950af589..610507cf7f0 100644 --- a/llvm/lib/ObjectYAML/WasmYAML.cpp +++ b/llvm/lib/ObjectYAML/WasmYAML.cpp @@ -100,6 +100,11 @@ static void sectionMapping(IO &IO, WasmYAML::GlobalSection &Section) { IO.mapOptional("Globals", Section.Globals); } +static void sectionMapping(IO &IO, WasmYAML::EventSection &Section) { + commonSectionMapping(IO, Section); + IO.mapOptional("Events", Section.Events); +} + static void sectionMapping(IO &IO, WasmYAML::ExportSection &Section) { commonSectionMapping(IO, Section); IO.mapOptional("Exports", Section.Exports); @@ -187,6 +192,11 @@ void MappingTraits<std::unique_ptr<WasmYAML::Section>>::mapping( Section.reset(new WasmYAML::GlobalSection()); sectionMapping(IO, *cast<WasmYAML::GlobalSection>(Section.get())); break; + case wasm::WASM_SEC_EVENT: + if (!IO.outputting()) + Section.reset(new WasmYAML::EventSection()); + sectionMapping(IO, *cast<WasmYAML::EventSection>(Section.get())); + break; case wasm::WASM_SEC_EXPORT: if (!IO.outputting()) Section.reset(new WasmYAML::ExportSection()); @@ -227,6 +237,7 @@ void ScalarEnumerationTraits<WasmYAML::SectionType>::enumeration( ECase(TABLE); ECase(MEMORY); ECase(GLOBAL); + ECase(EVENT); ECase(EXPORT); ECase(START); ECase(ELEM); @@ -307,6 +318,9 @@ void MappingTraits<WasmYAML::Import>::mapping(IO &IO, } else if (Import.Kind == wasm::WASM_EXTERNAL_GLOBAL) { IO.mapRequired("GlobalType", Import.GlobalImport.Type); IO.mapRequired("GlobalMutable", Import.GlobalImport.Mutable); + } else if (Import.Kind == wasm::WASM_EXTERNAL_EVENT) { + IO.mapRequired("EventAttribute", Import.EventImport.Attribute); + IO.mapRequired("EventSigIndex", Import.EventImport.SigIndex); } else if (Import.Kind == wasm::WASM_EXTERNAL_TABLE) { IO.mapRequired("Table", Import.TableImport); } else if (Import.Kind == wasm::WASM_EXTERNAL_MEMORY) { @@ -399,6 +413,8 @@ void MappingTraits<WasmYAML::SymbolInfo>::mapping(IO &IO, IO.mapRequired("Function", Info.ElementIndex); } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_GLOBAL) { IO.mapRequired("Global", Info.ElementIndex); + } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_EVENT) { + IO.mapRequired("Event", Info.ElementIndex); } else if (Info.Kind == wasm::WASM_SYMBOL_TYPE_DATA) { if ((Info.Flags & wasm::WASM_SYMBOL_UNDEFINED) == 0) { IO.mapRequired("Segment", Info.DataRef.Segment); @@ -412,6 +428,12 @@ void MappingTraits<WasmYAML::SymbolInfo>::mapping(IO &IO, } } +void MappingTraits<WasmYAML::Event>::mapping(IO &IO, WasmYAML::Event &Event) { + IO.mapRequired("Index", Event.Index); + IO.mapRequired("Attribute", Event.Attribute); + IO.mapRequired("SigIndex", Event.SigIndex); +} + void ScalarBitSetTraits<WasmYAML::LimitFlags>::bitset( IO &IO, WasmYAML::LimitFlags &Value) { #define BCase(X) IO.bitSetCase(Value, #X, wasm::WASM_LIMITS_FLAG_##X) @@ -443,6 +465,7 @@ void ScalarEnumerationTraits<WasmYAML::SymbolKind>::enumeration( ECase(DATA); ECase(GLOBAL); ECase(SECTION); + ECase(EVENT); #undef ECase } @@ -467,6 +490,7 @@ void ScalarEnumerationTraits<WasmYAML::ExportKind>::enumeration( ECase(TABLE); ECase(MEMORY); ECase(GLOBAL); + ECase(EVENT); #undef ECase } |