@@ -5043,70 +5043,6 @@ void StringCharAtGenerator::GenerateSlow(
5043
5043
}
5044
5044
5045
5045
5046
- class StringHelper : public AllStatic {
5047
- public:
5048
- // Generate code for copying characters using a simple loop. This should only
5049
- // be used in places where the number of characters is small and the
5050
- // additional setup and checking in GenerateCopyCharactersLong adds too much
5051
- // overhead. Copying of overlapping regions is not supported.
5052
- // Dest register ends at the position after the last character written.
5053
- static void GenerateCopyCharacters (MacroAssembler* masm,
5054
- Register dest,
5055
- Register src,
5056
- Register count,
5057
- Register scratch,
5058
- bool ascii);
5059
-
5060
- // Generate code for copying a large number of characters. This function
5061
- // is allowed to spend extra time setting up conditions to make copying
5062
- // faster. Copying of overlapping regions is not supported.
5063
- // Dest register ends at the position after the last character written.
5064
- static void GenerateCopyCharactersLong (MacroAssembler* masm,
5065
- Register dest,
5066
- Register src,
5067
- Register count,
5068
- Register scratch1,
5069
- Register scratch2,
5070
- Register scratch3,
5071
- Register scratch4,
5072
- Register scratch5,
5073
- int flags);
5074
-
5075
-
5076
- // Probe the symbol table for a two character string. If the string is
5077
- // not found by probing a jump to the label not_found is performed. This jump
5078
- // does not guarantee that the string is not in the symbol table. If the
5079
- // string is found the code falls through with the string in register r0.
5080
- // Contents of both c1 and c2 registers are modified. At the exit c1 is
5081
- // guaranteed to contain halfword with low and high bytes equal to
5082
- // initial contents of c1 and c2 respectively.
5083
- static void GenerateTwoCharacterSymbolTableProbe (MacroAssembler* masm,
5084
- Register c1,
5085
- Register c2,
5086
- Register scratch1,
5087
- Register scratch2,
5088
- Register scratch3,
5089
- Register scratch4,
5090
- Register scratch5,
5091
- Label* not_found);
5092
-
5093
- // Generate string hash.
5094
- static void GenerateHashInit (MacroAssembler* masm,
5095
- Register hash,
5096
- Register character);
5097
-
5098
- static void GenerateHashAddCharacter (MacroAssembler* masm,
5099
- Register hash,
5100
- Register character);
5101
-
5102
- static void GenerateHashGetHash (MacroAssembler* masm,
5103
- Register hash);
5104
-
5105
- private:
5106
- DISALLOW_IMPLICIT_CONSTRUCTORS (StringHelper);
5107
- };
5108
-
5109
-
5110
5046
void StringHelper::GenerateCopyCharacters (MacroAssembler* masm,
5111
5047
Register dest,
5112
5048
Register src,
@@ -5359,9 +5295,8 @@ void StringHelper::GenerateTwoCharacterSymbolTableProbe(MacroAssembler* masm,
5359
5295
static const int kProbes = 4 ;
5360
5296
Label found_in_symbol_table;
5361
5297
Label next_probe[kProbes ];
5298
+ Register candidate = scratch5; // Scratch register contains candidate.
5362
5299
for (int i = 0 ; i < kProbes ; i++) {
5363
- Register candidate = scratch5; // Scratch register contains candidate.
5364
-
5365
5300
// Calculate entry in symbol table.
5366
5301
if (i > 0 ) {
5367
5302
__ add (candidate, hash, Operand (SymbolTable::GetProbeOffset (i)));
@@ -5418,7 +5353,7 @@ void StringHelper::GenerateTwoCharacterSymbolTableProbe(MacroAssembler* masm,
5418
5353
__ jmp (not_found);
5419
5354
5420
5355
// Scratch register contains result when we fall through to here.
5421
- Register result = scratch ;
5356
+ Register result = candidate ;
5422
5357
__ bind (&found_in_symbol_table);
5423
5358
__ Move (r0, result);
5424
5359
}
@@ -5428,9 +5363,13 @@ void StringHelper::GenerateHashInit(MacroAssembler* masm,
5428
5363
Register hash,
5429
5364
Register character) {
5430
5365
// hash = character + (character << 10);
5431
- __ add (hash, character, Operand (character, LSL, 10 ));
5366
+ __ LoadRoot (hash, Heap::kStringHashSeedRootIndex );
5367
+ // Untag smi seed and add the character.
5368
+ __ add (hash, character, Operand (hash, LSR, kSmiTagSize ));
5369
+ // hash += hash << 10;
5370
+ __ add (hash, hash, Operand (hash, LSL, 10 ));
5432
5371
// hash ^= hash >> 6;
5433
- __ eor (hash, hash, Operand (hash, ASR , 6 ));
5372
+ __ eor (hash, hash, Operand (hash, LSR , 6 ));
5434
5373
}
5435
5374
5436
5375
@@ -5442,7 +5381,7 @@ void StringHelper::GenerateHashAddCharacter(MacroAssembler* masm,
5442
5381
// hash += hash << 10;
5443
5382
__ add (hash, hash, Operand (hash, LSL, 10 ));
5444
5383
// hash ^= hash >> 6;
5445
- __ eor (hash, hash, Operand (hash, ASR , 6 ));
5384
+ __ eor (hash, hash, Operand (hash, LSR , 6 ));
5446
5385
}
5447
5386
5448
5387
@@ -5451,12 +5390,15 @@ void StringHelper::GenerateHashGetHash(MacroAssembler* masm,
5451
5390
// hash += hash << 3;
5452
5391
__ add (hash, hash, Operand (hash, LSL, 3 ));
5453
5392
// hash ^= hash >> 11;
5454
- __ eor (hash, hash, Operand (hash, ASR , 11 ));
5393
+ __ eor (hash, hash, Operand (hash, LSR , 11 ));
5455
5394
// hash += hash << 15;
5456
5395
__ add (hash, hash, Operand (hash, LSL, 15 ), SetCC);
5457
5396
5397
+ uint32_t kHashShiftCutOffMask = (1 << (32 - String::kHashShift )) - 1 ;
5398
+ __ and_ (hash, hash, Operand (kHashShiftCutOffMask ));
5399
+
5458
5400
// if (hash == 0) hash = 27;
5459
- __ mov (hash, Operand (27 ), LeaveCC, ne );
5401
+ __ mov (hash, Operand (27 ), LeaveCC, eq );
5460
5402
}
5461
5403
5462
5404
0 commit comments