Skip to content

Commit 83b8e82

Browse files
committed
wip 2 - new commit to track perfs on codspeed easily
1 parent 35b9037 commit 83b8e82

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

include/Ark/VM/VM.hpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,15 @@ namespace Ark
248248
*/
249249
[[nodiscard]] inline ARK_ALWAYS_INLINE Value* loadConstAsPtr(uint16_t id) const;
250250

251+
/**
252+
* @brief Find the nearest variable of a given id
253+
*
254+
* @param id the id to find
255+
* @param context
256+
* @return Value*
257+
*/
258+
inline ARK_ALWAYS_INLINE Value* findNearestVariable(uint16_t id, internal::ExecutionContext& context) noexcept;
259+
251260
/**
252261
* @brief Create a new symbol with an associated value in the current scope
253262
*
@@ -268,9 +277,9 @@ namespace Ark
268277

269278
inline ARK_ALWAYS_INLINE void jump(uint16_t address, internal::ExecutionContext& context);
270279

271-
Value getField(Value* closure, uint16_t id, const internal::ExecutionContext& context, bool push_with_env = false);
280+
[[nodiscard]] Value getField(Value* closure, uint16_t id, const internal::ExecutionContext& context, bool push_with_env = false);
272281

273-
Value createList(std::size_t count, internal::ExecutionContext& context);
282+
[[nodiscard]] Value createList(std::size_t count, internal::ExecutionContext& context);
274283

275284
void listAppendInPlace(Value* list, std::size_t count, internal::ExecutionContext& context);
276285

@@ -286,6 +295,13 @@ namespace Ark
286295
*/
287296
inline ARK_ALWAYS_INLINE Value* pop(internal::ExecutionContext& context);
288297

298+
/**
299+
* @brief Return a pointer to the top of the stack without consuming it
300+
*
301+
* @param context
302+
* @param offset
303+
* @return Value*
304+
*/
289305
inline ARK_ALWAYS_INLINE Value* peek(internal::ExecutionContext& context, std::size_t offset = 0);
290306

291307
/**
@@ -329,19 +345,6 @@ namespace Ark
329345
*/
330346
inline ARK_ALWAYS_INLINE Value* popAndResolveAsPtr(internal::ExecutionContext& context);
331347

332-
// ================================================
333-
// locals related
334-
// ================================================
335-
336-
/**
337-
* @brief Find the nearest variable of a given id
338-
*
339-
* @param id the id to find
340-
* @param context
341-
* @return Value*
342-
*/
343-
inline Value* findNearestVariable(uint16_t id, internal::ExecutionContext& context) noexcept;
344-
345348
// ================================================
346349
// function calls
347350
// ================================================

include/Ark/VM/VM.inl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ inline ARK_ALWAYS_INLINE Value* VM::loadConstAsPtr(const uint16_t id) const
126126
return &m_state.m_constants[id];
127127
}
128128

129+
inline ARK_ALWAYS_INLINE Value* VM::findNearestVariable(const uint16_t id, internal::ExecutionContext& context) noexcept
130+
{
131+
for (auto it = context.locals.rbegin(), it_end = context.locals.rend(); it != it_end; ++it)
132+
{
133+
if (Value* val = (*it)[id]; val != nullptr)
134+
return val;
135+
}
136+
return nullptr;
137+
}
138+
129139
inline ARK_ALWAYS_INLINE void VM::store(const uint16_t id, const Value* val, internal::ExecutionContext& context)
130140
{
131141
// avoid adding the pair (id, _) multiple times, with different values
@@ -225,16 +235,6 @@ inline ARK_ALWAYS_INLINE Value* VM::popAndResolveAsPtr(internal::ExecutionContex
225235

226236
#pragma endregion
227237

228-
inline Value* VM::findNearestVariable(const uint16_t id, internal::ExecutionContext& context) noexcept
229-
{
230-
for (auto it = context.locals.rbegin(), it_end = context.locals.rend(); it != it_end; ++it)
231-
{
232-
if (Value* val = (*it)[id]; val != nullptr)
233-
return val;
234-
}
235-
return nullptr;
236-
}
237-
238238
inline ARK_ALWAYS_INLINE void VM::returnFromFuncCall(internal::ExecutionContext& context)
239239
{
240240
--context.fc;

0 commit comments

Comments
 (0)