mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:47:34 +00:00
LibWasm: Move some Values and Vector<Value>s instead of copying them
This commit is contained in:
parent
fa2ae02564
commit
8b6397446e
2 changed files with 5 additions and 7 deletions
|
@ -126,7 +126,7 @@ void BytecodeInterpreter::call_address(Configuration& configuration, FunctionAdd
|
||||||
for (auto& entry : span) {
|
for (auto& entry : span) {
|
||||||
auto* ptr = entry.get_pointer<Value>();
|
auto* ptr = entry.get_pointer<Value>();
|
||||||
TRAP_IF_NOT(ptr != nullptr);
|
TRAP_IF_NOT(ptr != nullptr);
|
||||||
args.unchecked_append(*ptr);
|
args.unchecked_append(move(*ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
configuration.stack().entries().remove(configuration.stack().size() - span.size(), span.size());
|
configuration.stack().entries().remove(configuration.stack().size() - span.size(), span.size());
|
||||||
|
@ -173,7 +173,7 @@ void BytecodeInterpreter::binary_numeric_operation(Configuration& configuration)
|
||||||
result = call_result;
|
result = call_result;
|
||||||
}
|
}
|
||||||
dbgln_if(WASM_TRACE_DEBUG, "{} {} {} = {}", lhs.value(), Operator::name(), rhs.value(), result);
|
dbgln_if(WASM_TRACE_DEBUG, "{} {} {} = {}", lhs.value(), Operator::name(), rhs.value(), result);
|
||||||
configuration.stack().peek() = Value(result);
|
lhs_entry = Value(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename PopType, typename PushType, typename Operator>
|
template<typename PopType, typename PushType, typename Operator>
|
||||||
|
@ -197,7 +197,7 @@ void BytecodeInterpreter::unary_operation(Configuration& configuration)
|
||||||
result = call_result;
|
result = call_result;
|
||||||
}
|
}
|
||||||
dbgln_if(WASM_TRACE_DEBUG, "map({}) {} = {}", Operator::name(), *value, result);
|
dbgln_if(WASM_TRACE_DEBUG, "map({}) {} = {}", Operator::name(), *value, result);
|
||||||
configuration.stack().peek() = Value(result);
|
entry = Value(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
@ -42,10 +42,8 @@ Result Configuration::call(Interpreter& interpreter, FunctionAddress address, Ve
|
||||||
if (!function)
|
if (!function)
|
||||||
return Trap {};
|
return Trap {};
|
||||||
if (auto* wasm_function = function->get_pointer<WasmFunction>()) {
|
if (auto* wasm_function = function->get_pointer<WasmFunction>()) {
|
||||||
Vector<Value> locals;
|
Vector<Value> locals = move(arguments);
|
||||||
locals.ensure_capacity(arguments.size() + wasm_function->code().locals().size());
|
locals.ensure_capacity(locals.size() + wasm_function->code().locals().size());
|
||||||
for (auto& value : arguments)
|
|
||||||
locals.append(Value { value });
|
|
||||||
for (auto& type : wasm_function->code().locals())
|
for (auto& type : wasm_function->code().locals())
|
||||||
locals.empend(type, 0ull);
|
locals.empend(type, 0ull);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue