Permalink
Browse files

don't slow ivars used inside an eval string

  • Loading branch information...
1 parent 5195bcd commit c219e864015eb5261d1ac2550e9ad3eacbc9fa09 @lrz lrz committed Jun 19, 2009
Showing with 19 additions and 8 deletions.
  1. +1 −0 compiler.cpp
  2. +6 −1 compiler.h
  3. +10 −5 vm.cpp
  4. +2 −2 vm.h
View
@@ -35,6 +35,7 @@ RoxorCompiler *RoxorCompiler::shared = NULL;
RoxorCompiler::RoxorCompiler(const char *_fname)
{
fname = _fname;
+ inside_eval = false;
bb = NULL;
entry_bb = NULL;
View
@@ -50,8 +50,12 @@ class RoxorCompiler {
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 @@ class RoxorCompiler {
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);
View
15 vm.cpp
@@ -3698,21 +3698,26 @@ __init_shared_compiler(void)
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 @@ rb_vm_run(const char *fname, NODE *node, rb_vm_binding_t *binding,
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 @@ rb_vm_run_under(VALUE klass, VALUE self, const char *fname, NODE *node,
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;
View
4 vm.h
@@ -199,9 +199,9 @@ rb_vm_cfunc_node_from_imp(Class klass, int arity, IMP imp, int noex)
}
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);

0 comments on commit c219e86

Please sign in to comment.