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 #include "precompiled.hpp"
26 #include "code/debugInfo.hpp"
27 #include "code/debugInfoRec.hpp"
28 #include "code/nmethod.hpp"
29 #include "runtime/handles.inline.hpp"
30
31 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
32
33 // Constructors
34
35 DebugInfoWriteStream::DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size)
36 : CompressedWriteStream(initial_size) {
37 _recorder = recorder;
38 }
39
40 // Serializing oops
41
42 void DebugInfoWriteStream::write_handle(jobject h) {
43 write_int(recorder()->oop_recorder()->find_index(h));
44 }
45
46 void DebugInfoWriteStream::write_metadata(Metadata* h) {
47 write_int(recorder()->oop_recorder()->find_index(h));
48 }
49
50 ScopeValue* DebugInfoReadStream::read_object_value() {
51 int id = read_int();
52 #ifdef ASSERT
53 assert(_obj_pool != NULL, "object pool does not exist");
54 for (int i = _obj_pool->length() - 1; i >= 0; i--) {
55 assert(((ObjectValue*) _obj_pool->at(i))->id() != id, "should not be read twice");
56 }
57 #endif
58 ObjectValue* result = new ObjectValue(id);
59 // Cache the object since an object field could reference it.
60 _obj_pool->push(result);
61 result->read_object(this);
62 return result;
63 }
64
65 ScopeValue* DebugInfoReadStream::get_cached_object() {
66 int id = read_int();
67 assert(_obj_pool != NULL, "object pool does not exist");
68 for (int i = _obj_pool->length() - 1; i >= 0; i--) {
69 ObjectValue* ov = (ObjectValue*) _obj_pool->at(i);
|
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 #include "precompiled.hpp"
26 #include "code/debugInfo.hpp"
27 #include "code/debugInfoRec.hpp"
28 #include "code/nmethod.hpp"
29 #include "oops/oop.inline.hpp"
30 #include "runtime/handles.inline.hpp"
31
32 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
33
34 // Constructors
35
36 DebugInfoWriteStream::DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size)
37 : CompressedWriteStream(initial_size) {
38 _recorder = recorder;
39 }
40
41 // Serializing oops
42
43 void DebugInfoWriteStream::write_handle(jobject h) {
44 write_int(recorder()->oop_recorder()->find_index(h));
45 }
46
47 void DebugInfoWriteStream::write_metadata(Metadata* h) {
48 write_int(recorder()->oop_recorder()->find_index(h));
49 }
50
51 oop DebugInfoReadStream::read_oop() {
52 oop o = code()->oop_at(read_int());
53 assert(o == NULL || o->is_oop(), "oop only");
54 return o;
55 }
56
57 ScopeValue* DebugInfoReadStream::read_object_value() {
58 int id = read_int();
59 #ifdef ASSERT
60 assert(_obj_pool != NULL, "object pool does not exist");
61 for (int i = _obj_pool->length() - 1; i >= 0; i--) {
62 assert(((ObjectValue*) _obj_pool->at(i))->id() != id, "should not be read twice");
63 }
64 #endif
65 ObjectValue* result = new ObjectValue(id);
66 // Cache the object since an object field could reference it.
67 _obj_pool->push(result);
68 result->read_object(this);
69 return result;
70 }
71
72 ScopeValue* DebugInfoReadStream::get_cached_object() {
73 int id = read_int();
74 assert(_obj_pool != NULL, "object pool does not exist");
75 for (int i = _obj_pool->length() - 1; i >= 0; i--) {
76 ObjectValue* ov = (ObjectValue*) _obj_pool->at(i);
|