klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit 6ad88b94038287a8998c301e5044936f9e5db5b4
parent b349726ef6ac4ba587de39c12320b8d6ac293284
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Fri, 24 Aug 2012 03:24:35 -0300

Removed the locking from memory allocation & deallocation.  Code calling these is responsible for locking before calling.

Diffstat:
Msrc/kerror.c | 2++
Msrc/kgc.c | 5+++++
Msrc/kmem.c | 6++++--
3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/kerror.c b/src/kerror.c @@ -48,6 +48,8 @@ TValue klispE_new_with_errno_irritants(klisp_State *K, const char *service, return error_obj; } +/* This is meant to be called by the GC */ +/* LOCK: GIL should be acquired */ void klispE_free(klisp_State *K, Error *error) { klispM_free(K, error); diff --git a/src/kgc.c b/src/kgc.c @@ -9,6 +9,11 @@ ** Parts that don't apply, or don't apply yet to klisp are in comments. */ +/* +** LOCK: no locks are explicitly acquired here. +** Whoever calls the GC needs to have already acquired the GIL. +*/ + #include <string.h> #include "kgc.h" diff --git a/src/kmem.c b/src/kmem.c @@ -9,6 +9,10 @@ ** SOURCE NOTE: This is from Lua, but greatly shortened */ +/* +** LOCK: Whoever calls these should have already acquired the GIL. +*/ + #include <stddef.h> #include <stdio.h> #include <assert.h> @@ -75,7 +79,6 @@ void *klispM_realloc_ (klisp_State *K, void *block, size_t osize, size_t nsize) /* TEMP: for now only Stop the world GC */ /* TEMP: prevent recursive call of klispC_fullgc() */ - klisp_lock(K); #ifdef KUSE_GC if (nsize > 0 && G(K)->totalbytes - osize + nsize >= G(K)->GCthreshold) { #ifdef KDEBUG_GC @@ -99,6 +102,5 @@ void *klispM_realloc_ (klisp_State *K, void *block, size_t osize, size_t nsize) } klisp_assert((nsize == 0) == (block == NULL)); G(K)->totalbytes = (G(K)->totalbytes - osize) + nsize; - klisp_unlock(K); return block; }