File: | jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp |
Warning: | line 63, column 31 Value stored to 'byte_arr_klass' during its initialization is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* |
2 | * Copyright (c) 2016, 2021, 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 | #include "precompiled.hpp" |
26 | #include "jfr/jni/jfrJavaSupport.hpp" |
27 | #include "jfr/jni/jfrUpcalls.hpp" |
28 | #include "jfr/recorder/checkpoint/jfrMetadataEvent.hpp" |
29 | #include "jfr/recorder/repository/jfrChunkWriter.hpp" |
30 | #include "jfr/recorder/jfrEventSetting.inline.hpp" |
31 | #include "oops/klass.inline.hpp" |
32 | #include "oops/oop.inline.hpp" |
33 | #include "oops/typeArrayOop.inline.hpp" |
34 | #include "runtime/interfaceSupport.inline.hpp" |
35 | #include "runtime/thread.inline.hpp" |
36 | #include "utilities/exceptions.hpp" |
37 | |
38 | static jbyteArray metadata_blob = NULL__null; |
39 | static u8 metadata_id = 0; |
40 | static u8 last_metadata_id = 0; |
41 | |
42 | static void check_internal_types() { |
43 | static bool visible = false; |
44 | if (!visible && JfrEventSetting::is_internal_types_visible()) { |
45 | JavaThread* const jt = JavaThread::current(); |
46 | DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_native(jt))JfrJavaSupport::check_java_thread_in_native(jt); |
47 | // can safepoint here |
48 | ThreadInVMfromNative transition(jt); |
49 | visible = JfrUpcalls::unhide_internal_types(jt); |
50 | } |
51 | } |
52 | |
53 | static void write_metadata_blob(JfrChunkWriter& chunkwriter, JavaThread* thread) { |
54 | assert(chunkwriter.is_valid(), "invariant")do { if (!(chunkwriter.is_valid())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp" , 54, "assert(" "chunkwriter.is_valid()" ") failed", "invariant" ); ::breakpoint(); } } while (0); |
55 | assert(thread != NULL, "invariant")do { if (!(thread != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp" , 55, "assert(" "thread != __null" ") failed", "invariant"); :: breakpoint(); } } while (0); |
56 | assert(metadata_blob != NULL, "invariant")do { if (!(metadata_blob != __null)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp" , 56, "assert(" "metadata_blob != __null" ") failed", "invariant" ); ::breakpoint(); } } while (0); |
57 | DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(thread))JfrJavaSupport::check_java_thread_in_vm(thread); |
58 | const typeArrayOop arr = (typeArrayOop)JfrJavaSupport::resolve_non_null(metadata_blob); |
59 | assert(arr != NULL, "invariant")do { if (!(arr != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp" , 59, "assert(" "arr != __null" ") failed", "invariant"); ::breakpoint (); } } while (0); |
60 | const int length = arr->length(); |
61 | const Klass* const k = arr->klass(); |
62 | assert(k != NULL && k->is_array_klass(), "invariant")do { if (!(k != __null && k->is_array_klass())) { ( *g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp" , 62, "assert(" "k != __null && k->is_array_klass()" ") failed", "invariant"); ::breakpoint(); } } while (0); |
63 | const TypeArrayKlass* const byte_arr_klass = TypeArrayKlass::cast(k); |
Value stored to 'byte_arr_klass' during its initialization is never read | |
64 | const jbyte* const data_address = arr->byte_at_addr(0); |
65 | chunkwriter.write_unbuffered(data_address, length); |
66 | } |
67 | |
68 | void JfrMetadataEvent::write(JfrChunkWriter& chunkwriter) { |
69 | assert(chunkwriter.is_valid(), "invariant")do { if (!(chunkwriter.is_valid())) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp" , 69, "assert(" "chunkwriter.is_valid()" ") failed", "invariant" ); ::breakpoint(); } } while (0); |
70 | check_internal_types(); |
71 | if (last_metadata_id == metadata_id && chunkwriter.has_metadata()) { |
72 | return; |
73 | } |
74 | JavaThread* const jt = JavaThread::current(); |
75 | DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_native(jt))JfrJavaSupport::check_java_thread_in_native(jt); |
76 | // can safepoint here |
77 | ThreadInVMfromNative transition(jt); |
78 | // header |
79 | const int64_t metadata_offset = chunkwriter.reserve(sizeof(u4)); |
80 | chunkwriter.write<u8>(EVENT_METADATA); // ID 0 |
81 | // time data |
82 | chunkwriter.write(JfrTicks::now()); |
83 | chunkwriter.write((u8)0); // duration |
84 | chunkwriter.write(metadata_id); // metadata id |
85 | write_metadata_blob(chunkwriter, jt); // payload |
86 | // fill in size of metadata descriptor event |
87 | const int64_t size_written = chunkwriter.current_offset() - metadata_offset; |
88 | chunkwriter.write_padded_at_offset((u4)size_written, metadata_offset); |
89 | chunkwriter.set_last_metadata_offset(metadata_offset); |
90 | last_metadata_id = metadata_id; |
91 | } |
92 | |
93 | void JfrMetadataEvent::update(jbyteArray metadata) { |
94 | JavaThread* thread = JavaThread::current(); |
95 | DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(thread))JfrJavaSupport::check_java_thread_in_vm(thread); |
96 | if (metadata_blob != NULL__null) { |
97 | JfrJavaSupport::destroy_global_jni_handle(metadata_blob); |
98 | } |
99 | const oop new_desc_oop = JfrJavaSupport::resolve_non_null(metadata); |
100 | assert(new_desc_oop != NULL, "invariant")do { if (!(new_desc_oop != __null)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jfr/recorder/checkpoint/jfrMetadataEvent.cpp" , 100, "assert(" "new_desc_oop != __null" ") failed", "invariant" ); ::breakpoint(); } } while (0); |
101 | metadata_blob = (jbyteArray)JfrJavaSupport::global_jni_handle(new_desc_oop, thread); |
102 | ++metadata_id; |
103 | } |