Skip to content

Commit 5852b13

Browse files
axickripken
authored andcommitted
Mark arguments const in callExport (#1626)
The arguments is read only and therefore could be const. The immediate benefit is callers do not need to define it as a local variable (see Literal callExport(Name name)).
1 parent 7db96b6 commit 5852b13

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/wasm-interpreter.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -649,15 +649,14 @@ class ModuleInstanceBase {
649649
}
650650

651651
// call an exported function
652-
Literal callExport(Name name, LiteralList& arguments) {
652+
Literal callExport(Name name, const LiteralList& arguments) {
653653
Export *export_ = wasm.getExportOrNull(name);
654654
if (!export_) externalInterface->trap("callExport not found");
655655
return callFunction(export_->value, arguments);
656656
}
657657

658658
Literal callExport(Name name) {
659-
LiteralList arguments;
660-
return callExport(name, arguments);
659+
return callExport(name, LiteralList());
661660
}
662661

663662
// get an exported global
@@ -689,22 +688,22 @@ class ModuleInstanceBase {
689688

690689
public:
691690
// Call a function, starting an invocation.
692-
Literal callFunction(Name name, LiteralList& arguments) {
691+
Literal callFunction(Name name, const LiteralList& arguments) {
693692
// if the last call ended in a jump up the stack, it might have left stuff for us to clean up here
694693
callDepth = 0;
695694
functionStack.clear();
696695
return callFunctionInternal(name, arguments);
697696
}
698697

699698
// Internal function call. Must be public so that callTable implementations can use it (refactor?)
700-
Literal callFunctionInternal(Name name, LiteralList& arguments) {
699+
Literal callFunctionInternal(Name name, const LiteralList& arguments) {
701700

702701
class FunctionScope {
703702
public:
704703
std::vector<Literal> locals;
705704
Function* function;
706705

707-
FunctionScope(Function* function, LiteralList& arguments)
706+
FunctionScope(Function* function, const LiteralList& arguments)
708707
: function(function) {
709708
if (function->params.size() != arguments.size()) {
710709
std::cerr << "Function `" << function->name << "` expects "

0 commit comments

Comments
 (0)