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

Side by Side Diff: src/x64/ic-x64.cc

Issue 9193015: Further robustify the keyed lookup cache against unlucky hash (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: 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 | Annotate | Revision Log
« src/heap.h ('K') | « src/mips/ic-mips.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 __ movl(rcx, rbx); 460 __ movl(rcx, rbx);
461 __ shr(rcx, Immediate(KeyedLookupCache::kMapHashShift)); 461 __ shr(rcx, Immediate(KeyedLookupCache::kMapHashShift));
462 __ movl(rdi, FieldOperand(rax, String::kHashFieldOffset)); 462 __ movl(rdi, FieldOperand(rax, String::kHashFieldOffset));
463 __ shr(rdi, Immediate(String::kHashShift)); 463 __ shr(rdi, Immediate(String::kHashShift));
464 __ xor_(rcx, rdi); 464 __ xor_(rcx, rdi);
465 int mask = (KeyedLookupCache::kCapacityMask & KeyedLookupCache::kHashMask); 465 int mask = (KeyedLookupCache::kCapacityMask & KeyedLookupCache::kHashMask);
466 __ and_(rcx, Immediate(mask)); 466 __ and_(rcx, Immediate(mask));
467 467
468 // Load the key (consisting of map and symbol) from the cache and 468 // Load the key (consisting of map and symbol) from the cache and
469 // check for match. 469 // check for match.
470 Label try_second_entry, hit_on_first_entry, load_in_object_property; 470 Label load_in_object_property;
471 static const int kEntriesPerBucket = KeyedLookupCache::kEntriesPerBucket;
472 Label hit_on_nth_entry[kEntriesPerBucket];
471 ExternalReference cache_keys 473 ExternalReference cache_keys
472 = ExternalReference::keyed_lookup_cache_keys(masm->isolate()); 474 = ExternalReference::keyed_lookup_cache_keys(masm->isolate());
473 __ movq(rdi, rcx);
474 __ shl(rdi, Immediate(kPointerSizeLog2 + 1));
475 __ LoadAddress(kScratchRegister, cache_keys);
476 __ cmpq(rbx, Operand(kScratchRegister, rdi, times_1, 0));
477 __ j(not_equal, &try_second_entry);
478 __ cmpq(rax, Operand(kScratchRegister, rdi, times_1, kPointerSize));
479 __ j(equal, &hit_on_first_entry);
480 475
481 __ bind(&try_second_entry); 476 for (int i = 0; i < kEntriesPerBucket - 1; i++) {
482 __ cmpq(rbx, Operand(kScratchRegister, rdi, times_1, kPointerSize * 2)); 477 Label try_next_entry;
478 __ movq(rdi, rcx);
479 __ shl(rdi, Immediate(kPointerSizeLog2 + 1));
480 __ LoadAddress(kScratchRegister, cache_keys);
481 int off = kPointerSize * i * 2;
482 __ cmpq(rbx, Operand(kScratchRegister, rdi, times_1, off));
483 __ j(not_equal, &try_next_entry);
484 __ cmpq(rax, Operand(kScratchRegister, rdi, times_1, off + kPointerSize));
485 __ j(equal, &hit_on_nth_entry[i]);
486 __ bind(&try_next_entry);
487 }
488
489 int off = kPointerSize * (kEntriesPerBucket - 1) * 2;
490 __ cmpq(rbx, Operand(kScratchRegister, rdi, times_1, off));
483 __ j(not_equal, &slow); 491 __ j(not_equal, &slow);
484 __ cmpq(rax, Operand(kScratchRegister, rdi, times_1, kPointerSize * 3)); 492 __ cmpq(rax, Operand(kScratchRegister, rdi, times_1, off + kPointerSize));
485 __ j(not_equal, &slow); 493 __ j(not_equal, &slow);
486 494
487 // Get field offset, which is a 32-bit integer. 495 // Get field offset, which is a 32-bit integer.
488 ExternalReference cache_field_offsets 496 ExternalReference cache_field_offsets
489 = ExternalReference::keyed_lookup_cache_field_offsets(masm->isolate()); 497 = ExternalReference::keyed_lookup_cache_field_offsets(masm->isolate());
490 498
491 // Hit on second entry. 499 // Hit on nth entry.
492 __ LoadAddress(kScratchRegister, cache_field_offsets); 500 for (int i = kEntriesPerBucket - 1; i >= 0; i--) {
493 __ addl(rcx, Immediate(1)); 501 __ bind(&hit_on_nth_entry[i]);
494 __ movl(rdi, Operand(kScratchRegister, rcx, times_4, 0)); 502 if (i != 0) {
495 __ movzxbq(rcx, FieldOperand(rbx, Map::kInObjectPropertiesOffset)); 503 __ addl(rcx, Immediate(i));
496 __ subq(rdi, rcx); 504 }
497 __ j(above_equal, &property_array_property); 505 __ LoadAddress(kScratchRegister, cache_field_offsets);
498 __ jmp(&load_in_object_property); 506 __ movl(rdi, Operand(kScratchRegister, rcx, times_4, 0));
499 507 __ movzxbq(rcx, FieldOperand(rbx, Map::kInObjectPropertiesOffset));
500 // Hit on first entry. 508 __ subq(rdi, rcx);
501 __ bind(&hit_on_first_entry); 509 __ j(above_equal, &property_array_property);
502 __ LoadAddress(kScratchRegister, cache_field_offsets); 510 if (i != 0) {
503 __ movl(rdi, Operand(kScratchRegister, rcx, times_4, 0)); 511 __ jmp(&load_in_object_property);
504 __ movzxbq(rcx, FieldOperand(rbx, Map::kInObjectPropertiesOffset)); 512 }
505 __ subq(rdi, rcx); 513 }
506 __ j(above_equal, &property_array_property);
507 514
508 // Load in-object property. 515 // Load in-object property.
509 __ bind(&load_in_object_property); 516 __ bind(&load_in_object_property);
510 __ movzxbq(rcx, FieldOperand(rbx, Map::kInstanceSizeOffset)); 517 __ movzxbq(rcx, FieldOperand(rbx, Map::kInstanceSizeOffset));
511 __ addq(rcx, rdi); 518 __ addq(rcx, rdi);
512 __ movq(rax, FieldOperand(rdx, rcx, times_pointer_size, 0)); 519 __ movq(rax, FieldOperand(rdx, rcx, times_pointer_size, 0));
513 __ IncrementCounter(counters->keyed_load_generic_lookup_cache(), 1); 520 __ IncrementCounter(counters->keyed_load_generic_lookup_cache(), 1);
514 __ ret(0); 521 __ ret(0);
515 522
516 // Load property array property. 523 // Load property array property.
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 Condition cc = *jmp_address == Assembler::kJncShortOpcode 1726 Condition cc = *jmp_address == Assembler::kJncShortOpcode
1720 ? not_zero 1727 ? not_zero
1721 : zero; 1728 : zero;
1722 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); 1729 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc);
1723 } 1730 }
1724 1731
1725 1732
1726 } } // namespace v8::internal 1733 } } // namespace v8::internal
1727 1734
1728 #endif // V8_TARGET_ARCH_X64 1735 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/heap.h ('K') | « src/mips/ic-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698