// RedefineClasses() API support: // If this ConstantPoolCacheEntry refers to old_method then update it // to refer to new_method. bool ConstantPoolCacheEntry::adjust_method_entry(Method* old_method, Method* new_method, bool * trace_name_printed) { if (is_vfinal()) { // virtual and final so _f2 contains method ptr instead of vtable index if (f2_as_vfinal_method() == old_method) { // match old_method so need an update // NOTE: can't use set_f2_as_vfinal_method as it asserts on different values _f2 = (intptr_t)new_method; if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) { if (!(*trace_name_printed)) { // RC_TRACE_MESG macro has an embedded ResourceMark RC_TRACE_MESG(("adjust: name=%s", old_method->method_holder()->external_name())); *trace_name_printed = true; } // RC_TRACE macro has an embedded ResourceMark RC_TRACE(0x00400000, ("cpc vf-entry update: %s(%s)", new_method->name()->as_C_string(), new_method->signature()->as_C_string())); } return true; } // f1() is not used with virtual entries so bail out return false; } if (_f1 == NULL) { // NULL f1() means this is a virtual entry so bail out // We are assuming that the vtable index does not need change. return false; } if (_f1 == old_method) { _f1 = new_method; if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) { if (!(*trace_name_printed)) { // RC_TRACE_MESG macro has an embedded ResourceMark RC_TRACE_MESG(("adjust: name=%s", old_method->method_holder()->external_name())); *trace_name_printed = true; } // RC_TRACE macro has an embedded ResourceMark RC_TRACE(0x00400000, ("cpc entry update: %s(%s)", new_method->name()->as_C_string(), new_method->signature()->as_C_string())); } return true; } return false; }
void Timer1::setCompareMatch(bool p_enable, bool p_OCIE1A, Callback p_callback) { RC_TRACE("set compare match enable: %d OCIE1A: %d Callback: %p", p_enable, p_OCIE1A, p_callback); if (p_enable) { if (p_OCIE1A) { s_OCI1ACallback = p_callback; TIMSK1 |= _BV(OCIE1A); } else { s_OCI1BCallback = p_callback; TIMSK1 |= _BV(OCIE1B); } } else { if (p_OCIE1A) { TIMSK1 &= ~_BV(OCIE1A); s_OCI1ACallback = 0; } else { TIMSK1 &= ~_BV(OCIE1B); s_OCI1BCallback = 0; } } }
bool MethodComparator::methods_EMCP(methodOop old_method, methodOop new_method) { if (old_method->code_size() != new_method->code_size()) return false; if (check_stack_and_locals_size(old_method, new_method) != 0) { // RC_TRACE macro has an embedded ResourceMark RC_TRACE(0x00800000, ("Methods %s non-comparable with diagnosis %d", old_method->name()->as_C_string(), check_stack_and_locals_size(old_method, new_method))); return false; } _old_cp = old_method->constants(); _new_cp = new_method->constants(); BytecodeStream s_old(old_method); BytecodeStream s_new(new_method); _s_old = &s_old; _s_new = &s_new; _switchable_test = false; Bytecodes::Code c_old, c_new; while ((c_old = s_old.next()) >= 0) { if ((c_new = s_new.next()) < 0 || c_old != c_new) return false; if (! args_same(c_old, c_new)) return false; } return true; }
void Engine::setIdle(int16_t p_idle) { RC_TRACE("Set idle: %d", p_idle); RC_ASSERT_MINMAX(p_idle, -256, 256); m_idle = p_idle; }
void Offset::setOffset(int8_t p_offset) { RC_TRACE("set offset: %d%%", p_offset); RC_ASSERT_MINMAX(p_offset, -100, 100); m_offset = p_offset; }
void SwitchModifier::setIndex(Switch p_index) { RC_TRACE("set index: %d", p_index); RC_ASSERT(p_index <= Switch_Count); m_index = p_index; }
void Gyro::setType(Type p_type) { RC_TRACE("set type: %d", p_type); RC_ASSERT(p_type < Type_Count); m_type = p_type; }
void SwashToThrottleMix::setAilMix(uint8_t p_mix) { RC_TRACE("set ail mix: %u", p_mix); RC_ASSERT_MINMAX(p_mix, 0, 100); m_ail = p_mix; }
void SwashToThrottleMix::setEleMix(uint8_t p_mix) { RC_TRACE("set ele mix: %u", p_mix); RC_ASSERT_MINMAX(p_mix, 0, 100); m_ele = p_mix; }
void PPMOut::setPulseLength(uint16_t p_length) { RC_TRACE("set pulse length %u us", p_length); RC_ASSERT_MINMAX(p_length, 0, 32766); m_pulseLength = p_length << 1; }
void OutputChannelProcessor::setSource(OutputChannel p_source) { RC_TRACE("set source: %d", p_source); RC_ASSERT(p_source <= OutputChannel_Count); m_source = p_source; }
void Gyro::setGain(int8_t p_gain) { RC_TRACE("set gain: %d", p_gain); RC_ASSERT_MINMAX(p_gain, 0, 100); m_gain = p_gain; }
void ServoOut::setPauseLength(uint16_t p_length) { RC_TRACE("set pause length: %u us", p_length); RC_ASSERT_MINMAX(p_length, 0, 32766); m_pauseLength = p_length; }
void Gyro::setMode(Mode p_mode) { RC_TRACE("set mode: %d", p_mode); RC_ASSERT(p_mode < Mode_Count); m_mode = p_mode; }
void Engine::setRudderMix(int8_t p_mix) { RC_TRACE("Set rudder mix: %d", p_mix); RC_ASSERT_MINMAX(p_mix, -100, 100); m_rudMix = p_mix; setPosMix(p_mix); setNegMix(p_mix); }
void JvmtiBreakpoint::each_method_version_do(method_action meth_act) { ((methodOopDesc*)_method->*meth_act)(_bci); // add/remove breakpoint to/from versions of the method that // are EMCP. Directly or transitively obsolete methods are // not saved in the PreviousVersionInfo. Thread *thread = Thread::current(); instanceKlassHandle ikh = instanceKlassHandle(thread, _method->method_holder()); Symbol* m_name = _method->name(); Symbol* m_signature = _method->signature(); { ResourceMark rm(thread); // PreviousVersionInfo objects returned via PreviousVersionWalker // contain a GrowableArray of handles. We have to clean up the // GrowableArray _after_ the PreviousVersionWalker destructor // has destroyed the handles. { // search previous versions if they exist PreviousVersionWalker pvw((instanceKlass *)ikh()->klass_part()); for (PreviousVersionInfo * pv_info = pvw.next_previous_version(); pv_info != NULL; pv_info = pvw.next_previous_version()) { GrowableArray<methodHandle>* methods = pv_info->prev_EMCP_method_handles(); if (methods == NULL) { // We have run into a PreviousVersion generation where // all methods were made obsolete during that generation's // RedefineClasses() operation. At the time of that // operation, all EMCP methods were flushed so we don't // have to go back any further. // // A NULL methods array is different than an empty methods // array. We cannot infer any optimizations about older // generations from an empty methods array for the current // generation. break; } for (int i = methods->length() - 1; i >= 0; i--) { methodHandle method = methods->at(i); if (method->name() == m_name && method->signature() == m_signature) { RC_TRACE(0x00000800, ("%sing breakpoint in %s(%s)", meth_act == &methodOopDesc::set_breakpoint ? "sett" : "clear", method->name()->as_C_string(), method->signature()->as_C_string())); assert(!method->is_obsolete(), "only EMCP methods here"); ((methodOopDesc*)method()->*meth_act)(_bci); break; } } } } // pvw is cleaned up } // rm is cleaned up }
void AnalogSwitch::setDuration(uint16_t p_duration) { RC_TRACE("set duration: %u", p_duration); RC_ASSERT_MINMAX(p_duration, 0, 10000); m_duration = p_duration; // instantly update, to prevent overflows and such m_time = 0xFFFF; update(); }
void AIPinCalibrator::setAIPin(AIPin* p_pin) { RC_TRACE("set AIPin: %p", p_pin); RC_ASSERT_MSG(m_active == false, "stop calibrator before setting pin"); if (m_active == false) { m_pin = p_pin; } }
bool MethodComparator::methods_switchable(methodOop old_method, methodOop new_method, BciMap &bci_map) { if (old_method->code_size() > new_method->code_size()) // Something has definitely been deleted in the new method, compared to the old one. return false; if (! check_stack_and_locals_size(old_method, new_method)) return false; _old_cp = old_method->constants(); _new_cp = new_method->constants(); BytecodeStream s_old(old_method); BytecodeStream s_new(new_method); _s_old = &s_old; _s_new = &s_new; _bci_map = &bci_map; _switchable_test = true; GrowableArray<int> fwd_jmps(16); _fwd_jmps = &fwd_jmps; Bytecodes::Code c_old, c_new; while ((c_old = s_old.next()) >= 0) { if ((c_new = s_new.next()) < 0) return false; if (! (c_old == c_new && args_same(c_old, c_new))) { int old_bci = s_old.bci(); int new_st_bci = s_new.bci(); bool found_match = false; do { c_new = s_new.next(); if (c_new == c_old && args_same(c_old, c_new)) { found_match = true; break; } } while (c_new >= 0); if (! found_match) return false; int new_end_bci = s_new.bci(); bci_map.store_fragment_location(old_bci, new_st_bci, new_end_bci); } } // Now we can test all forward jumps for (int i = 0; i < fwd_jmps.length() / 2; i++) { if (! bci_map.old_and_new_locations_same(fwd_jmps.at(i*2), fwd_jmps.at(i*2+1))) { RC_TRACE(0x00800000, ("Fwd jump miss: old dest = %d, calc new dest = %d, act new dest = %d", fwd_jmps.at(i*2), bci_map.new_bci_for_old(fwd_jmps.at(i*2)), fwd_jmps.at(i*2+1))); return false; } } return true; }
void Timer1::setToggle(bool p_enable, bool p_OC1A) { RC_TRACE("set toggle enable: %d OC1A: %d", p_enable, p_OC1A); if (p_enable) { TCCR1A |= p_OC1A ? _BV(COM1A0) : _BV(COM1B0); } else { TCCR1A &= p_OC1A ? ~_BV(COM1A0) : ~_BV(COM1B0); } }
void Timer1::init(bool p_debug) { RC_TRACE("init debug: %d", p_debug); s_debug = p_debug; TCCR1A = 0; TCCR1B = 0; TCCR1C = 0; TIMSK1 = 0; OCR1A = 0; OCR1B = 0; TCNT1 = 0; }
void Timer1::setOverflow(bool p_enable, Callback p_callback) { RC_TRACE("set overflow enable: %d Callback: %p", p_enable, p_callback); if (p_enable) { s_TOIE1Callback = p_callback; TIMSK1 |= _BV(TOIE1); } else { TIMSK1 &= ~_BV(TOIE1); s_TOIE1Callback = 0; } }
void JvmtiBreakpoint::each_method_version_do(method_action meth_act) { ((Method*)_method->*meth_act)(_bci); // add/remove breakpoint to/from versions of the method that // are EMCP. Directly or transitively obsolete methods are // not saved in the PreviousVersionNodes. Thread *thread = Thread::current(); instanceKlassHandle ikh = instanceKlassHandle(thread, _method->method_holder()); Symbol* m_name = _method->name(); Symbol* m_signature = _method->signature(); // search previous versions if they exist PreviousVersionWalker pvw(thread, (InstanceKlass *)ikh()); for (PreviousVersionNode * pv_node = pvw.next_previous_version(); pv_node != NULL; pv_node = pvw.next_previous_version()) { GrowableArray<Method*>* methods = pv_node->prev_EMCP_methods(); if (methods == NULL) { // We have run into a PreviousVersion generation where // all methods were made obsolete during that generation's // RedefineClasses() operation. At the time of that // operation, all EMCP methods were flushed so we don't // have to go back any further. // // A NULL methods array is different than an empty methods // array. We cannot infer any optimizations about older // generations from an empty methods array for the current // generation. break; } for (int i = methods->length() - 1; i >= 0; i--) { Method* method = methods->at(i); // obsolete methods that are running are not deleted from // previous version array, but they are skipped here. if (!method->is_obsolete() && method->name() == m_name && method->signature() == m_signature) { RC_TRACE(0x00000800, ("%sing breakpoint in %s(%s)", meth_act == &Method::set_breakpoint ? "sett" : "clear", method->name()->as_C_string(), method->signature()->as_C_string())); (method->*meth_act)(_bci); break; } } } }
void AIPinCalibrator::start() { RC_TRACE("start"); RC_ASSERT_MSG(m_active == false, "calibrator already started"); RC_ASSERT_MSG(m_pin != 0, "set pin before starting calibrator"); if (m_active == false && m_pin != 0) { m_min = 1023; m_max = 0; m_center = 0; m_start = 0; m_active = true; } }
void RotaryEncoder::setPinB(uint8_t p_pin) { RC_TRACE("set pin B: %u", p_pin); RC_ASSERT(p_pin != m_pinA); #ifdef RC_USE_EXTINT if (p_pin != m_pinB) { extint::disable(m_pinB); #endif m_pinB = p_pin; pinMode(m_pinB, m_pullUp ? INPUT_PULLUP : INPUT); #ifdef RC_USE_EXTINT extint::enable(m_pinB, extint::ISC_Change, RotaryEncoder::isr, this); } #endif }
void ServoOut::start() { RC_TRACE("start"); // set initial values update(true); // stop timer 1 rc::Timer1::stop(); // disable compare match B interrupts rc::Timer1::setCompareMatch(false, false); // set compare value (first, we wait) OCR1B = TCNT1 + (m_pauseLength << 1); // enable timer output compare match B interrupts rc::Timer1::setCompareMatch(true, false, ServoOut::handleInterrupt); // start the timer rc::Timer1::start(); }
void AIPinCalibrator::update() { if (m_active) { uint16_t raw = read(); if (raw > m_max) { m_max = raw; } if (raw < m_min) { m_min = raw; } // the average of min and max is a pretty darn good estimate for the center if (m_start == 0) { // initial value of the center m_center = (m_min + m_max) / 2; m_start = static_cast<uint16_t>(millis()); } // make sure a min and max are set and that they're far enough apart // then make sure the input is floating somewhere around the center for a period of time if (m_min < m_max && (m_max - m_min >= Minimum_Band) && (raw < m_center + Minimum_Center) && (raw > m_center - Minimum_Center)) { // we use a weighted average of the previous center and current raw value m_center = ((m_center * 3) + raw) / 4; } else { m_start = 0; } RC_TRACE("Raw: %u Min: %u Max: %u Center: %u Delta: %u", raw, m_min, m_max, m_center, m_start == 0 ? 0 : static_cast<uint16_t>(millis()) - m_start); } }
void RotaryEncoder::setMin(int8_t p_min) { RC_TRACE("set min: %d", p_min); m_min = p_min; }
void RotaryEncoder::setReversed(bool p_reverse) { RC_TRACE("set reversed: %d", p_reverse); m_reversed = p_reverse; }
void RotaryEncoder::setWrap(bool p_wrap) { RC_TRACE("set wrap: %d", p_wrap); m_wrap = p_wrap; }