Add a benchmark for wrenCall().

This commit is contained in:
Bob Nystrom
2015-12-23 17:29:53 -08:00
parent b7e62926ab
commit 15043b897f
6 changed files with 76 additions and 3 deletions
+6
View File
@@ -226,6 +226,12 @@ WrenInterpretResult wrenCallVarArgs(WrenVM* vm, WrenValue* method,
WrenValue** returnValue,
const char* argTypes, va_list args);
// Gets the numeric value of [value].
//
// It is an error to call this if the value is not a number.
double wrenGetValueDouble(WrenVM* vm, WrenValue* value);
// TODO: Functions for other types.
// Releases the reference stored in [value]. After calling this, [value] can no
// longer be used.
void wrenReleaseValue(WrenVM* vm, WrenValue* value);
+10 -2
View File
@@ -1474,9 +1474,17 @@ WrenValue* wrenCaptureValue(WrenVM* vm, Value value)
return wrappedValue;
}
double wrenGetValueDouble(WrenVM* vm, WrenValue* value)
{
ASSERT(value != NULL, "Value cannot be NULL.");
ASSERT(IS_NUM(value->value), "Value must be a number.");
return AS_NUM(value->value);
}
void wrenReleaseValue(WrenVM* vm, WrenValue* value)
{
ASSERT(value != NULL, "NULL value.");
ASSERT(value != NULL, "Value cannot be NULL.");
// Update the VM's head pointer if we're releasing the first handle.
if (vm->valueHandles == value) vm->valueHandles = value->next;
@@ -1734,7 +1742,7 @@ void wrenSetSlotBool(WrenVM* vm, int slot, bool value)
void wrenSetSlotBytes(WrenVM* vm, int slot, const char* bytes, int length)
{
ASSERT(bytes != NULL, "Byte arraybytes cannot be NULL.");
ASSERT(bytes != NULL, "Byte array cannot be NULL.");
setSlot(vm, slot, wrenNewString(vm, bytes, (size_t)length));
}