yarv-diff:336
From: ko1 atdot.net
Date: 25 May 2006 07:11:14 -0000
Subject: [yarv-diff:336] r503 - in trunk: . lib rb yarvtest
Author: ko1
Date: 2006-05-25 16:11:13 +0900 (Thu, 25 May 2006)
New Revision: 503
Modified:
trunk/
trunk/ChangeLog
trunk/blockinlining.c
trunk/class.c
trunk/compile.c
trunk/lib/monitor.rb
trunk/rb/insns2vm.rb
trunk/thread.c
trunk/vm_opts.h.base
trunk/yarvtest/test_class.rb
Log:
r780@lermite: ko1 | 2006-05-25 16:09:36 +0900
* blockinlining.c : support NEW_ATTRASGN attributes
* class.c : skip undefined method to collect ([yarv-dev:999])
* yarvtest/test_class.rb : add a test for above
* compile.c : fix opt_regexpmatch1 condition
* lib/monitor.rb : fix [yarv-dev:1009]
* rb/insns2vm.rb : fix typo
* thread.c : prohibit unlock by not mutex owner thread
* vm_opts.h.base : change default option
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:778
+ 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:780
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-05-18 07:02:51 UTC (rev 502)
+++ trunk/ChangeLog 2006-05-25 07:11:13 UTC (rev 503)
@@ -4,6 +4,27 @@
# from Mon, 03 May 2004 01:24:19 +0900
#
+
+2006-05-25(Thu) 15:37:11 +0900 Koichi Sasada <ko1 atdot.net>
+
+ * blockinlining.c : support NEW_ATTRASGN attributes
+
+ * class.c : skip undefined method to collect ([yarv-dev:999])
+
+ * yarvtest/test_class.rb : add a test for above
+
+ * compile.c : fix opt_regexpmatch1 condition
+
+ * lib/monitor.rb : fix [yarv-dev:1009]
+
+ * rb/insns2vm.rb : fix typo
+
+ * thread.c : prohibit unlock by not mutex owner thread
+
+ * vm_opts.h.base : change default option
+
+
+
2006-05-18(Thu) 16:00:50 +0900 Koichi Sasada <ko1 atdot.net>
* intern.h : fix prototype declarations for last re.c change
Modified: trunk/blockinlining.c
===================================================================
--- trunk/blockinlining.c 2006-05-18 07:02:51 UTC (rev 502)
+++ trunk/blockinlining.c 2006-05-25 07:11:13 UTC (rev 503)
@@ -65,18 +65,33 @@
new_assign(NODE * lnode, NODE * rhs)
{
switch (nd_type(lnode)) {
- case NODE_LASGN:{
- return NEW_NODE(NODE_LASGN, lnode->nd_vid, rhs, lnode->nd_cnt);
- /* NEW_LASGN(lnode->nd_vid, rhs); */
- }
- case NODE_GASGN:{
- return NEW_GASGN(lnode->nd_vid, rhs);
- }
- case NODE_DASGN:{
- return NEW_DASGN(lnode->nd_vid, rhs);
- }
- default:
- rb_bug("unimplemented");
+ case NODE_LASGN:{
+ return NEW_NODE(NODE_LASGN, lnode->nd_vid, rhs, lnode->nd_cnt);
+ /* NEW_LASGN(lnode->nd_vid, rhs); */
+ }
+ case NODE_GASGN:{
+ return NEW_GASGN(lnode->nd_vid, rhs);
+ }
+ case NODE_DASGN:{
+ return NEW_DASGN(lnode->nd_vid, rhs);
+ }
+ case NODE_ATTRASGN:{
+ NODE *args = 0;
+ if (lnode->nd_args) {
+ args = NEW_ARRAY(lnode->nd_args->nd_head);
+ args->nd_next = NEW_ARRAY(rhs);
+ args->nd_alen = 2;
+ }
+ else {
+ args = NEW_ARRAY(rhs);
+ }
+
+ return NEW_ATTRASGN(lnode->nd_recv,
+ lnode->nd_mid,
+ args);
+ }
+ default:
+ rb_bug("unimplemented (block inlining): %s", node_name(nd_type(lnode)));
}
return 0;
}
Modified: trunk/class.c
===================================================================
--- trunk/class.c 2006-05-18 07:02:51 UTC (rev 502)
+++ trunk/class.c 2006-05-25 07:11:13 UTC (rev 503)
@@ -510,6 +510,7 @@
ins_methods_push(ID name, long type, VALUE ary, long visi)
{
if (type == -1) return ST_CONTINUE;
+
switch (visi) {
case NOEX_PRIVATE:
case NOEX_PROTECTED:
@@ -553,24 +554,22 @@
static int
method_entry(ID key, NODE *body, st_table *list)
{
- long type;
+ long type;
- if (body == 0 /* undefed method */ ||
- key == ID_ALLOCATOR) {
- return ST_CONTINUE;
- }
- body = body->nd_body;
-
- if (!st_lookup(list, key, 0)) {
- if (!body->nd_body) {
- type = -1; /* none */
+ if (key == ID_ALLOCATOR) {
+ return ST_CONTINUE;
}
- else {
- type = VISI(body->nd_noex);
+
+ if (!st_lookup(list, key, 0)) {
+ if (body ==0 || !body->nd_body->nd_body) {
+ type = -1; /* none */
+ }
+ else {
+ type = VISI(body->nd_body->nd_noex);
+ }
+ st_add_direct(list, key, type);
}
- st_add_direct(list, key, type);
- }
- return ST_CONTINUE;
+ return ST_CONTINUE;
}
static VALUE
Modified: trunk/compile.c
===================================================================
--- trunk/compile.c 2006-05-18 07:02:51 UTC (rev 502)
+++ trunk/compile.c 2006-05-25 07:11:13 UTC (rev 503)
@@ -947,7 +947,7 @@
LINK_ELEMENT *elem;
COMPILE_POPED(anc, "set_block_local_tbl#masgn/other", node);
-
+
if (nd_type(node) == NODE_ATTRASGN) {
INSN *iobj = (INSN *)anc->last->prev;
iobj->operands[1] = INT2FIX(FIX2INT(iobj->operands[1]) + 1);
@@ -1721,7 +1721,8 @@
iobj->insn_id = SC_INSN(insn_id, state);
nstate = SC_NEXT(iobj->insn_id);
- if (insn_id == BIN(jump) || insn_id == BIN(if) || insn_id == BIN(unless)) {
+ if (insn_id == BIN(jump) ||
+ insn_id == BIN(branchif) || insn_id == BIN(branchunless)) {
LABEL *lobj = (LABEL *)OPERAND_AT(iobj, 0);
if (lobj->sc_state != 0) {
@@ -1938,10 +1939,11 @@
LINK_ANCHOR *ret, NODE * node_root, VALUE opt_p)
{
NODE *node = node_root;
- int len = node->nd_alen, line = nd_line(node);
+ int len = node->nd_alen, line = nd_line(node), i=0;
DECL_ANCHOR(anchor);
while (node) {
+ i++;
if (opt_p && nd_type(node->nd_head) != NODE_LIT) {
opt_p = Qfalse;
}
@@ -1949,6 +1951,12 @@
node = node->nd_next;
}
+ if (len != i) {
+ if (0) rb_bug("node error: compile_array (%d: %d-%d)",
+ nd_line(node_root), len, i);
+ len = i;
+ }
+
if (opt_p == Qtrue) {
VALUE ary = rb_ary_new();
node = node_root;
@@ -3858,7 +3866,8 @@
#if OPT_BASIC_OPERATIONS
/* TODO: detect by node */
if (recv->last == recv->anchor.next &&
- INSN_OF(recv->last) == BIN(putobject)) {
+ INSN_OF(recv->last) == BIN(putobject) &&
+ nd_type(node) == NODE_MATCH2) {
ADD_SEQ(ret, val);
ADD_INSN1(ret, nd_line(node), opt_regexpmatch1,
OPERAND_AT(recv->last, 0));
Modified: trunk/lib/monitor.rb
===================================================================
--- trunk/lib/monitor.rb 2006-05-18 07:02:51 UTC (rev 502)
+++ trunk/lib/monitor.rb 2006-05-25 07:11:13 UTC (rev 503)
@@ -90,6 +90,7 @@
def wait(timeout = nil)
@monitor.funcall(:mon_check_owner)
timer = create_timer(timeout)
+ count = nil
@mutex.synchronize{
count = @monitor.funcall(:mon_exit_for_cond)
@@ -112,7 +113,6 @@
end
@monitor.funcall(:mon_enter_for_cond, count)
}
- end
end
def wait_while
Modified: trunk/rb/insns2vm.rb
===================================================================
--- trunk/rb/insns2vm.rb 2006-05-18 07:02:51 UTC (rev 502)
+++ trunk/rb/insns2vm.rb 2006-05-25 07:11:13 UTC (rev 503)
@@ -947,7 +947,7 @@
val
when /^ID/
"INT2FIX(#{val})"
- when /^BLOCKISEQ/
+ when /^ISEQ/
val
when /GENTRY/
raise
Modified: trunk/thread.c
===================================================================
--- trunk/thread.c 2006-05-18 07:02:51 UTC (rev 502)
+++ trunk/thread.c 2006-05-25 07:11:13 UTC (rev 503)
@@ -1887,6 +1887,10 @@
mutex_t *mutex;
GetMutexVal(self, mutex);
+ if (mutex->th != GET_THREAD()) {
+ rb_raise(rb_eThreadError,
+ "Attempt to unlock a mutex which is locked by another thread");
+ }
mutex->th = 0;
native_mutex_unlock(&mutex->lock);
return self;
@@ -1982,6 +1986,10 @@
rb_define_method(cMutex, "lock", mutex_lock, 0);
rb_define_method(cMutex, "unlock", mutex_unlock, 0);
rb_define_method(cMutex, "sleep", mutex_sleep, -1);
+ yarvcore_eval(Qnil, rb_str_new2(
+ "class Mutex;"
+ " def synchronize; self.lock; yield; ensure; self.unlock; end;"
+ "end;") , rb_str_new2("<preload>"), INT2FIX(1));
Init_native_thread();
{
Modified: trunk/vm_opts.h.base
===================================================================
--- trunk/vm_opts.h.base 2006-05-18 07:02:51 UTC (rev 502)
+++ trunk/vm_opts.h.base 2006-05-25 07:11:13 UTC (rev 503)
@@ -11,13 +11,13 @@
#if IGNORE_OPTIMIZE == 0
-/* compiler depend */
-#define OPT_DIRECT_THREADED_CODE 0
+/* C compiler depend */
+#define OPT_DIRECT_THREADED_CODE 1
#define OPT_CALL_THREADED_CODE 0
/* architecture independent */
-#define OPT_BASIC_OPERATIONS 0
-#define OPT_INLINE_METHOD_CACHE 0
+#define OPT_BASIC_OPERATIONS 1
+#define OPT_INLINE_METHOD_CACHE 1
#define OPT_BLOCKINLINING 0
/* architecture independent, affects generated code */
Modified: trunk/yarvtest/test_class.rb
===================================================================
--- trunk/yarvtest/test_class.rb 2006-05-18 07:02:51 UTC (rev 502)
+++ trunk/yarvtest/test_class.rb 2006-05-25 07:11:13 UTC (rev 503)
@@ -704,5 +704,24 @@
C
}
end
+
+ def test_undef
+ # [yarv-dev:999]
+ ae %q{
+ class Parent
+ def foo
+ end
+ end
+ class Child < Parent
+ def bar
+ end
+
+ undef foo, bar
+ end
+
+ c = Child.new
+ [c.methods.include?('foo'), c.methods.include?('bar')]
+ }
+ end
end
--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml