yarv-diff:34
From: ko1 atdot.net
Date: 30 Jun 2005 14:32:23 -0000
Subject: [yarv-diff:34] r189 - in trunk: . benchmark rb tmpl
Author: ko1
Date: 2005-06-30 23:32:22 +0900 (Thu, 30 Jun 2005)
New Revision: 189
Added:
trunk/rb/asm_parse.rb
Modified:
trunk/ChangeLog
trunk/benchmark/run.rb
trunk/extconf.rb
trunk/insnhelper.h
trunk/insns.def
trunk/opt_operand.def
trunk/test.rb
trunk/tmpl/vmtc.inc.tmpl
trunk/vm_evalbody.h
Log:
* tmpl/vmtc.inc.tmpl : add const prefix
* /rb/asm_parse.rb, extconf.rb : added and make assembler analised output
* opt_operand.def : add send operands unification
* insnhelper.h : add HEAP_CLASS_OF(obj)
* insns.def : fix opt_plus, opt_ltlt
* vm_evalbody.h : move _tag
* benchmark/run.rb : fix file select
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2005-06-29 21:09:01 UTC (rev 188)
+++ trunk/ChangeLog 2005-06-30 14:32:22 UTC (rev 189)
@@ -4,6 +4,23 @@
# from Mon, 03 May 2004 01:24:19 +0900
#
+2005-06-30(Thu) 23:25:23 +0900 Koichi Sasada <ko1 atdot.net>
+
+ * tmpl/vmtc.inc.tmpl : add const prefix
+
+ * /rb/asm_parse.rb, extconf.rb : added and make assembler analised output
+
+ * opt_operand.def : add send operands unification
+
+ * insnhelper.h : add HEAP_CLASS_OF(obj)
+
+ * insns.def : fix opt_plus, opt_ltlt
+
+ * vm_evalbody.h : move _tag
+
+ * benchmark/run.rb : fix file select
+
+
2005-06-30(Thu) 06:07:04 +0900 Koichi Sasada <ko1 atdot.net>
* extconf.rb : add collect-usage-analysis option
Modified: trunk/benchmark/run.rb
===================================================================
--- trunk/benchmark/run.rb 2005-06-29 21:09:01 UTC (rev 188)
+++ trunk/benchmark/run.rb 2005-06-30 14:32:22 UTC (rev 189)
@@ -110,8 +110,10 @@
}
else
ARGV.each{|file|
- file = "#{File.dirname(__FILE__)}/#{file}.rb"
- bm file
+ Dir.glob(File.join(File.dirname(__FILE__), file + '*')){|ef|
+ # file = "#{File.dirname(__FILE__)}/#{file}.rb"
+ bm ef
+ }
}
end
Modified: trunk/extconf.rb
===================================================================
--- trunk/extconf.rb 2005-06-29 21:09:01 UTC (rev 188)
+++ trunk/extconf.rb 2005-06-30 14:32:22 UTC (rev 189)
@@ -81,7 +81,9 @@
# for GCC
vm.asm:
- $(CC) $(CFLAGS) -fno-crossjumping $(CPPFLAGS) -dA -S -o vm.asm.s $(srcdir)/vm.c
+ $(CC) $(CFLAGS) -fno-crossjumping $(CPPFLAGS) -dpA -S -o vm.asm.s $(srcdir)/vm.c
+ $(RUBY) $(srcdir)/rb/asm_parse.rb vm.asm.s > vm.asm.each
+
vm.cpp:
$(CPP) $(CPPFLAGS) $(CFLAGS) $(srcdir)/vm.c > vm.cpp.txt
EOS
Modified: trunk/insnhelper.h
===================================================================
--- trunk/insnhelper.h 2005-06-29 21:09:01 UTC (rev 188)
+++ trunk/insnhelper.h 2005-06-30 14:32:22 UTC (rev 189)
@@ -151,7 +151,7 @@
/* optimize insn */
#define FIXNUM_2_P(a, b) ((a) & (b) & 1)
#define BASIC_OP_UNREDEFINED(op) (yarv_unredefined_flag)
+#define HEAP_CLASS_OF(obj) RBASIC(obj)->klass
-
#endif // _INSNHELPER_H_INCLUDED_
Modified: trunk/insns.def
===================================================================
--- trunk/insns.def 2005-06-29 21:09:01 UTC (rev 188)
+++ trunk/insns.def 2005-06-30 14:32:22 UTC (rev 189)
@@ -1098,7 +1098,7 @@
*/
DEFINE_INSN
send
-(ID id, ulong argc, VALUE block, ulong flag, IC ic)
+(ID id, ulong op_argc, VALUE block, ulong flag, IC ic)
(...)
(VALUE val)
{
@@ -1108,7 +1108,7 @@
VALUE procblock = 0; /* block arg */
VALUE klass;
struct vm_block_object *block_ptr = 0;
- ulong num = argc;
+ ulong num = op_argc;
/* procblock? */
if(flag & VM_CALL_ARGS_BLOCKARG_BIT){
@@ -1828,24 +1828,32 @@
}
}
#endif
-
+
+ else if(!SPECIAL_CONST_P(recv) && !SPECIAL_CONST_P(obj)){
+ if(0){
+ }
#if 0
- else if(CLASS_OF(recv) == rb_cFloat &&
- CLASS_OF(obj) == rb_cFloat &&
- BASIC_OP_UNREDEFINED(FLOAT_PLUS)){
- val = rb_float_new(RFLOAT(recv)->value + RFLOAT(obj)->value);
- }
+ else if(HEAP_CLASS_OF(recv) == rb_cFloat &&
+ HEAP_CLASS_OF(obj) == rb_cFloat &&
+ BASIC_OP_UNREDEFINED(FLOAT_PLUS)){
+ val = rb_float_new(RFLOAT(recv)->value + RFLOAT(obj)->value);
+ }
#endif
#if 1
- else if(CLASS_OF(recv) == rb_cString &&
- CLASS_OF(obj) == rb_cString &&
- BASIC_OP_UNREDEFINED(STRING_PLUS)){
- val = rb_str_plus(recv, obj);
+ else if(HEAP_CLASS_OF(recv) == rb_cString &&
+ HEAP_CLASS_OF(obj) == rb_cString &&
+ BASIC_OP_UNREDEFINED(STRING_PLUS)){
+ val = rb_str_plus(recv, obj);
+ }
+#endif
+ else{
+ goto INSN_LABEL(normal_dispatch);
+ }
}
-#endif
-
else{
+ INSN_LABEL(normal_dispatch):
+
#ifdef YARV_AOT_COMPILED
val = rb_funcall(recv, idPLUS, 1, obj);
#else
@@ -1910,7 +1918,7 @@
c = a * b;
val = LONG2FIX(c);
- if (FIX2LONG(val) != c) {
+ if(FIX2LONG(val) != c || c/a != b){
val = rb_big_mul(rb_int2big(a), rb_int2big(b));
}
}
@@ -1973,16 +1981,22 @@
{
if(0){
}
- else if(CLASS_OF(recv) == rb_cString &&
- CLASS_OF(obj) == rb_cString &&
- BASIC_OP_UNREDEFINED(STRING_LTLT)){
- val = rb_str_concat(recv, obj);
+ if(!SPECIAL_CONST_P(recv) && SPECIAL_CONST_P(obj)){
+ if(HEAP_CLASS_OF(recv) == rb_cString &&
+ HEAP_CLASS_OF(obj) == rb_cString &&
+ BASIC_OP_UNREDEFINED(STRING_LTLT)){
+ val = rb_str_concat(recv, obj);
+ }
+ else if(HEAP_CLASS_OF(recv) == rb_cArray &&
+ BASIC_OP_UNREDEFINED(ARRAY_LTLT)){
+ val = rb_ary_push(recv, obj);
+ }
+ else{
+ goto INSN_LABEL(normal_dispatch);
+ }
}
- else if(CLASS_OF(recv) == rb_cArray &&
- BASIC_OP_UNREDEFINED(ARRAY_LTLT)){
- val = rb_ary_push(recv, obj);
- }
else{
+ INSN_LABEL(normal_dispatch):
/* other */
#ifdef YARV_AOT_COMPILED
val = rb_funcall(recv, idLTLT, 1, obj);
@@ -2038,7 +2052,7 @@
()
()
{
-#ifdef __GNUC__
+#if __GNUC__ && OPT_USE_JIT_COMPILE
struct iseq_object *iseq = GET_ISEQ();
void *label = (void *)iseq->jit_compiled;
Modified: trunk/opt_operand.def
===================================================================
--- trunk/opt_operand.def 2005-06-29 21:09:01 UTC (rev 188)
+++ trunk/opt_operand.def 2005-06-30 14:32:22 UTC (rev 189)
@@ -21,9 +21,7 @@
putobject Qfalse
end 5
-
__END__
-
send *, *, Qfalse, 0, *
send *, 0, Qfalse, 0, *
send *, 1, Qfalse, 0, *
Added: trunk/rb/asm_parse.rb
===================================================================
--- trunk/rb/asm_parse.rb 2005-06-29 21:09:01 UTC (rev 188)
+++ trunk/rb/asm_parse.rb 2005-06-30 14:32:22 UTC (rev 189)
@@ -0,0 +1,47 @@
+stat = {}
+
+while line = ARGF.gets
+ if /\[start\] (\w+)/ =~ line
+ name = $1
+ puts '--------------------------------------------------------------'
+ puts line
+ size = 0
+
+ while line = ARGF.gets
+ if /\[start\] (\w+)/ =~ line
+ puts "\t; # size: #{size}"
+ puts "\t; # !!"
+ stat[name] = size
+ #
+ name = $1
+ puts '--------------------------------------------------------------'
+ puts line
+ size = 0
+ next
+ end
+
+ unless /(\ALM)|(\ALB)|(\A\.)|(\A\/)/ =~ line
+ puts line
+ if /\[length = (\d+)\]/ =~ line
+ size += $1.to_i
+ end
+ end
+
+
+ if /__NEXT_INSN__/ !~ line && /\[end \] (\w+)/ =~ line
+ ename = $1
+ if name != ename
+ puts "!! start with #{name}, but end with #{ename}"
+ end
+ stat[ename] = size
+ puts "\t; # size: #{size}"
+ break
+ end
+ end
+ end
+end
+
+stat.sort_by{|a, b| -b * 1000 - a[0]}.each{|a, b|
+ puts "#{a}\t#{b}"
+}
+puts "total: #{stat.inject(0){|r, e| r+e[1]}}"
Modified: trunk/test.rb
===================================================================
--- trunk/test.rb 2005-06-29 21:09:01 UTC (rev 188)
+++ trunk/test.rb 2005-06-30 14:32:22 UTC (rev 189)
@@ -9,6 +9,35 @@
###########################################################
$prog =<<'__EOP__'
+p
+p 1
+p 1,2
+p 1,2,3
+
+__END__
+
+[1,2] + [3,4]
+
+__END__
+def iter
+ yield 10,20
+end
+
+iter{|$a,b|
+ p $a
+ [$a, b]
+} + [$a, 2]
+
+__END__
+def iter
+ yield 10, 20, 30, 40
+end
+
+a = nil
+iter{|a, $b, @c, d|
+ [a, $b]
+} + [a, $b, @c]
+__END__
def m
end
Modified: trunk/tmpl/vmtc.inc.tmpl
===================================================================
--- trunk/tmpl/vmtc.inc.tmpl 2005-06-29 21:09:01 UTC (rev 188)
+++ trunk/tmpl/vmtc.inc.tmpl 2005-06-30 14:32:22 UTC (rev 189)
@@ -12,7 +12,7 @@
or insns2vm.rb
*/
-static void *insns_address_table[] = {
+static const void *insns_address_table[] = {
<%= insns_table %>
};
Modified: trunk/vm_evalbody.h
===================================================================
--- trunk/vm_evalbody.h 2005-06-29 21:09:01 UTC (rev 188)
+++ trunk/vm_evalbody.h 2005-06-30 14:32:22 UTC (rev 189)
@@ -17,6 +17,7 @@
// #define DECL_SC_REG(r, reg) VALUE reg_##r
VALUE thread_eval_body(VALUE self){
+ struct tag _tag;
struct thread_object *th;
#ifdef OPT_STACK_CACHING
@@ -55,7 +56,6 @@
VALUE throwed;
int state;
- struct tag _tag;
#ifdef OPT_THREADED_CODE
#include "vmtc.inc"
--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml