@@ -781,7 +781,79 @@ void LIRGenerator::do_ArrayCopy(Intrinsic* x) {
781781}
782782
783783void LIRGenerator::do_update_CRC32 (Intrinsic* x) {
784- ShouldNotReachHere ();
784+ assert (UseCRC32Intrinsics, " why are we here?" );
785+ // Make all state_for calls early since they can emit code
786+ LIR_Opr result = rlock_result (x);
787+ switch (x->id ()) {
788+ case vmIntrinsics::_updateCRC32: {
789+ LIRItem crc (x->argument_at (0 ), this );
790+ LIRItem val (x->argument_at (1 ), this );
791+ // val is destroyed by update_crc32
792+ val.set_destroys_register ();
793+ crc.load_item ();
794+ val.load_item ();
795+ __ update_crc32 (crc.result (), val.result (), result);
796+ break ;
797+ }
798+ case vmIntrinsics::_updateBytesCRC32:
799+ case vmIntrinsics::_updateByteBufferCRC32: {
800+ bool is_updateBytes = (x->id () == vmIntrinsics::_updateBytesCRC32);
801+
802+ LIRItem crc (x->argument_at (0 ), this );
803+ LIRItem buf (x->argument_at (1 ), this );
804+ LIRItem off (x->argument_at (2 ), this );
805+ LIRItem len (x->argument_at (3 ), this );
806+ buf.load_item ();
807+ off.load_nonconstant ();
808+
809+ LIR_Opr index = off.result ();
810+ int offset = is_updateBytes ? arrayOopDesc::base_offset_in_bytes (T_BYTE) : 0 ;
811+ if (off.result ()->is_constant ()) {
812+ index = LIR_OprFact::illegalOpr;
813+ offset += off.result ()->as_jint ();
814+ }
815+ LIR_Opr base_op = buf.result ();
816+
817+ if (index->is_valid ()) {
818+ LIR_Opr tmp = new_register (T_LONG);
819+ __ convert (Bytecodes::_i2l, index, tmp);
820+ index = tmp;
821+ }
822+
823+ if (offset) {
824+ LIR_Opr tmp = new_pointer_register ();
825+ __ add (base_op, LIR_OprFact::intConst (offset), tmp);
826+ base_op = tmp;
827+ offset = 0 ;
828+ }
829+
830+ LIR_Address* a = new LIR_Address (base_op,
831+ index,
832+ offset,
833+ T_BYTE);
834+ BasicTypeList signature (3 );
835+ signature.append (T_INT);
836+ signature.append (T_ADDRESS);
837+ signature.append (T_INT);
838+ CallingConvention* cc = frame_map ()->c_calling_convention (&signature);
839+ const LIR_Opr result_reg = result_register_for (x->type ());
840+
841+ LIR_Opr addr = new_pointer_register ();
842+ __ leal (LIR_OprFact::address (a), addr);
843+
844+ crc.load_item_force (cc->at (0 ));
845+ __ move (addr, cc->at (1 ));
846+ len.load_item_force (cc->at (2 ));
847+
848+ __ call_runtime_leaf (StubRoutines::updateBytesCRC32 (), getThreadTemp (), result_reg, cc->args ());
849+ __ move (result_reg, result);
850+
851+ break ;
852+ }
853+ default : {
854+ ShouldNotReachHere ();
855+ }
856+ }
785857}
786858
787859void LIRGenerator::do_update_CRC32C (Intrinsic* x) {
0 commit comments