OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 3401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3412 int token_offset = | 3412 int token_offset = |
3413 Context::kHeaderSize + Context::SECURITY_TOKEN_INDEX * kPointerSize; | 3413 Context::kHeaderSize + Context::SECURITY_TOKEN_INDEX * kPointerSize; |
3414 movq(scratch, FieldOperand(scratch, token_offset)); | 3414 movq(scratch, FieldOperand(scratch, token_offset)); |
3415 cmpq(scratch, FieldOperand(kScratchRegister, token_offset)); | 3415 cmpq(scratch, FieldOperand(kScratchRegister, token_offset)); |
3416 j(not_equal, miss); | 3416 j(not_equal, miss); |
3417 | 3417 |
3418 bind(&same_contexts); | 3418 bind(&same_contexts); |
3419 } | 3419 } |
3420 | 3420 |
3421 | 3421 |
| 3422 void MacroAssembler::GetNumberHash(Register r0, Register scratch) { |
| 3423 // First of all we assign the hash seed to scratch. |
| 3424 LoadRoot(scratch, Heap::kStringHashSeedRootIndex); |
| 3425 SmiToInteger32(scratch, scratch); |
| 3426 |
| 3427 // Xor original key with a seed. |
| 3428 xorl(r0, scratch); |
| 3429 |
| 3430 // Compute the hash code from the untagged key. This must be kept in sync |
| 3431 // with ComputeIntegerHash in utils.h. |
| 3432 // |
| 3433 // hash = ~hash + (hash << 15); |
| 3434 movl(scratch, r0); |
| 3435 notl(r0); |
| 3436 shll(scratch, Immediate(15)); |
| 3437 addl(r0, scratch); |
| 3438 // hash = hash ^ (hash >> 12); |
| 3439 movl(scratch, r0); |
| 3440 shrl(scratch, Immediate(12)); |
| 3441 xorl(r0, scratch); |
| 3442 // hash = hash + (hash << 2); |
| 3443 leal(r0, Operand(r0, r0, times_4, 0)); |
| 3444 // hash = hash ^ (hash >> 4); |
| 3445 movl(scratch, r0); |
| 3446 shrl(scratch, Immediate(4)); |
| 3447 xorl(r0, scratch); |
| 3448 // hash = hash * 2057; |
| 3449 imull(r0, r0, Immediate(2057)); |
| 3450 // hash = hash ^ (hash >> 16); |
| 3451 movl(scratch, r0); |
| 3452 shrl(scratch, Immediate(16)); |
| 3453 xorl(r0, scratch); |
| 3454 } |
| 3455 |
| 3456 |
| 3457 |
3422 void MacroAssembler::LoadFromNumberDictionary(Label* miss, | 3458 void MacroAssembler::LoadFromNumberDictionary(Label* miss, |
3423 Register elements, | 3459 Register elements, |
3424 Register key, | 3460 Register key, |
3425 Register r0, | 3461 Register r0, |
3426 Register r1, | 3462 Register r1, |
3427 Register r2, | 3463 Register r2, |
3428 Register result) { | 3464 Register result) { |
3429 // Register use: | 3465 // Register use: |
3430 // | 3466 // |
3431 // elements - holds the slow-case elements of the receiver on entry. | 3467 // elements - holds the slow-case elements of the receiver on entry. |
(...skipping 10 matching lines...) Expand all Loading... |
3442 // | 3478 // |
3443 // r2 - used for the index into the dictionary. | 3479 // r2 - used for the index into the dictionary. |
3444 // | 3480 // |
3445 // result - holds the result on exit if the load succeeded. | 3481 // result - holds the result on exit if the load succeeded. |
3446 // Allowed to be the same as 'key' or 'result'. | 3482 // Allowed to be the same as 'key' or 'result'. |
3447 // Unchanged on bailout so 'key' or 'result' can be used | 3483 // Unchanged on bailout so 'key' or 'result' can be used |
3448 // in further computation. | 3484 // in further computation. |
3449 | 3485 |
3450 Label done; | 3486 Label done; |
3451 | 3487 |
3452 // Compute the hash code from the untagged key. This must be kept in sync | 3488 GetNumberHash(r0, r1); |
3453 // with ComputeIntegerHash in utils.h. | |
3454 // | |
3455 // hash = ~hash + (hash << 15); | |
3456 movl(r1, r0); | |
3457 notl(r0); | |
3458 shll(r1, Immediate(15)); | |
3459 addl(r0, r1); | |
3460 // hash = hash ^ (hash >> 12); | |
3461 movl(r1, r0); | |
3462 shrl(r1, Immediate(12)); | |
3463 xorl(r0, r1); | |
3464 // hash = hash + (hash << 2); | |
3465 leal(r0, Operand(r0, r0, times_4, 0)); | |
3466 // hash = hash ^ (hash >> 4); | |
3467 movl(r1, r0); | |
3468 shrl(r1, Immediate(4)); | |
3469 xorl(r0, r1); | |
3470 // hash = hash * 2057; | |
3471 imull(r0, r0, Immediate(2057)); | |
3472 // hash = hash ^ (hash >> 16); | |
3473 movl(r1, r0); | |
3474 shrl(r1, Immediate(16)); | |
3475 xorl(r0, r1); | |
3476 | 3489 |
3477 // Compute capacity mask. | 3490 // Compute capacity mask. |
3478 SmiToInteger32(r1, | 3491 SmiToInteger32(r1, |
3479 FieldOperand(elements, NumberDictionary::kCapacityOffset)); | 3492 FieldOperand(elements, NumberDictionary::kCapacityOffset)); |
3480 decl(r1); | 3493 decl(r1); |
3481 | 3494 |
3482 // Generate an unrolled loop that performs a few probes before giving up. | 3495 // Generate an unrolled loop that performs a few probes before giving up. |
3483 const int kProbes = 4; | 3496 const int kProbes = 4; |
3484 for (int i = 0; i < kProbes; i++) { | 3497 for (int i = 0; i < kProbes; i++) { |
3485 // Use r2 for index calculations and keep the hash intact in r0. | 3498 // Use r2 for index calculations and keep the hash intact in r0. |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4312 | 4325 |
4313 and_(bitmap_scratch, Immediate(~Page::kPageAlignmentMask)); | 4326 and_(bitmap_scratch, Immediate(~Page::kPageAlignmentMask)); |
4314 addl(Operand(bitmap_scratch, MemoryChunk::kLiveBytesOffset), length); | 4327 addl(Operand(bitmap_scratch, MemoryChunk::kLiveBytesOffset), length); |
4315 | 4328 |
4316 bind(&done); | 4329 bind(&done); |
4317 } | 4330 } |
4318 | 4331 |
4319 } } // namespace v8::internal | 4332 } } // namespace v8::internal |
4320 | 4333 |
4321 #endif // V8_TARGET_ARCH_X64 | 4334 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |