Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
41e32205
Commit
41e32205
authored
Jul 13, 2020
by
Rory OConnell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
All values use page slot size in calculation
parent
37d66286
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
5 deletions
+19
-5
include/mruby/gc.h
include/mruby/gc.h
+1
-0
mrbgems/mruby-objectspace/src/mruby_objectspace.c
mrbgems/mruby-objectspace/src/mruby_objectspace.c
+11
-5
src/gc.c
src/gc.c
+7
-0
No files found.
include/mruby/gc.h
View file @
41e32205
...
...
@@ -21,6 +21,7 @@ struct mrb_state;
#define MRB_EACH_OBJ_BREAK 1
typedef
int
(
mrb_each_object_callback
)(
struct
mrb_state
*
mrb
,
struct
RBasic
*
obj
,
void
*
data
);
void
mrb_objspace_each_objects
(
struct
mrb_state
*
mrb
,
mrb_each_object_callback
*
callback
,
void
*
data
);
const
mrb_int
mrb_objspace_page_slot_size
();
MRB_API
void
mrb_free_context
(
struct
mrb_state
*
mrb
,
struct
mrb_context
*
c
);
#ifndef MRB_GC_ARENA_SIZE
...
...
mrbgems/mruby-objectspace/src/mruby_objectspace.c
View file @
41e32205
...
...
@@ -251,6 +251,7 @@ os_memsize_of_object(mrb_state* mrb, mrb_value obj, mrb_bool recurse, mrb_int* t
case
MRB_TT_SCLASS
:
case
MRB_TT_ICLASS
:
case
MRB_TT_OBJECT
:
{
(
*
t
)
+=
mrb_objspace_page_slot_size
();
os_memsize_of_ivars
(
mrb
,
obj
,
recurse
,
t
);
if
(
mrb_obj_is_kind_of
(
mrb
,
obj
,
mrb_class_get
(
mrb
,
"UnboundMethod"
)))
{
os_memsize_of_method
(
mrb
,
obj
,
t
);
...
...
@@ -270,6 +271,7 @@ os_memsize_of_object(mrb_state* mrb, mrb_value obj, mrb_bool recurse, mrb_int* t
len
=
RARRAY_LEN
(
obj
);
/* Arrays that do not fit within an RArray perform a heap allocation
* storing an array of pointers to the original objects*/
(
*
t
)
+=
mrb_objspace_page_slot_size
();
if
(
len
>
MRB_ARY_EMBED_LEN_MAX
)
(
*
t
)
+=
sizeof
(
mrb_value
*
)
*
len
;
if
(
recurse
)
{
...
...
@@ -280,12 +282,14 @@ os_memsize_of_object(mrb_state* mrb, mrb_value obj, mrb_bool recurse, mrb_int* t
break
;
}
case
MRB_TT_PROC
:
{
(
*
t
)
+=
mrb_objspace_page_slot_size
();
struct
RProc
*
proc
=
mrb_proc_ptr
(
obj
);
(
*
t
)
+=
MRB_ENV_LEN
(
proc
->
e
.
env
)
*
sizeof
(
mrb_value
);
if
(
!
MRB_PROC_CFUNC_P
(
proc
))
os_memsize_of_irep
(
mrb
,
proc
->
body
.
irep
,
t
);
break
;
}
case
MRB_TT_DATA
:
(
*
t
)
+=
mrb_objspace_page_slot_size
();
if
(
mrb_respond_to
(
mrb
,
obj
,
mrb_intern_lit
(
mrb
,
"memsize"
)))
{
(
*
t
)
+=
mrb_fixnum
(
mrb_funcall
(
mrb
,
obj
,
"memsize"
,
0
));
}
...
...
@@ -293,23 +297,25 @@ os_memsize_of_object(mrb_state* mrb, mrb_value obj, mrb_bool recurse, mrb_int* t
#ifndef MRB_WITHOUT_FLOAT
case
MRB_TT_FLOAT
:
#ifdef MRB_WORD_BOXING
(
*
t
)
+=
sizeof
(
struct
RFloat
);
(
*
t
)
+=
mrb_objspace_page_slot_size
()
+
sizeof
(
struct
RFloat
);
#endif
break
;
#endif
case
MRB_TT_RANGE
:
#ifndef MRB_RANGE_EMBED
(
*
t
)
+=
sizeof
(
struct
mrb_range_edges
);
(
*
t
)
+=
mrb_objspace_page_slot_size
()
+
sizeof
(
struct
mrb_range_edges
);
#endif
break
;
case
MRB_TT_FIBER
:
{
/* struct RFiber* fiber = (struct RFiber*)mrb_ptr(obj); */
(
*
t
)
+=
sizeof
(
struct
mrb_context
);
case
MRB_TT_ISTRUCT
:
(
*
t
)
+=
mrb_objspace_page_slot_size
();
break
;
}
/* zero heap size types.
* immediate VM stack values, contained within mrb_state, mrb_heap_page,
* or on C stack */
* immediate VM stack values, contained within mrb_state, or on C stack */
case
MRB_TT_TRUE
:
case
MRB_TT_FALSE
:
case
MRB_TT_FIXNUM
:
...
...
src/gc.c
View file @
41e32205
...
...
@@ -1599,6 +1599,13 @@ mrb_objspace_each_objects(mrb_state *mrb, mrb_each_object_callback *callback, vo
}
}
const
mrb_int
mrb_objspace_page_slot_size
()
{
const
mrb_int
i
=
sizeof
(
RVALUE
);
return
i
;
}
#ifdef GC_TEST
#ifdef GC_DEBUG
static
mrb_value
gc_test
(
mrb_state
*
,
mrb_value
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment