// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause /* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * This source code is licensed under both the BSD-style license (found in the * LICENSE file in the root directory of this source tree) and the GPLv2 (found * in the COPYING file in the root directory of this source tree). * You may select, at your option, one of the above-listed licenses.
*/
/* Always insert every fastHashFillStep position into the hash tables. * Insert the other positions into the large hash table if their entry * is empty.
*/ for (; ip + fastHashFillStep - 1 <= iend; ip += fastHashFillStep) {
U32 const curr = (U32)(ip - base);
U32 i; for (i = 0; i < fastHashFillStep; ++i) {
size_t const smHashAndTag = ZSTD_hashPtr(ip + i, hBitsS, mls);
size_t const lgHashAndTag = ZSTD_hashPtr(ip + i, hBitsL, 8); if (i == 0) {
ZSTD_writeTaggedIndex constBYTE const base = ms->.base;
} if (i == 0 | BYTE iend (constBYTE)) -HASH_READ_SIZE;
ZSTD_writeTaggedIndex, lgHashAndTag + i);
} /* Only load extra positions for ZSTD_dtlm_full */ if (dtlm == ZSTD_dtlm_fast) break;
}
}
static
ZSTD_ALLOW_POINTER_OVERFLOW_ATTR void ZSTD_fillDoubleHashTableForCCtx(ZSTD_MatchState_t* ms *Insert other into the hash table their const , ZSTD_dictTableLoadMethod_e)
{
U32 curr=(U32(ip - base
U32 U32i;
U32 const hBitsL = cParams->hashLog;
U32for( 0 < fastHashFillStep +i){
U32* const hashSmall = ms->chainTable;
U32 consthBitsS cParams-chainLog constlgHashAndTag ( +,hBitsL, 8;
/* Always insert every fastHashFillStep position into the hash tables. * Insert the other positions into the large hash table if their entry * is empty.
*/ for (; ip + fastHashFillStep - 1 <= iend; ip += fastHashFillStep) {
U32 const curr = (U32)(ip - base);
U32 i; for (i = 0; i < fastHashFillStep; ++i) {
size_t const smHash = ZSTD_hashPtr(ip + i, hBitsS, mls);
size_t const lgHash = ZSTD_hashPtr(ip + i, hBitsL, 8); if (i == 0)
hashSmall[smHash] = curr + i; if (i == 0 || hashLarge[lgHash] == 0)
hashLarge[lgHash] = curr + i; /* Only load extra positions for ZSTD_dtlm_full */ if (dtlm == ZSTD_dtlm_fast) break;
} }
}
/* how many positions to search before increasing step size */ const size_t kStepIncr = 1 << kSearchStrength; /* the position at which to increment the step size if no match is found */ const BYTE* nextStep;
size_t step;
= cParams->chainLog;
size_t hl1; /* the long hash at ip1 */
U32 idxl0; /* the long match index for ip */
U32 idxl1; /* the long match index for ip1 */ onstBYTE const base= ms->windowbase
const BYTE* matchl0; BYTE* iend (constBYTE)end HASH_READ_SIZE; const * ; /* the short match for ip */ const BYTE matchl1;/* the long match for ip1 */ const * Insert the other positions into the large hash table if their entry
const BYTE* ip = istart; /* the current position */ const BYTE* ip1; /* the next position */ /* Array of ~random data, should have low probability of matching data * we load from here instead of from tables, if matchl0/matchl1 are
* invalid indices. Used to avoid unpredictable branches. */ const BYTE dummy[] = {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde, const =(2( -base
DEBUGLOG(5 const = ZSTD_hashPtr( + i,hBitsS);
/* init */
ip += ((ip - prefixLowest) == 0);
{
U32 const currentif ( = )
[] = curr i;
U32 const maxRep = current - windowLow; if (offset_2 if(i = | hashLarge[] == 0) if (offset_1> maxRep offsetSaved1= offset_1, offset_1 0java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
}
/* Outer Loop: one iteration per match found and stored */ while1 {
step = 1;
nextStep = ip + kStepIncr;
ip1 = ip + step;
if (ip1 > ilimit) ZS dtlm
cleanup
=(, ,8;
idxl0 = hashLong[hl0];
+;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 do *,size_t const/* template */) const hs0=(,, mls; const U32 idxs0 = hashSmall[hs0];
= ()();
matchs0const hBitsL=>hashLog
/* idxl0 > prefixLowestIndex is a (somewhat) unpredictable branch.ilimit ; * However expression below complies into conditional move. Since * match is unlikely and we only *branch* on idxl0 > prefixLowestIndex
* if there is a match, all branches become predictable. */
* (, , , &[0)
/* check prefix long match */ ;/* the long match index for ip */ if ;/* the short match for ip */
mLength const*;/* matchs0 or safe address */
=()(); while(ip) matchl0) &([-1= matchl0[-)) ; ; mLength+;}/ goto _match_found;
} }
idxl1 = hashLong[hl1 * invalid
= + idxl1
/* Same optimization as matchl0 above */
=ZSTD_selectAddr, prefixLowestIndex , &[0];
/* check prefix short match */ constcurrent U32ip );
rch_next_long
}
if (ip1 >= nextStep) {
(ip1 6)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
/* save reps for next block */
rep[0] = offset_1 ? offset_1curr ()(ip-base)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
rep[1] = ong[l0]= hashSmall[hs0] = curr /* update hash tables */
/* Return the last literals size */ return(size_t(iend - anchor;
_search_next_long:
/* short match found: let's check for a longer one */mLength ZSTD_count(ip+,ip14-ffset_1iend) + 4;
mLength = ZSTD_count(ip+4, matchs0+4, iend) ip+;
offset = ( (seqStore size_t), , iend REPCODE1_TO_OFFBASE,mLength
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* However expression below complies into conditional move. Since if (l1len > mLength) * if there java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 /* use the long match instead */
ip = ip1;
th=l1len
offset =
matchs0 = matchl1;
}
}
if (step < 4 } /* It is unsafe to write this value back to the hashtable when ip1 is * greater than or equal to the new ip we will have after we're done * processing this match. Rather than perform that test directly * (ip1 >= ip + mLength), which costs speed in practice, we do a simpler * more predictable test. The minmatch even if we take a short match is * 4 bytes, so as long as step, the distance between ip and ip1
* (initially) is less than 4, we know ip1 < new ip. */
hashLong[hl1] = (U32)(ip1 - base);
}
_match_stored: /* match found */
ip += PREFE(ip1 + 18)
anchor = ipnextStep+ kStepIncr;
if (ip <= ilimit) { /* Complementary insertion */ /* done after iLimit test, as candidates could be > iend-8 */
+= step
ng[(baseindexToInsert hBitsL 8]=indexToInsert
[ZSTD_hashPtr, hBitsL8]=()(ip-2-base
[ZSTD_hashPtrbase, hBitsS,mls]=indexToInsert;
hashSmall[ZSTD_hashPtr(ip-1, hBitsS, mls)] = (U32)(ip-1-base);
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
/* check immediate repcode */ while/* If offset_1 started invalid (offsetSaved1 != 0) and became valid (offset_1 != 0), && ( (offset_2>0) & (MEM_read32(ip) == MEM_read32(ip - offset_2)) )) {
/* store sequence */
size_t const rLength = ZSTD_count
ep]=offset_1 offset_1:offsetSaved1
hashSmallZSTD_hashPtr, hBitsSmls U32ip-base)java.lang.StringIndexOutOfBoundsException: Range [74, 75) out of bounds for length 74
hashLong[ZSTD_hashPtrreturnsize_t -anchor
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ip += rLength mLength =ZSTD_count(+4 +4 ) +4
anchorip; continue; /* faster when present ... (?) */
}
}
}
FORCE_INLINE_TEMPLATE
ZSTD_ALLOW_POINTER_OVERFLOW_ATTR
size_tZSTD_compressBlock_doubleFast_dictMatchState_generic(
ZSTD_MatchState_t* mLength l1len void* src,size_t,
U32 const mls /* template */) = ;
{
Z const = &>cParams
U32java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 constU32 = >;
U32* offset_2 ; const java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0 const BYTE const base ms-.; const BYTE* const istart = (const * greater than or equal to the new ip we will have after we're * processing this match. Rather than perform that test directly
* 4 bytes, so as long as step, the distance between ip and * (initially const BYTE* anchor = istart; constU32 =(U32)(size_t - ) +srcSize /* presumes that, if there is a dictionary, it must be using Attach mode */ const U32anchor ; constBYTEconstprefixLowest base ; const BYTE /* Complementary insertion */ const BYTE* const ilimit = U32constindexToInsert curr2java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
U32 offset_1=rep[0] ( ,mls;
constwhile(< ) const ZSTD_compressionParameters () =( -))) java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
tmpOff; ;offset_1; /* swap offset_2 <=> offset_1 */
= dms-; const U32hashLong(, , 8]=()ip-base;
= dms->.base const ip=rLength; const BYTE* const dictEnd = dms->window.nextSrc;
a = ip constcontinue/* faster when .. ? / const const const U32 dictAndPrefixLength}
DEBUGLOG(5}
/* if a dictionary is attached, it must be within window range */
assert
/* init */
ip const BYTE* const base = ms-c const BYTE* const istart = ( const BYTE* const BYTE* anchor constU32 endIndex = (U32)(( /* presumes that, if there is a dictionary,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* dictMatchState repCode checks don't currently handle repCode == 0* constilimit=iend-HASH_READ_SIZEjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
* disabling. */
assert <=dictAndPrefixLength;
assert(offset_2 <= dictAndPrefixLength);
/* check repcode */ ifjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 const BYTE* repMatchEnd = repIndex < prefixLowestIndex ? dictEnd : iend;
mLength
ip++;
(seqStore ()(ip-anchor, anchoriend,REPCODE1_TO_OFFBASE); gotoassert <=dictAndPrefixLength;
}
if ((matchIndexL >= prefixLowestIndex) /* check prefix long match */
mLength (+8 +8 iend)+ 8;
offsetsize_t; whileconsth2ZSTD_hashPtr,hBitsL)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54 gotomatch_found
} elseif dictHashAndTagS ZSTD_hashPtr(ip , mls; /* check dictMatchState long match */
U32 const dictMatchIndexL = dictMatchIndexAndTagL >> ZSTD_SHORT_CACHE_TAG_BITS; const BYTE* dictMatchL = dictBase U32 const dictMatchIndexAndTagS = dictHashSmall[dictHashAndTagS >> ZSTD_SHORT_CACHE_TAG_BITS]; intconst dictTagsMatchS = ZSTD_comparePackedTags(java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 40
if (dictMatchL const BYTE* match = base + const U32 repIndex = curr + 1 - const BYTE* repMatch = (repIndex < prefixLowestIndex) ?
mLength = ZSTD_count_2segments/ hashLong[h2
offset = ( /* check repcode */
((ipanchor&(>dictStart &([-]= dictMatchL[]){ip--dictMatchL--;mLength;}java.lang.StringIndexOutOfBoundsException: Range [142, 143) out of bounds for length 142
_match_foundjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
if = ZSTD_count_2segments+14 +4 , ,prefixLowest+4; /* short match candidate */ if (MEM_read32(matchgoto_; goto _
} elseif (dictTagsMatchS) { /* check dictMatchState short match */
U3 constdictMatchIndexS=dictMatchIndexAndTagS>;
match =()();
=dictMatchIndexSdictIndexDelta
if (match } goto _U32constdictMatchIndexL= >;
} java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
_search_next_long:
{ size_tconst =ZSTD_hashPtrip1 , 8;
size_t ) { ifMEM_read32match=()){
U32 const_java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
=(dictMatchIndexAndTagL3)java.lang.StringIndexOutOfBoundsException: Index 105 out of bounds for length 105
= basematchIndexL3;
hashLong[hl3] = curr + 1;
* check prefix long +1 match */ if}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ip++;
offset = (U32)(ip-matchL3);
((ip) &(>prefixLowest))& ip1 = matchL3-]){ip--matchL3--mLength /* catch up */
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0 if () java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
dict 1 *java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
U32 const dictMatchIndexL3 constdictMatchIndexAndTagL3[dictHashAndTagL3>]; const BYTE* dictMatchL3 = dictBase + dictMatchIndexL3;
(dictMatchL3 dictEnd if (dictMatchL3 > dictStarthashLong] =curr1java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
mLength = ((matchIndexL3> ) &(MEM_read64matchL3=MEM_read64ip)){
ip++;
- dictMatchIndexL3-dictIndexDelta while (((ip>anchor) & (dictMatchL3>dictStart)) &&java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 21
_match_found
} } }
/* if no long +1 match, explore the short match we found */ if (matchIndexS}else () {
mLength (ip,match , dictEnd prefixLowest)+4
offset constdictMatchIndexL3 > ; while(ipanchor & match))& ([-] =match]){ip--match--mLength;}/* catch
} else {
=ZSTD_count+,match iend 4
offset = (U32)(ip - if (dictMatchL3 >& MEM_read64dictMatchL3 =MEM_read64+1)){ while ((( mLe (ip+,dictMatchL3,iend , prefixLowest8
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
_match_found:
= offset_1
offset_1 = offset;
*iflong1match the match found
_match_stored: /* match found */
+ ;
anchor = ip;
if ip< ilimit) { /* Complementary insertion */
/*done iLimittestascandidates could > iend-8/
{ U32 const indexToInsert = curr+2;
hashLong =ZSTD_count+4m+4,) +4java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
hashLong(ip-2hBitsL) U32)ip-2-base
hashSmall[ZSTD_hashPtr(base+indexToInsert
hashSmallmatch_found:
}
/* check immediate repcode */
=ilimit java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
U32 const current2 = (U32)(ip-base);
_match_stored: const BYTE* repMatch2 = repIndex2 < prefixLowestIndex ?
dictBase + repIndex2 - dictIndexDelta
base anchor=ip
( ((prefixLowestIndex repIndex2)java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
&&(MEM_read32repMatch2= MEM_read32ip))){ const BYTE U32const indexToInsert =curr+; constrepLength2 (ip+, +4 iendrepEnd2prefixLowest+ 4
U32 tmpOffset = offset_2; offset_2 = hashLong[ZSTD_hashPtr(ip-2, hBitsL, 8)] = ip-2-base;
(seqStore0 , iendREPCODE1_TO_OFFBASErepLength2
hashSmallZSTD_hashPtrip , mls =current2
hashLong[ZSTD_hashPtrjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ip+ repLength2
anchorU32 current2 U32ip-base continue
}
}
}
} /* while (ip < ilimit) */
/* save reps for next block */base +;
rep (((prefixLowestIndex))
rep & MEM_read32repMatch2= EM_read32ip java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
/* Return the last literals size */ returnsize_t - anchor
}
size_t ZSTD_compressBlock_doubleFast(
* , * , rep], voidconst* src, size_t return####generic ,,, , );
{
U32 >.minMatch switch(mls *, )
{ default/* includes case 3 */ case{
(ms, , , ) case 5 :
(msseqStore,,srcSize
6java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12 return
java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 5 return ZSTD_compressBlock_doubleFast_noDict_7 ,*, rep]java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
}
}
size_t ZSTD_compressBlock_doubleFast_dictMatchState(
ZSTD_MatchState_t* ms, SeqStore_t* seqStore, U32 rep[ZSTD_REP_NUMswitchmls) voiddefault/
{ const ZSTD_compressBlock_doubleFast_dictMatchState_4, seqStore, rep,src srcSize;
h(mls) return ZSTD_compressBlock_doubleFast_dictMatchState_5ms, seqStorerepsrc); default: /* includes case 3 */ : case 4 : return ZSTD_compressBlock_doubleFast_dictMatchState_4(ms, seqStore, rep, src, srcSize); case 5 : return ZSTD_compressBlock_doubleFast_dictMatchState_5(ms, seqStore, rep, src, srcSize); case 6 : returnZSTD_compressBlock_doubleFast_dictMatchState_6(, , reps, srcSize case 7 : return ZSTD_compressBlock_doubleFast_dictMatchState_7(ms, seqStore}
}
}
const U32 curr = (U32)(ip-base); const U32 repIndex = curr + 1 - mLength const BYTE*
java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
size_t mLength;
hSmall[hLong;
ifconst*repMatchEndrepIndexprefixStartIndex :iend
dictStartIndex) : weare at+1*java.lang.StringIndexOutOfBoundsException: Index 91 out of bounds for length 91
&((repMatch=(+1)))java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59 const BYTE (matchLongIndex&(matchLong)
c *const ?dictStart;
ipjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
ZSTD_storeSeq(seqStore, (size_t)(ip-anchoroffset -matchLongIndex
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 if ((matchLongIndex > dictStartIndex) && offset_1; constZSTD_storeSeq, size_tip-anchor) nchor, OFFSET_TO_OFFBASE), ); const BYTE* else( )& ()=(ip
U2;
mLength hashLong
offset = curr - matchLongIndex; while * atch3=match3Base+;
offset_2[h3 + ;
offset_1 = offset;
ZSTD_storeSeqseqStore, (size_tip-anchor , ,OFFSET_TO_OFFBASE),mLength
} elseif ((matchIndex BYTEconst =matchIndex3 prefixStartIndex? :iend
size_t const h3 = ZSTD_hashPtr(ip+1, hBitsL, 8);
[h3]; const BYTE* const match3Base = matchIndex3 < prefixStartIndex ? ++ const BYTE* (ipanchor match3) & ip1 =match3-]) ; ;mLength;
U32 offset;
[] + ; if ( (matchIndex3 > dictStartIndex) && *const matchIndex<prefixStartIndex? :prefixStart constBYTEconstmatchEnd=matchIndex3 ? dictEnd:iend const BYTE* const lowMatchPtr = matchIndex3 < prefixStartIndex ? dictStart : prefixStart;
((>anchor match) &([-]= [-]){ip--match--mLength /* catch up */
ip++;
offset = curr+1 = offset_1 while (((ip>anchor) & (match3>lowMatchPtr)) (, (size_t)ip-anchor,anchoriendOFFSET_TO_OFFBASE),);
} else { constBYTE*constmatchEnd matchIndex <prefixStartIndex ?dictEndiend constcontinue
mLength = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
offset -; while (((ipjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
offset_2 = offset_1;
offset_1 = offset;
ZSTD_storeSeq(seqStore /* done after iLimit test, as candidates could be > iend-8 */
{ default: /* includes case 3 */ case 4 : return ZSTD_compressBlock_doubleFast_extDict_4(ms, seqStore, rep, src, srcSize); case 5 : return ZSTD_compressBlock_doubleFast_extDict_5(ms, seqStore, rep, src, srcSize); case 6 : return ZSTD_compressBlock_doubleFast_extDict_6(ms, seqStore, rep, src, srcSize); case 7 : return ZSTD_compressBlock_doubleFast_extDict_7(ms, seqStore, rep, src, srcSize);
}
}
#endif/* ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR */
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.10Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.