Skip to content

Commit

Permalink
Rename ExecutionContext::{inrement_call_depth() -> create_local_conte…
Browse files Browse the repository at this point in the history
…xt()}
  • Loading branch information
chfast committed Apr 9, 2021
1 parent 604a0dd commit 524e5aa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/fizzy/execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ ExecutionResult execute(
const auto& code = instance.module->get_code(func_idx);
auto* const memory = instance.memory.get();

const auto local_ctx = ctx.increment_call_depth();
const auto local_ctx = ctx.create_local_context();

OperandStack stack(args, func_type.inputs.size(), code.local_count,
static_cast<size_t>(code.max_stack_height));
Expand Down
2 changes: 1 addition & 1 deletion lib/fizzy/execution_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ class ExecutionContext

/// Increments the call depth and returns the local call context which
/// decrements the call depth back to the original value when going out of scope.
LocalContext increment_call_depth() noexcept { return LocalContext{*this}; }
LocalContext create_local_context() noexcept { return LocalContext{*this}; }
};
} // namespace fizzy
8 changes: 4 additions & 4 deletions test/unittests/execute_call_depth_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ TEST(execute_call_depth, call_host_function_calling_wasm_function_inclusive)
constexpr auto host_f = [](std::any&, Instance& instance, const Value*,
ExecutionContext& ctx) noexcept {
recorded_depth = ctx.depth;
const auto local_ctx = ctx.increment_call_depth();
const auto local_ctx = ctx.create_local_context();
return fizzy::execute(instance, 2 /* $leaf */, {}, ctx);
};

Expand Down Expand Up @@ -304,7 +304,7 @@ TEST(execute_call_depth, call_host_function_calling_another_wasm_module)
ExecutionContext& ctx) noexcept {
recorded_depth = ctx.depth;
auto instance = *std::any_cast<Instance*>(&host_context);
const auto local_ctx = ctx.increment_call_depth();
const auto local_ctx = ctx.create_local_context();
return fizzy::execute(*instance, 0, {}, ctx);
};

Expand Down Expand Up @@ -466,7 +466,7 @@ TEST(execute_call_depth, execute_host_function_within_wasm_recursion_limit)
constexpr auto host_f = [](std::any&, Instance& instance, const Value*,
ExecutionContext& ctx) noexcept {
max_recorded_wasm_recursion_depth = std::max(max_recorded_wasm_recursion_depth, ctx.depth);
const auto local_ctx = ctx.increment_call_depth();
const auto local_ctx = ctx.create_local_context();
return fizzy::execute(instance, 0, {}, ctx);
};

Expand Down Expand Up @@ -537,7 +537,7 @@ TEST(execute_call, call_host_function_calling_wasm_interleaved_infinite_recursio
ExecutionContext& ctx) noexcept {
EXPECT_LT(ctx.depth, DepthLimit);
++counter;
const auto local_ctx = ctx.increment_call_depth();
const auto local_ctx = ctx.create_local_context();
return fizzy::execute(instance, 1, {}, ctx);
};

Expand Down

0 comments on commit 524e5aa

Please sign in to comment.