// Reallocates a chunk. We can save on a new allocation if the new requested // size still fits in the chunk. void *reallocate(void *OldPtr, uptr NewSize) { if (UNLIKELY(!ThreadInited)) initThread(); UnpackedHeader OldHeader; uptr Size = getUsableSize(OldPtr, &OldHeader); uptr ChunkBeg = reinterpret_cast<uptr>(OldPtr); ScudoChunk *Chunk = reinterpret_cast<ScudoChunk *>(ChunkBeg - ChunkHeaderSize); if (OldHeader.AllocType != FromMalloc) { dieWithMessage("ERROR: invalid chunk type when reallocating address %p\n", Chunk); } UnpackedHeader NewHeader = OldHeader; // The new size still fits in the current chunk. if (NewSize <= Size) { NewHeader.RequestedSize = NewSize; Chunk->compareExchangeHeader(&NewHeader, &OldHeader); return OldPtr; } // Otherwise, we have to allocate a new chunk and copy the contents of the // old one. void *NewPtr = allocate(NewSize, MinAlignment, FromMalloc); if (NewPtr) { uptr OldSize = OldHeader.RequestedSize; memcpy(NewPtr, OldPtr, Min(NewSize, OldSize)); NewHeader.State = ChunkQuarantine; Chunk->compareExchangeHeader(&NewHeader, &OldHeader); if (LIKELY(!ThreadTornDown)) { AllocatorQuarantine.Put(&ThreadQuarantineCache, QuarantineCallback(&Cache), Chunk, OldSize); } else { SpinMutexLock l(&FallbackMutex); AllocatorQuarantine.Put(&FallbackQuarantineCache, QuarantineCallback(&FallbackAllocatorCache), Chunk, OldSize); } } return NewPtr; }
File::File(const char *fileName, Mode mode) : m_file(::open(fileName, 0)), m_size(0), m_cTime(0), m_mTime(0), m_aTime(0), m_permissions(0) { if (isValid()) { struct stat st; if (LIKELY(::fstat(m_file, &st) != -1)) { m_size = st.st_size; m_cTime = st.st_ctime; m_mTime = st.st_mtime; m_aTime = st.st_atime; m_permissions = translatePermissions(st); } } }
static ContainerNode& filterRootById(ContainerNode& rootNode, const CSSSelector& firstSelector) { if (!rootNode.inDocument()) return rootNode; if (rootNode.document().inQuirksMode()) return rootNode; // If there was an Id match in the rightmost Simple Selector, we should be in a RightMostWithIdMatch, not in filter. // Thus we can skip the rightmost match. const CSSSelector* selector = &firstSelector; do { ASSERT(selector->match() != CSSSelector::Id); if (selector->relation() != CSSSelector::SubSelector) break; selector = selector->tagHistory(); } while (selector); bool inAdjacentChain = false; for (; selector; selector = selector->tagHistory()) { if (selector->match() == CSSSelector::Id) { const AtomicString& idToMatch = selector->value(); if (ContainerNode* searchRoot = rootNode.treeScope().getElementById(idToMatch)) { if (LIKELY(!rootNode.treeScope().containsMultipleElementsWithId(idToMatch))) { if (inAdjacentChain) searchRoot = searchRoot->parentNode(); if (searchRoot && (isTreeScopeRoot(rootNode) || searchRoot == &rootNode || searchRoot->isDescendantOf(&rootNode))) return *searchRoot; } } } if (selector->relation() == CSSSelector::SubSelector) continue; if (selector->relation() == CSSSelector::DirectAdjacent || selector->relation() == CSSSelector::IndirectAdjacent) inAdjacentChain = true; else inAdjacentChain = false; } return rootNode; }
bool supportsToArray(ObjectData* obj) { if (obj->isCollection()) { assertx(isValidCollection(obj->collectionType())); return true; } else if (UNLIKELY(obj->getAttribute(ObjectData::CallToImpl))) { return obj->instanceof(SimpleXMLElement_classof()); } else if (UNLIKELY(obj->instanceof(SystemLib::s_ArrayObjectClass))) { return true; } else if (UNLIKELY(obj->instanceof(SystemLib::s_ArrayIteratorClass))) { return true; } else if (UNLIKELY(obj->instanceof(c_Closure::classof()))) { return true; } else if (UNLIKELY(obj->instanceof(DateTimeData::getClass()))) { return true; } else { if (LIKELY(!obj->hasInstanceDtor())) { return true; } return false; } }
void flext_base::ToSysAtom(int n,const t_atom &at) const { outlet *o = GetOut(n); if(LIKELY(o)) { CRITON(); if(IsSymbol(at)) outlet_symbol((t_outlet *)o,const_cast<t_symbol *>(GetSymbol(at))); else if(IsFloat(at)) outlet_float((t_outlet *)o,GetFloat(at)); #if FLEXT_SYS == FLEXT_SYS_MAX else if(IsInt(at)) outlet_flint((t_outlet *)o,GetInt(at)); #endif #if FLEXT_SYS == FLEXT_SYS_PD else if(IsPointer(at)) outlet_pointer((t_outlet *)o,GetPointer(at)); #endif else error("Atom type not supported"); CRITOFF(); } }
CVarRef APCLocalArray::getValueRef(ssize_t pos) const { APCHandle *sv = m_arr->getValue(pos); DataType t = sv->getType(); if (!IS_REFCOUNTED_TYPE(t)) { return APCTypedValue::fromHandle(sv)->asCVarRef(); } if (LIKELY(m_localCache != nullptr)) { assert(unsigned(pos) < m_arr->capacity()); TypedValue* tv = &m_localCache[pos]; if (tv->m_type != KindOfUninit) { return tvAsCVarRef(tv); } } else { static_assert(KindOfUninit == 0, "must be 0 since we use smart_calloc"); unsigned cap = m_arr->capacity(); m_localCache = (TypedValue*) smart_calloc(cap, sizeof(TypedValue)); } TypedValue* tv = &m_localCache[pos]; tvAsVariant(tv) = sv->toLocal(); assert(tv->m_type != KindOfUninit); return tvAsCVarRef(tv); }
static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem)) { Material **matar = NULL; int a, totcol = 0; if (GS(tsep->id->name) == ID_OB) { Object *ob = (Object *)tsep->id; totcol = ob->totcol; matar = ob->mat; } else if (GS(tsep->id->name) == ID_ME) { Mesh *me = (Mesh *)tsep->id; totcol = me->totcol; matar = me->mat; } else if (GS(tsep->id->name) == ID_CU) { Curve *cu = (Curve *)tsep->id; totcol = cu->totcol; matar = cu->mat; } else if (GS(tsep->id->name) == ID_MB) { MetaBall *mb = (MetaBall *)tsep->id; totcol = mb->totcol; matar = mb->mat; } else { BLI_assert(0); } if (LIKELY(matar != NULL)) { for (a = 0; a < totcol; a++) { if (a == te->index && matar[a]) { matar[a]->id.us--; matar[a] = NULL; } } } }
void DLinkList_append(DLinkList dest, DLinkList src) { if(UNLIKELY(src->len == 0)) { return; } if(LIKELY(dest->list != NULL)) { DLink dhead = dest->list; DLink dtail = dhead->prev; DLink shead = src->list; DLink stail = shead->prev; dtail->next = shead; shead->prev = dtail; stail->next = dhead; dhead->prev = stail; } else { dest->list = src->list; } dest->len += src->len; /* reset src list*/ src->list = NULL; src->len = 0; }
static void reverse_comple(const char* seq, char* rc) { int32_t end = strlen(seq), start = 0; static const int8_t rc_table[128] = { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 84, 4, 71, 4, 4, 4, 67, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 65, 65, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 84, 4, 71, 4, 4, 4, 67, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 65, 65, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }; rc[end] = '\0'; -- end; while (LIKELY(start < end)) { rc[start] = (char)rc_table[(int8_t)seq[end]]; rc[end] = (char)rc_table[(int8_t)seq[start]]; ++ start; -- end; } if (start == end) rc[start] = (char)rc_table[(int8_t)seq[start]]; }
/** * Duplicate of BM_mesh_cd_validate() for Mesh data. */ void BKE_mesh_cd_validate(Mesh *me) { int totlayer_mtex = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY); int totlayer_uv = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV); int mtex_index = CustomData_get_layer_index(&me->pdata, CD_MTEXPOLY); int uv_index = CustomData_get_layer_index(&me->ldata, CD_MLOOPUV); int i; if (LIKELY(totlayer_mtex == totlayer_uv)) { /* pass */ } else if (totlayer_mtex < totlayer_uv) { do { const char *from_name = me->ldata.layers[uv_index + totlayer_mtex].name; CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DEFAULT, NULL, me->totpoly, from_name); CustomData_set_layer_unique_name(&me->pdata, totlayer_mtex); } while (totlayer_uv != ++totlayer_mtex); mtex_index = CustomData_get_layer_index(&me->pdata, CD_MTEXPOLY); } else if (totlayer_uv < totlayer_mtex) { do { const char *from_name = me->pdata.layers[mtex_index + totlayer_uv].name; CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, from_name); CustomData_set_layer_unique_name(&me->ldata, totlayer_uv); } while (totlayer_mtex != ++totlayer_uv); uv_index = CustomData_get_layer_index(&me->ldata, CD_MLOOPUV); } BLI_assert(totlayer_mtex == totlayer_uv); /* Check uv/tex names match as well!!! */ for (i = 0; i < totlayer_mtex; i++, mtex_index++, uv_index++) { const char *name_src = me->pdata.layers[mtex_index].name; const char *name_dst = me->ldata.layers[uv_index].name; if (!STREQ(name_src, name_dst)) { BKE_mesh_uv_cdlayer_rename_index(me, mtex_index, uv_index, -1, name_src, false); } } }
void c_ExternalThreadEventWaitHandle::enterContext(context_idx_t ctx_idx) { assert(AsioSession::Get()->getContext(ctx_idx)); // stop before corrupting unioned data if (isFinished()) { return; } // already in the more specific context? if (LIKELY(getContextIdx() >= ctx_idx)) { return; } assert(getState() == STATE_WAITING); if (isInContext()) { getContext()->unregisterExternalThreadEvent(m_index); } setContextIdx(ctx_idx); m_index = getContext()->registerExternalThreadEvent(this); }
Variant f_array_keys(CVarRef input, CVarRef search_value /* = null_variant */, bool strict /* = false */) { const auto& cell_input = *input.asCell(); if (UNLIKELY(!isContainer(cell_input))) { goto warn; } { // We treat Sets differently. For Sets, we pretend the values are // also the keys (similar to how Set::toArray() behaves). bool isSetType = cell_input.m_type == KindOfObject && cell_input.m_data.pobj->getCollectionType() == Collection::SetType; if (UNLIKELY(isSetType)) { return arrayKeysSetHelper(cell_input, search_value, strict); } ArrayIter iter(cell_input); if (LIKELY(!search_value.isInitialized())) { PackedArrayInit ai(getContainerSize(cell_input)); for (; iter; ++iter) { ai.append(iter.first()); } return ai.toArray(); } Array ai = Array::attach(HphpArray::MakeReserve(0)); for (; iter; ++iter) { if ((strict && HPHP::same(iter.secondRefPlus(), search_value)) || (!strict && HPHP::equal(iter.secondRefPlus(), search_value))) { ai.append(iter.first()); } } return ai; } warn: raise_warning("array_keys() expects parameter 1 to be an array " "or collection"); return uninit_null(); }
void c_ContinuationWaitHandle::enterContext(context_idx_t ctx_idx) { assert(AsioSession::Get()->getContext(ctx_idx)); // stop before corrupting unioned data if (isFinished()) { return; } // already in the more specific context? if (LIKELY(getContextIdx() >= ctx_idx)) { return; } switch (getState()) { case STATE_BLOCKED: // enter child into new context recursively assert(dynamic_cast<c_WaitableWaitHandle*>(m_child.get())); static_cast<c_WaitableWaitHandle*>(m_child.get())->enterContext(ctx_idx); setContextIdx(ctx_idx); break; case STATE_SCHEDULED: // reschedule so that we get run setContextIdx(ctx_idx); getContext()->schedule(this); break; case STATE_RUNNING: { Object e(SystemLib::AllocInvalidOperationExceptionObject( "Detected cross-context dependency cycle. You are trying to depend " "on something that is running you serially.")); throw e; } default: assert(false); } }
/* iterators */ dict_si_t dict_sym_iter(dict_t d) { /* uses static state */ static BDBCUR *c; dict_si_t res; const void *vp; int z[1U]; if (UNLIKELY(c == NULL)) { c = tcbdbcurnew(d); tcbdbcurjump(c, SYM_SPACE, sizeof(SYM_SPACE)); } if (UNLIKELY((vp = tcbdbcurval3(c, z)) == NULL)) { goto null; } else if (*z != sizeof(int)) { goto null; } /* otherwise fill res */ res.sid = *(const int*)vp; if (UNLIKELY((vp = tcbdbcurkey3(c, z)) == NULL)) { goto null; } /* or fill */ res.sym = vp; /* also iterate to the next thing */ tcbdbcurnext(c); return res; null: if (LIKELY(c != NULL)) { tcbdbcurdel(c); } c = NULL; return (dict_si_t){}; }
void *MEM_lockfree_reallocN_id(void *vmemh, size_t len, const char *str) { void *newp = NULL; if (vmemh) { MemHead *memh = MEMHEAD_FROM_PTR(vmemh); size_t old_len = MEM_allocN_len(vmemh); if (LIKELY(!MEMHEAD_IS_ALIGNED(memh))) { newp = MEM_lockfree_mallocN(len, "realloc"); } else { MemHeadAligned *memh_aligned = MEMHEAD_ALIGNED_FROM_PTR(vmemh); newp = MEM_lockfree_mallocN_aligned( old_len, (size_t)memh_aligned->alignment, "realloc"); } if (newp) { if (len < old_len) { /* shrink */ memcpy(newp, vmemh, len); } else { /* grow (or remain same size) */ memcpy(newp, vmemh, old_len); } } MEM_lockfree_freeN(vmemh); } else { newp = MEM_lockfree_mallocN(len, str); } return newp; }
EncodedTiValue operationGetByVal(TiExcState* exec, EncodedTiValue encodedBase, EncodedTiValue encodedProperty) { TiValue baseValue = TiValue::decode(encodedBase); TiValue property = TiValue::decode(encodedProperty); if (LIKELY(baseValue.isCell())) { TiCell* base = baseValue.asCell(); if (property.isUInt32()) { TiGlobalData* globalData = &exec->globalData(); uint32_t i = property.asUInt32(); // FIXME: the JIT used to handle these in compiled code! if (isTiArray(globalData, base) && asArray(base)->canGetIndex(i)) return TiValue::encode(asArray(base)->getIndex(i)); // FIXME: the JITstub used to relink this to an optimized form! if (isTiString(globalData, base) && asString(base)->canGetIndex(i)) return TiValue::encode(asString(base)->getIndex(exec, i)); // FIXME: the JITstub used to relink this to an optimized form! if (isTiArrayArray(globalData, base) && asByteArray(base)->canAccessIndex(i)) return TiValue::encode(asByteArray(base)->getIndex(exec, i)); return TiValue::encode(baseValue.get(exec, i)); } if (property.isString()) { Identifier propertyName(exec, asString(property)->value(exec)); PropertySlot slot(base); if (base->fastGetOwnPropertySlot(exec, propertyName, slot)) return TiValue::encode(slot.getValue(exec, propertyName)); } } Identifier ident(exec, property.toString(exec)); return TiValue::encode(baseValue.get(exec, ident)); }
ObjectData *FrameInjection::getObjectV() const { // Must check first: an EvalFrame can also be // an ObjectMethodFrame (but its still implemented // using EvalFrameInjection). if (UNLIKELY(isEvalFrame())) { const Eval::EvalFrameInjection* efi = static_cast<const Eval::EvalFrameInjection*>(this); return efi->getThis(); } if (LIKELY(isObjectMethodFrame())) { const FrameInjectionObjectMethod* ofi = static_cast<const FrameInjectionObjectMethod*>(this); return ofi->getThis(); } if (m_flags & PseudoMain) { const FrameInjectionFunction *ffi = static_cast<const FrameInjectionFunction*>(this); return ffi->getThis(); } return NULL; }
HOT_FUNC void StringData::releaseDataSlowPath() { assert(!isSmall()); assert(checkSane()); auto const loadedMode = mode(); if (LIKELY(loadedMode == Mode::Smart)) { smart_free(m_data); return; } if (loadedMode == Mode::Shared) { assert(checkSane()); m_big.shared->decRef(); delist(); return; } assert(loadedMode == Mode::Malloc); assert(checkSane()); free(m_data); }
int ConvertPipeline::handle_frame(uvc_frame_t *frame) { ENTER(); Mutex::Autolock lock(pipeline_mutex); if (next_pipeline) { uvc_frame_t *copy = frame; if (mFrameConvFunc) { copy = get_frame(frame->actual_bytes); if (LIKELY(copy)) { const uvc_error_t r = mFrameConvFunc(frame, copy); if (UNLIKELY(r)) { LOGW("failed to convert:%d", r); recycle_frame(copy); copy = frame; } } } next_pipeline->queueFrame(copy); } RETURN(1, int); }
void c_AsyncGeneratorWaitHandle::resume() { // may happen if scheduled in multiple contexts if (getState() != STATE_SCHEDULED) { decRefObj(this); return; } assert(getState() == STATE_SCHEDULED); assert(m_child->isFinished()); setState(STATE_RUNNING); auto const resumable = m_generator->resumable(); resumable->actRec()->setReturnVMExit(); if (LIKELY(m_child->isSucceeded())) { // child succeeded, pass the result to the async generator g_context->resumeAsyncFunc(resumable, m_child, m_child->getResult()); } else { // child failed, raise the exception inside the async generator g_context->resumeAsyncFuncThrow(resumable, m_child, m_child->getException()); } }
void raise_call_to_undefined(const StringData* name, const Class* cls) { if (LIKELY(!needsStripInOut(name))) { if (cls) { raise_error("Call to undefined method %s::%s()", cls->name()->data(), name->data()); } raise_error("Call to undefined function %s()", name->data()); } else { auto stripped = stripInOutSuffix(name); if (cls) { if (cls->lookupMethod(stripped)) { raise_error("Call to method %s::%s() with incorrectly annotated inout " "parameter", cls->name()->data(), stripped->data()); } raise_error("Call to undefined method %s::%s()", cls->name()->data(), stripped->data()); } else if (Unit::lookupFunc(stripped)) { raise_error("Call to function %s() with incorrectly annotated inout " "parameter", stripped->data()); } raise_error("Call to undefined function %s()", stripped->data()); } }
WRAPPER(void *, malloc, size_t c) { size_t size_with_crumple_zones; DECLARE(void *, malloc, size_t c); void *result; BEGIN_PROTECT (malloc, c); size_with_crumple_zones = CLAMPADD(c,CLAMPADD(__mf_opts.crumple_zone, __mf_opts.crumple_zone)); BEGIN_MALLOC_PROTECT (); result = (char *) CALL_REAL (malloc, size_with_crumple_zones); END_MALLOC_PROTECT (); if (LIKELY(result)) { result += __mf_opts.crumple_zone; __mf_register (result, c, __MF_TYPE_HEAP, "malloc region"); /* XXX: register __MF_TYPE_NOACCESS for crumple zones. */ } return result; }
HOT_FUNC CVarRef SharedMap::getValueRef(ssize_t pos) const { SharedVariant *sv = m_arr->getValue(pos); DataType t = sv->getType(); if (!IS_REFCOUNTED_TYPE(t)) return sv->asCVarRef(); if (LIKELY(m_localCache != NULL)) { Variant *pv; ArrayData *escalated DEBUG_ONLY = m_localCache->ZendArray::lvalPtr((int64)pos, pv, false, false); assert(!escalated); if (pv) return *pv; } else { m_localCache = NEW(ZendArray)(); m_localCache->incRefCount(); } Variant v = sv->toLocal(); Variant *r; ArrayData *escalated DEBUG_ONLY = m_localCache->ZendArray::addLval((int64)pos, r, false); assert(!escalated); *r = v; return *r; }
static int exec_hooks(rb_thread_t *th, rb_hook_list_t *list, const rb_trace_arg_t *trace_arg, int can_clean_hooks) { int state; volatile int raised; if (UNLIKELY(list->need_clean > 0) && can_clean_hooks) { clean_hooks(list); } raised = rb_threadptr_reset_raised(th); /* TODO: Support !RUBY_EVENT_HOOK_FLAG_SAFE hooks */ TH_PUSH_TAG(th); if ((state = TH_EXEC_TAG()) == 0) { rb_event_hook_t *hook; for (hook = list->hooks; hook; hook = hook->next) { if (LIKELY(!(hook->hook_flags & RUBY_EVENT_HOOK_FLAG_DELETED)) && (trace_arg->event & hook->events)) { if (!(hook->hook_flags & RUBY_EVENT_HOOK_FLAG_RAW_ARG)) { (*hook->func)(trace_arg->event, hook->data, trace_arg->self, trace_arg->id, trace_arg->klass); } else { (*((rb_event_hook_raw_arg_func_t)hook->func))(hook->data, trace_arg); } } } } TH_POP_TAG(); if (raised) { rb_threadptr_set_raised(th); } return state; }
EncodedJSValue JIT_OPERATION operationGetByVal(ExecState* exec, EncodedJSValue encodedBase, EncodedJSValue encodedProperty) { VM& vm = exec->vm(); NativeCallFrameTracer tracer(&vm, exec); JSValue baseValue = JSValue::decode(encodedBase); JSValue property = JSValue::decode(encodedProperty); if (LIKELY(baseValue.isCell())) { JSCell* base = baseValue.asCell(); if (property.isUInt32()) { return getByVal(exec, base, property.asUInt32()); } else if (property.isDouble()) { double propertyAsDouble = property.asDouble(); uint32_t propertyAsUInt32 = static_cast<uint32_t>(propertyAsDouble); if (propertyAsUInt32 == propertyAsDouble && isIndex(propertyAsUInt32)) return getByVal(exec, base, propertyAsUInt32); } else if (property.isString()) { Structure& structure = *base->structure(vm); if (JSCell::canUseFastGetOwnProperty(structure)) { if (AtomicStringImpl* existingAtomicString = asString(property)->toExistingAtomicString(exec)) { if (JSValue result = base->fastGetOwnProperty(vm, structure, existingAtomicString)) return JSValue::encode(result); } } } } baseValue.requireObjectCoercible(exec); if (exec->hadException()) return JSValue::encode(jsUndefined()); auto propertyName = property.toPropertyKey(exec); if (exec->hadException()) return JSValue::encode(jsUndefined()); return JSValue::encode(baseValue.get(exec, propertyName)); }
static void apply_force_kernel_gadget(PM * pm, FastPMFloat * from, FastPMFloat * to, int dir, int cic) { /* This is the potential gradient in fourier space. - i k[dir] / k2 */ #pragma omp parallel { PMKIter kiter; for(pm_kiter_init(pm, &kiter); !pm_kiter_stop(&kiter); pm_kiter_next(&kiter)) { int d; double k_finite = kiter.k_finite[dir][kiter.iabs[dir]]; double kk_finite = 0; for(d = 0; d < 3; d++) { kk_finite += kiter.kk[d][kiter.iabs[d]]; } ptrdiff_t ind = kiter.ind; /* - i k[d] / k2 */ if(LIKELY(kk_finite > 0)) { to[ind + 0] = from[ind + 1] * (k_finite / kk_finite); to[ind + 1] = - from[ind + 0] * (k_finite / kk_finite); } else { to[ind + 0] = 0; to[ind + 1] = 0; } } } if(cic) { /* now sharpen for mass assignment */ /* L1 */ fastpm_apply_decic_transfer(pm, to, to); /* L2 */ fastpm_apply_decic_transfer(pm, to, to); } }
StringType v8StringToWebCoreString(v8::Handle<v8::String> v8String, ExternalMode external) { { // This portion of this function is very hot in certain Dromeao benchmarks. v8::String::Encoding encoding; v8::String::ExternalStringResourceBase* resource = v8String->GetExternalStringResourceBase(&encoding); if (LIKELY(!!resource)) { WebCoreStringResourceBase* base; if (encoding == v8::String::ONE_BYTE_ENCODING) base = static_cast<WebCoreStringResource8*>(resource); else base = static_cast<WebCoreStringResource16*>(resource); return StringTraits<StringType>::fromStringResource(base); } } int length = v8String->Length(); if (UNLIKELY(!length)) return StringType(""); bool oneByte = v8String->ContainsOnlyOneByte(); StringType result(oneByte ? StringTraits<StringType>::template fromV8String<V8StringOneByteTrait>(v8String, length) : StringTraits<StringType>::template fromV8String<V8StringTwoBytesTrait>(v8String, length)); if (external != Externalize || !v8String->CanMakeExternal()) return result; if (result.is8Bit()) { WebCoreStringResource8* stringResource = new WebCoreStringResource8(result); if (UNLIKELY(!v8String->MakeExternal(stringResource))) delete stringResource; } else { WebCoreStringResource16* stringResource = new WebCoreStringResource16(result); if (UNLIKELY(!v8String->MakeExternal(stringResource))) delete stringResource; } return result; }
HOT_FUNC_VM void VerifyParamTypeSlow(const Class* cls, const Class* constraint, int param, const TypeConstraint* expected) { if (LIKELY(constraint && cls->classof(constraint))) { return; } // Check a typedef for a class. We interp'd if the param wasn't an // object, so if it's a typedef for something non-objecty we're // failing anyway. if (auto namedEntity = expected->namedEntity()) { auto def = namedEntity->getCachedTypedef(); if (UNLIKELY(!def)) { VMRegAnchor _; String nameStr(const_cast<StringData*>(expected->typeName())); if (AutoloadHandler::s_instance->autoloadType(nameStr)) { def = namedEntity->getCachedTypedef(); } } if (def) { // There's no need to handle nullable typedefs specially here: // we already know we're checking a non-null object with the // class `cls'. We do however need to check for typedefs to // mixed. if (def->kind == KindOfObject) { constraint = def->klass; if (constraint && cls->classof(constraint)) return; } else if (def->kind == KindOfAny) { return; } } } VerifyParamTypeFail(param); }
void MXUser_DestroyExclLock(MXUserExclLock *lock) // IN: { if (lock != NULL) { MXUserValidateHeader(&lock->header, MXUSER_TYPE_EXCL); if (MXRecLockCount(&lock->recursiveLock) > 0) { MXUserDumpAndPanic(&lock->header, "%s: Destroy of an acquired exclusive lock\n", __FUNCTION__); } lock->header.signature = 0; // just in case... MXRecLockDestroy(&lock->recursiveLock); MXUserRemoveFromList(&lock->header); if (vmx86_stats) { MXUserStats *stats = Atomic_ReadPtr(&lock->statsMem); if (LIKELY(stats != NULL)) { MXUserAcquisitionStatsTearDown(&stats->acquisitionStats); MXUserHistoTearDown(Atomic_ReadPtr(&stats->acquisitionHisto)); MXUserBasicStatsTearDown(&stats->heldStats); MXUserHistoTearDown(Atomic_ReadPtr(&stats->heldHisto)); free(stats); } } free(lock->header.name); lock->header.name = NULL; free(lock); } }
static void dump_tick_bi5(mux_ctx_t ctx, struct dqbi5_s *tl) { /* create one or more sparse ticks, sl1t_t objects */ static struct dqbi5_s last; unsigned int ts = tl->ts / 1000; unsigned int ms = tl->ts % 1000; int32_t off = ctx->opts->tsoff; if (ctx->opts->flags & SUMUX_FLAG_ALL_TICKS || tl->bp != last.bp || tl->bq.i != last.bq.i) { printf("%s\t%u.%u\tb\t%u\t%f\n", ctx->opts->sname, ts + off, ms, tl->bp, tl->bq.d); } if (ctx->opts->flags & SUMUX_FLAG_ALL_TICKS || tl->ap != last.ap || tl->aq.i != last.aq.i) { printf("%s\t%u.%u\ta\t%u\t%f\n", ctx->opts->sname, ts + off, ms, tl->ap, tl->aq.d); } if (LIKELY(!(ctx->opts->flags & SUMUX_FLAG_ALL_TICKS))) { last = *tl; } return; }