bool hasResult(frame &cur_frame, uint64_t target) { if (!cur_frame.has_std_frame()) return false; const ::std_frame& cur_std_frame = cur_frame.std_frame(); if (!cur_std_frame.has_operand_post_list()) return false; const operand_value_list& operand_list = cur_std_frame.operand_post_list(); for (int i = 0; i < operand_list.elem_size(); i++) { const ::operand_info& cur_element = operand_list.elem(i); const ::operand_info_specific& cur_specific = cur_element.operand_info_specific(); if (!cur_specific.has_mem_operand()) continue; uint64_t curr = cur_specific.mem_operand().address(); if (curr == target) { std::cout << cur_frame_counter << " " << i << std::endl; return true; } } return false; }
inline bool frame::equal(frame other) const { // Seems close enough return sp() == other.sp() && fp() == other.fp() && pc_addr() == other.pc_addr() && pc() == other.pc(); }
inline void unpack_first_frame(char* ¤t_pc, frame ¤t, CodeIterator &c) { // first vframe in the array if (nlr_through_unpacking) { // NLR is comming through unpacked vframes current_pc = c.interpreter_return_point(); // current_pc points to a normal return point in the interpreter. // To find the nlr return point we first compute the nlr offset. current_pc = ic_info_at(current_pc)->NLR_target(); current.set_hp(c.next_hp()); } else if (redo_the_send) { // Deoptimizing uncommon trap current_pc = Interpreter::redo_bytecode_after_deoptimization(); current.set_hp(c.next_hp()); redo_send_offset = c.next_hp() - c.hp(); redo_the_send = false; } else { // Normal case current_pc = c.interpreter_return_point(true); current.set_hp(c.next_hp()); if (c.is_message_send()) { number_of_arguments_through_unpacking = c.ic()->nof_arguments(); } else if (c.is_primitive_call()) { number_of_arguments_through_unpacking = c.prim_cache()->number_of_parameters(); } else if (c.is_dll_call()) { // The callee should not pop the argument since a DLL call is like a c function call. // The continuation code for the DLL call will pop the arguments! number_of_arguments_through_unpacking = 0; } } }
void traceDeltaFrame(frame& f) { if (f.is_compiled_frame()) { traceCompiledFrame(f); } else if (f.is_interpreted_frame()) { traceInterpretedFrame(f); } }
bool RS485::receive(frame &frame_receive){ //读取的字节数 DWORD wCount; //读取状态 int bReadStat = 0; char byte_buf = 0; char *frame_length = new char[2]; char frame_type = 0; // printf("开始读取\n"); //读取起始位 ReadFile(hCom,&byte_buf,1,&wCount,NULL); if (byte_buf != 0x10) { // printf("未读取到起始位0x10\n"); return false; } ReadFile(hCom,&byte_buf,1,&wCount,NULL); if(byte_buf != 0x02){ // printf("未读取到到起始位0x02\n"); return false; } //读取帧长度 ReadFile(hCom,frame_length,2,&wCount,NULL); //读取帧类型 ReadFile(hCom, &frame_type, 1,&wCount,NULL); frame_receive.set_type(frame_type); //读取帧 ReadFile(hCom, frame_receive.getFrame() + 5, frame_receive.getLength() -5,&wCount,NULL); return true; }
size_t layer_raster::get_level(const frame& fr) { const projection pj_rast(get_pj()); const projection pj_fr(fr.get_pj()); const double scale(pj_rast == pj_fr? fr.scale(): fr.transform(pj_rast).scale()); return m_raster.snap_to_level(scale * scale); }
inline bool frame::equal(frame other) const { bool ret = sp() == other.sp() && fp() == other.fp() && pc() == other.pc(); assert(!ret || ret && cb() == other.cb() && _deopt_state == other._deopt_state, "inconsistent construction"); return ret; }
static bool is_in_expression_stack(const frame& fr, const intptr_t* const addr) { assert(addr != NULL, "invariant"); // Ensure to be 'inside' the expresion stack (i.e., addr >= sp for Intel). // In case of exceptions, the expression stack is invalid and the sp // will be reset to express this condition. if (frame::interpreter_frame_expression_stack_direction() > 0) { return addr <= fr.interpreter_frame_tos_address(); } return addr >= fr.interpreter_frame_tos_address(); }
inline void vframeStreamCommon::fill_from_interpreter_frame() { methodOop method = _frame.interpreter_frame_method(); intptr_t bcx = _frame.interpreter_frame_bcx(); int bci = method->validate_bci_from_bcx(bcx); // 6379830 AsyncGetCallTrace sometimes feeds us wild frames. if (bci < 0) { found_bad_method_frame(); bci = 0; // pretend it's on the point of entering } _mode = interpreted_mode; _method = method; _bci = bci; }
point string_stencil::write_to(frame& frame_, const std::string& str) const { auto dim =frame_.get_dimension(); auto rows =required_y(dim.x, str.size()); if(rows <= dim.y) { frame_.write({0, 0}, str); return { dim.x, rows }; } else { frame_.write({0, 0}, str.cbegin(), str.cbegin()+dim.y*dim.x-1); return dim; } }
bool RS485::send(frame &frm){ DWORD dwBytesWrite=frm.getLength(); COMSTAT ComStat; DWORD dwErrorFlags; BOOL bWriteStat; ClearCommError(hCom,&dwErrorFlags,&ComStat); bWriteStat=WriteFile(hCom,frm.getFrame(),dwBytesWrite,& dwBytesWrite,NULL); if(!bWriteStat) { std::cout<<"写串口失败"<<std::endl; return false; } return true; }
void do_oop(oop* o) { oop obj = *o; if (!obj->verify()) { lprintf("Verify failed in frame:\n"); fr->print(); } }
void sections::getTarget(accumTarget& inTarget,const int& inID,const units& inUnits,const frame& inFrame) { inTarget.size++; ID=inID; for(int i=0;i<=8;i++) { if(surroundingSections[i]!=0 && i!=4) { if(surroundingSections[i]->getID()!=inID) { surroundingSections[i]->getTarget(inTarget,inID,inUnits,inFrame); } } } inTarget.locX+=locationX; inTarget.locY+=locationY; const unsigned char* newData=inFrame.getData(); unsigned long pixCounter=0,i=0,j=0,y=0,x=0; int intUnitSize=inUnits.getUnitSize(); double unitHeight=inUnits.getUnitHeight(); double unitWidth=inUnits.getUnitWidth(); double unitSize=inUnits.getUnitSize(); i=locationY; j=locationX; y=0; while(y<unitHeight-1) { x=0; while(x<unitWidth) { unsigned long temp=i*unitSize*unitHeight*unitWidth*3+j*unitWidth*3+y*unitSize*unitWidth*3+x*3; for(unsigned long location=temp;location<=temp+2;location++) { switch(location%3) { case 0: inTarget.blue+=newData[location]; break; case 1: inTarget.green+=newData[location]; break; case 2: inTarget.red+=newData[location]; break; default: break; } } inTarget.totalPixilCount++; x++; } y++; } }
int tcp_connect::receive_data(frame &f) { char buf[256]; struct sockaddr_in client_addr; socklen_t len = sizeof(struct sockaddr_in); recvfrom(this->csock, buf, BUFLEN, 0, (struct sockaddr *) &(client_addr), &len); f.parse(buf,client_addr); }
// Iteration void next() { // handle frames with inlining if (_mode == compiled_mode && fill_in_compiled_inlined_sender()) return; // handle general case do { _frame = _frame.sender(&_reg_map); } while (!fill_from_frame()); }
static void stack_locals(StackValueCollection* result, int length, const InterpreterOopMap& oop_mask, const frame& fr) { assert(result != NULL, "invariant"); for (int i = 0; i < length; ++i) { const intptr_t* const addr = fr.interpreter_frame_local_at(i); assert(addr != NULL, "invariant"); assert(addr >= fr.sp(), "must be inside the frame"); StackValue* const sv = create_stack_value_from_oop_map(oop_mask, i, addr); assert(sv != NULL, "sanity check"); result->add(sv); } }
inline void vframeStreamCommon::fill_from_interpreter_frame() { Method* method = _frame.interpreter_frame_method(); address bcp = _frame.interpreter_frame_bcp(); int bci = method->validate_bci_from_bcp(bcp); // 6379830 AsyncGetCallTrace sometimes feeds us wild frames. // AsyncGetCallTrace interrupts the VM asynchronously. As a result // it is possible to access an interpreter frame for which // no Java-level information is yet available (e.g., becasue // the frame was being created when the VM interrupted it). // In this scenario, pretend that the interpreter is at the point // of entering the method. if (bci < 0) { found_bad_method_frame(); bci = 0; } _mode = interpreted_mode; _method = method; _bci = bci; }
// top-frame will be skipped vframeStream::vframeStream(JavaThread* thread, frame top_frame, bool stop_at_java_call_stub) : vframeStreamCommon(thread) { _stop_at_java_call_stub = stop_at_java_call_stub; // skip top frame, as it may not be at safepoint _frame = top_frame.sender(&_reg_map); while (!fill_from_frame()) { _frame = _frame.sender(&_reg_map); } }
void vframeArray::unpack_to_stack(frame &unpack_frame, int exec_mode, int caller_actual_parameters) { // stack picture // unpack_frame // [new interpreter frames ] (frames are skeletal but walkable) // caller_frame // // This routine fills in the missing data for the skeletal interpreter frames // in the above picture. // Find the skeletal interpreter frames to unpack into JavaThread* THREAD = JavaThread::current(); RegisterMap map(THREAD, false); // Get the youngest frame we will unpack (last to be unpacked) frame me = unpack_frame.sender(&map); int index; for (index = 0; index < frames(); index++ ) { *element(index)->iframe() = me; // Get the caller frame (possibly skeletal) me = me.sender(&map); } // Do the unpacking of interpreter frames; the frame at index 0 represents the top activation, so it has no callee // Unpack the frames from the oldest (frames() -1) to the youngest (0) frame* caller_frame = &me; for (index = frames() - 1; index >= 0 ; index--) { vframeArrayElement* elem = element(index); // caller int callee_parameters, callee_locals; if (index == 0) { callee_parameters = callee_locals = 0; } else { methodHandle caller = elem->method(); methodHandle callee = element(index - 1)->method(); Bytecode_invoke inv(caller, elem->bci()); // invokedynamic instructions don't have a class but obviously don't have a MemberName appendix. // NOTE: Use machinery here that avoids resolving of any kind. const bool has_member_arg = !inv.is_invokedynamic() && MethodHandles::has_member_arg(inv.klass(), inv.name()); callee_parameters = callee->size_of_parameters() + (has_member_arg ? 1 : 0); callee_locals = callee->max_locals(); } elem->unpack_on_stack(caller_actual_parameters, callee_parameters, callee_locals, caller_frame, index == 0, index == frames() - 1, exec_mode); if (index == frames() - 1) { Deoptimization::unwind_callee_save_values(elem->iframe(), this); } caller_frame = elem->iframe(); caller_actual_parameters = callee_parameters; } deallocate_monitor_chunks(); }
// --- locked ---------------------------------------------------------------- // Count times an oop is locked in this frame & codeblob int CodeBlob::locked( frame fr, oop o ) const { methodCodeRef mcref = owner(); if( mcref.is_null() ) return 0; // call stubs hit here methodCodeOop mcoop = mcref.as_methodCodeOop(); if( mcoop->_blob != this ) return 0; // vtable stubs share the mcoop with the real blob const DebugMap *dbg = mcoop->_debuginfo; if( !dbg ) return 0; // Commonly natives have no debug info const DebugScope *ds = dbg->get( fr.pc() -(address)this ); if ( !ds ) return 0; return ds->count_locks( dbg, fr, o ); }
void layer_raster::draw(const std::vector<brig::variant>& row, const frame& fr, QPainter& painter) { if (row.size() < 2|| row[0].type() != typeid(brig::blob_t)) return; const brig::blob_t& g(boost::get<brig::blob_t>(row[0])); const QRectF rect_rast(box_to_rect(brig::boost::envelope(brig::boost::geom_from_wkb(g)))); // todo: rotated raster QImage img_rast; if (row[1].type() != typeid(brig::blob_t)) return; const brig::blob_t& r(boost::get<brig::blob_t>(row[1])); if (!img_rast.loadFromData(r.data(), uint(r.size()))) return; projection pj_rast(get_pj()); projection pj_fr(fr.get_pj()); if (pj_rast == pj_fr) painter.drawImage(fr.proj_to_pixel(rect_rast).toAlignedRect(), img_rast); else { const QRectF rect_fr(transformer(pj_rast, pj_fr).transform(rect_rast)); const QRect rect_fr_px(fr.proj_to_pixel(fr.prepare_rect().intersected(rect_fr)).toAlignedRect()); if (!rect_fr_px.isValid()) return; QImage img_fr(rect_fr_px.size(), QImage::Format_ARGB32_Premultiplied); transformer tr(pj_fr, pj_rast); for (int j(0); j < img_fr.height(); ++j) for (int i(0); i < img_fr.width(); ++i) { const QPointF point_fr(static_cast<brig::qt::frame>(fr).pixel_to_proj(rect_fr_px.topLeft() + QPoint(i, j))); const QPointF point_rast(tr.transform(point_fr)); if (rect_rast.contains(point_rast)) { const double dx((point_rast.x() - rect_rast.left()) / rect_rast.width()); const double dy((point_rast.y() - rect_rast.top()) / rect_rast.height()); auto pixel(img_rast.pixel(int(dx * img_rast.width()), int((1 - dy) * img_rast.height()))); img_fr.setPixel(i, j, pixel); } else img_fr.setPixel(i, j, QColor(0, 0, 0, 0).rgba()); } painter.drawImage(rect_fr_px, img_fr); } }
json_string metashell::system_test::to_json_string(const frame& f_) { rapidjson::StringBuffer buff; rapidjson::Writer<rapidjson::StringBuffer> w(buff); w.StartObject(); w.Key("type"); w.String("frame"); w.Key("name"); w.String(f_.name().name().c_str()); if (f_.has_kind()) { w.Key("kind"); const std::string kind = to_string(f_.kind()); w.String(kind.c_str()); } w.EndObject(); return json_string(buff.GetString()); }
//============================================================================= // --- do_closure // Convenience: apply closure to all oops void OopMapStream::do_closure( CodeBlob *cb, frame fr, OopClosure *f ) { address pc = fr.pc(); assert0( cb->contains(pc) ); int rel_pc = pc-(address)cb; // Derived pointers first: need to record the derived offset before the base moves methodCodeRef mcref = cb->owner(); if(mcref.not_null()){ const DebugMap *dm = mcref.as_methodCodeOop()->_debuginfo; if( dm ) { const DebugScope *scope = dm->get(rel_pc); scope->gc_base_derived(fr,f); } } // Now normal oops cb->_oop_maps->do_closure(rel_pc,fr,f); }
// Run skin-detection algorithm frame detect_skin(const frame& in) { dtn_frame = in; const rgb_byte ZERO = { }; for(int y = HEIGHT - 1; y; --y) { for(int x = WIDTH - 1; x; --x) { auto orig = dtn_frame.get_pixel(x, y); rgb hist_in = { orig[2], orig[1], orig[0] }; if(hist.value(hist_in) < tld) { orig[0] = orig[1] = orig[2] = 0; } } } return dtn_frame; }
/// \brief Decode supplied \c frame into a \c pubrel packet. /// /// \see io_wally::protocol::decoder::packet_body_decoder::parse /// virtual std::shared_ptr<protocol::mqtt_packet> decode( const frame& frame ) const { using namespace io_wally::protocol; assert( frame.type( ) == packet::Type::PUBREL ); // [MQTT-2.2.2-1] Flags in PUBREL MUST be 0010 if ( ( frame.type_and_flags & 0x0F ) != 0x02 ) throw error::malformed_mqtt_packet{"[MQTT-2.2.2-1] Invalid flags in PUBREL packet."}; // Parse variable header pubrel_header auto packet_id = uint16_t{0}; std::tie( std::ignore, packet_id ) = decode_uint16( frame.begin, frame.end ); return std::make_shared<protocol::pubrel>( packet_id ); }
void print_memory_values(frame &cur_frame) { const ::std_frame& cur_std_frame = cur_frame.std_frame(); if(cur_std_frame.has_operand_pre_list()) { //std::cout << " post_list:" << std::endl; print_list(cur_std_frame.operand_pre_list()); } if(cur_std_frame.has_operand_post_list()) { //std::cout << " post_list:" << std::endl; print_list(cur_std_frame.operand_post_list()); } }
//this is a higher level error checked version of copywin void copy(frame& src, frame& dst, const point& src_upper_left, const point& dst_upper_left, const point& size) { auto dst_lower_right=dst_upper_left + size - point{1,1}; #ifndef NDEBUG { //this like all high arity functions is a bitch to get right //hence this debug block auto dst_dim=dst.get_dimension(); auto src_dim=src.get_dimension(); auto src_lower_right=src_upper_left + size - point{1,1}; CONS_ASSERT(dst_dim.x > dst_lower_right.x && dst_dim.y > dst_lower_right.y, "copy area is larger than destination" ); CONS_ASSERT(src_dim.x > src_lower_right.x && src_dim.y > src_lower_right.y, "copy area is larger than source: " ); CONS_ASSERT(src.get_handle(), "source frame is not valid"); CONS_ASSERT(dst.get_handle(), "destination frame is not valid"); } #endif if(::copywin(src.get_handle(), dst.get_handle(), src_upper_left.y, src_upper_left.x, dst_upper_left.y, dst_upper_left.x, dst_lower_right.y, dst_lower_right.x, false)==ERR) { std::ostringstream oss; oss << "unable to copy window" << "\nsource size " << src.get_dimension() << "\ndestination size " << dst.get_dimension() << "\nupper left source position " << src_upper_left << "\nupper left destination position " << dst_upper_left << "\ndimension to copy " << size << "\ncalculated destination lower right " << dst_lower_right; throw CONS_MAKE_EXCEPTION(oss.str()); } }
void traceCompiledFrame(frame& f) { ResourceMark mark; // Find the nmethod containing the pc compiledVFrame* vf = (compiledVFrame*) vframe::new_vframe(&f); assert(vf->is_compiled_frame(), "must be compiled frame"); nmethod* nm = vf->code(); lprintf("Found nmethod: 0x%x\n", nm); nm->print_value_on(std); std->print("\n @%d called from %#x", vf->scope()->offset(), f.pc() - Assembler::sizeOfCall); std->cr(); trace(vf, 0, 10); }
void FlatProfiler::record_tick_for_running_frame(frame fr) { // The tick happend in real code -> non VM code if (fr.is_interpreted_frame()) { methodOop method = fr.method(); if (method == NULL) return; assert(method->is_method(), "must be method"); FlatProfiler::interpreted_update(method, fr.receiver()->klass(), in_code); } else if (fr.is_compiled_frame()) { FlatProfiler::compiled_update(findNMethod(fr.pc()), in_code); } else if (PIC::in_heap(fr.pc())) { PIC* pic = PIC::find(fr.pc()); FlatProfiler::compiled_update(findNMethod((char*) pic->compiled_ic()), in_pic); } else if (StubRoutines::contains(fr.pc())) { FlatProfiler::stub_ticks++; } }
bool isAddressOverwritten(frame &cur_frame,uint64_t ele) { const ::std_frame& cur_std_frame = cur_frame.std_frame(); if (cur_std_frame.has_operand_pre_list()) { for(int i = 0; i < cur_std_frame.operand_pre_list().elem_size(); i++){ const ::operand_info_specific& cur_specific = cur_std_frame.operand_pre_list().elem(i).operand_info_specific(); if(cur_specific.has_mem_operand()){ if (ele == cur_specific.mem_operand().address()){ if(cur_std_frame.operand_pre_list().elem(i).operand_usage().written()) return true; } } } } return false; }