forked from berry-lang/berry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbe_gclib.c
More file actions
38 lines (33 loc) · 998 Bytes
/
be_gclib.c
File metadata and controls
38 lines (33 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/********************************************************************
** Copyright (c) 2018-2020 Guan Wenliang
** This file is part of the Berry default interpreter.
** skiars@qq.com, https://github.com/Skiars/berry
** See Copyright Notice in the LICENSE file or at
** https://github.com/Skiars/berry/blob/master/LICENSE
********************************************************************/
#include "be_object.h"
#include "be_gc.h"
#if BE_USE_GC_MODULE
static int m_allocated(bvm *vm)
{
size_t count = be_gc_memcount(vm);
if (count < 0x80000000) {
be_pushint(vm, (bint)count);
} else {
be_pushreal(vm, (breal)count);
}
be_return(vm);
}
static int m_collect(bvm *vm)
{
be_gc_collect(vm);
be_return_nil(vm);
}
/* @const_object_info_begin
module gc (scope: global, depend: BE_USE_GC_MODULE) {
allocated, func(m_allocated)
collect, func(m_collect)
}
@const_object_info_end */
#include "../generate/be_fixed_gc.h"
#endif /* BE_USE_SYS_MODULE */