1 /*
2 * Copyright (c) 1998, 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 *
71 assert(header_size == round_to(header_size, oopSize), "unaligned size");
72 assert(!UseRelocIndex, "no space allocated for reloc index yet");
73
74 // Note: If UseRelocIndex is enabled, there needs to be (at least) one
75 // extra word for the relocation information, containing the reloc
76 // index table length. Unfortunately, the reloc index table imple-
77 // mentation is not easily understandable and thus it is not clear
78 // what exactly the format is supposed to be. For now, we just turn
79 // off the use of this table (gri 7/6/2000).
80
81 _name = name;
82 _size = size;
83 _frame_complete_offset = frame_complete;
84 _header_size = header_size;
85 _relocation_size = locs_size;
86 _content_offset = align_code_offset(header_size + _relocation_size);
87 _code_offset = _content_offset;
88 _data_offset = size;
89 _frame_size = 0;
90 set_oop_maps(NULL);
91 }
92
93
94 // Creates a CodeBlob from a CodeBuffer. Sets up the size of the different regions,
95 // and copy code and relocation info.
96 CodeBlob::CodeBlob(
97 const char* name,
98 CodeBuffer* cb,
99 int header_size,
100 int size,
101 int frame_complete,
102 int frame_size,
103 OopMapSet* oop_maps
104 ) {
105 assert(size == round_to(size, oopSize), "unaligned size");
106 assert(header_size == round_to(header_size, oopSize), "unaligned size");
107
108 _name = name;
109 _size = size;
110 _frame_complete_offset = frame_complete;
111 _header_size = header_size;
112 _relocation_size = round_to(cb->total_relocation_size(), oopSize);
113 _content_offset = align_code_offset(header_size + _relocation_size);
114 _code_offset = _content_offset + cb->total_offset_of(cb->insts());
115 _data_offset = _content_offset + round_to(cb->total_content_size(), oopSize);
116 assert(_data_offset <= size, "codeBlob is too small");
117
118 cb->copy_code_and_locs_to(this);
119 set_oop_maps(oop_maps);
120 _frame_size = frame_size;
121 #ifdef COMPILER1
122 // probably wrong for tiered
123 assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
124 #endif // COMPILER1
125 }
126
127
128 void CodeBlob::set_oop_maps(OopMapSet* p) {
129 // Danger Will Robinson! This method allocates a big
130 // chunk of memory, its your job to free it.
131 if (p != NULL) {
132 _oop_maps = ImmutableOopMapSet::build_from(p);
133 } else {
134 _oop_maps = NULL;
135 }
136 }
|
1 /*
2 * Copyright (c) 1998, 2015, 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 *
71 assert(header_size == round_to(header_size, oopSize), "unaligned size");
72 assert(!UseRelocIndex, "no space allocated for reloc index yet");
73
74 // Note: If UseRelocIndex is enabled, there needs to be (at least) one
75 // extra word for the relocation information, containing the reloc
76 // index table length. Unfortunately, the reloc index table imple-
77 // mentation is not easily understandable and thus it is not clear
78 // what exactly the format is supposed to be. For now, we just turn
79 // off the use of this table (gri 7/6/2000).
80
81 _name = name;
82 _size = size;
83 _frame_complete_offset = frame_complete;
84 _header_size = header_size;
85 _relocation_size = locs_size;
86 _content_offset = align_code_offset(header_size + _relocation_size);
87 _code_offset = _content_offset;
88 _data_offset = size;
89 _frame_size = 0;
90 set_oop_maps(NULL);
91 _strings = CodeStrings();
92 }
93
94
95 // Creates a CodeBlob from a CodeBuffer. Sets up the size of the different regions,
96 // and copy code and relocation info.
97 CodeBlob::CodeBlob(
98 const char* name,
99 CodeBuffer* cb,
100 int header_size,
101 int size,
102 int frame_complete,
103 int frame_size,
104 OopMapSet* oop_maps
105 ) {
106 assert(size == round_to(size, oopSize), "unaligned size");
107 assert(header_size == round_to(header_size, oopSize), "unaligned size");
108
109 _name = name;
110 _size = size;
111 _frame_complete_offset = frame_complete;
112 _header_size = header_size;
113 _relocation_size = round_to(cb->total_relocation_size(), oopSize);
114 _content_offset = align_code_offset(header_size + _relocation_size);
115 _code_offset = _content_offset + cb->total_offset_of(cb->insts());
116 _data_offset = _content_offset + round_to(cb->total_content_size(), oopSize);
117 assert(_data_offset <= size, "codeBlob is too small");
118 _strings = CodeStrings();
119
120 cb->copy_code_and_locs_to(this);
121 set_oop_maps(oop_maps);
122 _frame_size = frame_size;
123 #ifdef COMPILER1
124 // probably wrong for tiered
125 assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs");
126 #endif // COMPILER1
127 }
128
129
130 void CodeBlob::set_oop_maps(OopMapSet* p) {
131 // Danger Will Robinson! This method allocates a big
132 // chunk of memory, its your job to free it.
133 if (p != NULL) {
134 _oop_maps = ImmutableOopMapSet::build_from(p);
135 } else {
136 _oop_maps = NULL;
137 }
138 }
|