From df8bcb1e929a0565ab476a327fac75b816870336 Mon Sep 17 00:00:00 2001 From: Pannous Date: Tue, 8 Nov 2022 23:40:38 +0100 Subject: [PATCH] --- .gitignore | 1 + playground/binary-writer-spec.cc | 652 ------------------ playground/binary-writer-spec.h | 64 -- playground/build-emcc.sh | 77 --- playground/build-wasi.sh | 92 --- playground/build-wasm-via-llc.sh | 77 --- playground/build-wasm-via-lld.sh | 59 -- playground/build-wasm.sh | 59 -- playground/build-wasp.sh | 86 --- playground/index.html | 91 --- playground/mark.kt | 250 ------- playground/t.decompile | 79 --- playground/t.dwarfdump | 256 ------- playground/t.llvm.objdump | 21 - playground/t.map | 1 - playground/t.objdump | 235 ------- playground/test-lld-wasm/README.md | 14 - playground/test-lld-wasm/compile-shared.sh | 19 - playground/test-lld-wasm/compile-via-wat.sh | 7 - playground/test-lld-wasm/compile.sh | 11 - playground/test-lld-wasm/lib.c | 3 - playground/test-lld-wasm/lib.rs | 6 - playground/test-lld-wasm/main.c | 5 - playground/test.wast copy | 15 - .../test_compile_wasm_to_c_to_native.sh | 4 - playground/utf.txt | 1 - playground/utf_ok_in_wasm_but_not_in_wat.txt | 11 - playground/wapm.lock | 35 - 28 files changed, 1 insertion(+), 2230 deletions(-) delete mode 100644 playground/binary-writer-spec.cc delete mode 100644 playground/binary-writer-spec.h delete mode 100644 playground/build-emcc.sh delete mode 100755 playground/build-wasi.sh delete mode 100755 playground/build-wasm-via-llc.sh delete mode 100755 playground/build-wasm-via-lld.sh delete mode 100755 playground/build-wasm.sh delete mode 100755 playground/build-wasp.sh delete mode 100644 playground/index.html delete mode 100644 playground/mark.kt delete mode 100644 playground/t.decompile delete mode 100644 playground/t.dwarfdump delete mode 100644 playground/t.llvm.objdump delete mode 100644 playground/t.map delete mode 100644 playground/t.objdump delete mode 100644 playground/test-lld-wasm/README.md delete mode 100644 playground/test-lld-wasm/compile-shared.sh delete mode 100644 playground/test-lld-wasm/compile-via-wat.sh delete mode 100644 playground/test-lld-wasm/compile.sh delete mode 100644 playground/test-lld-wasm/lib.c delete mode 100644 playground/test-lld-wasm/lib.rs delete mode 100644 playground/test-lld-wasm/main.c delete mode 100644 playground/test.wast copy delete mode 100755 playground/test_compile_wasm_to_c_to_native.sh delete mode 100644 playground/utf.txt delete mode 100644 playground/utf_ok_in_wasm_but_not_in_wat.txt delete mode 100644 playground/wapm.lock diff --git a/.gitignore b/.gitignore index 414ca295..0b162886 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,4 @@ xwabt /Testing/Temporary/ wasm-micro-runtime.me Frameworks +playground/ diff --git a/playground/binary-writer-spec.cc b/playground/binary-writer-spec.cc deleted file mode 100644 index a5b6cb71..00000000 --- a/playground/binary-writer-spec.cc +++ /dev/null @@ -1,652 +0,0 @@ -/* - * Copyright 2016 WebAssembly Community Group participants - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "binary-writer-spec.h" - -#include -#include - -#include "binary-writer.h" -#include "binary.h" -#include "cast.h" -//#include "filenames.h" -#include "ir.h" -#include "literal.h" -#include "stream.h" - -//#include "string-view.h" -const char *kWasmExtension = ".wasm"; -const char *kWatExtension = ".wat"; -namespace wabt { - - namespace { - - class BinaryWriterSpec { - public: - BinaryWriterSpec(Stream *json_stream, - WriteBinarySpecStreamFactory module_stream_factory, - string_view source_filename, - string_view module_filename_noext, - const WriteBinaryOptions &options); - - Result WriteScript(const Script &script); - - private: - std::string GetModuleFilename(const char *extension); - - void WriteString(const char *s); - - void WriteKey(const char *key); - - void WriteSeparator(); - - void WriteEscapedString(string_view); - - void WriteCommandType(const Command &command); - - void WriteLocation(const Location &loc); - - void WriteVar(const Var &var); - - void WriteTypeObject(Type type); - - void WriteF32(uint32_t, ExpectedNan); - - void WriteF64(uint64_t, ExpectedNan); - - void WriteRefBits(uintptr_t ref_bits); - - void WriteConst(const Const &const_); - - void WriteConstVector(const ConstVector &consts); - - void WriteAction(const Action &action); - - void WriteActionResultType(const Action &action); - - void WriteModule(string_view filename, const Module &module); - - void WriteScriptModule(string_view filename, - const ScriptModule &script_module); - - void WriteInvalidModule(const ScriptModule &module, string_view text); - - void WriteCommands(); - - const Script *script_ = nullptr; - Stream *json_stream_ = nullptr; - WriteBinarySpecStreamFactory module_stream_factory_; - std::string source_filename_; - std::string module_filename_noext_; - const WriteBinaryOptions &options_; - Result result_ = Result::Ok; - size_t num_modules_ = 0; - }; - - BinaryWriterSpec::BinaryWriterSpec( - Stream *json_stream, - WriteBinarySpecStreamFactory module_stream_factory, - string_view source_filename, - string_view module_filename_noext, - const WriteBinaryOptions &options) - : json_stream_(json_stream), - module_stream_factory_(module_stream_factory), - source_filename_(source_filename), - module_filename_noext_(module_filename_noext), - options_(options) {} - - std::string BinaryWriterSpec::GetModuleFilename(const char *extension) { - std::string result = module_filename_noext_; - result += '.'; - result += std::to_string(num_modules_); - result += extension; -// ConvertBackslashToSlash(&result); - return result; - } - - void BinaryWriterSpec::WriteString(const char *s) { - json_stream_->Writef("\"%s\"", s); - } - - void BinaryWriterSpec::WriteKey(const char *key) { - json_stream_->Writef("\"%s\": ", key); - } - - void BinaryWriterSpec::WriteSeparator() { - json_stream_->Writef(", "); - } - - void BinaryWriterSpec::WriteEscapedString(string_view s) { - json_stream_->WriteChar('"'); - for (size_t i = 0; i < s.length; ++i) { - uint8_t c = s[i]; - if (c < 0x20 || c == '\\' || c == '"') { - json_stream_->Writef("\\u%04x", c); - } else { - json_stream_->WriteChar(c); - } - } - json_stream_->WriteChar('"'); - } - - void BinaryWriterSpec::WriteCommandType(const Command &command) { - static const char *s_command_names[] = { - "module", - "action", - "register", - "assert_malformed", - "assert_invalid", - "assert_unlinkable", - "assert_uninstantiable", - "assert_return", - "assert_trap", - "assert_exhaustion", - }; -// WABT_STATIC_ASSERT(WABT_ARRAY_SIZE(s_command_names) == kCommandTypeCount); - - WriteKey("type"); - assert(s_command_names[static_cast(command.type)]); - WriteString(s_command_names[static_cast(command.type)]); - } - - void BinaryWriterSpec::WriteLocation(const Location &loc) { - WriteKey("line"); - json_stream_->Writef("%d", loc.line); - } - - void BinaryWriterSpec::WriteVar(const Var &var) { - if (var.is_index()) { - json_stream_->Writef("\"%" - PRIindex - "\"", var.index()); - } else { - WriteEscapedString(s(var.name())); - } - } - - void BinaryWriterSpec::WriteTypeObject(Type type) { - json_stream_->Writef("{"); - WriteKey("type"); - WriteString(type.GetName()); - json_stream_->Writef("}"); - } - - void BinaryWriterSpec::WriteF32(uint32_t f32_bits, ExpectedNan expected) { - switch (expected) { - case ExpectedNan::None: - json_stream_->Writef("\"%u\"", f32_bits); - break; - - case ExpectedNan::Arithmetic: - WriteString("nan:arithmetic"); - break; - - case ExpectedNan::Canonical: - WriteString("nan:canonical"); - break; - } - } - - void BinaryWriterSpec::WriteF64(uint64_t f64_bits, ExpectedNan expected) { - switch (expected) { - case ExpectedNan::None: - json_stream_->Writef("\"%" PRIu64 "\"", f64_bits); - break; - - case ExpectedNan::Arithmetic: - WriteString("nan:arithmetic"); - break; - - case ExpectedNan::Canonical: - WriteString("nan:canonical"); - break; - } - } - - void BinaryWriterSpec::WriteRefBits(uintptr_t ref_bits) { - if (ref_bits == Const::kRefNullBits) { - json_stream_->Writef("\"null\""); - } else { - json_stream_->Writef("\"%" PRIuPTR "\"", ref_bits); - } - } - - void BinaryWriterSpec::WriteConst(const Const &const_) { - json_stream_->Writef("{"); - WriteKey("type"); - - /* Always write the values as strings, even though they may be representable - * as JSON numbers. This way the formatting is consistent. */ - switch (const_.type()) { - case Type::I32: - WriteString("i32"); - WriteSeparator(); - WriteKey("value"); - json_stream_->Writef("\"%u\"", const_.u32()); - break; - - case Type::I64: - WriteString("i64"); - WriteSeparator(); - WriteKey("value"); - json_stream_->Writef("\"%" PRIu64 "\"", const_.u64()); - break; - - case Type::F32: - WriteString("f32"); - WriteSeparator(); - WriteKey("value"); - WriteF32(const_.f32_bits(), const_.expected_nan()); - break; - - case Type::F64: - WriteString("f64"); - WriteSeparator(); - WriteKey("value"); - WriteF64(const_.f64_bits(), const_.expected_nan()); - break; - - case Type::FuncRef: { - WriteString("funcref"); - WriteSeparator(); - WriteKey("value"); - WriteRefBits(const_.ref_bits()); - break; - } - - case Type::ExternRef: { - WriteString("externref"); - WriteSeparator(); - WriteKey("value"); - WriteRefBits(const_.ref_bits()); - break; - } - - case Type::V128: { - WriteString("v128"); - WriteSeparator(); - WriteKey("lane_type"); - WriteString(const_.lane_type().GetName()); - WriteSeparator(); - WriteKey("value"); - json_stream_->Writef("["); - - for (int lane = 0; lane < const_.lane_count(); ++lane) { - switch (const_.lane_type()) { - case Type::I8: - json_stream_->Writef("\"%u\"", const_.v128_lane(lane)); - break; - - case Type::I16: - json_stream_->Writef("\"%u\"", const_.v128_lane(lane)); - break; - - case Type::I32: - json_stream_->Writef("\"%u\"", const_.v128_lane(lane)); - break; - - case Type::I64: - json_stream_->Writef("\"%" PRIu64 "\"", - const_.v128_lane(lane)); - break; - - case Type::F32: - WriteF32(const_.v128_lane(lane), - const_.expected_nan(lane)); - break; - - case Type::F64: - WriteF64(const_.v128_lane(lane), - const_.expected_nan(lane)); - break; - - default: - WABT_UNREACHABLE; - } - - if (lane != const_.lane_count() - 1) { - WriteSeparator(); - } - } - - json_stream_->Writef("]"); - - break; - } - - default: - WABT_UNREACHABLE; - } - - json_stream_->Writef("}"); - } - - void BinaryWriterSpec::WriteConstVector(const ConstVector &consts) { - json_stream_->Writef("["); - for (size_t i = 0; i < consts.size(); ++i) { - const Const &const_ = consts[i]; - WriteConst(const_); - if (i != consts.size() - 1) { - WriteSeparator(); - } - } - json_stream_->Writef("]"); - } - - void BinaryWriterSpec::WriteAction(const Action &action) { - WriteKey("action"); - json_stream_->Writef("{"); - WriteKey("type"); - if (action.type() == ActionType::Invoke) { - WriteString("invoke"); - } else { - assert(action.type() == ActionType::Get); - WriteString("get"); - } - WriteSeparator(); - if (action.module_var.is_name()) { - WriteKey("module"); - WriteVar(action.module_var); - WriteSeparator(); - } - if (action.type() == ActionType::Invoke) { - WriteKey("field"); - WriteEscapedString(s(action.name)); - WriteSeparator(); - WriteKey("args"); - WriteConstVector(cast(&action)->args); - } else { - WriteKey("field"); - WriteEscapedString(s(action.name)); - } - json_stream_->Writef("}"); - } - - void BinaryWriterSpec::WriteActionResultType(const Action &action) { - const Module *module = script_->GetModule(action.module_var); - const Export *export_; - json_stream_->Writef("["); - switch (action.type()) { - case ActionType::Invoke: { - export_ = module->GetExport(action.name); - assert(export_->kind == ExternalKind::Func); - const Func *func = module->GetFunc(export_->var); - Index num_results = func->GetNumResults(); - for (Index i = 0; i < num_results; ++i) - WriteTypeObject(func->GetResultType(i)); - break; - } - - case ActionType::Get: { - export_ = module->GetExport(action.name); - assert(export_->kind == ExternalKind::Global); - const Global *global = module->GetGlobal(export_->var); - WriteTypeObject(global->type); - break; - } - } - json_stream_->Writef("]"); - } - - void BinaryWriterSpec::WriteModule(string_view filename, const Module &module) { - result_ |= - WriteBinaryModule(module_stream_factory_(filename), &module, options_); - } - - void BinaryWriterSpec::WriteScriptModule(string_view filename, - const ScriptModule &script_module) { - switch (script_module.type()) { - case ScriptModuleType::Text: - WriteModule(filename, cast(&script_module)->module); - break; - - case ScriptModuleType::Binary: - module_stream_factory_(filename)->WriteData( - cast(&script_module)->data, ""); - break; - - case ScriptModuleType::Quoted: - module_stream_factory_(filename)->WriteData( - cast(&script_module)->data, ""); - break; - } - } - - // todo REMOVE THIS FUNC - void BinaryWriterSpec::WriteInvalidModule(const ScriptModule &module, string_view text) { - const char *extension = ""; - const char *module_type = ""; - switch (module.type()) { - case ScriptModuleType::Text: - extension = kWasmExtension; - module_type = "binary"; - break; - - case ScriptModuleType::Binary: - extension = kWasmExtension; - module_type = "binary"; - break; - - case ScriptModuleType::Quoted: - extension = kWatExtension; - module_type = "text"; - break; - } - - WriteLocation(module.location()); - WriteSeparator(); - std::string filename = GetModuleFilename(extension); - WriteKey("filename"); - error("REMOVE THIS FUNC"); -// WriteEscapedString(GetBasename(filename)); - WriteSeparator(); - WriteKey("text"); - WriteEscapedString(text); - WriteSeparator(); - WriteKey("module_type"); - WriteString(module_type); -// WriteScriptModule(filename, module); - } - - void BinaryWriterSpec::WriteCommands() { - json_stream_->Writef("{\"source_filename\": "); - WriteEscapedString(s(source_filename_)); - json_stream_->Writef(",\n \"commands\": [\n"); - Index last_module_index = kInvalidIndex; - for (size_t i = 0; i < script_->commands.size(); ++i) { - const Command *command = script_->commands[i].get(); - - if (i != 0) { - WriteSeparator(); - json_stream_->Writef("\n"); - } - - json_stream_->Writef(" {"); - WriteCommandType(*command); - WriteSeparator(); - - switch (command->type) { - case CommandType::Module: { - const Module &module = cast(command)->module; - std::string filename = GetModuleFilename(kWasmExtension); - WriteLocation(module.loc); - WriteSeparator(); - if (!module.name.empty()) { - WriteKey("name"); - WriteEscapedString(module.name); - WriteSeparator(); - } - WriteKey("filename"); -// WriteEscapedString(GetBasename(filename)); - WriteModule(filename, module); - num_modules_++; - last_module_index = i; - break; - } - - case CommandType::Action: { - const Action &action = *cast(command)->action; - WriteLocation(action.loc); - WriteSeparator(); - WriteAction(action); - WriteSeparator(); - WriteKey("expected"); - WriteActionResultType(action); - break; - } - - case CommandType::Register: { - auto *register_command = cast(command); - const Var &var = register_command->var; - WriteLocation(var.loc); - WriteSeparator(); - if (var.is_name()) { - WriteKey("name"); - WriteVar(var); - WriteSeparator(); - } else { - /* If we're not registering by name, then we should only be - * registering the last module. */ - WABT_USE(last_module_index); - assert(var.index() == last_module_index); - } - WriteKey("as"); - WriteEscapedString(register_command->module_name); - break; - } - - case CommandType::AssertMalformed: { - auto *assert_malformed_command = cast(command); - WriteInvalidModule(*assert_malformed_command->module, - assert_malformed_command->text); - num_modules_++; - break; - } - - case CommandType::AssertInvalid: { - auto *assert_invalid_command = cast(command); - WriteInvalidModule(*assert_invalid_command->module, - assert_invalid_command->text); - num_modules_++; - break; - } - - case CommandType::AssertUnlinkable: { - auto *assert_unlinkable_command = - cast(command); - WriteInvalidModule(*assert_unlinkable_command->module, - assert_unlinkable_command->text); - num_modules_++; - break; - } - - case CommandType::AssertUninstantiable: { - auto *assert_uninstantiable_command = - cast(command); - WriteInvalidModule(*assert_uninstantiable_command->module, - assert_uninstantiable_command->text); - num_modules_++; - break; - } - - case CommandType::AssertReturn: { - auto *assert_return_command = cast(command); - WriteLocation(assert_return_command->action->loc); - WriteSeparator(); - WriteAction(*assert_return_command->action); - WriteSeparator(); - WriteKey("expected"); - WriteConstVector(assert_return_command->expected); - break; - } - - case CommandType::AssertTrap: { - auto *assert_trap_command = cast(command); - WriteLocation(assert_trap_command->action->loc); - WriteSeparator(); - WriteAction(*assert_trap_command->action); - WriteSeparator(); - WriteKey("text"); - WriteEscapedString(assert_trap_command->text); - WriteSeparator(); - WriteKey("expected"); - WriteActionResultType(*assert_trap_command->action); - break; - } - - case CommandType::AssertExhaustion: { - auto *assert_exhaustion_command = - cast(command); - WriteLocation(assert_exhaustion_command->action->loc); - WriteSeparator(); - WriteAction(*assert_exhaustion_command->action); - WriteSeparator(); - WriteKey("text"); - WriteEscapedString(assert_exhaustion_command->text); - WriteSeparator(); - WriteKey("expected"); - WriteActionResultType(*assert_exhaustion_command->action); - break; - } - } - - json_stream_->Writef("}"); - } - json_stream_->Writef("]}\n"); - } - - Result BinaryWriterSpec::WriteScript(const Script &script) { - script_ = &script; - WriteCommands(); - return result_; - } - - } // end anonymous namespace - - Result WriteBinarySpecScript(Stream *json_stream, - WriteBinarySpecStreamFactory module_stream_factory, - Script *script, - string_view source_filename, - string_view module_filename_noext, - const WriteBinaryOptions &options) { - BinaryWriterSpec binary_writer_spec(json_stream, module_stream_factory, - source_filename, module_filename_noext, - options); - return binary_writer_spec.WriteScript(*script); - } - - Result WriteBinarySpecScript( - Stream *json_stream, - Script *script, - string_view source_filename, - string_view module_filename_noext, - const WriteBinaryOptions &options, - std::vector *out_module_streams, - Stream *log_stream) { - WriteBinarySpecStreamFactory module_stream_factory = - [&](string_view filename) { - out_module_streams->emplace_back(filename, - MakeUnique(log_stream)); - return out_module_streams->back().stream.get(); - }; - - BinaryWriterSpec binary_writer_spec(json_stream, module_stream_factory, - source_filename, module_filename_noext, - options); - return binary_writer_spec.WriteScript(*script); - } - -} // namespace wabt diff --git a/playground/binary-writer-spec.h b/playground/binary-writer-spec.h deleted file mode 100644 index cf9652af..00000000 --- a/playground/binary-writer-spec.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2016 WebAssembly Community Group participants - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WABT_BINARY_WRITER_SPEC_H_ -#define WABT_BINARY_WRITER_SPEC_H_ - -#include -#include -#include - -#include "binary-writer.h" -#include "common.h" -#include "ir.h" - -namespace wabt { - - struct FilenameMemoryStreamPair { - FilenameMemoryStreamPair(string_view filename, - std::unique_ptr stream) - : filename(filename), stream(std::move(stream)) {} - - std::string filename; - std::unique_ptr stream; - }; - - typedef std::function< Stream - *( - string_view filename - )> - WriteBinarySpecStreamFactory; - - Result WriteBinarySpecScript(Stream *json_stream, - WriteBinarySpecStreamFactory module_stream_factory, - Script *, - string_view source_filename, - string_view module_filename_noext, - const WriteBinaryOptions &); - -// Convenience function for producing MemoryStream outputs all modules. - Result WriteBinarySpecScript( - Stream *json_stream, - Script *, - string_view source_filename, - string_view module_filename_noext, - const WriteBinaryOptions &, - std::vector *out_module_streams, - Stream *log_stream = nullptr); - -} // namespace wabt - -#endif /* WABT_BINARY_WRITER_SPEC_H_ */ diff --git a/playground/build-emcc.sh b/playground/build-emcc.sh deleted file mode 100644 index 271ee3ad..00000000 --- a/playground/build-emcc.sh +++ /dev/null @@ -1,77 +0,0 @@ -echo check leaks -# valgrind --leak-check=full --track-origins=yes ./mark - -echo build wasm -rm *.bc -rm *.o - -# WASM env: -# export PATH="/usr/local/opt/llvm/bin:$PATH" -# export LDFLAGS="-L/usr/local/opt/llvm/lib" -# export CPPFLAGS="-I/usr/local/opt/llvm/include" -#export C_INCLUDE_PATH="/usr/include/:/usr/lib/x86_64-linux-gnu/glib-2.0/include/" -#for x in `ls -d /usr/include/*/`;do export C_INCLUDE_PATH="$C_INCLUDE_PATH:$x";done -clang=/usr/local/bin/emcc -export BINARYEN=/opt/wasm/binaryen/ -export CPATH=/opt/wasm/swift-wasm/usr/share/wasi-sysroot/include/ - -# clang-10: error: cannot specify -o when generating multiple output files -#"String.cpp" "Node.cpp" "WasmHelpers.cpp" - -#DIRECT COMPILE: SLOWER! -clang_options="-O2 -DWASM -s --target=wasm32-unknown-unknown-wasm -nostartfiles -nostdlib -allow-undefined -Wl,--no-entry,--export-all,--allow-undefined,--export-table,--gc-sections" -# -Wl…,… == linker flags for wasm-ld -# --relocatable -# --print-gc-sections -# --demangle -# --export-all - # --mllvm Options to pass to LLVM - # --import-memory Import memory from the environment - # --import-table Import function table from the environment - # --initial-memory= Initial size of the linear memory - # --features= - -# -# $clang $clang_options -w String.cpp -o wasp.wasm #Wasp.cpp #--sysroot=/opt/wasm/swift-wasm/usr/share/wasi-sysroot - -# COMPILE DIRECTLY from .cpp files wow WORKS!! -$clang -std=c++2a -DWASM=1 -nostdlib -march=wasm -w -v -Wl,--entry=main,--demangle,--allow-undefined String.cpp Node.cpp wasm_helpers.cpp Wasp.cpp -o wasp.wasm || exit - - -# COMPILE FROM .o files WORKS!! -# $clang -std=c++2a -B=/opt/wasm/wasi-sdk-11.0/bin/ -DWASM=1 -nostdlib -march=wasm -w -v -Xlinker -t -Xlinker --verbose -Wl,--entry=main,--demangle,--allow-undefined -L/usr/local/opt/llvm/lib CMakeFiles/String.cpp.o CMakeFiles/Node.cpp.o CMakeFiles/Wasp.cpp.o CMakeFiles/WasmHelpers.cpp.o -o wasp.wasm - -#COMPILE VIA llc & wasm-ld -# clang_options="-DWASM -fvisibility=hidden" # -I /usr/include/ " VS -stdlib=libc++ -nostdinc -nostdlib -# $clang -w -g -emit-llvm -isystem --target=wasm32-unknown-unknown-wasm -Oz -c $clang_options "Wasp.cpp" - - -wasm_ld_options="--export-table --gc-sections -error-limit=0 --no-check-features --allow-undefined --entry main" # --undefined=NIL -# llc -march=wasm32 -filetype=obj Wasp.bc -o wasp.o &> /dev/null -# wasm-ld $wasm_ld_options --demangle --allow-undefined wasp.o -o wasp.wasm || exit -# calls wasm-ld under the hood! - -# wasmtime "wasp".wasm - -# DEBUG: -llvm-dwarfdump wasp.wasm > wasp.dwarf -/opt/wasm/emscripten/tools/wasm-sourcemap.py wasp.wasm --dwarfdump-output=wasp.dwarf -o wasp.map -# lldb -- wasmtime -g wasp.wasm - - - # --split-dwarf-file=wasp.dwarf --split-dwarf-output=wasp.map ONLY with ELF -#"--export-all --flavor wasm -#wasm-ld $wasm_ld_options --demangle --allow-undefined CMakeFiles/wasp.dir/Wasp.cpp.o -o wasp.wasm || exit -wasm2wat wasp.wasm > wasp.wat -wasm-dis wasp.wasm > wasp.wast # wasm2wast -llvm-objdump -h wasp.wasm > wasp.llvm.objdump -llvm-dwarfdump wasp.wasm --all -o wasp.dwarfdump -wasm-objdump -hxd wasp.wasm > wasp.objdump -wasm-dis -sm wasp.wasm.map wasp.wasm -o wasp.dis -wasm-decompile wasp.wasm -o wasp.decompile # WORKS EVEN IF wasm2wat FAILS!! also very readable -# No wasm-compile exists: The format is very low-level, much like Wasm itself, so even though it looks more high level than the .wat format, it wouldn't be any more suitable for general purpose programming. - -./wasm-sourcemap.py -o wasp.map wasp.wasm - -wasmx wasp.wasm # danger, -O0 fucks up memoryBase ! - diff --git a/playground/build-wasi.sh b/playground/build-wasi.sh deleted file mode 100755 index 4bcabc69..00000000 --- a/playground/build-wasi.sh +++ /dev/null @@ -1,92 +0,0 @@ -echo check leaks -# valgrind --leak-check=full --track-origins=yes ./mark - -echo build wasm -rm *.bc -rm *.o - -export PATH="/opt/wasm/wasi-sdk/bin/:$PATH" -# export clang=/opt/wasm/wasi-sdk/bin/clang - -export NODE_PATH=/opt/homebrew/lib/node_modules/ # WHY?? - -# WASM env: -# export PATH="/usr/local/opt/llvm/bin:$PATH" -# export LDFLAGS="-L/usr/local/opt/llvm/lib" -# export CPPFLAGS="-I/usr/local/opt/llvm/include" -#export C_INCLUDE_PATH="/usr/include/:/usr/lib/x86_64-linux-gnu/glib-2.0/include/" -#for x in `ls -d /usr/include/*/`;do export C_INCLUDE_PATH="$C_INCLUDE_PATH:$x";done -export BINARYEN=/opt/wasm/binaryen/ -export CPATH=/opt/wasm/wasi-sdk/share/wasi-sysroot/include/ - -# clang-10: error: cannot specify -o when generating multiple output files -#"String.cpp" "Node.cpp" "WasmHelpers.cpp" - -# --target=wasm32-unknown-unknown-wasm -nostartfiles -nostdlib -allow-undefined ,--export-table,--gc-sections - -#DIRECT COMPILE: SLOWER! -clang_options="-O2 -DWASM -s -Wl,--no-entry,--export-all,--allow-undefined" -# -Wl…,… == linker flags for wasm-ld -# --relocatable -# --print-gc-sections -# --demangle -# --export-all - # --mllvm Options to pass to LLVM - # --import-memory Import memory from the environment - # --import-table Import function table from the environment - # --initial-memory= Initial size of the linear memory - # --features= - -# -# $clang $clang_options -w String.cpp -o wasp.wasm #Wasp.cpp #--sysroot=/opt/wasm/wasi-sdk/share/wasi-sysroot - -# COMPILE DIRECTLY from .cpp files wow WORKS!! -# -nostdlib -march=wasm -# -lstd_v2 -lCsup -lunwind - -# exceptions.cpp polyfill for throw … in raise(chars) - -# --entry=main, -clang -std=c++2a -fno-builtin -DWASM=1 -DWASI=1 -lm --sysroot=/opt/wasm/wasi-sdk/share/wasi-sysroot -w -Wl,--demangle,--allow-undefined source/Wasp.cpp source/String.cpp source/Node.cpp source/Wasm_Helpers.cpp source/Angle.cpp source/exceptions.cpp source/wasm_emitter.cpp -o wasp.wasm || exit - - -# COMPILE FROM .o files WORKS!! -# /opt/wasm/wasi-sdk/bin/clang -std=c++2a -B=/opt/wasm/wasi-sdk/bin/ -DWASM=1 -nostdlib -march=wasm -w -v -Xlinker -t -Xlinker --verbose -Wl,--entry=main,--demangle,--allow-undefined -L/usr/local/opt/llvm/lib CMakeFiles/angle.dir/source/String.cpp.o CMakeFiles/angle.dir/source/Node.cpp.o CMakeFiles/angle.dir/source/Wasp.cpp.o CMakeFiles/angle.dir/source/Wasm_Helpers.cpp.o -o wasp.wasm - -#COMPILE VIA llc & wasm-ld -# clang_options="-DWASM -fvisibility=hidden" # -I /usr/include/ " VS -stdlib=libc++ -nostdinc -nostdlib -# $clang -w -g -emit-llvm -isystem --target=wasm32-unknown-unknown-wasm -Oz -c $clang_options "Wasp.cpp" - - -wasm_ld_options="--export-table --gc-sections -error-limit=0 --no-check-features --allow-undefined --entry main" # --undefined=NIL -# llc -march=wasm32 -filetype=obj Wasp.bc -o wasp.o &> /dev/null -# wasm-ld $wasm_ld_options --demangle --allow-undefined wasp.o -o wasp.wasm || exit -# calls wasm-ld under the hood! - -# wasmtime "wasp".wasm - -# DEBUG: -llvm-dwarfdump wasp.wasm > wasp.dwarf -# /opt/wasm/emscripten/tools/wasm-sourcemap.py wasp.wasm --dwarfdump-output=wasp.dwarf -o wasp.map -# lldb -- wasmtime -g wasp.wasm - - - # --split-dwarf-file=wasp.dwarf --split-dwarf-output=wasp.map ONLY with ELF -#"--export-all --flavor wasm -#wasm-ld $wasm_ld_options --demangle --allow-undefined CMakeFiles/wasp.dir/Wasp.cpp.o -o wasp.wasm || exit -wasm2wat wasp.wasm > wasp.wat -wasm-dis wasp.wasm > wasp.wast # wasm2wast -llvm-objdump -h wasp.wasm > wasp.llvm.objdump -llvm-dwarfdump wasp.wasm --all -o wasp.dwarfdump -wasm-objdump -hxd wasp.wasm > wasp.objdump -wasm-dis -sm wasp.wasm.map wasp.wasm -o wasp.dis -wasm-decompile wasp.wasm -o wasp.decompile # WORKS EVEN IF wasm2wat FAILS!! also very readable -# No wasm-compile exists: The format is very low-level, much like Wasm itself, so even though it looks more high level than the .wat format, it wouldn't be any more suitable for general purpose programming. - -# ./wasm-sourcemap.py -o wasp.map wasp.wasm - -# wasmx wasp.wasm # danger, -O0 fucks up memoryBase ! -wasmer wasp.wasm -# wasmtime wasp.wasm - - diff --git a/playground/build-wasm-via-llc.sh b/playground/build-wasm-via-llc.sh deleted file mode 100755 index 5469daa0..00000000 --- a/playground/build-wasm-via-llc.sh +++ /dev/null @@ -1,77 +0,0 @@ -echo check leaks -# valgrind --leak-check=full --track-origins=yes ./mark - -echo build wasm - -# WASM env: -# export PATH="/usr/local/opt/llvm/bin:$PATH" -# export LDFLAGS="-L/usr/local/opt/llvm/lib" -# export CPPFLAGS="-I/usr/local/opt/llvm/include" -#export C_INCLUDE_PATH="/usr/include/:/usr/lib/x86_64-linux-gnu/glib-2.0/include/" -#for x in `ls -d /usr/include/*/`;do export C_INCLUDE_PATH="$C_INCLUDE_PATH:$x";done -clang=/opt/wasm/wasi-sdk-11.0/bin/clang -export BINARYEN=/opt/wasm/binaryen/ -export CPATH=/opt/wasm/swift-wasm/usr/share/wasi-sysroot/include/ - -# clang-10: error: cannot specify -o when generating multiple output files -#"String.cpp" "Node.cpp" "WasmHelpers.cpp" - -# -fdebug-pass-arguments -fdebug-pass-structure -clang_options="-Os -g --target=wasm32-unknown-unknown--wasm -nostartfiles -nostdlib -Wl,--demangle,--no-entry,--export-all,--export-table,--allow-undefined" -# --target=wasm32-unknown-emscripten-wasm -# -Wl…,… == linker flags for wasm-ld -# --relocatable -# --print-gc-sections -# --demangle -# --export-all - # --mllvm Options to pass to LLVM - # --import-memory Import memory from the environment - # --import-table Import function table from the environment - # --initial-memory= Initial size of the linear memory - # --features= - -# -$clang $clang_options t.c -o t.wasm #t.cpp #--sysroot=/opt/wasm/swift-wasm/usr/share/wasi-sysroot - -# COMPILE DIRECTLY from .cpp files wow WORKS!! -# clang -std=c++2a -DWASM=1 -nostdlib -march=wasm -w -v -Wl,--entry=main,--demangle,--allow-undefined String.cpp Node.cpp WasmHelpers.cpp t.cpp -o t.wasm || exit - - -# COMPILE FROM .o files WORKS!! -# /opt/wasm/wasi-sdk-11.0/bin/clang -std=c++2a -B=/opt/wasm/wasi-sdk-11.0/bin/ -DWASM=1 -nostdlib -march=wasm -w -v -Xlinker -t -Xlinker --verbose -Wl,--entry=main,--demangle,--allow-undefined -L/usr/local/opt/llvm/lib CMakeFiles/String.cpp.o CMakeFiles/Node.cpp.o CMakeFiles/t.cpp.o CMakeFiles/WasmHelpers.cpp.o -o t.wasm - -#COMPILE VIA llc & wasm-ld -# clang_options="-DWASM -fvisibility=hidden" # -I /usr/include/ " VS -stdlib=libc++ -nostdinc -nostdlib -$clang -w -g -emit-llvm -isystem --target=wasm32-unknown-unknown-wasm -Oz -c $clang_options "t.c" -wasm-ld $wasm_ld_options --demangle --allow-undefined t.o -o t.wasm || exit - -wasm_ld_options="--export-table --gc-sections -error-limit=0 --no-check-features --allow-undefined --entry main" # --undefined=NIL -llc -march=wasm32 -filetype=obj t.bc -o t.o &> /dev/null -wasm-ld $wasm_ld_options --demangle --allow-undefined t.o -o t.wasm || exit -# calls wasm-ld under the hood! - - -# DEBUG: -llvm-dwarfdump t.wasm > t.dwarf - - -# --split-dwarf-file=t.dwarf --split-dwarf-output=t.map ONLY with ELF -#"--export-all --flavor wasm -#wasm-ld $wasm_ld_options --demangle --allow-undefined CMakeFiles/t.dir/t.cpp.o -o t.wasm || exit -wasm2wat t.wasm > t.auto.wat -wasm-dis t.wasm > t.wast # wasm2wast -llvm-objdump -h t.wasm > t.llvm.objdump -llvm-dwarfdump t.wasm --all -o t.dwarfdump -wasm-objdump -hxd t.wasm > t.objdump -wasm-dis -sm t.wasm.map t.wasm -o t.dis -wasm-decompile t.wasm -o t.decompile # WORKS EVEN IF wasm2wat FAILS!! also very readable -# No wasm-compile exists: The format is very low-level, much like Wasm itself, so even though it looks more high level than the .wat format, it wouldn't be any more suitable for general purpose programming. - - -# NO LONGER NECESSARY: clang -g sould work -/opt/wasm/emscripten/tools/wasm-sourcemap.py t.wasm --dwarfdump-output=t.dwarf -o t.map -# ./wasm-sourcemap.py -o t.map t.wasm -# lldb -- wasmtime -g t.wasm - -wasmx t.wasm # danger, -O0 fucks up memoryBase ! - diff --git a/playground/build-wasm-via-lld.sh b/playground/build-wasm-via-lld.sh deleted file mode 100755 index c9fbc9d7..00000000 --- a/playground/build-wasm-via-lld.sh +++ /dev/null @@ -1,59 +0,0 @@ -echo check leaks -# valgrind --leak-check=full --track-origins=yes ./mark - -echo build wasm - -# WASM env: -# export PATH="/usr/local/opt/llvm/bin:$PATH" -# export LDFLAGS="-L/usr/local/opt/llvm/lib" -# export CPPFLAGS="-I/usr/local/opt/llvm/include" -#export C_INCLUDE_PATH="/usr/include/:/usr/lib/x86_64-linux-gnu/glib-2.0/include/" -#for x in `ls -d /usr/include/*/`;do export C_INCLUDE_PATH="$C_INCLUDE_PATH:$x";done -clang=/opt/wasm/wasi-sdk/bin/clang -export BINARYEN=/opt/wasm/binaryen/ -export CPATH=/opt/wasm/wasi-sdk/share/wasi-sysroot/include/ - -# clang-10: error: cannot specify -o when generating multiple output files - -# -fdebug-pass-arguments -fdebug-pass-structure -# --target=wasm32-unknown-emscripten-wasm -# -Wl…,… == linker flags for wasm-ld -# --relocatable -# --print-gc-sections -# --demangle -# --export-all - # --mllvm Options to pass to LLVM - # --import-memory Import memory from the environment - # --import-table Import function table from the environment - # --initial-memory= Initial size of the linear memory - # --features= -clang_options="-Os -g --target=wasm32-unknown-unknown--wasm -nostartfiles -nostdlib" -# https://prereleases.llvm.org/10.0.0/rc6/tools/clang/docs/ClangCommandLineReference.html -wasm_ld_options="--entry main --export-table --gc-sections -error-limit=0 --no-check-features --allow-undefined " - -$clang $clang_options t.c -o t.o -wasm-ld --entry=main $wasm_ld_options --demangle t.o -o t.wasm || exit - -# DEBUG: -llvm-dwarfdump t.wasm > t.dwarf - -# --split-dwarf-file=t.dwarf --split-dwarf-output=t.map ONLY with ELF -#"--export-all --flavor wasm -#wasm-ld $wasm_ld_options --demangle --allow-undefined CMakeFiles/t.dir/t.cpp.o -o t.wasm || exit -wasm2wat t.wasm > t.auto.wat -wasm-dis t.wasm > t.wast # wasm2wast -llvm-objdump -h t.wasm > t.llvm.objdump -llvm-dwarfdump t.wasm --all -o t.dwarfdump -wasm-objdump -hxd t.wasm > t.objdump -wasm-dis -sm t.wasm.map t.wasm -o t.dis -wasm-decompile t.wasm -o t.decompile # WORKS EVEN IF wasm2wat FAILS!! also very readable -# No wasm-compile exists: The format is very low-level, much like Wasm itself, so even though it looks more high level than the .wat format, it wouldn't be any more suitable for general purpose programming. - - -# NO LONGER NECESSARY: clang -g sould work -/opt/wasm/emscripten/tools/wasm-sourcemap.py t.wasm --dwarfdump-output=t.dwarf -o t.map -# ./wasm-sourcemap.py -o t.map t.wasm -# lldb -- wasmtime -g t.wasm - -wasmx t.wasm # danger, -O0 fucks up memoryBase ! - diff --git a/playground/build-wasm.sh b/playground/build-wasm.sh deleted file mode 100755 index 9651b25d..00000000 --- a/playground/build-wasm.sh +++ /dev/null @@ -1,59 +0,0 @@ -echo check leaks -# valgrind --leak-check=full --track-origins=yes ./mark - -echo build wasm - -# WASM env: -# export PATH="/usr/local/opt/llvm/bin:$PATH" -# export LDFLAGS="-L/usr/local/opt/llvm/lib" -# export CPPFLAGS="-I/usr/local/opt/llvm/include" -#export C_INCLUDE_PATH="/usr/include/:/usr/lib/x86_64-linux-gnu/glib-2.0/include/" -#for x in `ls -d /usr/include/*/`;do export C_INCLUDE_PATH="$C_INCLUDE_PATH:$x";done -clang=/opt/wasm/wasi-sdk-11.0/bin/clang -export BINARYEN=/opt/wasm/binaryen/ -export CPATH=/opt/wasm/swift-wasm/usr/share/wasi-sysroot/include/ - -# clang-10: error: cannot specify -o when generating multiple output files -#"String.cpp" "Node.cpp" "WasmHelpers.cpp" - -# -Os -Oz ok? -O1 removes symbols! -clang_options="-g --target=wasm32-unknown-unknown--wasm -nostartfiles -nostdlib -Wl,--demangle,--no-entry,--export-all,--export-table,--allow-undefined" -clang_options="$clang_options -fdebug-pass-arguments -fdebug-pass-structure " - -# --target=wasm32-unknown-emscripten-wasm -# -Wl…,… == linker flags for wasm-ld -# --relocatable -# --print-gc-sections -# --demangle -# --export-all - # --mllvm Options to pass to LLVM - # --import-memory Import memory from the environment - # --import-table Import function table from the environment - # --initial-memory= Initial size of the linear memory - # --features= - -# -$clang $clang_options t.c -o t.wasm || exit - -# DEBUG: -llvm-dwarfdump t.wasm > t.dwarf -# --split-dwarf-file=t.dwarf --split-dwarf-output=t.map ONLY with ELF -#"--export-all --flavor wasm - -wasm2wat t.wasm > t.auto.wat -wasm-dis t.wasm > t.wast # wasm2wast -llvm-objdump -h t.wasm > t.llvm.objdump -llvm-dwarfdump t.wasm --all -o t.dwarfdump -wasm-objdump -hxd t.wasm > t.objdump -wasm-dis -sm t.wasm.map t.wasm -o t.dis -wasm-decompile t.wasm -o t.decompile # WORKS EVEN IF wasm2wat FAILS!! also very readable -# No wasm-compile exists: The format is very low-level, much like Wasm itself, so even though it looks more high level than the .wat format, it wouldn't be any more suitable for general purpose programming. - - -# NO LONGER NECESSARY: clang -g sould work -/opt/wasm/emscripten/tools/wasm-sourcemap.py t.wasm --dwarfdump-output=t.dwarf -o t.map -# ./wasm-sourcemap.py -o t.map t.wasm -# lldb -- wasmtime -g t.wasm - -wasmx t.wasm # danger, -O0 fucks up memoryBase ! - diff --git a/playground/build-wasp.sh b/playground/build-wasp.sh deleted file mode 100755 index 9b94b4ba..00000000 --- a/playground/build-wasp.sh +++ /dev/null @@ -1,86 +0,0 @@ -echo check leaks -# valgrind --leak-check=full --track-origins=yes ./mark - -echo build wasm -rm *.bc -rm *.o - -# WASM env: -export PATH="/opt/wasm/wasi-sdk/bin/:$PATH" -# export PATH="/usr/local/opt/llvm/bin:$PATH" -# export LDFLAGS="-L/usr/local/opt/llvm/lib" -# export CPPFLAGS="-I/usr/local/opt/llvm/include" -#export C_INCLUDE_PATH="/usr/include/:/usr/lib/x86_64-linux-gnu/glib-2.0/include/" -#for x in `ls -d /usr/include/*/`;do export C_INCLUDE_PATH="$C_INCLUDE_PATH:$x";done -clang=/opt/wasm/wasi-sdk/bin/clang -export BINARYEN=/opt/wasm/binaryen/ -export CPATH=/opt/wasm/swift-wasm/usr/share/wasi-sysroot/include/ - -# clang-10: error: cannot specify -o when generating multiple output files -#"String.cpp" "Node.cpp" "WasmHelpers.cpp" - -#DIRECT COMPILE: SLOWER! -clang_options="-w -DWASM -DMY_WASM -DHEAP_OFFSET=65536 -DMEMORY_SIZE=117964800 -s --target=wasm32 -nostdlib -Wl,--demangle,--allow-undefined,--export-all,--export-table,--gc-sections,--initial-memory=117964800,-z,stack-size=104857600" -# -nostartfiles -# --export-all, # NEEDED for stack traces! NOT demangled! -# -allow-undefined -# -Wl…,… == linker flags for wasm-ld -# -O2 -# -v verbose -# --relocatable -# --print-gc-sections -# --demangle -# --export-all - # --mllvm Options to pass to LLVM - # --import-memory Import memory from the environment - # --import-table Import function table from the environment - # --initial-memory= Initial size of the linear memory - # --features= - -# -SOURCE_FILES="source/String.cpp source/Angle.cpp source/Node.cpp source/wasm_helpers.cpp source/Wasp.cpp" -$clang $clang_options $SOURCE_FILES -o wasp.wasm || exit #Wasp.cpp #--sysroot=/opt/wasm/swift-wasm/usr/share/wasi-sysroot - -# COMPILE DIRECTLY from .cpp files wow WORKS!! -# --entry=start, does NOT work again, as of 2021/2 -# -v -# clang -std=c++2a -DWASM=1 -DMY_WASM=1 -nostdlib -march=wasm -w -Wl,--demangle,--allow-undefined source/String.cpp source/Node.cpp source/wasm_helpers.cpp source/Wasp.cpp -o wasp.wasm || exit - - -# COMPILE FROM .o files WORKS!! -# /opt/wasm/wasi-sdk-11.0/bin/clang -std=c++2a -B=/opt/wasm/wasi-sdk-11.0/bin/ -DWASM=1 -nostdlib -march=wasm -w -v -Xlinker -t -Xlinker --verbose -Wl,--entry=main,--demangle,--allow-undefined -L/usr/local/opt/llvm/lib CMakeFiles/String.cpp.o CMakeFiles/Node.cpp.o CMakeFiles/Wasp.cpp.o CMakeFiles/WasmHelpers.cpp.o -o wasp.wasm - -#COMPILE VIA llc & wasm-ld -# clang_options="-DWASM -fvisibility=hidden" # -I /usr/include/ " VS -stdlib=libc++ -nostdinc -nostdlib -# $clang -w -g -emit-llvm -isystem --target=wasm32-unknown-unknown-wasm -Oz -c $clang_options "Wasp.cpp" - - -# wasm_ld_options="--export-table --gc-sections -error-limit=0 --no-check-features --allow-undefined --entry main" # --undefined=NIL -# llc -march=wasm32 -filetype=obj Wasp.bc -o wasp.o &> /dev/null -# wasm-ld $wasm_ld_options --demangle --allow-undefined wasp.o -o wasp.wasm || exit -# calls wasm-ld under the hood! - -# wasmtime "wasp".wasm - -# DEBUG: -llvm-dwarfdump wasp.wasm > wasp.dwarf -# /opt/wasm/emscripten/tools/wasm-sourcemap.py wasp.wasm --dwarfdump-output=wasp.dwarf -o wasp.map -# lldb -- wasmtime -g wasp.wasm - - - # --split-dwarf-file=wasp.dwarf --split-dwarf-output=wasp.map ONLY with ELF -#"--export-all --flavor wasm -#wasm-ld $wasm_ld_options --demangle --allow-undefined CMakeFiles/wasp.dir/Wasp.cpp.o -o wasp.wasm || exit -wasm2wat wasp.wasm > wasp.wat -# wasm-dis wasp.wasm > wasp.wast # wasm2wast -# llvm-objdump -h wasp.wasm > wasp.llvm.objdump -# llvm-dwarfdump wasp.wasm --all -o wasp.dwarfdump -# wasm-objdump -hxd wasp.wasm > wasp.objdump -# wasm-dis -sm wasp.wasm.map wasp.wasm -o wasp.dis -# wasm-decompile wasp.wasm -o wasp.decompile # WORKS EVEN IF wasm2wat FAILS!! also very readable -# No wasm-compile exists: The format is very low-level, much like Wasm itself, so even though it looks more high level than the .wat format, it wouldn't be any more suitable for general purpose programming. - -# ./wasm-sourcemap.py -o wasp.map wasp.wasm - -wasmx wasp.wasm # danger, -O0 fucks up memoryBase ! - diff --git a/playground/index.html b/playground/index.html deleted file mode 100644 index 950bf048..00000000 --- a/playground/index.html +++ /dev/null @@ -1,91 +0,0 @@ - - -% \ No newline at end of file diff --git a/playground/mark.kt b/playground/mark.kt deleted file mode 100644 index 687b5d18..00000000 --- a/playground/mark.kt +++ /dev/null @@ -1,250 +0,0 @@ -import kotlinx.serialization.* - -import kotlin.io.println as println -import kotlin.io.println as print -import com.beust.klaxon.JsonReader -import com.beust.klaxon.KlaxonException -import kotlinx.io.StringReader -import java.lang.Double.isFinite - -import kotlin.collections.mutableMapOf as map -import kotlin.collections.mutableListOf as list // YES! -//import extensions.* - -@Serializable -data class Data(val a: Int, @Optional val b: String = "42") - -fun main(args: Array) { - val json = """ - {"a": 42, "b": "42", "c":{"d":123}} - """ -// val dyn: dynamic // ONLY IN JS - val mark = mark(json) - print(mark) -// parseKlaxon(json) -} - -fun mark(json: String): Any? { - return MarkParser(json).values() -} - -val NULL:Char = 0.toChar()// Char.(0)// Char.MIN_SURROGATE // '\\0' - -data class MarkParser(var json: String) { - var index = 0 - var len: Int - var cur: Char='?' - - init { - len=json.length - cur=json[0] - } - - fun data(): Map { - val map = map() - white() - token('{') - while (!peek('}')) { - white() - val key:String = key() - var value: Any? = null - white() - val assign = maybe(':') or maybe('=') - if (!!assign) { - value = values() - } - white() - maybe(',') - map[key] = value - } - next() - return map - - if (json[index] != '{') throw Error("expect") - } - - fun values():Any? { - white() - if(peek('{'))return data() - if(peek('"'))return key() - if(isNameStart(current())) return key() - if(isNumber(current())) return number() - return null - } - - private fun number(): Number { - - var number=0 - var sign = NULL - var string = "" - var base = 10 - - if (cur == '-' || cur == '+') { - sign = cur; next(); - } - - // support for Infinity (could tweak to allow other words): -// if (ch == 'I') { -// number = word() -// if (typeof number !== 'number' || isNaN(number)) { -// error('Unexpected word for number'); -// } -// return (sign == '-') ? -number : number; -// } - - // support for NaN -// if (ch == 'N' ) { -// number = word(); -// if (!isNaN(number)) { -// error('expected word to be NaN'); -// } -// // ignore sign as -NaN also is NaN -// return number; -// } - - if (cur == '0') { - string += cur; next(); - } else { - while (cur >= '0' && cur <= '9' ) { - string += cur; - next(); - } - if (cur == '.') { - string += '.'; - while (cur >= '0' && cur <= '9') { - string += cur; - next() - } - } - if (cur == 'e' || cur == 'E') { - string += cur; - next(); - if (cur == '-' || cur == '+') { - string += cur; - next(); - } - while (cur >= '0' && cur <= '9') { - string += cur; - next(); - } - } - } - number= string.tonumber().toInt() - - if (sign == '-') number = -number - - if (!isFinite(number.toDouble())) { - error("Bad number"); - } else { - return number; - } - } - - - - private fun white() { - while (cur == ' ' || cur == '\n' || cur == '\t') next() - } - - private fun key(): String { - val quot = maybe('"') - val word = word(!!quot) - if (!!quot) token(quot) - return word - } - - private fun word(quoted: Boolean): String { - var w = "" - if (!quoted && !isNameStart(current())) - throw Error("Invalid name start " + current()) - while (true) { - if (isNameChar(cur)) w += cur - else break - next() - } - return w - } - - private fun current(): Char { - return json[index] - } - - fun isNumber(c: Char): Boolean { // todo : -0x.75E12 - return ('0' <= c && c <= '9') - } - - fun isNameChar(c: Char): Boolean { - return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || - c == '_' || c == '.' || c == '-'; - } - - fun isNameStart(c: Char): Boolean { - return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '_'; - } - - - var base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - - private fun peek(c: Char): Boolean { - return json[index] == c - } - - private fun maybe(c: Char): Char { - if (json[index] == c){ - next() - return c; - } - return NULL - } - - private fun next(): Char { - val c = json[index++]; - cur = json[index]; - return c; - } - - private fun token(c: Char): Char { - if(endOfFile())throw Error("endOfFile") - if (json[index] != c) throw Error("expected " + c) - index++ - cur=json[index] - return c // tested token, not 'next'! - } - -// val endOfFile:()->Boolean={index>=len} - val endOfFile={index>=len} -// -} - -private infix fun Char.or(maybe: Char): Any { - if (this == NULL) return maybe - else return this -} - - - - - -fun parseKlaxon(json: String) { - JsonReader(StringReader(json)).use { reader -> - while (reader.hasNext()) { - try { - val root = reader.nextObject() - for (e in root.entries) - println(e) - } catch (e: KlaxonException) { - if ("read EOF" in e.message!!) - break // WTF hasNext() EOF!? - throw e -// print(e) - } -// if(!!nextObject) -// val readName = reader.nextName() -// val obj = reader.nextObject() -// val entries = obj.entries -// for (e in entries) -// print(e) - } - } -} diff --git a/playground/t.decompile b/playground/t.decompile deleted file mode 100644 index 662a9c1c..00000000 --- a/playground/t.decompile +++ /dev/null @@ -1,79 +0,0 @@ -export memory memory(initial: 2, max: 0); - -global g_a:int = 66576; -export global x:int = 1024; -export global dso_handle:int = 1024; -export global data_end:int = 1028; -export global global_base:int = 1024; -export global heap_base:int = 66576; -export global memory_base:int = 0; -export global table_base:int = 1; - -export table indirect_function_table:funcref(min: 1, max: 1); - -data d_a(offset: 1024) = "{\00\00\00"; - -export function wasm_call_ctors() { -} - -export function panic() { - var a:int = g_a; - var b:int = 16; - var c:int_ptr = a - b; - var d:int = 2; - var e:int = 0; - c[3] = e; - var f:int = c[3]; - var g:int = -1; - var h:byte_ptr = f + g; - h[0] = d; -} - -export function id(a:int):int { - var b:int = g_a; - var c:int = 16; - var d:int_ptr = b - c; - g_a = d; - d[3] = a; - panic(); - var e:int = d[3]; - var f:int = 16; - var g:int = d + f; - g_a = g; - return e; -} - -export function add(a:int, b:int):int { - var c:int = g_a; - var d:int = 16; - var e:int_ptr = c - d; - e[3] = a; - e[2] = b; - var f:int = e[3]; - var g:int = e[2]; - var h:int = f + g; - return h; -} - -export function original_main():int { - var a:int = g_a; - var b:int = 16; - var c:int_ptr = a - b; - g_a = c; - var d:int = 22; - var e:int = 20; - var f:int = 0; - c[3] = f; - var g:int = add(d, e); - var h:int = id(g); - var i:int = 16; - var j:int = c + i; - g_a = j; - return h; -} - -export function main(a:int, b:int):int { - var c:int = original_main(); - return c; -} - diff --git a/playground/t.dwarfdump b/playground/t.dwarfdump deleted file mode 100644 index 0fab97df..00000000 --- a/playground/t.dwarfdump +++ /dev/null @@ -1,256 +0,0 @@ -t.wasm: file format WASM - -.debug_abbrev contents: -Abbrev table for offset: 0x00000000 -[1] DW_TAG_compile_unit DW_CHILDREN_yes - DW_AT_producer DW_FORM_strp - DW_AT_language DW_FORM_data2 - DW_AT_name DW_FORM_strp - DW_AT_stmt_list DW_FORM_sec_offset - DW_AT_comp_dir DW_FORM_strp - DW_AT_low_pc DW_FORM_addr - DW_AT_ranges DW_FORM_sec_offset - -[2] DW_TAG_variable DW_CHILDREN_no - DW_AT_name DW_FORM_strp - DW_AT_type DW_FORM_ref4 - DW_AT_external DW_FORM_flag_present - DW_AT_decl_file DW_FORM_data1 - DW_AT_decl_line DW_FORM_data1 - DW_AT_location DW_FORM_exprloc - -[3] DW_TAG_base_type DW_CHILDREN_no - DW_AT_name DW_FORM_strp - DW_AT_encoding DW_FORM_data1 - DW_AT_byte_size DW_FORM_data1 - -[4] DW_TAG_subprogram DW_CHILDREN_yes - DW_AT_low_pc DW_FORM_addr - DW_AT_high_pc DW_FORM_data4 - DW_AT_name DW_FORM_strp - DW_AT_decl_file DW_FORM_data1 - DW_AT_decl_line DW_FORM_data1 - DW_AT_external DW_FORM_flag_present - -[5] DW_TAG_variable DW_CHILDREN_no - DW_AT_location DW_FORM_exprloc - DW_AT_name DW_FORM_strp - DW_AT_decl_file DW_FORM_data1 - DW_AT_decl_line DW_FORM_data1 - DW_AT_type DW_FORM_ref4 - -[6] DW_TAG_subprogram DW_CHILDREN_yes - DW_AT_low_pc DW_FORM_addr - DW_AT_high_pc DW_FORM_data4 - DW_AT_name DW_FORM_strp - DW_AT_decl_file DW_FORM_data1 - DW_AT_decl_line DW_FORM_data1 - DW_AT_prototyped DW_FORM_flag_present - DW_AT_type DW_FORM_ref4 - DW_AT_external DW_FORM_flag_present - -[7] DW_TAG_formal_parameter DW_CHILDREN_no - DW_AT_location DW_FORM_exprloc - DW_AT_name DW_FORM_strp - DW_AT_decl_file DW_FORM_data1 - DW_AT_decl_line DW_FORM_data1 - DW_AT_type DW_FORM_ref4 - -[8] DW_TAG_subprogram DW_CHILDREN_no - DW_AT_low_pc DW_FORM_addr - DW_AT_high_pc DW_FORM_data4 - DW_AT_name DW_FORM_strp - DW_AT_decl_file DW_FORM_data1 - DW_AT_decl_line DW_FORM_data1 - DW_AT_type DW_FORM_ref4 - DW_AT_external DW_FORM_flag_present - -[9] DW_TAG_pointer_type DW_CHILDREN_no - DW_AT_type DW_FORM_ref4 - - -.debug_info contents: -0x00000000: Compile Unit: length = 0x000000ca version = 0x0004 abbr_offset = 0x0000 addr_size = 0x04 (next unit at 0x000000ce) - -0x0000000b: DW_TAG_compile_unit - DW_AT_producer ("clang version 10.0.0 (https://github.com/llvm/llvm-project d32170dbd5b0d54436537b6b75beaf44324e0c28)") - DW_AT_language (DW_LANG_C99) - DW_AT_name ("t.c") - DW_AT_stmt_list (0x00000000) - DW_AT_comp_dir ("/Users/me/dev/apps/wasp/playground") - DW_AT_low_pc (0x0000000000000000) - DW_AT_ranges (0x00000000 - [0x00000005, 0x00000045) - [0x00000046, 0x0000008f) - [0x00000090, 0x000000cd) - [0x000000ce, 0x0000012c)) - -0x00000026: DW_TAG_variable - DW_AT_name ("x") - DW_AT_type (0x00000037 "int") - DW_AT_external (true) - DW_AT_decl_file ("/Users/me/dev/apps/wasp/playground/t.c") - DW_AT_decl_line (2) - DW_AT_location (DW_OP_addr 0x400) - -0x00000037: DW_TAG_base_type - DW_AT_name ("int") - DW_AT_encoding (DW_ATE_signed) - DW_AT_byte_size (0x04) - -0x0000003e: DW_TAG_subprogram - DW_AT_low_pc (0x0000000000000005) - DW_AT_high_pc (0x0000000000000045) - DW_AT_name ("panic") - DW_AT_decl_file ("/Users/me/dev/apps/wasp/playground/t.c") - DW_AT_decl_line (20) - DW_AT_external (true) - -0x0000004d: DW_TAG_variable - DW_AT_location (DW_OP_plus_uconst 0xc) - DW_AT_name ("x") - DW_AT_decl_file ("/Users/me/dev/apps/wasp/playground/t.c") - DW_AT_decl_line (21) - DW_AT_type (0x000000c1 "char*") - -0x0000005b: NULL - -0x0000005c: DW_TAG_subprogram - DW_AT_low_pc (0x0000000000000046) - DW_AT_high_pc (0x000000000000008f) - DW_AT_name ("id") - DW_AT_decl_file ("/Users/me/dev/apps/wasp/playground/t.c") - DW_AT_decl_line (25) - DW_AT_prototyped (true) - DW_AT_type (0x00000037 "int") - DW_AT_external (true) - -0x0000006f: DW_TAG_formal_parameter - DW_AT_location (DW_OP_plus_uconst 0xc) - DW_AT_name ("x") - DW_AT_decl_file ("/Users/me/dev/apps/wasp/playground/t.c") - DW_AT_decl_line (25) - DW_AT_type (0x00000037 "int") - -0x0000007d: NULL - -0x0000007e: DW_TAG_subprogram - DW_AT_low_pc (0x0000000000000090) - DW_AT_high_pc (0x00000000000000cd) - DW_AT_name ("add") - DW_AT_decl_file ("/Users/me/dev/apps/wasp/playground/t.c") - DW_AT_decl_line (30) - DW_AT_prototyped (true) - DW_AT_type (0x00000037 "int") - DW_AT_external (true) - -0x00000091: DW_TAG_formal_parameter - DW_AT_location (DW_OP_plus_uconst 0xc) - DW_AT_name ("x") - DW_AT_decl_file ("/Users/me/dev/apps/wasp/playground/t.c") - DW_AT_decl_line (30) - DW_AT_type (0x00000037 "int") - -0x0000009f: DW_TAG_formal_parameter - DW_AT_location (DW_OP_plus_uconst 0x8) - DW_AT_name ("y") - DW_AT_decl_file ("/Users/me/dev/apps/wasp/playground/t.c") - DW_AT_decl_line (30) - DW_AT_type (0x00000037 "int") - -0x000000ad: NULL - -0x000000ae: DW_TAG_subprogram - DW_AT_low_pc (0x00000000000000ce) - DW_AT_high_pc (0x000000000000012c) - DW_AT_name ("main") - DW_AT_decl_file ("/Users/me/dev/apps/wasp/playground/t.c") - DW_AT_decl_line (33) - DW_AT_type (0x00000037 "int") - DW_AT_external (true) - -0x000000c1: DW_TAG_pointer_type - DW_AT_type (0x000000c6 "char") - -0x000000c6: DW_TAG_base_type - DW_AT_name ("char") - DW_AT_encoding (DW_ATE_signed_char) - DW_AT_byte_size (0x01) - -0x000000cd: NULL - -.debug_line contents: -debug_line[0x00000000] -Line table prologue: - total_length: 0x00000098 - version: 4 - prologue_length: 0x0000001b - min_inst_length: 1 -max_ops_per_inst: 1 - default_is_stmt: 1 - line_base: -5 - line_range: 14 - opcode_base: 13 -standard_opcode_lengths[DW_LNS_copy] = 0 -standard_opcode_lengths[DW_LNS_advance_pc] = 1 -standard_opcode_lengths[DW_LNS_advance_line] = 1 -standard_opcode_lengths[DW_LNS_set_file] = 1 -standard_opcode_lengths[DW_LNS_set_column] = 1 -standard_opcode_lengths[DW_LNS_negate_stmt] = 0 -standard_opcode_lengths[DW_LNS_set_basic_block] = 0 -standard_opcode_lengths[DW_LNS_const_add_pc] = 0 -standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1 -standard_opcode_lengths[DW_LNS_set_prologue_end] = 0 -standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0 -standard_opcode_lengths[DW_LNS_set_isa] = 1 -file_names[ 1]: - name: "t.c" - dir_index: 0 - mod_time: 0x00000000 - length: 0x00000000 - -Address Line Column File ISA Discriminator Flags ------------------- ------ ------ ------ --- ------------- ------------- -0x0000000000000005 20 0 1 0 0 is_stmt -0x0000000000000023 21 11 1 0 0 is_stmt prologue_end -0x000000000000002a 22 5 1 0 0 is_stmt -0x000000000000003c 22 10 1 0 0 -0x0000000000000043 23 1 1 0 0 is_stmt -0x0000000000000045 23 1 1 0 0 is_stmt end_sequence -0x0000000000000046 25 0 1 0 0 is_stmt -0x000000000000006b 26 5 1 0 0 is_stmt prologue_end -0x0000000000000071 27 9 1 0 0 is_stmt -0x0000000000000078 27 2 1 0 0 -0x000000000000008f 27 2 1 0 0 end_sequence -0x0000000000000090 30 0 1 0 0 is_stmt -0x00000000000000b4 31 12 1 0 0 is_stmt prologue_end -0x00000000000000bb 31 14 1 0 0 -0x00000000000000c2 31 13 1 0 0 -0x00000000000000c9 31 5 1 0 0 -0x00000000000000cd 31 5 1 0 0 end_sequence -0x00000000000000ce 33 0 1 0 0 is_stmt -0x00000000000000ff 34 12 1 0 0 is_stmt prologue_end -0x000000000000010b 34 9 1 0 0 -0x0000000000000115 34 2 1 0 0 -0x000000000000012c 34 2 1 0 0 end_sequence - - -.debug_str contents: -0x00000000: "clang version 10.0.0 (https://github.com/llvm/llvm-project d32170dbd5b0d54436537b6b75beaf44324e0c28)" -0x00000065: "t.c" -0x00000069: "/Users/me/dev/apps/wasp/playground" -0x0000008c: "x" -0x0000008e: "int" -0x00000092: "panic" -0x00000098: "id" -0x0000009b: "add" -0x0000009f: "main" -0x000000a4: "char" -0x000000a9: "y" - -.debug_ranges contents: -00000000 00000005 00000045 -00000000 00000046 0000008f -00000000 00000090 000000cd -00000000 000000ce 0000012c -00000000 diff --git a/playground/t.llvm.objdump b/playground/t.llvm.objdump deleted file mode 100644 index ce4765ac..00000000 --- a/playground/t.llvm.objdump +++ /dev/null @@ -1,21 +0,0 @@ - -t.wasm: file format WASM - -Sections: -Idx Name Size VMA Type - 0 TYPE 00000013 00000000 - 1 FUNCTION 00000007 00000000 - 2 TABLE 00000005 00000000 - 3 MEMORY 00000003 00000000 - 4 GLOBAL 00000031 00000000 - 5 EXPORT 000000c3 00000000 - 6 CODE 0000013c 00000000 TEXT - 7 DATA 0000000b 00000000 DATA - 8 .debug_info 000000ce 00000000 - 9 .debug_ranges 00000028 00000000 - 10 .debug_abbrev 0000008e 00000000 - 11 .debug_line 0000009c 00000000 - 12 .debug_str 000000ab 00000000 - 13 name 0000003d 00000000 - 14 producers 0000007b 00000000 - diff --git a/playground/t.map b/playground/t.map deleted file mode 100644 index 3126932b..00000000 --- a/playground/t.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"names":[],"sources":[],"sourcesContent":null,"mappings":""} \ No newline at end of file diff --git a/playground/t.objdump b/playground/t.objdump deleted file mode 100644 index 124db0ab..00000000 --- a/playground/t.objdump +++ /dev/null @@ -1,235 +0,0 @@ - -t.wasm: file format wasm 0x1 - -Sections: - - Type start=0x0000000a end=0x0000001d (size=0x00000013) count: 4 - Function start=0x0000001f end=0x00000026 (size=0x00000007) count: 6 - Table start=0x00000028 end=0x0000002d (size=0x00000005) count: 1 - Memory start=0x0000002f end=0x00000032 (size=0x00000003) count: 1 - Global start=0x00000034 end=0x00000065 (size=0x00000031) count: 8 - Export start=0x00000068 end=0x0000012b (size=0x000000c3) count: 15 - Code start=0x0000012e end=0x0000026a (size=0x0000013c) count: 6 - Data start=0x0000026c end=0x00000277 (size=0x0000000b) count: 1 - Custom start=0x0000027a end=0x00000354 (size=0x000000da) ".debug_info" - Custom start=0x00000356 end=0x0000038c (size=0x00000036) ".debug_ranges" - Custom start=0x0000038f end=0x0000042b (size=0x0000009c) ".debug_abbrev" - Custom start=0x0000042e end=0x000004d6 (size=0x000000a8) ".debug_line" - Custom start=0x000004d9 end=0x0000058f (size=0x000000b6) ".debug_str" - Custom start=0x00000591 end=0x000005d3 (size=0x00000042) "name" - Custom start=0x000005d6 end=0x0000065b (size=0x00000085) "producers" - -Section Details: - -Type[4]: - - type[0] () -> nil - - type[1] (i32) -> i32 - - type[2] (i32, i32) -> i32 - - type[3] () -> i32 -Function[6]: - - func[0] sig=0 <__wasm_call_ctors> - - func[1] sig=0 - - func[2] sig=1 - - func[3] sig=2 - - func[4] sig=3 <__original_main> - - func[5] sig=2
-Table[1]: - - table[0] type=funcref initial=1 max=1 -Memory[1]: - - memory[0] pages: initial=2 -Global[8]: - - global[0] i32 mutable=1 - init i32=66576 - - global[1] i32 mutable=0 - init i32=1024 - - global[2] i32 mutable=0 <__dso_handle> - init i32=1024 - - global[3] i32 mutable=0 <__data_end> - init i32=1028 - - global[4] i32 mutable=0 <__global_base> - init i32=1024 - - global[5] i32 mutable=0 <__heap_base> - init i32=66576 - - global[6] i32 mutable=0 <__memory_base> - init i32=0 - - global[7] i32 mutable=0 <__table_base> - init i32=1 -Export[15]: - - memory[0] -> "memory" - - table[0] -> "__indirect_function_table" - - func[0] <__wasm_call_ctors> -> "__wasm_call_ctors" - - func[1] -> "panic" - - func[2] -> "id" - - func[3] -> "add" - - func[4] <__original_main> -> "__original_main" - - func[5]
-> "main" - - global[1] -> "x" - - global[2] -> "__dso_handle" - - global[3] -> "__data_end" - - global[4] -> "__global_base" - - global[5] -> "__heap_base" - - global[6] -> "__memory_base" - - global[7] -> "__table_base" -Code[6]: - - func[0] size=2 <__wasm_call_ctors> - - func[1] size=64 - - func[2] size=73 - - func[3] size=61 - - func[4] size=94 <__original_main> - - func[5] size=15
-Data[1]: - - segment[0] memory=0 size=4 - init i32=1024 - - 0000400: 7b00 0000 {... -Custom: - - name: ".debug_info" -Custom: - - name: ".debug_ranges" -Custom: - - name: ".debug_abbrev" -Custom: - - name: ".debug_line" -Custom: - - name: ".debug_str" -Custom: - - name: "name" - - func[0] <__wasm_call_ctors> - - func[1] - - func[2] - - func[3] - - func[4] <__original_main> - - func[5]
-Custom: - - name: "producers" - -Code Disassembly: - -000130 func[0] <__wasm_call_ctors>: - 000131: 0b | end -000133 func[1] : - 000134: 08 7f | local[0..7] type=i32 - 000136: 23 80 80 80 80 00 | global.get 0 - 00013c: 21 00 | local.set 0 - 00013e: 41 10 | i32.const 16 - 000140: 21 01 | local.set 1 - 000142: 20 00 | local.get 0 - 000144: 20 01 | local.get 1 - 000146: 6b | i32.sub - 000147: 21 02 | local.set 2 - 000149: 41 02 | i32.const 2 - 00014b: 21 03 | local.set 3 - 00014d: 41 00 | i32.const 0 - 00014f: 21 04 | local.set 4 - 000151: 20 02 | local.get 2 - 000153: 20 04 | local.get 4 - 000155: 36 02 0c | i32.store 2 12 - 000158: 20 02 | local.get 2 - 00015a: 28 02 0c | i32.load 2 12 - 00015d: 21 05 | local.set 5 - 00015f: 41 7f | i32.const 4294967295 - 000161: 21 06 | local.set 6 - 000163: 20 05 | local.get 5 - 000165: 20 06 | local.get 6 - 000167: 6a | i32.add - 000168: 21 07 | local.set 7 - 00016a: 20 07 | local.get 7 - 00016c: 20 03 | local.get 3 - 00016e: 3a 00 00 | i32.store8 0 0 - 000171: 0f | return - 000172: 0b | end -000174 func[2] : - 000175: 06 7f | local[0..5] type=i32 - 000177: 23 80 80 80 80 00 | global.get 0 - 00017d: 21 01 | local.set 1 - 00017f: 41 10 | i32.const 16 - 000181: 21 02 | local.set 2 - 000183: 20 01 | local.get 1 - 000185: 20 02 | local.get 2 - 000187: 6b | i32.sub - 000188: 21 03 | local.set 3 - 00018a: 20 03 | local.get 3 - 00018c: 24 80 80 80 80 00 | global.set 0 - 000192: 20 03 | local.get 3 - 000194: 20 00 | local.get 0 - 000196: 36 02 0c | i32.store 2 12 - 000199: 10 81 80 80 80 00 | call 1 - 00019f: 20 03 | local.get 3 - 0001a1: 28 02 0c | i32.load 2 12 - 0001a4: 21 04 | local.set 4 - 0001a6: 41 10 | i32.const 16 - 0001a8: 21 05 | local.set 5 - 0001aa: 20 03 | local.get 3 - 0001ac: 20 05 | local.get 5 - 0001ae: 6a | i32.add - 0001af: 21 06 | local.set 6 - 0001b1: 20 06 | local.get 6 - 0001b3: 24 80 80 80 80 00 | global.set 0 - 0001b9: 20 04 | local.get 4 - 0001bb: 0f | return - 0001bc: 0b | end -0001be func[3] : - 0001bf: 06 7f | local[0..5] type=i32 - 0001c1: 23 80 80 80 80 00 | global.get 0 - 0001c7: 21 02 | local.set 2 - 0001c9: 41 10 | i32.const 16 - 0001cb: 21 03 | local.set 3 - 0001cd: 20 02 | local.get 2 - 0001cf: 20 03 | local.get 3 - 0001d1: 6b | i32.sub - 0001d2: 21 04 | local.set 4 - 0001d4: 20 04 | local.get 4 - 0001d6: 20 00 | local.get 0 - 0001d8: 36 02 0c | i32.store 2 12 - 0001db: 20 04 | local.get 4 - 0001dd: 20 01 | local.get 1 - 0001df: 36 02 08 | i32.store 2 8 - 0001e2: 20 04 | local.get 4 - 0001e4: 28 02 0c | i32.load 2 12 - 0001e7: 21 05 | local.set 5 - 0001e9: 20 04 | local.get 4 - 0001eb: 28 02 08 | i32.load 2 8 - 0001ee: 21 06 | local.set 6 - 0001f0: 20 05 | local.get 5 - 0001f2: 20 06 | local.get 6 - 0001f4: 6a | i32.add - 0001f5: 21 07 | local.set 7 - 0001f7: 20 07 | local.get 7 - 0001f9: 0f | return - 0001fa: 0b | end -0001fc func[4] <__original_main>: - 0001fd: 0a 7f | local[0..9] type=i32 - 0001ff: 23 80 80 80 80 00 | global.get 0 - 000205: 21 00 | local.set 0 - 000207: 41 10 | i32.const 16 - 000209: 21 01 | local.set 1 - 00020b: 20 00 | local.get 0 - 00020d: 20 01 | local.get 1 - 00020f: 6b | i32.sub - 000210: 21 02 | local.set 2 - 000212: 20 02 | local.get 2 - 000214: 24 80 80 80 80 00 | global.set 0 - 00021a: 41 16 | i32.const 22 - 00021c: 21 03 | local.set 3 - 00021e: 41 14 | i32.const 20 - 000220: 21 04 | local.set 4 - 000222: 41 00 | i32.const 0 - 000224: 21 05 | local.set 5 - 000226: 20 02 | local.get 2 - 000228: 20 05 | local.get 5 - 00022a: 36 02 0c | i32.store 2 12 - 00022d: 20 03 | local.get 3 - 00022f: 20 04 | local.get 4 - 000231: 10 83 80 80 80 00 | call 3 - 000237: 21 06 | local.set 6 - 000239: 20 06 | local.get 6 - 00023b: 10 82 80 80 80 00 | call 2 - 000241: 21 07 | local.set 7 - 000243: 41 10 | i32.const 16 - 000245: 21 08 | local.set 8 - 000247: 20 02 | local.get 2 - 000249: 20 08 | local.get 8 - 00024b: 6a | i32.add - 00024c: 21 09 | local.set 9 - 00024e: 20 09 | local.get 9 - 000250: 24 80 80 80 80 00 | global.set 0 - 000256: 20 07 | local.get 7 - 000258: 0f | return - 000259: 0b | end -00025b func[5]
: - 00025c: 01 7f | local[0] type=i32 - 00025e: 10 84 80 80 80 00 | call 4 <__original_main> - 000264: 21 02 | local.set 2 - 000266: 20 02 | local.get 2 - 000268: 0f | return - 000269: 0b | end diff --git a/playground/test-lld-wasm/README.md b/playground/test-lld-wasm/README.md deleted file mode 100644 index 23cd69b6..00000000 --- a/playground/test-lld-wasm/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# test-lld-wasm -try to merge/concat/link/combine two wasm files via wasm-ld -`compile.sh` -`compile-via-wat.sh` - -Maybe it's not a bug, but incorrect usage from our side. We ran into similar problems as this blog post: - - -``` -wasm-ld --entry main lib.wasm main.wasm -o linked.wasm -wasm-ld: error: entry symbol not defined (pass --no-entry to supress): main -``` - -Update: It works diff --git a/playground/test-lld-wasm/compile-shared.sh b/playground/test-lld-wasm/compile-shared.sh deleted file mode 100644 index afd80760..00000000 --- a/playground/test-lld-wasm/compile-shared.sh +++ /dev/null @@ -1,19 +0,0 @@ -# sudo -S ls -export PATH=/opt/wasm/wasi-sdk/bin/:$PATH - -echo whatever “shared” means, it doesnt work yet, BUT it works without “shared”, see ./compile.sh - -clang -Qn --target=wasm32 -nostdlib -Wl,--relocatable,--shared,--export-all -o lib.wasm lib.c -clang -Qn --target=wasm32 -nostdlib -Wl,--relocatable,--shared,--export-all -o main.wasm main.c - -wasm-ld --whole-archive -y test --export-all --import-memory --shared --no-entry lib.wasm main.wasm -o linked.wasm -# wasm-objdump -h linked.wasm -# wasm-objdump -x linked.wasm -# wasm2wat --no-check --enable-all --ignore-custom-section-errors linked.wasm -# --export=main doesn't work because main is somehow renamed to main.1 ! -# clang adds two parameters (argc, argv) to main by convention: -# wasmer -i main linked.wasm || -wasmer -i main linked.wasm -- 1 2 - -# ls -l linked.wasm -# wasmx linked.wasm \ No newline at end of file diff --git a/playground/test-lld-wasm/compile-via-wat.sh b/playground/test-lld-wasm/compile-via-wat.sh deleted file mode 100644 index ae32378e..00000000 --- a/playground/test-lld-wasm/compile-via-wat.sh +++ /dev/null @@ -1,7 +0,0 @@ -echo needs wat2wasm from https://github.com/WebAssembly/wabt -wat2wasm --relocatable lib.wat -wat2wasm --relocatable main.wat -wasm-ld --verbose --trace -E --entry main lib.wasm main.wasm -o linked.wasm -hexdump -C linked.wasm -echo expect '42' as result: -wasmer -i main linked.wasm \ No newline at end of file diff --git a/playground/test-lld-wasm/compile.sh b/playground/test-lld-wasm/compile.sh deleted file mode 100644 index e4e2593a..00000000 --- a/playground/test-lld-wasm/compile.sh +++ /dev/null @@ -1,11 +0,0 @@ -export PATH=/opt/wasm/wasi-sdk/bin/:$PATH - -# --target=wasm32 -clang -Qn -nostdlib -Wl,--relocatable,--export-all -o lib.wasm lib.c -clang -Qn -nostdlib -Wl,--relocatable -o main.wasm main.c - -wasm-ld --entry main lib.wasm main.wasm -o linked.wasm - -# $clang adds two parameters (argc, argv) to main by convention: -# wasmer -i main linked.wasm || -wasmer -i main linked.wasm -- 1 2 \ No newline at end of file diff --git a/playground/test-lld-wasm/lib.c b/playground/test-lld-wasm/lib.c deleted file mode 100644 index 84adeec1..00000000 --- a/playground/test-lld-wasm/lib.c +++ /dev/null @@ -1,3 +0,0 @@ -int test(){ - return 42; -} diff --git a/playground/test-lld-wasm/lib.rs b/playground/test-lld-wasm/lib.rs deleted file mode 100644 index 116a3491..00000000 --- a/playground/test-lld-wasm/lib.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[allow(non_camel_case_types)] -type int = u32; - -fn add(a: int, b: int) { - return a + b; -} \ No newline at end of file diff --git a/playground/test-lld-wasm/main.c b/playground/test-lld-wasm/main.c deleted file mode 100644 index be69443b..00000000 --- a/playground/test-lld-wasm/main.c +++ /dev/null @@ -1,5 +0,0 @@ -int test(); -int main() -{ - return test(); -} diff --git a/playground/test.wast copy b/playground/test.wast copy deleted file mode 100644 index e156028a..00000000 --- a/playground/test.wast copy +++ /dev/null @@ -1,15 +0,0 @@ -(module $wasp_module - (type (;0;) (func (result i64))) - (func $main (type 0) (result i64) - (local $one i32) (local $plus i32) (local $two i32) (local $times i32) (local $three i32) - local.get $one - local.get $plus - local.get $two - local.get $times - local.get $three - return) - (memory (;0;) 10240) - (global (;0;) f64 (f64.const 0x1.921fb54442d18p+1 (;=3.14159;))) - (export "main" (func $main)) - (export "memory" (memory 0)) - (export "\cf\80" (global 0))) diff --git a/playground/test_compile_wasm_to_c_to_native.sh b/playground/test_compile_wasm_to_c_to_native.sh deleted file mode 100755 index ea722bf9..00000000 --- a/playground/test_compile_wasm_to_c_to_native.sh +++ /dev/null @@ -1,4 +0,0 @@ -# https://github.com/WebAssembly/wabt/tree/main/wasm2c - -wasm2c test.wasm -o test_generated.c -cc -o wasp_native wasp_wrapper.c test_generated.c wasm-rt-impl.c && ./wasp_native \ No newline at end of file diff --git a/playground/utf.txt b/playground/utf.txt deleted file mode 100644 index f731d050..00000000 --- a/playground/utf.txt +++ /dev/null @@ -1 +0,0 @@ -∑ \ No newline at end of file diff --git a/playground/utf_ok_in_wasm_but_not_in_wat.txt b/playground/utf_ok_in_wasm_but_not_in_wat.txt deleted file mode 100644 index cf4a8150..00000000 --- a/playground/utf_ok_in_wasm_but_not_in_wat.txt +++ /dev/null @@ -1,11 +0,0 @@ -replacing "main" with "0x6DE28891" in hexedit works, and can be invoked: -wasmer t.wasm -i m∑ - -wat does not work though -w2w yields $m___ instead of $m∑ and does not compile back: - -(module - (type (;0;) (func (result i32))) - (func $m∑ (type 0) (result i32) - i32.const 123) - (export "m\e2\88\91" (func $m∑))) \ No newline at end of file diff --git a/playground/wapm.lock b/playground/wapm.lock deleted file mode 100644 index d0f308d9..00000000 --- a/playground/wapm.lock +++ /dev/null @@ -1,35 +0,0 @@ -# Lockfile v4 -# This file is automatically generated by Wapm. -# It is not intended for manual editing. The schema of this file may change. -[modules."_/clang"."0.1.0".clang] -name = "clang" -package_version = "0.1.0" -package_name = "_/clang" -package_path = "_/clang@0.1.0" -resolved = "https://registry-cdn.wapm.io/packages/_/clang/clang-0.1.0.tar.gz" -resolved_source = "registry+clang" -abi = "wasi" -source = "clang.wasm" - -[modules."_/clang"."0.1.0".wasm-ld] -name = "wasm-ld" -package_version = "0.1.0" -package_name = "_/clang" -package_path = "_/clang@0.1.0" -resolved = "https://registry-cdn.wapm.io/packages/_/clang/clang-0.1.0.tar.gz" -resolved_source = "registry+wasm-ld" -abi = "wasi" -source = "wasm-ld.wasm" -[commands.clang] -name = "clang" -package_name = "_/clang" -package_version = "0.1.0" -module = "clang" -is_top_level_dependency = true - -[commands.wasm-ld] -name = "wasm-ld" -package_name = "_/clang" -package_version = "0.1.0" -module = "wasm-ld" -is_top_level_dependency = true