comparison src/gpu/hsail/vm/gpu_hsail_Frame.hpp @ 16242:e9998e2be7f5

use oops_do to modify saved hsail state Contributed-by: Tom Deneau <tom.deneau@amd.com>
author Gilles Duboscq <duboscq@ssw.jku.at>
date Thu, 26 Jun 2014 18:25:35 +0200
parents 06eedda53e14
children
comparison
equal deleted inserted replaced
16241:c6ebc1997a55 16242:e9998e2be7f5
35 jint _pc_offset; // The HSAIL "pc_offset" where the exception happens 35 jint _pc_offset; // The HSAIL "pc_offset" where the exception happens
36 jbyte _num_s_regs; 36 jbyte _num_s_regs;
37 jbyte _num_d_regs; 37 jbyte _num_d_regs;
38 jshort _num_stack_slots; 38 jshort _num_stack_slots;
39 39
40 jbyte* data_start() {return (jbyte*) this + sizeof(*this); }
41 int sreg_ofst_start() { return 0; }
42 int dreg_ofst_start() { return sreg_ofst_start() + num_s_regs() * sizeof(jint); }
43 int stackslot_ofst_start() { return dreg_ofst_start() + num_d_regs() * sizeof(jlong); }
44
45 int sreg_ofst(int idx) {
46 assert(idx >= 0 && idx < num_s_regs(), "bad sreg index");
47 return sreg_ofst_start() + idx * sizeof(jint);
48 }
49
50 int dreg_ofst(int idx) {
51 assert(idx >= 0 && idx < num_d_regs(), "bad dreg index");
52 return dreg_ofst_start() + idx * sizeof(jlong);
53 }
54
55 int stackslot_ofst(int stackOffset) {
56 assert(stackOffset >= 0 && (unsigned int) stackOffset < num_stack_slots() * sizeof(jlong), "bad stackoffset");
57 return stackslot_ofst_start() + stackOffset;
58 }
59
60 // the _ptr versions just return a pointer to the indicated d reg or stackslot64
61 // some of these are used for oops_do processing
62 jint* get_s_reg_ptr(int idx) {
63 return((jint*) (data_start() + sreg_ofst(idx)));
64 }
65
66 jlong* get_d_reg_ptr(int idx) {
67 return((jlong*) (data_start() + dreg_ofst(idx)));
68 }
69
70 jlong* get_stackslot64_ptr(int stackOffset) {
71 return((jlong*) (data_start() + stackslot_ofst(stackOffset)));
72 }
73
74 jint* get_stackslot32_ptr(int stackOffset) {
75 return((jint*) (data_start() + stackslot_ofst(stackOffset)));
76 }
77
78 void* get_oop_ptr_for_bit(int bit) {
79 void* oop_ptr;
80 if (bit < num_d_regs()) {
81 // d register
82 oop_ptr = (void*) get_d_reg_ptr(bit);
83 } else {
84 // stack slot
85 int stackOffset = (bit - num_d_regs()) * 8; // 8 bytes per stack slot
86 oop_ptr = (void*) get_stackslot64_ptr(stackOffset);
87 }
88 return oop_ptr;
89 }
90
40 public: 91 public:
41 // Accessors 92 // Accessors
42 jint pc_offset() { return _pc_offset; } 93 jint pc_offset() { return _pc_offset; }
43 jint num_s_regs() {return _num_s_regs; } 94 jint num_s_regs() {return _num_s_regs; }
44 jint num_d_regs() {return _num_d_regs; } 95 jint num_d_regs() {return _num_d_regs; }
45 jint num_stack_slots() {return _num_stack_slots; } 96 jint num_stack_slots() {return _num_stack_slots; }
46 jbyte* data_start() {return (jbyte*) this + sizeof(*this); } 97
47 jlong get_d_reg(int idx) { 98 jlong get_oop_for_bit(int bit) {
48 int ofst = num_s_regs() * 4 + idx * 8; 99 return * (jlong *) get_oop_ptr_for_bit(bit);
49 return(*(jlong*) (data_start() + ofst));
50 } 100 }
51 jint get_s_reg(int idx) { 101
52 int ofst = idx * 4; 102 // do the oops from this frame
53 return(*(jint*) (data_start() + ofst)); 103 void oops_do(OopClosure* f, HSAILOopMapHelper* oopMapHelper) {
54 } 104 int oops_per_deopt = num_d_regs() + num_stack_slots();
55 void put_d_reg(int idx, jlong val) { 105
56 int ofst = num_s_regs() * 4 + idx * 8; 106 // handle the dregister and stackSlot based oops
57 (*(jlong*) (data_start() + ofst)) = val; 107 for (int bit = 0; bit < oops_per_deopt; bit++) {
58 } 108 if (oopMapHelper->is_oop(pc_offset(), bit)) {
59 jint get_stackslot32(int stackOffset) { 109 void* oop_ptr = get_oop_ptr_for_bit(bit);
60 int ofst = num_s_regs() * 4 + num_d_regs() * 8 + stackOffset; 110 // the oops we are dealing with here in the hsailFrame are always uncompressed
61 return(*(jint*) (data_start() + ofst)); 111 oop old_oop = oopDesc::load_heap_oop((oop *)oop_ptr);
62 } 112 f->do_oop((oop*) oop_ptr);
63 jlong get_stackslot64(int stackOffset) { 113 if (TraceGPUInteraction) {
64 int ofst = num_s_regs() * 4 + num_d_regs() * 8 + stackOffset; 114 oop new_oop = oopDesc::load_heap_oop((oop *)oop_ptr);
65 return(*(jlong*) (data_start() + ofst)); 115 tty->print_cr("bit=%d, oop_ptr=%p, old=%p, new=%p", bit, oop_ptr, (void *)old_oop, (void *)new_oop);
66 } 116 }
67 void put_stackslot64(int stackOffset, jlong val) { 117 }
68 int ofst = num_s_regs() * 4 + num_d_regs() * 8 + stackOffset; 118 }
69 (*(jlong*) (data_start() + ofst)) = val;
70 } 119 }
71 }; 120 };
72 121
73 #endif // GPU_HSAIL_VM_GPU_HSAIL_FRAME_HPP 122 #endif // GPU_HSAIL_VM_GPU_HSAIL_FRAME_HPP