Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
diff --git a/vm/llvm/jit_visit.hpp b/vm/llvm/jit_visit.hpp
index 04e7a94..898f6ff 100644
--- a/vm/llvm/jit_visit.hpp
+++ b/vm/llvm/jit_visit.hpp
@@ -730,16 +730,22 @@ namespace rubinius {

       Value* i = CastInst::Create(
           Instruction::PtrToInt,
-          obj, type, "as_int", block);
+          obj, Type::Int32Ty, "as_int", block);

-      return BinaryOperator::CreateLShr(i, ConstantInt::get(type, 1), "lshr", block);
+      Value * more = BinaryOperator::CreateLShr(
+          i, ConstantInt::get(Type::Int32Ty, 1),
+          "lshr", block);
+      return CastInst::CreateIntegerCast(
+          more, type, true, "stripped", block);
     }

     Value* fixnum_tag(Value* obj, BasicBlock* block = NULL) {
       if(!block) block = block_;
-      Value* one = ConstantInt::get(Int31Ty, 1);
-      Value* more = BinaryOperator::CreateShl(obj, one, "shl", block);
-      Value* tagged = BinaryOperator::CreateOr(more, one, "or", block);
+      Value * obj32 = CastInst::CreateZExtOrBitCast(
+          obj, Type::Int32Ty, "as_32bit", block);
+      Value* one = ConstantInt::get(Type::Int32Ty, 1);
+      Value* more = BinaryOperator::CreateShl(obj32, one, "shl", block);
+      Value * tagged = BinaryOperator::CreateOr(more, one, "or", block);

       return CastInst::Create(
           Instruction::IntToPtr, tagged, ObjType, "as_obj", block);
@@ -1103,6 +1109,15 @@ namespace rubinius {
       };

       stack_push(CallInst::Create(func, call_args, call_args+3, "create_block", block_));
+
+      // top_scope
+      Value* idx[] = {
+        ConstantInt::get(Type::Int32Ty, 0),
+        ConstantInt::get(Type::Int32Ty, 7)
+      };
+      Value* gep = GetElementPtrInst::Create(call_frame_, idx, idx+2, "ts_gep", block_);
+      vars_ = new LoadInst(gep, "top_scope", block_);
+
     }

     void visit_send_stack_with_block(opcode which, opcode args) {
@@ -1324,7 +1339,7 @@ namespace rubinius {
       };

       Value* gep = GetElementPtrInst::Create(call_frame_, idx, idx+2, "scope_pos", block_);
-      std::cout << *gep << "\n";
+      // std::cout << *gep << "\n";
       stack_push(new LoadInst(gep, "scope", block_));
     }

@@ -1808,6 +1823,7 @@ namespace rubinius {
       };

       Value* val = sig.call("rbx_make_array", call_args, 4, "constant", block_);
+      stack_remove(count);
       stack_push(val);
     }

@@ -1823,10 +1839,11 @@ namespace rubinius {
         vm_,
         call_frame_,
         ConstantInt::get(Type::Int32Ty, count),
-        stack_objects(count)
+        stack_objects(count + 1)
       };

       Value* val = sig.call("rbx_meta_send_call", call_args, 4, "constant", block_);
+      stack_remove(count+1);
       stack_push(val);
     }

diff --git a/vm/vmmethod.cpp b/vm/vmmethod.cpp
index 2fbb4d5..4a724a2 100644
--- a/vm/vmmethod.cpp
+++ b/vm/vmmethod.cpp
@@ -425,6 +425,7 @@ namespace rubinius {
         uint64_t start = get_current_time();
         MachineMethod* mm = cm->make_machine_method(state);
         mm->activate();
+        cm->resolve_primitive(state);
         vmm->call_count = -1;
         state->stats.jit_timing += (get_current_time() - start);
       } else {