OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 Context::SECURITY_TOKEN_INDEX * kPointerSize; | 336 Context::SECURITY_TOKEN_INDEX * kPointerSize; |
337 | 337 |
338 lw(scratch, FieldMemOperand(scratch, token_offset)); | 338 lw(scratch, FieldMemOperand(scratch, token_offset)); |
339 lw(at, FieldMemOperand(at, token_offset)); | 339 lw(at, FieldMemOperand(at, token_offset)); |
340 Branch(miss, ne, scratch, Operand(at)); | 340 Branch(miss, ne, scratch, Operand(at)); |
341 | 341 |
342 bind(&same_contexts); | 342 bind(&same_contexts); |
343 } | 343 } |
344 | 344 |
345 | 345 |
| 346 void MacroAssembler::GetNumberHash(Register reg0, Register scratch) { |
| 347 // First of all we assign the hash seed to scratch. |
| 348 LoadRoot(scratch, Heap::kHashSeedRootIndex); |
| 349 SmiUntag(scratch); |
| 350 |
| 351 // Xor original key with a seed. |
| 352 xor_(reg0, reg0, scratch); |
| 353 |
| 354 // Compute the hash code from the untagged key. This must be kept in sync |
| 355 // with ComputeIntegerHash in utils.h. |
| 356 // |
| 357 // hash = ~hash + (hash << 15); |
| 358 nor(scratch, reg0, zero_reg); |
| 359 sll(at, reg0, 15); |
| 360 addu(reg0, scratch, at); |
| 361 |
| 362 // hash = hash ^ (hash >> 12); |
| 363 srl(at, reg0, 12); |
| 364 xor_(reg0, reg0, at); |
| 365 |
| 366 // hash = hash + (hash << 2); |
| 367 sll(at, reg0, 2); |
| 368 addu(reg0, reg0, at); |
| 369 |
| 370 // hash = hash ^ (hash >> 4); |
| 371 srl(at, reg0, 4); |
| 372 xor_(reg0, reg0, at); |
| 373 |
| 374 // hash = hash * 2057; |
| 375 li(scratch, Operand(2057)); |
| 376 mul(reg0, reg0, scratch); |
| 377 |
| 378 // hash = hash ^ (hash >> 16); |
| 379 srl(at, reg0, 16); |
| 380 xor_(reg0, reg0, at); |
| 381 } |
| 382 |
| 383 |
346 void MacroAssembler::LoadFromNumberDictionary(Label* miss, | 384 void MacroAssembler::LoadFromNumberDictionary(Label* miss, |
347 Register elements, | 385 Register elements, |
348 Register key, | 386 Register key, |
349 Register result, | 387 Register result, |
350 Register reg0, | 388 Register reg0, |
351 Register reg1, | 389 Register reg1, |
352 Register reg2) { | 390 Register reg2) { |
353 // Register use: | 391 // Register use: |
354 // | 392 // |
355 // elements - holds the slow-case elements of the receiver on entry. | 393 // elements - holds the slow-case elements of the receiver on entry. |
(...skipping 11 matching lines...) Expand all Loading... |
367 // Scratch registers: | 405 // Scratch registers: |
368 // | 406 // |
369 // reg0 - holds the untagged key on entry and holds the hash once computed. | 407 // reg0 - holds the untagged key on entry and holds the hash once computed. |
370 // | 408 // |
371 // reg1 - Used to hold the capacity mask of the dictionary. | 409 // reg1 - Used to hold the capacity mask of the dictionary. |
372 // | 410 // |
373 // reg2 - Used for the index into the dictionary. | 411 // reg2 - Used for the index into the dictionary. |
374 // at - Temporary (avoid MacroAssembler instructions also using 'at'). | 412 // at - Temporary (avoid MacroAssembler instructions also using 'at'). |
375 Label done; | 413 Label done; |
376 | 414 |
377 // Compute the hash code from the untagged key. This must be kept in sync | 415 GetNumberHash(reg0, reg1); |
378 // with ComputeIntegerHash in utils.h. | |
379 // | |
380 // hash = ~hash + (hash << 15); | |
381 nor(reg1, reg0, zero_reg); | |
382 sll(at, reg0, 15); | |
383 addu(reg0, reg1, at); | |
384 | |
385 // hash = hash ^ (hash >> 12); | |
386 srl(at, reg0, 12); | |
387 xor_(reg0, reg0, at); | |
388 | |
389 // hash = hash + (hash << 2); | |
390 sll(at, reg0, 2); | |
391 addu(reg0, reg0, at); | |
392 | |
393 // hash = hash ^ (hash >> 4); | |
394 srl(at, reg0, 4); | |
395 xor_(reg0, reg0, at); | |
396 | |
397 // hash = hash * 2057; | |
398 li(reg1, Operand(2057)); | |
399 mul(reg0, reg0, reg1); | |
400 | |
401 // hash = hash ^ (hash >> 16); | |
402 srl(at, reg0, 16); | |
403 xor_(reg0, reg0, at); | |
404 | 416 |
405 // Compute the capacity mask. | 417 // Compute the capacity mask. |
406 lw(reg1, FieldMemOperand(elements, NumberDictionary::kCapacityOffset)); | 418 lw(reg1, FieldMemOperand(elements, NumberDictionary::kCapacityOffset)); |
407 sra(reg1, reg1, kSmiTagSize); | 419 sra(reg1, reg1, kSmiTagSize); |
408 Subu(reg1, reg1, Operand(1)); | 420 Subu(reg1, reg1, Operand(1)); |
409 | 421 |
410 // Generate an unrolled loop that performs a few probes before giving up. | 422 // Generate an unrolled loop that performs a few probes before giving up. |
411 static const int kProbes = 4; | 423 static const int kProbes = 4; |
412 for (int i = 0; i < kProbes; i++) { | 424 for (int i = 0; i < kProbes; i++) { |
413 // Use reg2 for index calculations and keep the hash intact in reg0. | 425 // Use reg2 for index calculations and keep the hash intact in reg0. |
(...skipping 3989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4403 opcode == BGTZL); | 4415 opcode == BGTZL); |
4404 opcode = (cond == eq) ? BEQ : BNE; | 4416 opcode = (cond == eq) ? BEQ : BNE; |
4405 instr = (instr & ~kOpcodeMask) | opcode; | 4417 instr = (instr & ~kOpcodeMask) | opcode; |
4406 masm_.emit(instr); | 4418 masm_.emit(instr); |
4407 } | 4419 } |
4408 | 4420 |
4409 | 4421 |
4410 } } // namespace v8::internal | 4422 } } // namespace v8::internal |
4411 | 4423 |
4412 #endif // V8_TARGET_ARCH_MIPS | 4424 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |