hotspot/src/share/vm/shark/sharkBlock.cpp
changeset 14622 8e94e4186d35
parent 7397 5b173b4ca846
child 15204 a8960bf92b09
equal deleted inserted replaced
14621:fd9265ab0f67 14622:8e94e4186d35
   168       push(SharkValue::jint_constant(iter()->get_constant_u2()));
   168       push(SharkValue::jint_constant(iter()->get_constant_u2()));
   169       break;
   169       break;
   170 
   170 
   171     case Bytecodes::_ldc:
   171     case Bytecodes::_ldc:
   172     case Bytecodes::_ldc_w:
   172     case Bytecodes::_ldc_w:
   173     case Bytecodes::_ldc2_w:
   173     case Bytecodes::_ldc2_w: {
   174       push(SharkConstant::for_ldc(iter())->value(builder()));
   174       SharkConstant* constant = SharkConstant::for_ldc(iter());
   175       break;
   175       assert(constant->is_loaded(), "trap should handle unloaded classes");
   176 
   176       push(constant->value(builder()));
       
   177       break;
       
   178     }
   177     case Bytecodes::_iload_0:
   179     case Bytecodes::_iload_0:
   178     case Bytecodes::_lload_0:
   180     case Bytecodes::_lload_0:
   179     case Bytecodes::_fload_0:
   181     case Bytecodes::_fload_0:
   180     case Bytecodes::_dload_0:
   182     case Bytecodes::_dload_0:
   181     case Bytecodes::_aload_0:
   183     case Bytecodes::_aload_0:
   998   builder()->CreateBr(done);
  1000   builder()->CreateBr(done);
   999 
  1001 
  1000   builder()->SetInsertPoint(done);
  1002   builder()->SetInsertPoint(done);
  1001   PHINode *result;
  1003   PHINode *result;
  1002   if (is_long)
  1004   if (is_long)
  1003     result = builder()->CreatePHI(SharkType::jlong_type(), "result");
  1005     result = builder()->CreatePHI(SharkType::jlong_type(), 0, "result");
  1004   else
  1006   else
  1005     result = builder()->CreatePHI(SharkType::jint_type(), "result");
  1007     result = builder()->CreatePHI(SharkType::jint_type(), 0, "result");
  1006   result->addIncoming(special_result, special_case);
  1008   result->addIncoming(special_result, special_case);
  1007   result->addIncoming(general_result, general_case);
  1009   result->addIncoming(general_result, general_case);
  1008 
  1010 
  1009   if (is_long)
  1011   if (is_long)
  1010     push(SharkValue::create_jlong(result, false));
  1012     push(SharkValue::create_jlong(result, false));
  1034     SharkConstant *constant = SharkConstant::for_field(iter());
  1036     SharkConstant *constant = SharkConstant::for_field(iter());
  1035     if (constant->is_loaded())
  1037     if (constant->is_loaded())
  1036       value = constant->value(builder());
  1038       value = constant->value(builder());
  1037   }
  1039   }
  1038   if (!is_get || value == NULL) {
  1040   if (!is_get || value == NULL) {
  1039     if (!is_field)
  1041     if (!is_field) {
  1040       object = builder()->CreateInlineOop(field->holder());
  1042       object = builder()->CreateInlineOop(field->holder()->java_mirror());
  1041 
  1043     }
  1042     BasicType   basic_type = field->type()->basic_type();
  1044     BasicType   basic_type = field->type()->basic_type();
  1043     const Type *stack_type = SharkType::to_stackType(basic_type);
  1045     Type *stack_type = SharkType::to_stackType(basic_type);
  1044     const Type *field_type = SharkType::to_arrayType(basic_type);
  1046     Type *field_type = SharkType::to_arrayType(basic_type);
  1045 
  1047 
  1046     Value *addr = builder()->CreateAddressOfStructEntry(
  1048     Value *addr = builder()->CreateAddressOfStructEntry(
  1047       object, in_ByteSize(field->offset_in_bytes()),
  1049       object, in_ByteSize(field->offset_in_bytes()),
  1048       PointerType::getUnqual(field_type),
  1050       PointerType::getUnqual(field_type),
  1049       "addr");
  1051       "addr");
  1050 
  1052 
  1051     // Do the access
  1053     // Do the access
  1052     if (is_get) {
  1054     if (is_get) {
  1053       Value *field_value = builder()->CreateLoad(addr);
  1055       Value* field_value;
  1054 
  1056       if (field->is_volatile()) {
       
  1057         field_value = builder()->CreateAtomicLoad(addr);
       
  1058       } else {
       
  1059         field_value = builder()->CreateLoad(addr);
       
  1060       }
  1055       if (field_type != stack_type) {
  1061       if (field_type != stack_type) {
  1056         field_value = builder()->CreateIntCast(
  1062         field_value = builder()->CreateIntCast(
  1057           field_value, stack_type, basic_type != T_CHAR);
  1063           field_value, stack_type, basic_type != T_CHAR);
  1058       }
  1064       }
  1059 
  1065 
  1065       if (field_type != stack_type) {
  1071       if (field_type != stack_type) {
  1066         field_value = builder()->CreateIntCast(
  1072         field_value = builder()->CreateIntCast(
  1067           field_value, field_type, basic_type != T_CHAR);
  1073           field_value, field_type, basic_type != T_CHAR);
  1068       }
  1074       }
  1069 
  1075 
  1070       builder()->CreateStore(field_value, addr);
  1076       if (field->is_volatile()) {
  1071 
  1077         builder()->CreateAtomicStore(field_value, addr);
  1072       if (!field->type()->is_primitive_type())
  1078       } else {
       
  1079         builder()->CreateStore(field_value, addr);
       
  1080       }
       
  1081 
       
  1082       if (!field->type()->is_primitive_type()) {
  1073         builder()->CreateUpdateBarrierSet(oopDesc::bs(), addr);
  1083         builder()->CreateUpdateBarrierSet(oopDesc::bs(), addr);
  1074 
  1084       }
  1075       if (field->is_volatile())
       
  1076         builder()->CreateMemoryBarrier(SharkBuilder::BARRIER_STORELOAD);
       
  1077     }
  1085     }
  1078   }
  1086   }
  1079 
  1087 
  1080   // Push the value onto the stack where necessary
  1088   // Push the value onto the stack where necessary
  1081   if (is_get)
  1089   if (is_get)
  1103 
  1111 
  1104   builder()->SetInsertPoint(gt);
  1112   builder()->SetInsertPoint(gt);
  1105   builder()->CreateBr(done);
  1113   builder()->CreateBr(done);
  1106 
  1114 
  1107   builder()->SetInsertPoint(done);
  1115   builder()->SetInsertPoint(done);
  1108   PHINode *result = builder()->CreatePHI(SharkType::jint_type(), "result");
  1116   PHINode *result = builder()->CreatePHI(SharkType::jint_type(), 0, "result");
  1109   result->addIncoming(LLVMValue::jint_constant(-1), lt);
  1117   result->addIncoming(LLVMValue::jint_constant(-1), lt);
  1110   result->addIncoming(LLVMValue::jint_constant(0),  eq);
  1118   result->addIncoming(LLVMValue::jint_constant(0),  eq);
  1111   result->addIncoming(LLVMValue::jint_constant(1),  gt);
  1119   result->addIncoming(LLVMValue::jint_constant(1),  gt);
  1112 
  1120 
  1113   push(SharkValue::create_jint(result, false));
  1121   push(SharkValue::create_jint(result, false));
  1150 
  1158 
  1151   builder()->SetInsertPoint(eq);
  1159   builder()->SetInsertPoint(eq);
  1152   builder()->CreateBr(done);
  1160   builder()->CreateBr(done);
  1153 
  1161 
  1154   builder()->SetInsertPoint(done);
  1162   builder()->SetInsertPoint(done);
  1155   PHINode *result = builder()->CreatePHI(SharkType::jint_type(), "result");
  1163   PHINode *result = builder()->CreatePHI(SharkType::jint_type(), 0, "result");
  1156   result->addIncoming(LLVMValue::jint_constant(-1), lt);
  1164   result->addIncoming(LLVMValue::jint_constant(-1), lt);
  1157   result->addIncoming(LLVMValue::jint_constant(0),  eq);
  1165   result->addIncoming(LLVMValue::jint_constant(0),  eq);
  1158   result->addIncoming(LLVMValue::jint_constant(1),  gt);
  1166   result->addIncoming(LLVMValue::jint_constant(1),  gt);
  1159 
  1167 
  1160   push(SharkValue::create_jint(result, false));
  1168   push(SharkValue::create_jint(result, false));