Skip to content

Commit 604a0dd

Browse files
committed
Rename ExecutionContext::{Guard -> LocalContext}
1 parent 10442dd commit 604a0dd

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

lib/fizzy/execute.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ ExecutionResult execute(
573573
const auto& code = instance.module->get_code(func_idx);
574574
auto* const memory = instance.memory.get();
575575

576-
const auto ctx_guard = ctx.increment_call_depth();
576+
const auto local_ctx = ctx.increment_call_depth();
577577

578578
OperandStack stack(args, func_type.inputs.size(), code.local_count,
579579
static_cast<size_t>(code.max_stack_height));

lib/fizzy/execution_context.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,32 @@ namespace fizzy
1010
/// Users may decide how to allocate the execution context, but some good defaults are available.
1111
class ExecutionContext
1212
{
13-
/// Call depth increment guard.
13+
/// Call local execution context.
1414
/// It will automatically decrement the call depth to the original value
1515
/// when going out of scope.
16-
class [[nodiscard]] Guard
16+
class [[nodiscard]] LocalContext
1717
{
18-
ExecutionContext& m_execution_context; ///< Reference to the guarded execution context.
18+
ExecutionContext& m_shared_ctx; ///< Reference to the shared execution context.
1919

2020
public:
21-
Guard(const Guard&) = delete;
22-
Guard(Guard&&) = delete;
23-
Guard& operator=(const Guard&) = delete;
24-
Guard& operator=(Guard&&) = delete;
21+
LocalContext(const LocalContext&) = delete;
22+
LocalContext(LocalContext&&) = delete;
23+
LocalContext& operator=(const LocalContext&) = delete;
24+
LocalContext& operator=(LocalContext&&) = delete;
2525

26-
explicit Guard(ExecutionContext& ctx) noexcept : m_execution_context{ctx}
26+
explicit LocalContext(ExecutionContext& ctx) noexcept : m_shared_ctx{ctx}
2727
{
28-
++m_execution_context.depth;
28+
++m_shared_ctx.depth;
2929
}
3030

31-
~Guard() noexcept { --m_execution_context.depth; }
31+
~LocalContext() noexcept { --m_shared_ctx.depth; }
3232
};
3333

3434
public:
3535
int depth = 0; ///< Current call depth.
3636

37-
/// Increments the call depth and returns the guard object which decrements
38-
/// the call depth back to the original value when going out of scope.
39-
Guard increment_call_depth() noexcept { return Guard{*this}; }
37+
/// Increments the call depth and returns the local call context which
38+
/// decrements the call depth back to the original value when going out of scope.
39+
LocalContext increment_call_depth() noexcept { return LocalContext{*this}; }
4040
};
4141
} // namespace fizzy

test/unittests/execute_call_depth_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ TEST(execute_call_depth, call_host_function_calling_wasm_function_inclusive)
213213
constexpr auto host_f = [](std::any&, Instance& instance, const Value*,
214214
ExecutionContext& ctx) noexcept {
215215
recorded_depth = ctx.depth;
216-
const auto ctx_guard = ctx.increment_call_depth();
216+
const auto local_ctx = ctx.increment_call_depth();
217217
return fizzy::execute(instance, 2 /* $leaf */, {}, ctx);
218218
};
219219

@@ -304,7 +304,7 @@ TEST(execute_call_depth, call_host_function_calling_another_wasm_module)
304304
ExecutionContext& ctx) noexcept {
305305
recorded_depth = ctx.depth;
306306
auto instance = *std::any_cast<Instance*>(&host_context);
307-
const auto ctx_guard = ctx.increment_call_depth();
307+
const auto local_ctx = ctx.increment_call_depth();
308308
return fizzy::execute(*instance, 0, {}, ctx);
309309
};
310310

@@ -466,7 +466,7 @@ TEST(execute_call_depth, execute_host_function_within_wasm_recursion_limit)
466466
constexpr auto host_f = [](std::any&, Instance& instance, const Value*,
467467
ExecutionContext& ctx) noexcept {
468468
max_recorded_wasm_recursion_depth = std::max(max_recorded_wasm_recursion_depth, ctx.depth);
469-
const auto ctx_guard = ctx.increment_call_depth();
469+
const auto local_ctx = ctx.increment_call_depth();
470470
return fizzy::execute(instance, 0, {}, ctx);
471471
};
472472

@@ -537,7 +537,7 @@ TEST(execute_call, call_host_function_calling_wasm_interleaved_infinite_recursio
537537
ExecutionContext& ctx) noexcept {
538538
EXPECT_LT(ctx.depth, DepthLimit);
539539
++counter;
540-
const auto ctx_guard = ctx.increment_call_depth();
540+
const auto local_ctx = ctx.increment_call_depth();
541541
return fizzy::execute(instance, 1, {}, ctx);
542542
};
543543

0 commit comments

Comments
 (0)