Skip to content

Instantly share code, notes, and snippets.

@sshao
Created October 30, 2014 14:27
Show Gist options
  • Select an option

  • Save sshao/c0fde02937d502187026 to your computer and use it in GitHub Desktop.

Select an option

Save sshao/c0fde02937d502187026 to your computer and use it in GitHub Desktop.
diff --git a/vm/llvm/jit_builder.cpp b/vm/llvm/jit_builder.cpp
index c479aab..6e6c90f 100644
--- a/vm/llvm/jit_builder.cpp
+++ b/vm/llvm/jit_builder.cpp
@@ -646,8 +646,14 @@ namespace jit {
cint((sizeof(CallFrame) / sizeof(Object*)) + machine_code_->stack_size),
"cfstk");
+ size_t upper = machine_code_->number_of_locals;
+
+ if ((size_t)machine_code_->total_args > upper) {
+ upper = machine_code_->total_args;
+ }
+
Value* var_mem = b().CreateAlloca(obj_type,
- cint((sizeof(StackVariables) / sizeof(Object*)) + machine_code_->number_of_locals),
+ cint((sizeof(StackVariables) / sizeof(Object*)) + upper),
"var_mem");
call_frame = b().CreateBitCast(
diff --git a/vm/llvm/jit_inline_block.cpp b/vm/llvm/jit_inline_block.cpp
index 3da96f6..c68e35a 100644
--- a/vm/llvm/jit_inline_block.cpp
+++ b/vm/llvm/jit_inline_block.cpp
@@ -43,8 +43,14 @@ namespace jit {
info_.set_stack(stk);
+ size_t upper = machine_code_->number_of_locals;
+
+ if ((size_t)machine_code_->total_args > upper) {
+ upper = machine_code_->total_args;
+ }
+
Value* var_mem = new AllocaInst(obj_type,
- cint((sizeof(StackVariables) / sizeof(Object*)) + machine_code_->number_of_locals),
+ cint((sizeof(StackVariables) / sizeof(Object*)) + upper),
"var_mem", alloca_block->getTerminator());
vars = b().CreateBitCast(
diff --git a/vm/llvm/jit_inline_method.cpp b/vm/llvm/jit_inline_method.cpp
index c53c0c4..94679fd 100644
--- a/vm/llvm/jit_inline_method.cpp
+++ b/vm/llvm/jit_inline_method.cpp
@@ -41,9 +41,15 @@ namespace jit {
info_.set_call_frame(call_frame);
info_.set_stack(stk);
+ size_t upper = machine_code_->number_of_locals;
+
+ if ((size_t) machine_code_->total_args > upper) {
+ upper = machine_code_->total_args;
+ }
+
Value* var_mem = new AllocaInst(obj_type,
ConstantInt::get(ctx_->Int32Ty,
- (sizeof(StackVariables) / sizeof(Object*)) + machine_code_->number_of_locals),
+ (sizeof(StackVariables) / sizeof(Object*)) + upper),
"var_mem", alloca_block->getTerminator());
vars = b().CreateBitCast(
@@ -110,7 +116,13 @@ namespace jit {
assert(stack_args.size() <= (size_t)machine_code_->total_args);
- for(size_t i = 0; i < stack_args.size(); i++) {
+ size_t limit = stack_args.size();
+
+ if ((int)stack_args.size() > (int)machine_code_->number_of_locals) {
+ limit = machine_code_->number_of_locals;
+ }
+
+ for(size_t i = 0; i < limit; i++) {
Value* int_pos = cint(i);
Value* idx2[] = {
diff --git a/vm/llvm/jit_method.cpp b/vm/llvm/jit_method.cpp
index 2a3072e..3bf8758 100644
--- a/vm/llvm/jit_method.cpp
+++ b/vm/llvm/jit_method.cpp
@@ -269,10 +269,12 @@ namespace jit {
void MethodBuilder::import_args() {
setup_scope();
+ /*
if(machine_code_->post_args > 0) {
import_args_19_style();
return;
}
+ */
// Import the arguments
Value* offset = b().CreateConstGEP2_32(info_.args(), 0, offset::Arguments::arguments, "arg_ary_pos");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment