[macruby-changes] [3010] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Nov 13 22:19:33 PST 2009


Revision: 3010
          http://trac.macosforge.org/projects/ruby/changeset/3010
Author:   vincent.isambart at gmail.com
Date:     2009-11-13 22:19:30 -0800 (Fri, 13 Nov 2009)
Log Message:
-----------
the commit fixing the compilation of class bodies, once again!

It's mostly the same as last time, but I could not find any problem with
it. If you have any, do not hesitate to revert it (once again...)

Modified Paths:
--------------
    MacRuby/trunk/compiler.cpp
    MacRuby/trunk/vm.cpp
    MacRuby/trunk/vm.h

Modified: MacRuby/trunk/compiler.cpp
===================================================================
--- MacRuby/trunk/compiler.cpp	2009-11-14 05:19:43 UTC (rev 3009)
+++ MacRuby/trunk/compiler.cpp	2009-11-14 06:19:30 UTC (rev 3010)
@@ -3032,7 +3032,8 @@
 	    {
 		rb_vm_arity_t arity = rb_vm_node_arity(node);
 		const int nargs = bb == NULL ? 0 : arity.real;
-		const bool has_dvars = current_block && current_mid == 0;
+		const bool has_dvars = current_block && current_mid == 0 && !class_declaration;
+		class_declaration = false;
 
 		// Get dynamic vars.
 		if (has_dvars && node->nd_tbl != NULL) {
@@ -3937,11 +3938,6 @@
 		NODE *body = node->nd_body;
 		if (body != NULL) {
 		    assert(nd_type(body) == NODE_SCOPE);
-		    ID *tbl = body->nd_tbl;
-		    if (tbl != NULL) {
-			const int args_count = (int)tbl[0];
-			compile_lvars(&tbl[args_count + 1]);
-		    }
 		    if (body->nd_body != NULL) {	
 			Value *old_self = current_self;
 			current_self = classVal;
@@ -3952,7 +3948,12 @@
 				GlobalValue::InternalLinkage, nilVal, "");
 
 			bool old_current_module = current_module;
+			bool old_current_block_chain = current_block_chain;
+			bool old_dynamic_class = dynamic_class;
 
+			current_block_chain = false;
+			dynamic_class = false;
+
 			std::map<ID, Value *> old_ivar_slots_cache
 			    = ivar_slots_cache;
 			ivar_slots_cache.clear();
@@ -3962,11 +3963,20 @@
 			current_module = nd_type(node) == NODE_MODULE;
 
 			compile_set_current_scope(classVal, publicScope);
-			bool old_dynamic_class = dynamic_class;
-			dynamic_class = false;
 
-			Value *val = compile_node(body->nd_body);
+			DEBUG_LEVEL_INC();
+			class_declaration = true;
+			Value *val = compile_node(body);
+			assert(Function::classof(val));
+			Function *f = cast<Function>(val);
+			GET_CORE()->optimize(f);
+			DEBUG_LEVEL_DEC();
 
+			std::vector<Value *> params;
+			params.push_back(classVal);
+			params.push_back(compile_const_pointer(NULL));
+			val = compile_protected_call(f, params);
+
 			dynamic_class = old_dynamic_class;
 			compile_set_current_scope(classVal, defaultScope);
 
@@ -3976,6 +3986,7 @@
 			current_self = old_self;
 			current_opened_class = old_class;
 			current_module = old_current_module;
+			current_block_chain = old_current_block_chain;
 
 			ivar_slots_cache = old_ivar_slots_cache;
 

Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp	2009-11-14 05:19:43 UTC (rev 3009)
+++ MacRuby/trunk/vm.cpp	2009-11-14 06:19:30 UTC (rev 3010)
@@ -234,6 +234,7 @@
 	fprintf(stderr, "error while creating JIT: %s\n", err.c_str());
 	abort();
     }
+    ee->DisableLazyCompilation();
 
     fpm = new FunctionPassManager(emp);
     fpm->add(new TargetData(*ee->getTargetData()));
@@ -392,12 +393,6 @@
     return s;
 }
 
-inline void
-RoxorCore::optimize(Function *func)
-{
-    fpm->run(*func);
-}
-
 IMP
 RoxorCore::compile(Function *func)
 {

Modified: MacRuby/trunk/vm.h
===================================================================
--- MacRuby/trunk/vm.h	2009-11-14 05:19:43 UTC (rev 3009)
+++ MacRuby/trunk/vm.h	2009-11-14 06:19:30 UTC (rev 3010)
@@ -671,7 +671,9 @@
 	void register_thread(VALUE thread);
 	void unregister_thread(VALUE thread);
 
-	void optimize(Function *func);
+	void optimize(Function *func) {
+	    fpm->run(*func);
+	}
 	IMP compile(Function *func);
 	void delenda(Function *func);
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091113/afc55250/attachment-0001.html>


More information about the macruby-changes mailing list