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