Skip to content

Commit

Permalink
gc time is after stack_add. removed stack_restore_no_gc.
Browse files Browse the repository at this point in the history
  • Loading branch information
kimtg committed Feb 26, 2020
1 parent 1ca5b92 commit 3e76182
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
16 changes: 4 additions & 12 deletions arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ void stack_add(atom a) {
stack = realloc(stack, stack_capacity * sizeof(atom));
}
stack[stack_size - 1] = a;
consider_gc();
}

void stack_restore_no_gc(int saved_size) {
void stack_restore(int saved_size) {
stack_size = saved_size;
/* if there is waste of memory, realloc */
if (stack_size < stack_capacity / 4) {
Expand All @@ -95,15 +96,9 @@ void stack_restore_no_gc(int saved_size) {
}
}

void stack_restore(int saved_size) {
stack_restore_no_gc(saved_size);
consider_gc();
}

void stack_restore_add(int saved_size, atom a) {
stack_restore_no_gc(saved_size);
stack_restore(saved_size);
stack_add(a);
consider_gc();
}

void consider_gc() {
Expand Down Expand Up @@ -2497,10 +2492,7 @@ error eval_expr(atom expr, atom env, atom *result)
if (no(cdr(args))) {
/* tail call */
expr = car(args);
stack_restore_no_gc(ss);
stack_add(expr);
stack_add(env);
stack_restore(ss + 2);
stack_restore(ss);
goto start_eval;
}
error err = eval_expr(car(args), env, result);
Expand Down
2 changes: 1 addition & 1 deletion arc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef _INC_ARC
#define _INC_ARC

#define VERSION "0.19"
#define VERSION "0.20"

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
Expand Down
2 changes: 1 addition & 1 deletion arcadia.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Keyword>Win32Proj</Keyword>
<RootNamespace>arcadia</RootNamespace>
<ProjectName>arcadia</ProjectName>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down

0 comments on commit 3e76182

Please sign in to comment.