mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-05-24 03:59:09 +00:00
LibWasm+Everywhere: Make the instruction count limit configurable
...and enable it for LibWeb and test-wasm. Note that `wasm` will not be limited by this.
This commit is contained in:
@@ -37,12 +37,15 @@ void BytecodeInterpreter::interpret(Configuration& configuration)
|
||||
auto& instructions = configuration.frame().expression().instructions();
|
||||
auto max_ip_value = InstructionPointer { instructions.size() };
|
||||
auto& current_ip_value = configuration.ip();
|
||||
auto const should_limit_instruction_count = configuration.should_limit_instruction_count();
|
||||
u64 executed_instructions = 0;
|
||||
|
||||
while (current_ip_value < max_ip_value) {
|
||||
if (executed_instructions++ >= Constants::max_allowed_executed_instructions_per_call) [[unlikely]] {
|
||||
m_trap = Trap { "Exceeded maximum allowed number of instructions" };
|
||||
return;
|
||||
if (should_limit_instruction_count) {
|
||||
if (executed_instructions++ >= Constants::max_allowed_executed_instructions_per_call) [[unlikely]] {
|
||||
m_trap = Trap { "Exceeded maximum allowed number of instructions" };
|
||||
return;
|
||||
}
|
||||
}
|
||||
auto& instruction = instructions[current_ip_value.value()];
|
||||
auto old_ip = current_ip_value;
|
||||
|
||||
Reference in New Issue
Block a user