< prev index next >

src/share/vm/c1/c1_LIRGenerator.cpp

Print this page

        

@@ -402,11 +402,11 @@
     // assert(instr->use_count() > 0 || instr->as_Phi() != NULL, "leaf instruction must have a use");
   }
 }
 
 
-CodeEmitInfo* LIRGenerator::state_for(Instruction* x, ValueStack* state, bool ignore_xhandler) {
+CodeEmitInfo* LIRGenerator::state_for(Instruction* x, ValueStack* state, bool ignore_xhandler, bool deoptimize_on_exception) {
   assert(state != NULL, "state must be defined");
 
 #ifndef PRODUCT
   state->verify();
 #endif

@@ -459,11 +459,11 @@
         }
       }
     }
   }
 
-  return new CodeEmitInfo(state, ignore_xhandler ? NULL : x->exception_handlers(), x->check_flag(Instruction::DeoptimizeOnException));
+  return new CodeEmitInfo(state, ignore_xhandler ? NULL : x->exception_handlers(), deoptimize_on_exception || x->check_flag(Instruction::DeoptimizeOnException));
 }
 
 
 CodeEmitInfo* LIRGenerator::state_for(Instruction* x) {
   return state_for(x, x->exception_state());

@@ -1805,11 +1805,14 @@
   BasicType field_type = x->field_type();
 
   CodeEmitInfo* info = NULL;
   if (needs_patching) {
     assert(x->explicit_null_check() == NULL, "can't fold null check into patching field access");
-    info = state_for(x, x->state_before());
+    // If the class is not loaded and the object is NULL, we need to deoptimize to throw a
+    // NoClassDefFoundError in the interpreter instead of an implicit NPE from compiled code.
+    bool deoptimize_on_exception = x->needs_null_check();
+    info = state_for(x, x->state_before(), false, deoptimize_on_exception);
   } else if (x->needs_null_check()) {
     NullCheck* nc = x->explicit_null_check();
     if (nc == NULL) {
       info = state_for(x);
     } else {
< prev index next >