1 /*
2 * Copyright (c) 2002, 2016, 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 *
2151 obj->long_field_put(field_offset, STACK_LONG(-1));
2152 } else if (tos_type == ctos) {
2153 obj->char_field_put(field_offset, STACK_INT(-1));
2154 } else if (tos_type == stos) {
2155 obj->short_field_put(field_offset, STACK_INT(-1));
2156 } else if (tos_type == ftos) {
2157 obj->float_field_put(field_offset, STACK_FLOAT(-1));
2158 } else {
2159 obj->double_field_put(field_offset, STACK_DOUBLE(-1));
2160 }
2161 }
2162
2163 UPDATE_PC_AND_TOS_AND_CONTINUE(3, count);
2164 }
2165
2166 CASE(_new): {
2167 u2 index = Bytes::get_Java_u2(pc+1);
2168 ConstantPool* constants = istate->method()->constants();
2169 if (!constants->tag_at(index).is_unresolved_klass()) {
2170 // Make sure klass is initialized and doesn't have a finalizer
2171 Klass* entry = constants->slot_at(index).get_klass();
2172 InstanceKlass* ik = InstanceKlass::cast(entry);
2173 if (ik->is_initialized() && ik->can_be_fastpath_allocated() ) {
2174 size_t obj_size = ik->size_helper();
2175 oop result = NULL;
2176 // If the TLAB isn't pre-zeroed then we'll have to do it
2177 bool need_zero = !ZeroTLAB;
2178 if (UseTLAB) {
2179 result = (oop) THREAD->tlab().allocate(obj_size);
2180 }
2181 // Disable non-TLAB-based fast-path, because profiling requires that all
2182 // allocations go through InterpreterRuntime::_new() if THREAD->tlab().allocate
2183 // returns NULL.
2184 #ifndef CC_INTERP_PROFILE
2185 if (result == NULL) {
2186 need_zero = true;
2187 // Try allocate in shared eden
2188 retry:
2189 HeapWord* compare_to = *Universe::heap()->top_addr();
2190 HeapWord* new_top = compare_to + obj_size;
2191 if (new_top <= *Universe::heap()->end_addr()) {
2251 Interpreter::stackElementWords-1];
2252 //adjust pointer to start of stack element
2253 CALL_VM(InterpreterRuntime::multianewarray(THREAD, dimarray),
2254 handle_exception);
2255 // Must prevent reordering of stores for object initialization
2256 // with stores that publish the new object.
2257 OrderAccess::storestore();
2258 SET_STACK_OBJECT(THREAD->vm_result(), -dims);
2259 THREAD->set_vm_result(NULL);
2260 UPDATE_PC_AND_TOS_AND_CONTINUE(4, -(dims-1));
2261 }
2262 CASE(_checkcast):
2263 if (STACK_OBJECT(-1) != NULL) {
2264 VERIFY_OOP(STACK_OBJECT(-1));
2265 u2 index = Bytes::get_Java_u2(pc+1);
2266 // Constant pool may have actual klass or unresolved klass. If it is
2267 // unresolved we must resolve it.
2268 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) {
2269 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception);
2270 }
2271 Klass* klassOf = (Klass*) METHOD->constants()->slot_at(index).get_klass();
2272 Klass* objKlass = STACK_OBJECT(-1)->klass(); // ebx
2273 //
2274 // Check for compatibilty. This check must not GC!!
2275 // Seems way more expensive now that we must dispatch.
2276 //
2277 if (objKlass != klassOf && !objKlass->is_subtype_of(klassOf)) {
2278 // Decrement counter at checkcast.
2279 BI_PROFILE_SUBTYPECHECK_FAILED(objKlass);
2280 ResourceMark rm(THREAD);
2281 char* message = SharedRuntime::generate_class_cast_message(
2282 objKlass, klassOf);
2283 VM_JAVA_ERROR(vmSymbols::java_lang_ClassCastException(), message, note_classCheck_trap);
2284 }
2285 // Profile checkcast with null_seen and receiver.
2286 BI_PROFILE_UPDATE_CHECKCAST(/*null_seen=*/false, objKlass);
2287 } else {
2288 // Profile checkcast with null_seen and receiver.
2289 BI_PROFILE_UPDATE_CHECKCAST(/*null_seen=*/true, NULL);
2290 }
2291 UPDATE_PC_AND_CONTINUE(3);
2292
2293 CASE(_instanceof):
2294 if (STACK_OBJECT(-1) == NULL) {
2295 SET_STACK_INT(0, -1);
2296 // Profile instanceof with null_seen and receiver.
2297 BI_PROFILE_UPDATE_INSTANCEOF(/*null_seen=*/true, NULL);
2298 } else {
2299 VERIFY_OOP(STACK_OBJECT(-1));
2300 u2 index = Bytes::get_Java_u2(pc+1);
2301 // Constant pool may have actual klass or unresolved klass. If it is
2302 // unresolved we must resolve it.
2303 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) {
2304 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception);
2305 }
2306 Klass* klassOf = (Klass*) METHOD->constants()->slot_at(index).get_klass();
2307 Klass* objKlass = STACK_OBJECT(-1)->klass();
2308 //
2309 // Check for compatibilty. This check must not GC!!
2310 // Seems way more expensive now that we must dispatch.
2311 //
2312 if ( objKlass == klassOf || objKlass->is_subtype_of(klassOf)) {
2313 SET_STACK_INT(1, -1);
2314 } else {
2315 SET_STACK_INT(0, -1);
2316 // Decrement counter at checkcast.
2317 BI_PROFILE_SUBTYPECHECK_FAILED(objKlass);
2318 }
2319 // Profile instanceof with null_seen and receiver.
2320 BI_PROFILE_UPDATE_INSTANCEOF(/*null_seen=*/false, objKlass);
2321 }
2322 UPDATE_PC_AND_CONTINUE(3);
2323
2324 CASE(_ldc_w):
2325 CASE(_ldc):
2326 {
|
1 /*
2 * Copyright (c) 2002, 2017, 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 *
2151 obj->long_field_put(field_offset, STACK_LONG(-1));
2152 } else if (tos_type == ctos) {
2153 obj->char_field_put(field_offset, STACK_INT(-1));
2154 } else if (tos_type == stos) {
2155 obj->short_field_put(field_offset, STACK_INT(-1));
2156 } else if (tos_type == ftos) {
2157 obj->float_field_put(field_offset, STACK_FLOAT(-1));
2158 } else {
2159 obj->double_field_put(field_offset, STACK_DOUBLE(-1));
2160 }
2161 }
2162
2163 UPDATE_PC_AND_TOS_AND_CONTINUE(3, count);
2164 }
2165
2166 CASE(_new): {
2167 u2 index = Bytes::get_Java_u2(pc+1);
2168 ConstantPool* constants = istate->method()->constants();
2169 if (!constants->tag_at(index).is_unresolved_klass()) {
2170 // Make sure klass is initialized and doesn't have a finalizer
2171 Klass* entry = constants->resolved_klass_at(index);
2172 InstanceKlass* ik = InstanceKlass::cast(entry);
2173 if (ik->is_initialized() && ik->can_be_fastpath_allocated() ) {
2174 size_t obj_size = ik->size_helper();
2175 oop result = NULL;
2176 // If the TLAB isn't pre-zeroed then we'll have to do it
2177 bool need_zero = !ZeroTLAB;
2178 if (UseTLAB) {
2179 result = (oop) THREAD->tlab().allocate(obj_size);
2180 }
2181 // Disable non-TLAB-based fast-path, because profiling requires that all
2182 // allocations go through InterpreterRuntime::_new() if THREAD->tlab().allocate
2183 // returns NULL.
2184 #ifndef CC_INTERP_PROFILE
2185 if (result == NULL) {
2186 need_zero = true;
2187 // Try allocate in shared eden
2188 retry:
2189 HeapWord* compare_to = *Universe::heap()->top_addr();
2190 HeapWord* new_top = compare_to + obj_size;
2191 if (new_top <= *Universe::heap()->end_addr()) {
2251 Interpreter::stackElementWords-1];
2252 //adjust pointer to start of stack element
2253 CALL_VM(InterpreterRuntime::multianewarray(THREAD, dimarray),
2254 handle_exception);
2255 // Must prevent reordering of stores for object initialization
2256 // with stores that publish the new object.
2257 OrderAccess::storestore();
2258 SET_STACK_OBJECT(THREAD->vm_result(), -dims);
2259 THREAD->set_vm_result(NULL);
2260 UPDATE_PC_AND_TOS_AND_CONTINUE(4, -(dims-1));
2261 }
2262 CASE(_checkcast):
2263 if (STACK_OBJECT(-1) != NULL) {
2264 VERIFY_OOP(STACK_OBJECT(-1));
2265 u2 index = Bytes::get_Java_u2(pc+1);
2266 // Constant pool may have actual klass or unresolved klass. If it is
2267 // unresolved we must resolve it.
2268 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) {
2269 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception);
2270 }
2271 Klass* klassOf = (Klass*) METHOD->constants()->resolved_klass_at(index);
2272 Klass* objKlass = STACK_OBJECT(-1)->klass(); // ebx
2273 //
2274 // Check for compatibilty. This check must not GC!!
2275 // Seems way more expensive now that we must dispatch.
2276 //
2277 if (objKlass != klassOf && !objKlass->is_subtype_of(klassOf)) {
2278 // Decrement counter at checkcast.
2279 BI_PROFILE_SUBTYPECHECK_FAILED(objKlass);
2280 ResourceMark rm(THREAD);
2281 char* message = SharedRuntime::generate_class_cast_message(
2282 objKlass, klassOf);
2283 VM_JAVA_ERROR(vmSymbols::java_lang_ClassCastException(), message, note_classCheck_trap);
2284 }
2285 // Profile checkcast with null_seen and receiver.
2286 BI_PROFILE_UPDATE_CHECKCAST(/*null_seen=*/false, objKlass);
2287 } else {
2288 // Profile checkcast with null_seen and receiver.
2289 BI_PROFILE_UPDATE_CHECKCAST(/*null_seen=*/true, NULL);
2290 }
2291 UPDATE_PC_AND_CONTINUE(3);
2292
2293 CASE(_instanceof):
2294 if (STACK_OBJECT(-1) == NULL) {
2295 SET_STACK_INT(0, -1);
2296 // Profile instanceof with null_seen and receiver.
2297 BI_PROFILE_UPDATE_INSTANCEOF(/*null_seen=*/true, NULL);
2298 } else {
2299 VERIFY_OOP(STACK_OBJECT(-1));
2300 u2 index = Bytes::get_Java_u2(pc+1);
2301 // Constant pool may have actual klass or unresolved klass. If it is
2302 // unresolved we must resolve it.
2303 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) {
2304 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception);
2305 }
2306 Klass* klassOf = (Klass*) METHOD->constants()->resolved_klass_at(index);
2307 Klass* objKlass = STACK_OBJECT(-1)->klass();
2308 //
2309 // Check for compatibilty. This check must not GC!!
2310 // Seems way more expensive now that we must dispatch.
2311 //
2312 if ( objKlass == klassOf || objKlass->is_subtype_of(klassOf)) {
2313 SET_STACK_INT(1, -1);
2314 } else {
2315 SET_STACK_INT(0, -1);
2316 // Decrement counter at checkcast.
2317 BI_PROFILE_SUBTYPECHECK_FAILED(objKlass);
2318 }
2319 // Profile instanceof with null_seen and receiver.
2320 BI_PROFILE_UPDATE_INSTANCEOF(/*null_seen=*/false, objKlass);
2321 }
2322 UPDATE_PC_AND_CONTINUE(3);
2323
2324 CASE(_ldc_w):
2325 CASE(_ldc):
2326 {
|