mirror of
https://github.com/bellard/quickjs.git
synced 2026-05-27 19:09:36 +00:00
added custom malloc for small blocks (11% faster on bench-v8)
Some checks are pending
ci / Linux (Ubuntu) (push) Waiting to run
ci / Linux LTO (push) Waiting to run
ci / Linux 32bit (push) Waiting to run
ci / linux-asan (push) Waiting to run
ci / linux-msan (push) Waiting to run
ci / linux-ubsan (push) Waiting to run
ci / macOS (push) Waiting to run
ci / macos-asan (push) Waiting to run
ci / macos-ubsan (push) Waiting to run
ci / freebsd (push) Waiting to run
ci / Cosmopolitan (push) Waiting to run
ci / MinGW Windows target (push) Waiting to run
ci / Windows MSYS2 (push) Waiting to run
ci / qemu-alpine (linux/386) (push) Waiting to run
ci / qemu-alpine (linux/arm/v6) (push) Waiting to run
ci / qemu-alpine (linux/arm/v7) (push) Waiting to run
ci / qemu-alpine (linux/arm64) (push) Waiting to run
ci / qemu-alpine (linux/ppc64le) (push) Waiting to run
ci / qemu-alpine (linux/riscv64) (push) Waiting to run
ci / qemu-alpine (linux/s390x) (push) Waiting to run
Some checks are pending
ci / Linux (Ubuntu) (push) Waiting to run
ci / Linux LTO (push) Waiting to run
ci / Linux 32bit (push) Waiting to run
ci / linux-asan (push) Waiting to run
ci / linux-msan (push) Waiting to run
ci / linux-ubsan (push) Waiting to run
ci / macOS (push) Waiting to run
ci / macos-asan (push) Waiting to run
ci / macos-ubsan (push) Waiting to run
ci / freebsd (push) Waiting to run
ci / Cosmopolitan (push) Waiting to run
ci / MinGW Windows target (push) Waiting to run
ci / Windows MSYS2 (push) Waiting to run
ci / qemu-alpine (linux/386) (push) Waiting to run
ci / qemu-alpine (linux/arm/v6) (push) Waiting to run
ci / qemu-alpine (linux/arm/v7) (push) Waiting to run
ci / qemu-alpine (linux/arm64) (push) Waiting to run
ci / qemu-alpine (linux/ppc64le) (push) Waiting to run
ci / qemu-alpine (linux/riscv64) (push) Waiting to run
ci / qemu-alpine (linux/s390x) (push) Waiting to run
This commit is contained in:
parent
e182e3df5c
commit
99e9181d11
@ -1,3 +1,4 @@
|
||||
- added custom malloc for small blocks (11% faster on bench-v8)
|
||||
- micro optimizations (30% faster on bench-v8)
|
||||
- added resizable array buffers
|
||||
- added ArrayBuffer.prototype.transfer
|
||||
|
||||
15
quickjs.h
15
quickjs.h
@ -95,6 +95,7 @@ enum {
|
||||
/* any larger tag is FLOAT64 if JS_NAN_BOXING */
|
||||
};
|
||||
|
||||
/* must match the layout of 'JSMallocBlockHeader' */
|
||||
typedef struct JSRefCountHeader {
|
||||
int ref_count;
|
||||
} JSRefCountHeader;
|
||||
@ -675,10 +676,16 @@ JSValue __js_printf_like(2, 3) JS_ThrowInternalError(JSContext *ctx, const char
|
||||
JSValue JS_ThrowOutOfMemory(JSContext *ctx);
|
||||
|
||||
void __JS_FreeValue(JSContext *ctx, JSValue v);
|
||||
|
||||
static inline JSRefCountHeader *__js_rc(void *ptr)
|
||||
{
|
||||
return (JSRefCountHeader *)((uint32_t *)ptr - 1);
|
||||
}
|
||||
|
||||
static inline void JS_FreeValue(JSContext *ctx, JSValue v)
|
||||
{
|
||||
if (JS_VALUE_HAS_REF_COUNT(v)) {
|
||||
JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v);
|
||||
JSRefCountHeader *p = __js_rc(JS_VALUE_GET_PTR(v));
|
||||
if (--p->ref_count <= 0) {
|
||||
__JS_FreeValue(ctx, v);
|
||||
}
|
||||
@ -688,7 +695,7 @@ void __JS_FreeValueRT(JSRuntime *rt, JSValue v);
|
||||
static inline void JS_FreeValueRT(JSRuntime *rt, JSValue v)
|
||||
{
|
||||
if (JS_VALUE_HAS_REF_COUNT(v)) {
|
||||
JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v);
|
||||
JSRefCountHeader *p = __js_rc(JS_VALUE_GET_PTR(v));
|
||||
if (--p->ref_count <= 0) {
|
||||
__JS_FreeValueRT(rt, v);
|
||||
}
|
||||
@ -698,7 +705,7 @@ static inline void JS_FreeValueRT(JSRuntime *rt, JSValue v)
|
||||
static inline JSValue JS_DupValue(JSContext *ctx, JSValueConst v)
|
||||
{
|
||||
if (JS_VALUE_HAS_REF_COUNT(v)) {
|
||||
JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v);
|
||||
JSRefCountHeader *p = __js_rc(JS_VALUE_GET_PTR(v));
|
||||
p->ref_count++;
|
||||
}
|
||||
return (JSValue)v;
|
||||
@ -707,7 +714,7 @@ static inline JSValue JS_DupValue(JSContext *ctx, JSValueConst v)
|
||||
static inline JSValue JS_DupValueRT(JSRuntime *rt, JSValueConst v)
|
||||
{
|
||||
if (JS_VALUE_HAS_REF_COUNT(v)) {
|
||||
JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v);
|
||||
JSRefCountHeader *p = __js_rc(JS_VALUE_GET_PTR(v));
|
||||
p->ref_count++;
|
||||
}
|
||||
return (JSValue)v;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user