1 /*
2 * Copyright (c) 1997, 2025, 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 *
36 #include "utilities/macros.hpp"
37 #include "utilities/resizableHashTable.hpp"
38
39 template <typename T>
40 static inline void put_native(address p, T x) {
41 memcpy((void*)p, &x, sizeof x);
42 }
43
44 class PhaseCFG;
45 class Compile;
46 class BufferBlob;
47 class CodeBuffer;
48 class Label;
49 class ciMethod;
50 class SharedStubToInterpRequest;
51
52 class CodeOffsets: public StackObj {
53 public:
54 enum Entries { Entry,
55 Verified_Entry,
56 Frame_Complete, // Offset in the code where the frame setup is (for forte stackwalks) is complete
57 OSR_Entry,
58 Exceptions, // Offset where exception handler lives
59 Deopt, // Offset where deopt handler lives
60 UnwindHandler, // Offset to default unwind handler
61 max_Entries };
62
63 // special value to note codeBlobs where profile (forte) stack walking is
64 // always dangerous and suspect.
65
66 enum { frame_never_safe = -1 };
67
68 private:
69 int _values[max_Entries];
70
71 public:
72 CodeOffsets() {
73 _values[Entry ] = 0;
74 _values[Verified_Entry] = 0;
75 _values[Frame_Complete] = frame_never_safe;
76 _values[OSR_Entry ] = 0;
77 _values[Exceptions ] = -1;
78 _values[Deopt ] = -1;
79 _values[UnwindHandler ] = -1;
80 }
81
82 int value(Entries e) { return _values[e]; }
83 void set_value(Entries e, int val) { _values[e] = val; }
84 };
85
86 // This class represents a stream of code and associated relocations.
87 // There are a few in each CodeBuffer.
88 // They are filled concurrently, and concatenated at the end.
89 class CodeSection {
90 friend class CodeBuffer;
91 friend class AOTCodeReader;
92 public:
93 typedef int csize_t; // code size type; would be size_t except for history
94
95 private:
96 address _start; // first byte of contents (instructions)
97 address _mark; // user mark, usually an instruction beginning
98 address _end; // current end address
99 address _limit; // last possible (allocated) end address
100 relocInfo* _locs_start; // first byte of relocation information
101 relocInfo* _locs_end; // first byte after relocation information
102 relocInfo* _locs_limit; // first byte after relocation information buf
103 address _locs_point; // last relocated position (grows upward)
|
1 /*
2 * Copyright (c) 1997, 2026, 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 *
36 #include "utilities/macros.hpp"
37 #include "utilities/resizableHashTable.hpp"
38
39 template <typename T>
40 static inline void put_native(address p, T x) {
41 memcpy((void*)p, &x, sizeof x);
42 }
43
44 class PhaseCFG;
45 class Compile;
46 class BufferBlob;
47 class CodeBuffer;
48 class Label;
49 class ciMethod;
50 class SharedStubToInterpRequest;
51
52 class CodeOffsets: public StackObj {
53 public:
54 enum Entries { Entry,
55 Verified_Entry,
56 Inline_Entry,
57 Verified_Inline_Entry,
58 Verified_Inline_Entry_RO,
59 Frame_Complete, // Offset in the code where the frame setup is (for forte stackwalks) is complete
60 OSR_Entry,
61 Exceptions, // Offset where exception handler lives
62 Deopt, // Offset where deopt handler lives
63 UnwindHandler, // Offset to default unwind handler
64 max_Entries };
65
66 // special value to note codeBlobs where profile (forte) stack walking is
67 // always dangerous and suspect.
68
69 static const int frame_never_safe = -1;
70 static const int no_such_entry_point = -1;
71
72 private:
73 int _values[max_Entries];
74 void check(int e) const { assert(0 <= e && e < max_Entries, "must be"); }
75
76 public:
77 CodeOffsets() {
78 _values[Entry ] = 0;
79 _values[Verified_Entry] = 0;
80 _values[Inline_Entry ] = 0;
81 _values[Verified_Inline_Entry ] = no_such_entry_point;
82 _values[Verified_Inline_Entry_RO] = no_such_entry_point;
83 _values[Frame_Complete] = frame_never_safe;
84 _values[OSR_Entry ] = 0;
85 _values[Exceptions ] = -1;
86 _values[Deopt ] = -1;
87 _values[UnwindHandler ] = -1;
88 }
89
90 int value(Entries e) const { check(e); return _values[e]; }
91 void set_value(Entries e, int val) { check(e); _values[e] = val; }
92 };
93
94 // This class represents a stream of code and associated relocations.
95 // There are a few in each CodeBuffer.
96 // They are filled concurrently, and concatenated at the end.
97 class CodeSection {
98 friend class CodeBuffer;
99 friend class AOTCodeReader;
100 public:
101 typedef int csize_t; // code size type; would be size_t except for history
102
103 private:
104 address _start; // first byte of contents (instructions)
105 address _mark; // user mark, usually an instruction beginning
106 address _end; // current end address
107 address _limit; // last possible (allocated) end address
108 relocInfo* _locs_start; // first byte of relocation information
109 relocInfo* _locs_end; // first byte after relocation information
110 relocInfo* _locs_limit; // first byte after relocation information buf
111 address _locs_point; // last relocated position (grows upward)
|