void ArrayCopyStub::emit_code(LIR_Assembler* ce) { //---------------slow case: call to native----------------- __ bind(_entry); __ mov(src()->as_register(), O0); __ mov(src_pos()->as_register(), O1); __ mov(dst()->as_register(), O2); __ mov(dst_pos()->as_register(), O3); __ mov(length()->as_register(), O4); ce->emit_static_call_stub(); __ call(SharedRuntime::get_resolve_static_call_stub(), relocInfo::static_call_type); __ delayed()->nop(); ce->add_call_info_here(info()); ce->verify_oop_map(info()); #ifndef PRODUCT __ set((intptr_t)&Runtime1::_arraycopy_slowcase_cnt, O0); __ ld(O0, 0, O1); __ inc(O1); __ st(O1, 0, O0); #endif __ br(Assembler::always, false, Assembler::pt, _continuation); __ delayed()->nop(); }
void LIRGenerator::do_ArrayCopy(Intrinsic* x) { assert(x->number_of_arguments() == 5, "wrong type"); // Note: spill caller save before setting the item LIRItem src (x->argument_at(0), this); LIRItem src_pos (x->argument_at(1), this); LIRItem dst (x->argument_at(2), this); LIRItem dst_pos (x->argument_at(3), this); LIRItem length (x->argument_at(4), this); // load all values in callee_save_registers, as this makes the // parameter passing to the fast case simpler src.load_item_force (rlock_callee_saved(T_OBJECT)); src_pos.load_item_force (rlock_callee_saved(T_INT)); dst.load_item_force (rlock_callee_saved(T_OBJECT)); dst_pos.load_item_force (rlock_callee_saved(T_INT)); length.load_item_force (rlock_callee_saved(T_INT)); int flags; ciArrayKlass* expected_type; arraycopy_helper(x, &flags, &expected_type); CodeEmitInfo* info = state_for(x, x->state()); __ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(), length.result(), rlock_callee_saved(T_INT), expected_type, flags, info); set_no_result(x); }
void ArrayCopyStub::emit_code(LIR_Assembler* ce) { // Slow case: call to native. __ bind(_entry); __ lgr_if_needed(Z_ARG1, src()->as_register()); __ lgr_if_needed(Z_ARG2, src_pos()->as_register()); __ lgr_if_needed(Z_ARG3, dst()->as_register()); __ lgr_if_needed(Z_ARG4, dst_pos()->as_register()); __ lgr_if_needed(Z_ARG5, length()->as_register()); // Must align calls sites, otherwise they can't be updated atomically on MP hardware. ce->align_call(lir_static_call); assert((__ offset() + NativeCall::call_far_pcrelative_displacement_offset) % NativeCall::call_far_pcrelative_displacement_alignment == 0, "must be aligned"); ce->emit_static_call_stub(); // Prepend each BRASL with a nop. __ relocate(relocInfo::static_call_type); __ z_nop(); __ z_brasl(Z_R14, SharedRuntime::get_resolve_static_call_stub()); ce->add_call_info_here(info()); ce->verify_oop_map(info()); #ifndef PRODUCT __ load_const_optimized(Z_R1_scratch, (address)&Runtime1::_arraycopy_slowcase_cnt); __ add2mem_32(Address(Z_R1_scratch), 1, Z_R0_scratch); #endif __ branch_optimized(Assembler::bcondAlways, _continuation); }
void ArrayCopyStub::emit_code(LIR_Assembler* ce) { //---------------slow case: call to native----------------- __ bind(_entry); __ mov(src().as_register(), O0); __ mov(src_pos().as_register(), O1); __ mov(dst().as_register(), O2); __ mov(dst_pos().as_register(), O3); __ mov(length().as_register(), O4); address call_pc = __ pc(); ce->emit_code_stub(_call_stub); __ call(Runtime1::entry_for(Runtime1::resolve_invokestatic_id), relocInfo::static_call_type); __ delayed()->nop(); ce->add_call_info_here(_info); #ifndef PRODUCT __ set((intptr_t)&Runtime1::_arraycopy_slowcase_cnt, O0); __ ld(O0, 0, O1); __ inc(O1); __ st(O1, 0, O0); #endif __ br(Assembler::always, false, Assembler::pt, _continuation); __ delayed()->nop(); _call_stub->set_code_pc(call_pc); }
virtual void visit(LIR_OpVisitState* visitor) { visitor->do_stub_info(_info); visitor->do_rinfo(src()); visitor->do_rinfo(src_pos()); visitor->do_rinfo(dst()); visitor->do_rinfo(dst_pos()); visitor->do_rinfo(length()); visitor->do_rinfo(tmp()); visitor->do_call(); }
void ArrayCopyStub::emit_code(LIR_Assembler* ce) { //---------------slow case: call to native----------------- __ bind(_entry); // Figure out where the args should go // This should really convert the IntrinsicID to the Method* and signature // but I don't know how to do that. // VMRegPair args[5]; BasicType signature[5] = { T_OBJECT, T_INT, T_OBJECT, T_INT, T_INT}; SharedRuntime::java_calling_convention(signature, args, 5, true); // push parameters // (src, src_pos, dest, destPos, length) Register r[5]; r[0] = src()->as_register(); r[1] = src_pos()->as_register(); r[2] = dst()->as_register(); r[3] = dst_pos()->as_register(); r[4] = length()->as_register(); // next registers will get stored on the stack for (int i = 0; i < 5 ; i++ ) { VMReg r_1 = args[i].first(); if (r_1->is_stack()) { int st_off = r_1->reg2stack() * wordSize; __ str (r[i], Address(sp, st_off)); } else { assert(r[i] == args[i].first()->as_Register(), "Wrong register for arg "); } } ce->align_call(lir_static_call); ce->emit_static_call_stub(); if (ce->compilation()->bailed_out()) { return; // CodeCache is full } Address resolve(SharedRuntime::get_resolve_static_call_stub(), relocInfo::static_call_type); address call = __ trampoline_call(resolve); if (call == NULL) { ce->bailout("trampoline stub overflow"); return; } ce->add_call_info_here(info()); #ifndef PRODUCT __ lea(rscratch2, ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt)); __ incrementw(Address(rscratch2)); #endif __ b(_continuation); }
void LIRGenerator::do_ArrayCopy(Intrinsic* x) { assert(x->number_of_arguments() == 5, "wrong type"); // Make all state_for calls early since they can emit code CodeEmitInfo* info = state_for(x, x->state()); LIRItem src(x->argument_at(0), this); LIRItem src_pos(x->argument_at(1), this); LIRItem dst(x->argument_at(2), this); LIRItem dst_pos(x->argument_at(3), this); LIRItem length(x->argument_at(4), this); // operands for arraycopy must use fixed registers, otherwise // LinearScan will fail allocation (because arraycopy always needs a // call) #ifndef _LP64 src.load_item_force (FrameMap::rcx_oop_opr); src_pos.load_item_force (FrameMap::rdx_opr); dst.load_item_force (FrameMap::rax_oop_opr); dst_pos.load_item_force (FrameMap::rbx_opr); length.load_item_force (FrameMap::rdi_opr); LIR_Opr tmp = (FrameMap::rsi_opr); #else // The java calling convention will give us enough registers // so that on the stub side the args will be perfect already. // On the other slow/special case side we call C and the arg // positions are not similar enough to pick one as the best. // Also because the java calling convention is a "shifted" version // of the C convention we can process the java args trivially into C // args without worry of overwriting during the xfer src.load_item_force (FrameMap::as_oop_opr(j_rarg0)); src_pos.load_item_force (FrameMap::as_opr(j_rarg1)); dst.load_item_force (FrameMap::as_oop_opr(j_rarg2)); dst_pos.load_item_force (FrameMap::as_opr(j_rarg3)); length.load_item_force (FrameMap::as_opr(j_rarg4)); LIR_Opr tmp = FrameMap::as_opr(j_rarg5); #endif // LP64 set_no_result(x); int flags; ciArrayKlass* expected_type; arraycopy_helper(x, &flags, &expected_type); __ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(), length.result(), tmp, expected_type, flags, info); // does add_safepoint }
void LIRGenerator::do_ArrayCopy(Intrinsic* x) { spill_values_on_stack(x->state()); assert(x->number_of_arguments() == 5, "wrong type"); LIRItem src(x->argument_at(0), this); LIRItem src_pos(x->argument_at(1), this); LIRItem dst(x->argument_at(2), this); LIRItem dst_pos(x->argument_at(3), this); LIRItem length(x->argument_at(4), this); src.load_item(); src_pos.load_item(); dst.load_item(); dst_pos.load_item(); length.load_item(); RInfo tmp = new_register(T_INT)->rinfo(); set_no_result(x); CodeEmitInfo* info = state_for(x, x->state()); // we may want to have stack (deoptimization?) emit()->arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(), length.result(), tmp, false, NULL, info); // does add_safepoint }
void File::copyData( const File &src ) { uint64_t N = src.getDarkCount(); uint64_t O = src.m_iOrder; uint64_t i; hsize_t n; hsize_t off[2], Dims[2]; std::cout << "Copying data from " << src.m_name << std::endl; H5::Group dstGroup(openGroup( "dark" )); H5::Group srcGroup(src.openGroup( "dark" )); H5::DataSet dst_pos( dstGroup.openDataSet("position") ); H5::DataSet dst_vel( dstGroup.openDataSet("velocity") ); //H5::DataSet dst_cls( dstGroup.openDataSet("class") ); H5::DataSet src_pos( srcGroup.openDataSet("position") ); H5::DataSet src_vel( srcGroup.openDataSet("velocity") ); //H5::DataSet src_cls( srcGroup.openDataSet("class") ); double *buffer = new double[3*CHUNK_SIZE]; src_pos.getSpace().getSimpleExtentDims(Dims); H5::DataSpace src_spaceDisk(2,Dims); dst_pos.getSpace().getSimpleExtentDims(Dims); H5::DataSpace dst_spaceDisk(2,Dims); for ( i=0; i<N; i+=n ) { n = N-i > CHUNK_SIZE ? CHUNK_SIZE : N-i; Dims[0] = n; Dims[1] = 3; H5::DataSpace spaceMem(2,Dims); Dims[0] = n; Dims[1] = 3; off[0] = off[1] = 0; spaceMem.selectHyperslab(H5S_SELECT_SET,Dims,off); off[0] = i; off[1] = 0; src_spaceDisk.selectHyperslab(H5S_SELECT_SET,Dims,off); src_pos.read( buffer, H5::PredType::NATIVE_DOUBLE, spaceMem, src_spaceDisk ); off[0] = i+O; off[1] = 0; dst_spaceDisk.selectHyperslab(H5S_SELECT_SET,Dims,off); dst_pos.write( buffer, H5::PredType::NATIVE_DOUBLE, spaceMem, dst_spaceDisk ); off[0] = i; off[1] = 0; src_spaceDisk.selectHyperslab(H5S_SELECT_SET,Dims,off); src_vel.read( buffer, H5::PredType::NATIVE_DOUBLE, spaceMem, src_spaceDisk ); off[0] = i+O; off[1] = 0; dst_spaceDisk.selectHyperslab(H5S_SELECT_SET,Dims,off); dst_vel.write( buffer, H5::PredType::NATIVE_DOUBLE, spaceMem, dst_spaceDisk ); } delete [] buffer; }
static void draw_crack(video::IImage *crack, video::IImage *dst, bool use_overlay, s32 frame_count, s32 progression, video::IVideoDriver *driver) { // Dimension of destination image core::dimension2d<u32> dim_dst = dst->getDimension(); // Dimension of original image core::dimension2d<u32> dim_crack = crack->getDimension(); // Count of crack stages s32 crack_count = dim_crack.Height / dim_crack.Width; // Limit frame_count if(frame_count > (s32) dim_dst.Height) frame_count = dim_dst.Height; if(frame_count < 1) frame_count = 1; // Limit progression if(progression > crack_count-1) progression = crack_count-1; // Dimension of a single crack stage core::dimension2d<u32> dim_crack_cropped( dim_crack.Width, dim_crack.Width ); // Dimension of the scaled crack stage, // which is the same as the dimension of a single destination frame core::dimension2d<u32> dim_crack_scaled( dim_dst.Width, dim_dst.Height / frame_count ); // Create cropped and scaled crack images video::IImage *crack_cropped = driver->createImage( video::ECF_A8R8G8B8, dim_crack_cropped); video::IImage *crack_scaled = driver->createImage( video::ECF_A8R8G8B8, dim_crack_scaled); if(crack_cropped && crack_scaled) { // Crop crack image v2s32 pos_crack(0, progression*dim_crack.Width); crack->copyTo(crack_cropped, v2s32(0,0), core::rect<s32>(pos_crack, dim_crack_cropped)); // Scale crack image by copying crack_cropped->copyToScaling(crack_scaled); // Copy or overlay crack image onto each frame for(s32 i = 0; i < frame_count; ++i) { v2s32 dst_pos(0, dim_crack_scaled.Height * i); if(use_overlay) { blit_with_alpha_overlay(crack_scaled, dst, v2s32(0,0), dst_pos, dim_crack_scaled); } else { blit_with_alpha(crack_scaled, dst, v2s32(0,0), dst_pos, dim_crack_scaled); } } } if(crack_scaled) crack_scaled->drop(); if(crack_cropped) crack_cropped->drop(); }