/* static */ bool InefficientNonFlatteningStringHashPolicy::match(const JSString *const &k, const Lookup &l) { // We can't use js::EqualStrings, because that flattens our strings. if (k->length() != l->length()) return false; const jschar *c1; ScopedJSFreePtr<jschar> ownedChars1; if (k->hasPureChars()) { c1 = k->pureChars(); } else { if (!k->copyNonPureChars(/* tcx */ nullptr, ownedChars1)) MOZ_CRASH("oom"); c1 = ownedChars1; } const jschar *c2; ScopedJSFreePtr<jschar> ownedChars2; if (l->hasPureChars()) { c2 = l->pureChars(); } else { if (!l->copyNonPureChars(/* tcx */ nullptr, ownedChars2)) MOZ_CRASH("oom"); c2 = ownedChars2; } return PodEqual(c1, c2, k->length()); }
/* static */ bool IteratorHashPolicy::match(PropertyIteratorObject* obj, const Lookup& lookup) { NativeIterator* ni = obj->getNativeIterator(); if (ni->guard_key != lookup.key || ni->guard_length != lookup.numGuards) return false; return PodEqual(reinterpret_cast<ReceiverGuard*>(ni->guard_array), lookup.guards, ni->guard_length); }
static void finalize_str(const JSStringFinalizer* fin, char16_t* chars) { if (chars && PodEqual(const_cast<const char16_t*>(chars), arr, arrlen)) { if (fin == &finalizer1) { ++finalized1; } else if (fin == &finalizer2) { ++finalized2; } } }
static bool VersionCheck(XDRState<mode>* xdr) { JS::BuildIdCharVector buildId; if (!xdr->cx()->buildIdOp() || !xdr->cx()->buildIdOp()(&buildId)) { JS_ReportErrorNumber(xdr->cx(), GetErrorMessage, nullptr, JSMSG_BUILD_ID_NOT_AVAILABLE); return false; } MOZ_ASSERT(!buildId.empty()); uint32_t buildIdLength; if (mode == XDR_ENCODE) buildIdLength = buildId.length(); if (!xdr->codeUint32(&buildIdLength)) return false; if (mode == XDR_DECODE && buildIdLength != buildId.length()) { JS_ReportErrorNumber(xdr->cx(), GetErrorMessage, nullptr, JSMSG_BAD_BUILD_ID); return false; } if (mode == XDR_ENCODE) { if (!xdr->codeBytes(buildId.begin(), buildIdLength)) return false; } else { JS::BuildIdCharVector decodedBuildId; // buildIdLength is already checked against the length of current // buildId. if (!decodedBuildId.resize(buildIdLength)) { ReportOutOfMemory(xdr->cx()); return false; } if (!xdr->codeBytes(decodedBuildId.begin(), buildIdLength)) return false; if (!PodEqual(decodedBuildId.begin(), buildId.begin(), buildIdLength)) { // We do not provide binary compatibility with older scripts. JS_ReportErrorNumber(xdr->cx(), GetErrorMessage, nullptr, JSMSG_BAD_BUILD_ID); return false; } } return true; }