1.1 --- a/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp Tue Jul 02 07:51:31 2013 +0200 1.2 +++ b/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp Tue Jul 02 20:42:12 2013 -0400 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -932,6 +932,81 @@ 1.11 __ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(), length.result(), tmp, expected_type, flags, info); // does add_safepoint 1.12 } 1.13 1.14 +void LIRGenerator::do_update_CRC32(Intrinsic* x) { 1.15 + assert(UseCRC32Intrinsics, "need AVX and LCMUL instructions support"); 1.16 + // Make all state_for calls early since they can emit code 1.17 + LIR_Opr result = rlock_result(x); 1.18 + int flags = 0; 1.19 + switch (x->id()) { 1.20 + case vmIntrinsics::_updateCRC32: { 1.21 + LIRItem crc(x->argument_at(0), this); 1.22 + LIRItem val(x->argument_at(1), this); 1.23 + crc.load_item(); 1.24 + val.load_item(); 1.25 + __ update_crc32(crc.result(), val.result(), result); 1.26 + break; 1.27 + } 1.28 + case vmIntrinsics::_updateBytesCRC32: 1.29 + case vmIntrinsics::_updateByteBufferCRC32: { 1.30 + bool is_updateBytes = (x->id() == vmIntrinsics::_updateBytesCRC32); 1.31 + 1.32 + LIRItem crc(x->argument_at(0), this); 1.33 + LIRItem buf(x->argument_at(1), this); 1.34 + LIRItem off(x->argument_at(2), this); 1.35 + LIRItem len(x->argument_at(3), this); 1.36 + buf.load_item(); 1.37 + off.load_nonconstant(); 1.38 + 1.39 + LIR_Opr index = off.result(); 1.40 + int offset = is_updateBytes ? arrayOopDesc::base_offset_in_bytes(T_BYTE) : 0; 1.41 + if(off.result()->is_constant()) { 1.42 + index = LIR_OprFact::illegalOpr; 1.43 + offset += off.result()->as_jint(); 1.44 + } 1.45 + LIR_Opr base_op = buf.result(); 1.46 + 1.47 +#ifndef _LP64 1.48 + if (!is_updateBytes) { // long b raw address 1.49 + base_op = new_register(T_INT); 1.50 + __ convert(Bytecodes::_l2i, buf.result(), base_op); 1.51 + } 1.52 +#else 1.53 + if (index->is_valid()) { 1.54 + LIR_Opr tmp = new_register(T_LONG); 1.55 + __ convert(Bytecodes::_i2l, index, tmp); 1.56 + index = tmp; 1.57 + } 1.58 +#endif 1.59 + 1.60 + LIR_Address* a = new LIR_Address(base_op, 1.61 + index, 1.62 + LIR_Address::times_1, 1.63 + offset, 1.64 + T_BYTE); 1.65 + BasicTypeList signature(3); 1.66 + signature.append(T_INT); 1.67 + signature.append(T_ADDRESS); 1.68 + signature.append(T_INT); 1.69 + CallingConvention* cc = frame_map()->c_calling_convention(&signature); 1.70 + const LIR_Opr result_reg = result_register_for(x->type()); 1.71 + 1.72 + LIR_Opr addr = new_pointer_register(); 1.73 + __ leal(LIR_OprFact::address(a), addr); 1.74 + 1.75 + crc.load_item_force(cc->at(0)); 1.76 + __ move(addr, cc->at(1)); 1.77 + len.load_item_force(cc->at(2)); 1.78 + 1.79 + __ call_runtime_leaf(StubRoutines::updateBytesCRC32(), getThreadTemp(), result_reg, cc->args()); 1.80 + __ move(result_reg, result); 1.81 + 1.82 + break; 1.83 + } 1.84 + default: { 1.85 + ShouldNotReachHere(); 1.86 + } 1.87 + } 1.88 +} 1.89 1.90 // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f 1.91 // _i2b, _i2c, _i2s