comparison src/gpu/hsail/vm/gpu_hsail_OopMapHelper.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
children
comparison
equal deleted inserted replaced
16241:c6ebc1997a55 16242:e9998e2be7f5
1 /*
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef GPU_HSAIL_VM_GPU_HSAIL_OOPMAPHELPER_HPP
26 #define GPU_HSAIL_VM_GPU_HSAIL_OOPMAPHELPER_HPP
27
28 #include "graal/graalEnv.hpp"
29 #include "code/debugInfo.hpp"
30 #include "code/location.hpp"
31
32 // Takes the jobject for the array of ints created by the java side
33 // and decodes the information based on pc_offset to find oops
34 class HSAILOopMapHelper : public StackObj {
35 private:
36 jobject _oop_map_array_jobject;
37 typeArrayOop _oop_map_array;
38 int _last_pcoffset;
39 int _last_idx;
40
41 enum {
42 SAVEAREACOUNTS_OFST=0,
43 SPAN_OFST=1,
44 HEADERSIZE=2
45 };
46 int mapPcOffsetToIndex(int pcOffset) {
47 if (pcOffset == _last_pcoffset) {
48 return _last_idx;
49 }
50 int span = _oop_map_array->int_at(SPAN_OFST);
51 for (int idx = HEADERSIZE; idx < _oop_map_array->length(); idx += span) {
52 int ofst = _oop_map_array->int_at(idx);
53 if (ofst == pcOffset) {
54 _last_pcoffset = pcOffset;
55 _last_idx = idx + 1;
56 return _last_idx;
57 }
58 }
59 ShouldNotReachHere();
60 return -1;
61 }
62
63 public:
64 HSAILOopMapHelper(jobject oop_map_array_jobject) {
65 _oop_map_array_jobject = oop_map_array_jobject;
66 _last_pcoffset = -1;
67 resolve_arrays();
68 }
69
70 void resolve_arrays() {
71 _oop_map_array = (typeArrayOop) JNIHandles::resolve(_oop_map_array_jobject);
72 }
73
74 static int get_save_area_counts(jobject oop_map_array_jobject) {
75 typeArrayOop oop_map_array_resolved = (typeArrayOop) JNIHandles::resolve(oop_map_array_jobject);
76 return oop_map_array_resolved->int_at(SAVEAREACOUNTS_OFST);
77 }
78
79 bool is_oop(int pcOffset, int bit){
80 int bits_int_idx = mapPcOffsetToIndex(pcOffset) + (bit / 32);
81 int bitpos = bit % 32;
82 int bits = _oop_map_array->int_at(bits_int_idx);
83 return ((bits & (1 << bitpos)) != 0);
84 }
85
86 };
87
88 #endif // GPU_HSAIL_VM_GPU_HSAIL_OOPMAPHELPER_HPP