summaryrefslogtreecommitdiff
path: root/apps/plugins/lua/lapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lua/lapi.c')
-rw-r--r--apps/plugins/lua/lapi.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/apps/plugins/lua/lapi.c b/apps/plugins/lua/lapi.c
index 487d6b173a..6426cd94a9 100644
--- a/apps/plugins/lua/lapi.c
+++ b/apps/plugins/lua/lapi.c
@@ -547,7 +547,9 @@ LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
547 lua_lock(L); 547 lua_lock(L);
548 t = index2adr(L, idx); 548 t = index2adr(L, idx);
549 api_checkvalidindex(L, t); 549 api_checkvalidindex(L, t);
550 fixedstack(L);
550 setsvalue(L, &key, luaS_new(L, k)); 551 setsvalue(L, &key, luaS_new(L, k));
552 unfixedstack(L);
551 luaV_gettable(L, t, &key, L->top); 553 luaV_gettable(L, t, &key, L->top);
552 api_incr_top(L); 554 api_incr_top(L);
553 lua_unlock(L); 555 lua_unlock(L);
@@ -656,14 +658,14 @@ LUA_API void lua_settable (lua_State *L, int idx) {
656 658
657LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { 659LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
658 StkId t; 660 StkId t;
659 TValue key;
660 lua_lock(L); 661 lua_lock(L);
661 api_checknelems(L, 1); 662 api_checknelems(L, 1);
662 t = index2adr(L, idx); 663 t = index2adr(L, idx);
663 api_checkvalidindex(L, t); 664 api_checkvalidindex(L, t);
664 setsvalue(L, &key, luaS_new(L, k)); 665 setsvalue2s(L, L->top, luaS_new(L, k));
665 luaV_settable(L, t, &key, L->top - 1); 666 api_incr_top(L);
666 L->top--; /* pop value */ 667 luaV_settable(L, t, L->top - 1, L->top - 2);
668 L->top -= 2; /* pop key and value */
667 lua_unlock(L); 669 lua_unlock(L);
668} 670}
669 671
@@ -674,7 +676,9 @@ LUA_API void lua_rawset (lua_State *L, int idx) {
674 api_checknelems(L, 2); 676 api_checknelems(L, 2);
675 t = index2adr(L, idx); 677 t = index2adr(L, idx);
676 api_check(L, ttistable(t)); 678 api_check(L, ttistable(t));
679 fixedstack(L);
677 setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1); 680 setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1);
681 unfixedstack(L);
678 luaC_barriert(L, hvalue(t), L->top-1); 682 luaC_barriert(L, hvalue(t), L->top-1);
679 L->top -= 2; 683 L->top -= 2;
680 lua_unlock(L); 684 lua_unlock(L);
@@ -687,7 +691,9 @@ LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
687 api_checknelems(L, 1); 691 api_checknelems(L, 1);
688 o = index2adr(L, idx); 692 o = index2adr(L, idx);
689 api_check(L, ttistable(o)); 693 api_check(L, ttistable(o));
694 fixedstack(L);
690 setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1); 695 setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1);
696 unfixedstack(L);
691 luaC_barriert(L, hvalue(o), L->top-1); 697 luaC_barriert(L, hvalue(o), L->top-1);
692 L->top--; 698 L->top--;
693 lua_unlock(L); 699 lua_unlock(L);
@@ -903,11 +909,11 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
903 g = G(L); 909 g = G(L);
904 switch (what) { 910 switch (what) {
905 case LUA_GCSTOP: { 911 case LUA_GCSTOP: {
906 g->GCthreshold = MAX_LUMEM; 912 set_block_gc(L);
907 break; 913 break;
908 } 914 }
909 case LUA_GCRESTART: { 915 case LUA_GCRESTART: {
910 g->GCthreshold = g->totalbytes; 916 unset_block_gc(L);
911 break; 917 break;
912 } 918 }
913 case LUA_GCCOLLECT: { 919 case LUA_GCCOLLECT: {
@@ -924,6 +930,10 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
924 break; 930 break;
925 } 931 }
926 case LUA_GCSTEP: { 932 case LUA_GCSTEP: {
933 if(is_block_gc(L)) {
934 res = 1; /* gc is block so we need to pretend that the collection cycle finished. */
935 break;
936 }
927 lu_mem a = (cast(lu_mem, data) << 10); 937 lu_mem a = (cast(lu_mem, data) << 10);
928 if (a <= g->totalbytes) 938 if (a <= g->totalbytes)
929 g->GCthreshold = g->totalbytes - a; 939 g->GCthreshold = g->totalbytes - a;