[macruby-changes] [1885] MacRuby/branches/experimental

source_changes at macosforge.org source_changes at macosforge.org
Fri Jun 19 14:08:56 PDT 2009


Revision: 1885
          http://trac.macosforge.org/projects/ruby/changeset/1885
Author:   lsansonetti at apple.com
Date:     2009-06-19 14:08:55 -0700 (Fri, 19 Jun 2009)
Log Message:
-----------
don't slow ivars used inside an eval string

Modified Paths:
--------------
    MacRuby/branches/experimental/compiler.cpp
    MacRuby/branches/experimental/compiler.h
    MacRuby/branches/experimental/vm.cpp
    MacRuby/branches/experimental/vm.h

Modified: MacRuby/branches/experimental/compiler.cpp
===================================================================
--- MacRuby/branches/experimental/compiler.cpp	2009-06-19 20:39:33 UTC (rev 1884)
+++ MacRuby/branches/experimental/compiler.cpp	2009-06-19 21:08:55 UTC (rev 1885)
@@ -35,6 +35,7 @@
 RoxorCompiler::RoxorCompiler(const char *_fname)
 {
     fname = _fname;
+    inside_eval = false;
 
     bb = NULL;
     entry_bb = NULL;

Modified: MacRuby/branches/experimental/compiler.h
===================================================================
--- MacRuby/branches/experimental/compiler.h	2009-06-19 20:39:33 UTC (rev 1884)
+++ MacRuby/branches/experimental/compiler.h	2009-06-19 21:08:55 UTC (rev 1885)
@@ -50,8 +50,12 @@
 
 	const Type *convert_type(const char *type);
 
+	bool is_inside_eval(void) { return inside_eval; }
+	void set_inside_eval(bool flag) { inside_eval = flag; }
+
     protected:
 	const char *fname;
+	bool inside_eval;
 
 	std::map<ID, Value *> lvars;
 	std::vector<ID> dvars;
@@ -248,7 +252,8 @@
 					  const Type *llvm_type, Value *val);
 
 	int *get_slot_cache(ID id) {
-	    if (current_block || !current_instance_method || current_module) {
+	    if (inside_eval || current_block || !current_instance_method
+		|| current_module) {
 		return NULL;
 	    }
 	    std::map<ID, int *>::iterator iter = ivar_slots_cache.find(id);

Modified: MacRuby/branches/experimental/vm.cpp
===================================================================
--- MacRuby/branches/experimental/vm.cpp	2009-06-19 20:39:33 UTC (rev 1884)
+++ MacRuby/branches/experimental/vm.cpp	2009-06-19 21:08:55 UTC (rev 1885)
@@ -3698,21 +3698,26 @@
 extern "C"
 VALUE
 rb_vm_run(const char *fname, NODE *node, rb_vm_binding_t *binding,
-	  bool try_interpreter)
+	  bool inside_eval)
 {
     if (binding != NULL) {
 	GET_VM()->bindings.push_back(binding);
     }
 
     __init_shared_compiler();
-    Function *function = RoxorCompiler::shared->compile_main_function(node);
+    RoxorCompiler *compiler = RoxorCompiler::shared;
 
+    bool old_inside_eval = compiler->is_inside_eval();
+    compiler->set_inside_eval(inside_eval); 
+    Function *function = compiler->compile_main_function(node);
+    compiler->set_inside_eval(old_inside_eval);
+
     if (binding != NULL) {
 	GET_VM()->bindings.pop_back();
     }
 
 #if ROXOR_INTERPRET_EVAL
-    if (try_interpreter) {
+    if (inside_eval) {
 	return GET_VM()->interpret(function);
     }
     else {
@@ -3728,7 +3733,7 @@
 extern "C"
 VALUE
 rb_vm_run_under(VALUE klass, VALUE self, const char *fname, NODE *node,
-		rb_vm_binding_t *binding, bool try_interpreter)
+		rb_vm_binding_t *binding, bool inside_eval)
 {
     VALUE old_top_object = GET_VM()->current_top_object;
     if (binding != NULL) {
@@ -3742,7 +3747,7 @@
 	GET_VM()->current_class = (Class)klass;
     }
 
-    VALUE val = rb_vm_run(fname, node, binding, try_interpreter);
+    VALUE val = rb_vm_run(fname, node, binding, inside_eval);
 
     GET_VM()->current_top_object = old_top_object;
     GET_VM()->current_class = old_class;

Modified: MacRuby/branches/experimental/vm.h
===================================================================
--- MacRuby/branches/experimental/vm.h	2009-06-19 20:39:33 UTC (rev 1884)
+++ MacRuby/branches/experimental/vm.h	2009-06-19 21:08:55 UTC (rev 1885)
@@ -199,9 +199,9 @@
 }
 
 VALUE rb_vm_run(const char *fname, NODE *node, rb_vm_binding_t *binding,
-		bool try_interpreter);
+		bool inside_eval);
 VALUE rb_vm_run_under(VALUE klass, VALUE self, const char *fname, NODE *node,
-		      rb_vm_binding_t *binding, bool try_interpreter);
+		      rb_vm_binding_t *binding, bool inside_eval);
 void rb_vm_aot_compile(NODE *node);
 
 bool rb_vm_running(void);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090619/5f5c1738/attachment.html>


More information about the macruby-changes mailing list