130 double (* StubRoutines::_intrinsic_exp )(double) = NULL;
131 double (* StubRoutines::_intrinsic_pow )(double, double) = NULL;
132 double (* StubRoutines::_intrinsic_sin )(double) = NULL;
133 double (* StubRoutines::_intrinsic_cos )(double) = NULL;
134 double (* StubRoutines::_intrinsic_tan )(double) = NULL;
135
136 // Initialization
137 //
138 // Note: to break cycle with universe initialization, stubs are generated in two phases.
139 // The first one generates stubs needed during universe init (e.g., _handle_must_compile_first_entry).
140 // The second phase includes all other stubs (which may depend on universe being initialized.)
141
142 extern void StubGenerator_generate(CodeBuffer* code, bool all); // only interface to generators
143
144 void StubRoutines::initialize1() {
145 if (_code1 == NULL) {
146 ResourceMark rm;
147 TraceTime timer("StubRoutines generation 1", TraceStartupTime);
148 _code1 = BufferBlob::create("StubRoutines (1)", code_size1);
149 if (_code1 == NULL) {
150 vm_exit_out_of_memory(code_size1, "CodeCache: no room for StubRoutines (1)");
151 }
152 CodeBuffer buffer(_code1);
153 StubGenerator_generate(&buffer, false);
154 }
155 }
156
157
158 #ifdef ASSERT
159 typedef void (*arraycopy_fn)(address src, address dst, int count);
160
161 // simple tests of generated arraycopy functions
162 static void test_arraycopy_func(address func, int alignment) {
163 int v = 0xcc;
164 int v2 = 0x11;
165 jlong lbuffer[8];
166 jlong lbuffer2[8];
167 address fbuffer = (address) lbuffer;
168 address fbuffer2 = (address) lbuffer2;
169 unsigned int i;
170 for (i = 0; i < sizeof(lbuffer); i++) {
182 // adjust destination alignment
183 ((arraycopy_fn)func)(buffer, buffer2 + alignment, 0);
184 for (i = 0; i < sizeof(lbuffer); i++) {
185 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
186 }
187 // adjust source alignment
188 ((arraycopy_fn)func)(buffer + alignment, buffer2, 0);
189 for (i = 0; i < sizeof(lbuffer); i++) {
190 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
191 }
192 }
193 #endif
194
195
196 void StubRoutines::initialize2() {
197 if (_code2 == NULL) {
198 ResourceMark rm;
199 TraceTime timer("StubRoutines generation 2", TraceStartupTime);
200 _code2 = BufferBlob::create("StubRoutines (2)", code_size2);
201 if (_code2 == NULL) {
202 vm_exit_out_of_memory(code_size2, "CodeCache: no room for StubRoutines (2)");
203 }
204 CodeBuffer buffer(_code2);
205 StubGenerator_generate(&buffer, true);
206 }
207
208 #ifdef ASSERT
209
210 #define TEST_ARRAYCOPY(type) \
211 test_arraycopy_func( type##_arraycopy(), sizeof(type)); \
212 test_arraycopy_func( type##_disjoint_arraycopy(), sizeof(type)); \
213 test_arraycopy_func(arrayof_##type##_arraycopy(), sizeof(HeapWord)); \
214 test_arraycopy_func(arrayof_##type##_disjoint_arraycopy(), sizeof(HeapWord))
215
216 // Make sure all the arraycopy stubs properly handle zero count
217 TEST_ARRAYCOPY(jbyte);
218 TEST_ARRAYCOPY(jshort);
219 TEST_ARRAYCOPY(jint);
220 TEST_ARRAYCOPY(jlong);
221
222 #undef TEST_ARRAYCOPY
|
130 double (* StubRoutines::_intrinsic_exp )(double) = NULL;
131 double (* StubRoutines::_intrinsic_pow )(double, double) = NULL;
132 double (* StubRoutines::_intrinsic_sin )(double) = NULL;
133 double (* StubRoutines::_intrinsic_cos )(double) = NULL;
134 double (* StubRoutines::_intrinsic_tan )(double) = NULL;
135
136 // Initialization
137 //
138 // Note: to break cycle with universe initialization, stubs are generated in two phases.
139 // The first one generates stubs needed during universe init (e.g., _handle_must_compile_first_entry).
140 // The second phase includes all other stubs (which may depend on universe being initialized.)
141
142 extern void StubGenerator_generate(CodeBuffer* code, bool all); // only interface to generators
143
144 void StubRoutines::initialize1() {
145 if (_code1 == NULL) {
146 ResourceMark rm;
147 TraceTime timer("StubRoutines generation 1", TraceStartupTime);
148 _code1 = BufferBlob::create("StubRoutines (1)", code_size1);
149 if (_code1 == NULL) {
150 vm_exit_out_of_memory(code_size1, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (1)");
151 }
152 CodeBuffer buffer(_code1);
153 StubGenerator_generate(&buffer, false);
154 }
155 }
156
157
158 #ifdef ASSERT
159 typedef void (*arraycopy_fn)(address src, address dst, int count);
160
161 // simple tests of generated arraycopy functions
162 static void test_arraycopy_func(address func, int alignment) {
163 int v = 0xcc;
164 int v2 = 0x11;
165 jlong lbuffer[8];
166 jlong lbuffer2[8];
167 address fbuffer = (address) lbuffer;
168 address fbuffer2 = (address) lbuffer2;
169 unsigned int i;
170 for (i = 0; i < sizeof(lbuffer); i++) {
182 // adjust destination alignment
183 ((arraycopy_fn)func)(buffer, buffer2 + alignment, 0);
184 for (i = 0; i < sizeof(lbuffer); i++) {
185 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
186 }
187 // adjust source alignment
188 ((arraycopy_fn)func)(buffer + alignment, buffer2, 0);
189 for (i = 0; i < sizeof(lbuffer); i++) {
190 assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
191 }
192 }
193 #endif
194
195
196 void StubRoutines::initialize2() {
197 if (_code2 == NULL) {
198 ResourceMark rm;
199 TraceTime timer("StubRoutines generation 2", TraceStartupTime);
200 _code2 = BufferBlob::create("StubRoutines (2)", code_size2);
201 if (_code2 == NULL) {
202 vm_exit_out_of_memory(code_size2, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (2)");
203 }
204 CodeBuffer buffer(_code2);
205 StubGenerator_generate(&buffer, true);
206 }
207
208 #ifdef ASSERT
209
210 #define TEST_ARRAYCOPY(type) \
211 test_arraycopy_func( type##_arraycopy(), sizeof(type)); \
212 test_arraycopy_func( type##_disjoint_arraycopy(), sizeof(type)); \
213 test_arraycopy_func(arrayof_##type##_arraycopy(), sizeof(HeapWord)); \
214 test_arraycopy_func(arrayof_##type##_disjoint_arraycopy(), sizeof(HeapWord))
215
216 // Make sure all the arraycopy stubs properly handle zero count
217 TEST_ARRAYCOPY(jbyte);
218 TEST_ARRAYCOPY(jshort);
219 TEST_ARRAYCOPY(jint);
220 TEST_ARRAYCOPY(jlong);
221
222 #undef TEST_ARRAYCOPY
|