Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 9148006: [objects] seed NumberDictionary (only ia32 now) Base URL: gh:v8/v8@master
Patch Set: added test, decoupled code Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 3368 matching lines...) Expand 10 before | Expand all | Expand 10 after
3379 int token_offset = 3379 int token_offset =
3380 Context::kHeaderSize + Context::SECURITY_TOKEN_INDEX * kPointerSize; 3380 Context::kHeaderSize + Context::SECURITY_TOKEN_INDEX * kPointerSize;
3381 movq(scratch, FieldOperand(scratch, token_offset)); 3381 movq(scratch, FieldOperand(scratch, token_offset));
3382 cmpq(scratch, FieldOperand(kScratchRegister, token_offset)); 3382 cmpq(scratch, FieldOperand(kScratchRegister, token_offset));
3383 j(not_equal, miss); 3383 j(not_equal, miss);
3384 3384
3385 bind(&same_contexts); 3385 bind(&same_contexts);
3386 } 3386 }
3387 3387
3388 3388
3389 void MacroAssembler::GetNumberHash(Register r0, Register scratch) {
3390 // First of all we assign the hash seed to scratch.
3391 LoadRoot(scratch, Heap::kStringHashSeedRootIndex);
3392 SmiToInteger32(scratch, scratch);
3393
3394 // Xor original key with a seed
3395 xorl(r0, scratch);
3396
3397 // Compute the hash code from the untagged key. This must be kept in sync
3398 // with ComputeIntegerHash in utils.h.
3399 //
3400 // hash = ~hash + (hash << 15);
3401 movl(scratch, r0);
3402 notl(r0);
3403 shll(scratch, Immediate(15));
3404 addl(r0, scratch);
3405 // hash = hash ^ (hash >> 12);
3406 movl(scratch, r0);
3407 shrl(scratch, Immediate(12));
3408 xorl(r0, scratch);
3409 // hash = hash + (hash << 2);
3410 leal(r0, Operand(r0, r0, times_4, 0));
3411 // hash = hash ^ (hash >> 4);
3412 movl(scratch, r0);
3413 shrl(scratch, Immediate(4));
3414 xorl(r0, scratch);
3415 // hash = hash * 2057;
3416 imull(r0, r0, Immediate(2057));
3417 // hash = hash ^ (hash >> 16);
3418 movl(scratch, r0);
3419 shrl(scratch, Immediate(16));
3420 xorl(r0, scratch);
3421 }
3422
3423
3424
3389 void MacroAssembler::LoadFromNumberDictionary(Label* miss, 3425 void MacroAssembler::LoadFromNumberDictionary(Label* miss,
3390 Register elements, 3426 Register elements,
3391 Register key, 3427 Register key,
3392 Register r0, 3428 Register r0,
3393 Register r1, 3429 Register r1,
3394 Register r2, 3430 Register r2,
3395 Register result) { 3431 Register result) {
3396 // Register use: 3432 // Register use:
3397 // 3433 //
3398 // elements - holds the slow-case elements of the receiver on entry. 3434 // elements - holds the slow-case elements of the receiver on entry.
(...skipping 10 matching lines...) Expand all
3409 // 3445 //
3410 // r2 - used for the index into the dictionary. 3446 // r2 - used for the index into the dictionary.
3411 // 3447 //
3412 // result - holds the result on exit if the load succeeded. 3448 // result - holds the result on exit if the load succeeded.
3413 // Allowed to be the same as 'key' or 'result'. 3449 // Allowed to be the same as 'key' or 'result'.
3414 // Unchanged on bailout so 'key' or 'result' can be used 3450 // Unchanged on bailout so 'key' or 'result' can be used
3415 // in further computation. 3451 // in further computation.
3416 3452
3417 Label done; 3453 Label done;
3418 3454
3419 // Compute the hash code from the untagged key. This must be kept in sync 3455 GetNumberHash(r0, r1);
3420 // with ComputeIntegerHash in utils.h.
3421 //
3422 // hash = ~hash + (hash << 15);
3423 movl(r1, r0);
3424 notl(r0);
3425 shll(r1, Immediate(15));
3426 addl(r0, r1);
3427 // hash = hash ^ (hash >> 12);
3428 movl(r1, r0);
3429 shrl(r1, Immediate(12));
3430 xorl(r0, r1);
3431 // hash = hash + (hash << 2);
3432 leal(r0, Operand(r0, r0, times_4, 0));
3433 // hash = hash ^ (hash >> 4);
3434 movl(r1, r0);
3435 shrl(r1, Immediate(4));
3436 xorl(r0, r1);
3437 // hash = hash * 2057;
3438 imull(r0, r0, Immediate(2057));
3439 // hash = hash ^ (hash >> 16);
3440 movl(r1, r0);
3441 shrl(r1, Immediate(16));
3442 xorl(r0, r1);
3443 3456
3444 // Compute capacity mask. 3457 // Compute capacity mask.
3445 SmiToInteger32(r1, 3458 SmiToInteger32(r1,
3446 FieldOperand(elements, NumberDictionary::kCapacityOffset)); 3459 FieldOperand(elements, NumberDictionary::kCapacityOffset));
3447 decl(r1); 3460 decl(r1);
3448 3461
3449 // Generate an unrolled loop that performs a few probes before giving up. 3462 // Generate an unrolled loop that performs a few probes before giving up.
3450 const int kProbes = 4; 3463 const int kProbes = 4;
3451 for (int i = 0; i < kProbes; i++) { 3464 for (int i = 0; i < kProbes; i++) {
3452 // Use r2 for index calculations and keep the hash intact in r0. 3465 // Use r2 for index calculations and keep the hash intact in r0.
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
4279 4292
4280 and_(bitmap_scratch, Immediate(~Page::kPageAlignmentMask)); 4293 and_(bitmap_scratch, Immediate(~Page::kPageAlignmentMask));
4281 addl(Operand(bitmap_scratch, MemoryChunk::kLiveBytesOffset), length); 4294 addl(Operand(bitmap_scratch, MemoryChunk::kLiveBytesOffset), length);
4282 4295
4283 bind(&done); 4296 bind(&done);
4284 } 4297 }
4285 4298
4286 } } // namespace v8::internal 4299 } } // namespace v8::internal
4287 4300
4288 #endif // V8_TARGET_ARCH_X64 4301 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698