void RequestInjectionData::updateJit() { m_jit = RuntimeOption::EvalJit && !(RuntimeOption::EvalJitDisabledByHphpd && m_debugger) && !m_debuggerIntr && !m_coverage && !shouldProfile(); }
void recordType(TypeProfileKey key, DataType dt) { if (!profiles) return; if (!shouldProfile()) return; assert(dt != KindOfUninit); // Normalize strings to KindOfString. if (dt == KindOfStaticString) dt = KindOfString; TRACE(1, "recordType lookup: %s -> %d\n", key.m_name->data(), dt); ValueProfile *prof = keyToVP(key, KeyToVPMode::Write); if (prof->m_totalSamples != kMaxCounter) { prof->m_totalSamples++; // NB: we can't quite assert that we have fewer than kMaxCounter samples, // because other threads are updating this structure without locks. int dtIndex = getDataTypeIndex(dt); if (prof->m_samples[dtIndex] < kMaxCounter) { prof->m_samples[dtIndex]++; } } ONTRACE(2, prof->dump()); }
bool TypeConstraint::check(const TypedValue* tv, const Func* func) const { assert(hasConstraint()); // This is part of the interpreter runtime; perf matters. if (tv->m_type == KindOfRef) { tv = tv->m_data.pref->tv(); } if (nullable() && IS_NULL_TYPE(tv->m_type)) return true; if (tv->m_type == KindOfObject) { if (!isObjectOrTypedef()) return false; // Perfect match seems common enough to be worth skipping the hash // table lookup. if (m_typeName->isame(tv->m_data.pobj->getVMClass()->name())) { if (shouldProfile()) Class::profileInstanceOf(m_typeName); return true; } const Class *c = nullptr; const bool selfOrParentOrCallable = isSelf() || isParent() || isCallable(); if (selfOrParentOrCallable) { if (isSelf()) { selfToClass(func, &c); } else if (isParent()) { parentToClass(func, &c); } else { assert(isCallable()); return f_is_callable(tvAsCVarRef(tv)); } } else { // We can't save the Class* since it moves around from request // to request. assert(m_namedEntity); c = Unit::lookupClass(m_namedEntity); } if (shouldProfile() && c) { Class::profileInstanceOf(c->preClass()->name()); } if (c && tv->m_data.pobj->instanceof(c)) { return true; } return !selfOrParentOrCallable && checkTypedefObj(tv); } if (isObjectOrTypedef()) { switch (tv->m_type) { case KindOfArray: if (interface_supports_array(m_typeName)) { return true; } break; case KindOfString: case KindOfStaticString: if (interface_supports_string(m_typeName)) { return true; } break; case KindOfInt64: if (interface_supports_int(m_typeName)) { return true; } break; case KindOfDouble: if (interface_supports_double(m_typeName)) { return true; } break; default: break; } if (isCallable()) { return f_is_callable(tvAsCVarRef(tv)); } return isPrecise() && checkTypedefNonObj(tv); } return equivDataTypes(m_type.m_dt, tv->m_type); }