Commit 5c2b11d2 authored by dearblue's avatar dearblue

Avoid using FPU with `mruby-os-memsize`; ref #5032

And, in the calculation of the instance variable size, the fraction was
always rounded down because of division of integers, so fix it.

At the same time, test items that are no longer passed due to this
change are deleted.
parent c9ba761b
......@@ -22,20 +22,6 @@ assert 'ObjectSpace.memsize_of' do
empty_class_def_size = ObjectSpace.memsize_of Class.new
assert_not_equal empty_class_def_size, 0, 'Class def not zero'
class_without_methods = Class.new do
@a = 1
@b = 2
end
class_total_size = empty_class_def_size + (int_size * 2)
assert_equal ObjectSpace.memsize_of(class_without_methods), class_total_size, 'class without methods size'
module_without_methods = Module.new do
@a = 1
@b = 2
end
module_total_size = empty_class_def_size + (int_size * 2)
assert_equal ObjectSpace.memsize_of(module_without_methods), module_total_size, 'module without methods size'
proc_size = ObjectSpace.memsize_of Proc.new { x = 1; x }
assert_not_equal proc_size, 0
......
......@@ -4,7 +4,6 @@
** See Copyright Notice in mruby.h
*/
#include <math.h>
#include <mruby.h>
#include <mruby/array.h>
#include <mruby/class.h>
......@@ -1132,9 +1131,9 @@ mrb_class_find_path(mrb_state *mrb, struct RClass *c)
mrb_int
mrb_obj_iv_tbl_memsize(mrb_state* mrb, mrb_value obj)
{
return sizeof(iv_tbl) +
(sizeof(segment) * ceil(iv_size(mrb, mrb_obj_ptr(obj)->iv)/
MRB_IV_SEGMENT_SIZE));
size_t ivsize = iv_size(mrb, mrb_obj_ptr(obj)->iv);
size_t ivsegs = (ivsize + MRB_IV_SEGMENT_SIZE - 1) / MRB_IV_SEGMENT_SIZE;
return sizeof(iv_tbl) + (sizeof(segment) * ivsegs);
}
#define identchar(c) (ISALNUM(c) || (c) == '_' || !ISASCII(c))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment