summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-10-14 15:52:14 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-10-14 15:52:14 +0900
commit5b40bb8d159c1432bb87973b2b5f42473dd0c623 (patch)
tree7d845bda931b2842c21ed5e6113243d067103fc4
parent82046ff26ec9ae93d6d0cb5132a1dfd9651b5c3f (diff)
downloadmruby-5b40bb8d159c1432bb87973b2b5f42473dd0c623.tar.gz
mruby-5b40bb8d159c1432bb87973b2b5f42473dd0c623.zip
Avoid using C struct dump for test Ruby code.
Files under `test/t` and `mrbgem/*/test` are for tests, not for actual execution. So symbols in those files need not to be pre-allocated. This change slightly reduce the memory consumption.
-rw-r--r--Rakefile10
-rw-r--r--lib/mruby/build/command.rb6
-rw-r--r--mrbgems/mruby-test/driver.c4
-rw-r--r--mrbgems/mruby-test/mrbgem.rake14
-rw-r--r--test/presym4
5 files changed, 17 insertions, 21 deletions
diff --git a/Rakefile b/Rakefile
index 1234daf66..5c5a6e8eb 100644
--- a/Rakefile
+++ b/Rakefile
@@ -108,14 +108,14 @@ mkdir_p "#{MRUBY_ROOT}/build"
cfiles = (
Dir.glob("#{MRUBY_ROOT}/src/*.c")+
Dir.glob("#{MRUBY_ROOT}/mrbgems/**/*.c")+
- Dir.glob("#{MRUBY_ROOT}/build/repos/**/{src,test,core}/*.c")
+ Dir.glob("#{MRUBY_ROOT}/build/repos/**/{src,core}/*.c")
).uniq
rbfiles = (
- Dir.glob("#{MRUBY_ROOT}/{mrblib,test,test/t}/**/*.rb")+
- Dir.glob("#{MRUBY_ROOT}/mrbgems/*/{mrblib,test}/**/*.rb")+
- Dir.glob("#{MRUBY_ROOT}/build/repos/**/{mrblib,test}/**/*.rb")
+ Dir.glob("#{MRUBY_ROOT}/mrblib/**/*.rb")+
+ Dir.glob("#{MRUBY_ROOT}/mrbgems/*/mrblib/**/*.rb")+
+ Dir.glob("#{MRUBY_ROOT}/build/repos/**/mrblib/**/*.rb")
).uniq
-psfiles = Dir.glob("#{MRUBY_ROOT}/{mrblib,mrbgems,test,build/repos}/**/presym")
+psfiles = Dir.glob("#{MRUBY_ROOT}/{mrblib,mrbgems,build/repos}/**/presym")
symbols = []
psfiles.each do |file|
symbols += File.readlines(file).grep_v(/^# /)
diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb
index 39981cc32..3d47c304f 100644
--- a/lib/mruby/build/command.rb
+++ b/lib/mruby/build/command.rb
@@ -310,16 +310,16 @@ module MRuby
def initialize(build)
super
@command = nil
- @compile_options = "-S -B%{funcname} -o-"
+ @compile_options = "-B%{funcname} -o-"
end
- def run(out, infiles, funcname)
+ def run(out, infiles, funcname, cdump = true)
@command ||= @build.mrbcfile
infiles = [infiles].flatten
infiles.each do |f|
_pp "MRBC", f.relative_path, nil, :indent => 2
end
- cmd = %Q["#{filename @command}" #{@compile_options % {:funcname => funcname}} #{filename(infiles).map{|f| %Q["#{f}"]}.join(' ')}]
+ cmd = %Q["#{filename @command}" #{cdump ? "-S" : ""} #{@compile_options % {:funcname => funcname}} #{filename(infiles).map{|f| %Q["#{f}"]}.join(' ')}]
puts cmd if Rake.verbose
IO.popen(cmd, 'r+') do |io|
out.puts io.read
diff --git a/mrbgems/mruby-test/driver.c b/mrbgems/mruby-test/driver.c
index 3bd52e175..f780e7e57 100644
--- a/mrbgems/mruby-test/driver.c
+++ b/mrbgems/mruby-test/driver.c
@@ -18,7 +18,7 @@
#include <mruby/variable.h>
#include <mruby/array.h>
-extern const struct RProc mrbtest_assert_proc[];
+extern const uint8_t mrbtest_assert_irep[];
void mrbgemtest_init(mrb_state* mrb);
void mrb_init_test_vformat(mrb_state* mrb);
@@ -300,7 +300,7 @@ main(int argc, char **argv)
}
mrb_init_test_driver(mrb, verbose);
- mrb_load_proc(mrb, mrbtest_assert_proc);
+ mrb_load_irep(mrb, mrbtest_assert_irep);
mrbgemtest_init(mrb);
ret = eval_test(mrb);
mrb_close(mrb);
diff --git a/mrbgems/mruby-test/mrbgem.rake b/mrbgems/mruby-test/mrbgem.rake
index 9e8e4041f..0df683f7f 100644
--- a/mrbgems/mruby-test/mrbgem.rake
+++ b/mrbgems/mruby-test/mrbgem.rake
@@ -28,7 +28,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
file assert_c => [assert_rb, build.mrbcfile] do |t|
mkdir_p File.dirname(t.name)
open(t.name, 'w') do |f|
- mrbc.run f, assert_rb, 'mrbtest_assert_proc'
+ mrbc.run f, assert_rb, 'mrbtest_assert_irep', false
end
end
@@ -56,12 +56,12 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
f.puts %Q[ * All manual changes will get lost.]
f.puts %Q[ */]
if test_preload.nil?
- f.puts %Q[extern const struct RProc mrbtest_assert_proc[];]
+ f.puts %Q[extern const uint8_t mrbtest_assert_irep[];]
else
- g.build.mrbc.run f, test_preload, "gem_test_#{g.funcname}_preload"
+ g.build.mrbc.run f, test_preload, "gem_test_irep_#{g.funcname}_preload", false
end
g.test_rbfiles.flatten.each_with_index do |rbfile, i|
- g.build.mrbc.run f, rbfile, "gem_test_#{g.funcname}_#{i}_proc"
+ g.build.mrbc.run f, rbfile, "gem_test_irep_#{g.funcname}_#{i}", false
end
f.puts %Q[void mrb_#{g.funcname}_gem_test(mrb_state *mrb);] unless g.test_objs.empty?
dep_list.each do |d|
@@ -90,9 +90,9 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
end
f.puts %Q[ mrb_init_test_driver(mrb2, mrb_test(mrb_gv_get(mrb, mrb_intern_lit(mrb, "$mrbtest_verbose"))));]
if test_preload.nil?
- f.puts %Q[ mrb_load_proc(mrb2, mrbtest_assert_proc);]
+ f.puts %Q[ mrb_load_irep(mrb2, mrbtest_assert_irep);]
else
- f.puts %Q[ mrb_load_proc(mrb2, gem_test_#{g.funcname}_preload);]
+ f.puts %Q[ mrb_load_irep(mrb2, gem_test_irep_#{g.funcname}_preload);]
end
f.puts %Q[ if (mrb2->exc) {]
f.puts %Q[ mrb_print_error(mrb2);]
@@ -113,7 +113,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
f.puts %Q[ mrb_#{g.funcname}_gem_test(mrb2);] if g.custom_test_init?
- f.puts %Q[ mrb_load_proc(mrb2, gem_test_#{g.funcname}_#{i}_proc);]
+ f.puts %Q[ mrb_load_irep(mrb2, gem_test_irep_#{g.funcname}_#{i});]
f.puts %Q[ ]
f.puts %Q[ mrb_t_pass_result(mrb, mrb2);]
diff --git a/test/presym b/test/presym
deleted file mode 100644
index 1e551143b..000000000
--- a/test/presym
+++ /dev/null
@@ -1,4 +0,0 @@
-# List of symbols that cannot be detected by Rakefile
-# Those symbols are not defined (to cause exceptions)
-doesNotExistAsAMethodNameForVerySure
-UnknownConstant