Permalink
Browse files

Define ALLOCA_STACKVARIABLES like ALLOCA_CALLFRAME

  • Loading branch information...
ryoqun committed May 9, 2012
1 parent b90a394 commit e38aaa8ec4c0448b3d1b5a1adfb2be4d7f93ae72
Showing with 6 additions and 13 deletions.
  1. +1 −5 vm/builtin/block_environment.cpp
  2. +3 −0 vm/stack_variables.hpp
  3. +2 −8 vm/vmmethod.cpp
@@ -281,11 +281,7 @@ namespace rubinius {
}
#endif
- size_t scope_size = sizeof(StackVariables) +
- (vmm->number_of_locals * sizeof(Object*));
-
- StackVariables* scope =
- reinterpret_cast<StackVariables*>(alloca(scope_size));
+ StackVariables* scope = ALLOCA_STACKVARIABLES(vmm->number_of_locals);
Module* mod = invocation.module;
if(!mod) mod = env->module();
View
@@ -75,6 +75,9 @@ namespace rubinius {
friend class GarbageCollector;
};
+
+#define ALLOCA_STACKVARIABLES(local_size) \
+ (StackVariables*)alloca(sizeof(StackVariables) + (sizeof(Object*) * local_size))
}
#endif
View
@@ -562,10 +562,7 @@ namespace rubinius {
CompiledMethod* cm = as<CompiledMethod>(exec);
VMMethod* vmm = cm->backend_method();
- size_t scope_size = sizeof(StackVariables) +
- (vmm->number_of_locals * sizeof(Object*));
- StackVariables* scope =
- reinterpret_cast<StackVariables*>(alloca(scope_size));
+ StackVariables* scope = ALLOCA_STACKVARIABLES(vmm->number_of_locals);
// Originally, I tried using msg.module directly, but what happens is if
// super is used, that field is read. If you combine that with the method
// being called recursively, msg.module can change, causing super() to
@@ -639,10 +636,7 @@ namespace rubinius {
Object* VMMethod::execute_as_script(STATE, CompiledMethod* cm, CallFrame* previous) {
VMMethod* vmm = cm->backend_method();
- size_t scope_size = sizeof(StackVariables) +
- (vmm->number_of_locals * sizeof(Object*));
- StackVariables* scope =
- reinterpret_cast<StackVariables*>(alloca(scope_size));
+ StackVariables* scope = ALLOCA_STACKVARIABLES(vmm->number_of_locals);
// Originally, I tried using msg.module directly, but what happens is if
// super is used, that field is read. If you combine that with the method
// being called recursively, msg.module can change, causing super() to

0 comments on commit e38aaa8

Please sign in to comment.