mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 17:15: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:
parent
70b94f58b2
commit
65cd5526cb
6 changed files with 25 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue