[llvm-dev] [WebAssembly] lld dynamic loader

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] [WebAssembly] lld dynamic loader

U.Mutlu via llvm-dev

Hello, 

The table generated by lld (Wasm target) have a max size.  

So this make impossible to add some others functions in the table .

As for the moment only one Table is available in WAsm this is the only way to add function in a dynamic way.

 

Having a none static size of the table is useful for a kind dynamic loader/inker at run-time: by adding some exported functions coming from another modules in the table, so call_indirect can call dynamically some function coming from another wasm module.

 

So I am wondering if the static size of the table have a specific goal ?

If not did you think the WASM_LIMITS_FLAG_HAS_MAX can be remove ?

 

https://llvm.org/svn/llvm-project/lld/trunk/wasm/Writer.cpp
 void Writer::createTableSection() {
..
WasmLimits Limits = {WASM_LIMITS_FLAG_HAS_MAX, TableSize, TableSize};

 

 

Thks in advance,

Ghis



_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] [WebAssembly] lld dynamic loader

U.Mutlu via llvm-dev
Hi Ghis

Originally when we wrote the wasm port of lld we didn't support
importing or exporting the table so it made sense to set a max size.
However, now that we have the --import-table flag I don't see why we
shouldn't support tables without a max size.  Feel free to send a
patch, or open a bug and I will get around to it.

cheers,
sam

On Fri, Jun 1, 2018 at 6:00 AM, HUDE Ghislain via llvm-dev
<[hidden email]> wrote:

> Hello,
>
> The table generated by lld (Wasm target) have a max size.
>
> So this make impossible to add some others functions in the table .
>
> As for the moment only one Table is available in WAsm this is the only way
> to add function in a dynamic way.
>
>
>
> Having a none static size of the table is useful for a kind dynamic
> loader/inker at run-time: by adding some exported functions coming from
> another modules in the table, so call_indirect can call dynamically some
> function coming from another wasm module.
>
>
>
> So I am wondering if the static size of the table have a specific goal ?
>
> If not did you think the WASM_LIMITS_FLAG_HAS_MAX can be remove ?
>
>
>
> https://llvm.org/svn/llvm-project/lld/trunk/wasm/Writer.cpp
>
>  void Writer::createTableSection() {
>
> ..
>
> WasmLimits Limits = {WASM_LIMITS_FLAG_HAS_MAX, TableSize, TableSize};
>
>
>
>
>
> Thks in advance,
>
> Ghis
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] [WebAssembly] lld dynamic loader

U.Mutlu via llvm-dev
Hi Sam,
Thanks for your answer!

Sorry I didn't really know how to process, but this issue block me to make some legacy C code works without having some glue with a bit static lib ;(

(The change have really low risk)
The changes I used locally to make dlopen/dlclose et dlsym mechanism works :) :
Index: wasm/Writer.cpp
===================================================================
--- wasm/Writer.cpp     (revision 330555)
+++ wasm/Writer.cpp     (working copy)
@@ -257,7 +257,7 @@
   raw_ostream &OS = Section->getStream();

   writeUleb128(OS, 1, "table count");
-  WasmLimits Limits = {WASM_LIMITS_FLAG_HAS_MAX, TableSize, TableSize};
+  WasmLimits Limits = {0, TableSize, TableSize};
   writeTableType(OS, WasmTable{WASM_TYPE_ANYFUNC, Limits});
 }

May be to have a code more readable   WASM_LIMITS_FLAG_HAS_NO_MAX (=0) can be added.

Thks,
Ghis


2018-06-03 23:45 GMT+02:00 Sam Clegg <[hidden email]>:
Hi Ghis

Originally when we wrote the wasm port of lld we didn't support
importing or exporting the table so it made sense to set a max size.
However, now that we have the --import-table flag I don't see why we
shouldn't support tables without a max size.  Feel free to send a
patch, or open a bug and I will get around to it.

cheers,
sam

On Fri, Jun 1, 2018 at 6:00 AM, HUDE Ghislain via llvm-dev
<[hidden email]> wrote:
> Hello,
>
> The table generated by lld (Wasm target) have a max size.
>
> So this make impossible to add some others functions in the table .
>
> As for the moment only one Table is available in WAsm this is the only way
> to add function in a dynamic way.
>
>
>
> Having a none static size of the table is useful for a kind dynamic
> loader/inker at run-time: by adding some exported functions coming from
> another modules in the table, so call_indirect can call dynamically some
> function coming from another wasm module.
>
>
>
> So I am wondering if the static size of the table have a specific goal ?
>
> If not did you think the WASM_LIMITS_FLAG_HAS_MAX can be remove ?
>
>
>
> https://llvm.org/svn/llvm-project/lld/trunk/wasm/Writer.cpp
>
>  void Writer::createTableSection() {
>
> ..
>
> WasmLimits Limits = {WASM_LIMITS_FLAG_HAS_MAX, TableSize, TableSize};
>
>
>
>
>
> Thks in advance,
>
> Ghis
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev