@@ -572,14 +572,22 @@ void V8::getModuleFunctionImpl(std::string_view function_name,
572
572
return ;
573
573
}
574
574
*function = [func, function_name, this ](ContextBase *context, Args... args) -> void {
575
- wasm::Val params[] = {makeVal (args)...};
576
575
const bool log = cmpLogLevel (LogLevel::trace);
577
- if (log ) {
578
- integration ()->trace (" [host->vm] " + std::string (function_name) + " (" +
579
- printValues (params, sizeof ...(Args)) + " )" );
580
- }
581
576
SaveRestoreContext saved_context (context);
582
- auto trap = func->call (params, nullptr );
577
+ wasm::own<wasm::Trap> trap = nullptr ;
578
+ if constexpr (sizeof ...(args) > 0 ) {
579
+ wasm::Val params[] = {makeVal (args)...};
580
+ if (log ) {
581
+ integration ()->trace (" [host->vm] " + std::string (function_name) + " (" +
582
+ printValues (params, sizeof ...(Args)) + " )" );
583
+ }
584
+ trap = func->call (params, nullptr );
585
+ } else {
586
+ if (log ) {
587
+ integration ()->trace (" [host->vm] " + std::string (function_name) + " ()" );
588
+ }
589
+ trap = func->call (nullptr , nullptr );
590
+ }
583
591
if (trap) {
584
592
fail (FailState::RuntimeError, getFailMessage (std::string (function_name), std::move (trap)));
585
593
return ;
@@ -612,15 +620,23 @@ void V8::getModuleFunctionImpl(std::string_view function_name,
612
620
return ;
613
621
}
614
622
*function = [func, function_name, this ](ContextBase *context, Args... args) -> R {
615
- wasm::Val params[] = {makeVal (args)...};
616
- wasm::Val results[1 ];
617
623
const bool log = cmpLogLevel (LogLevel::trace);
618
- if (log ) {
619
- integration ()->trace (" [host->vm] " + std::string (function_name) + " (" +
620
- printValues (params, sizeof ...(Args)) + " )" );
621
- }
622
624
SaveRestoreContext saved_context (context);
623
- auto trap = func->call (params, results);
625
+ wasm::Val results[1 ];
626
+ wasm::own<wasm::Trap> trap = nullptr ;
627
+ if constexpr (sizeof ...(args) > 0 ) {
628
+ wasm::Val params[] = {makeVal (args)...};
629
+ if (log ) {
630
+ integration ()->trace (" [host->vm] " + std::string (function_name) + " (" +
631
+ printValues (params, sizeof ...(Args)) + " )" );
632
+ }
633
+ trap = func->call (params, results);
634
+ } else {
635
+ if (log ) {
636
+ integration ()->trace (" [host->vm] " + std::string (function_name) + " ()" );
637
+ }
638
+ trap = func->call (nullptr , results);
639
+ }
624
640
if (trap) {
625
641
fail (FailState::RuntimeError, getFailMessage (std::string (function_name), std::move (trap)));
626
642
return R{};
0 commit comments