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

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

Issue 3141022: Using array index hash code for string-to-number conversion. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 3 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
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 __ j(zero, index_string); // The value in hash is used at jump target. 565 __ j(zero, index_string); // The value in hash is used at jump target.
566 566
567 // Is the string a symbol? 567 // Is the string a symbol?
568 ASSERT(kSymbolTag != 0); 568 ASSERT(kSymbolTag != 0);
569 __ testb(FieldOperand(map, Map::kInstanceTypeOffset), 569 __ testb(FieldOperand(map, Map::kInstanceTypeOffset),
570 Immediate(kIsSymbolMask)); 570 Immediate(kIsSymbolMask));
571 __ j(zero, not_symbol); 571 __ j(zero, not_symbol);
572 } 572 }
573 573
574 574
575 // Picks out an array index from the hash field.
576 static void GenerateIndexFromHash(MacroAssembler* masm,
577 Register key,
578 Register hash) {
579 // Register use:
580 // key - holds the overwritten key on exit.
581 // hash - holds the key's hash. Clobbered.
582
583 // The assert checks that the constants for the maximum number of digits
584 // for an array index cached in the hash field and the number of bits
585 // reserved for it does not conflict.
586 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
587 (1 << String::kArrayIndexValueBits));
588 // We want the smi-tagged index in key. Even if we subsequently go to
589 // the slow case, converting the key to a smi is always valid.
590 // key: string key
591 // hash: key's hash field, including its array index value.
592 __ and_(hash, Immediate(String::kArrayIndexValueMask));
593 __ shr(hash, Immediate(String::kHashShift));
594 // Here we actually clobber the key which will be used if calling into
595 // runtime later. However as the new key is the numeric value of a string key
596 // there is no difference in using either key.
597 __ Integer32ToSmi(key, hash);
598 }
599
600 575
601 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { 576 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
602 // ----------- S t a t e ------------- 577 // ----------- S t a t e -------------
603 // -- rax : key 578 // -- rax : key
604 // -- rdx : receiver 579 // -- rdx : receiver
605 // -- rsp[0] : return address 580 // -- rsp[0] : return address
606 // ----------------------------------- 581 // -----------------------------------
607 Label slow, check_string, index_smi, index_string, property_array_property; 582 Label slow, check_string, index_smi, index_string, property_array_property;
608 Label check_pixel_array, probe_dictionary, check_number_dictionary; 583 Label check_pixel_array, probe_dictionary, check_number_dictionary;
609 584
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 711
737 __ movq(rcx, FieldOperand(rdx, JSObject::kMapOffset)); 712 __ movq(rcx, FieldOperand(rdx, JSObject::kMapOffset));
738 __ movb(rcx, FieldOperand(rcx, Map::kInstanceTypeOffset)); 713 __ movb(rcx, FieldOperand(rcx, Map::kInstanceTypeOffset));
739 GenerateGlobalInstanceTypeCheck(masm, rcx, &slow); 714 GenerateGlobalInstanceTypeCheck(masm, rcx, &slow);
740 715
741 GenerateDictionaryLoad(masm, &slow, rbx, rax, rcx, rdi, rax); 716 GenerateDictionaryLoad(masm, &slow, rbx, rax, rcx, rdi, rax);
742 __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1); 717 __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1);
743 __ ret(0); 718 __ ret(0);
744 719
745 __ bind(&index_string); 720 __ bind(&index_string);
746 GenerateIndexFromHash(masm, rax, rbx); 721 __ IndexFromHash(rbx, rax);
747 __ jmp(&index_smi); 722 __ jmp(&index_smi);
748 } 723 }
749 724
750 725
751 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { 726 void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
752 // ----------- S t a t e ------------- 727 // ----------- S t a t e -------------
753 // -- rax : key 728 // -- rax : key
754 // -- rdx : receiver 729 // -- rdx : receiver
755 // -- rsp[0] : return address 730 // -- rsp[0] : return address
756 // ----------------------------------- 731 // -----------------------------------
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 // This branch is taken if: 1567 // This branch is taken if:
1593 // - the receiver requires boxing or access check, 1568 // - the receiver requires boxing or access check,
1594 // - the key is neither smi nor symbol, 1569 // - the key is neither smi nor symbol,
1595 // - the value loaded is not a function, 1570 // - the value loaded is not a function,
1596 // - there is hope that the runtime will create a monomorphic call stub 1571 // - there is hope that the runtime will create a monomorphic call stub
1597 // that will get fetched next time. 1572 // that will get fetched next time.
1598 __ IncrementCounter(&Counters::keyed_call_generic_slow, 1); 1573 __ IncrementCounter(&Counters::keyed_call_generic_slow, 1);
1599 GenerateMiss(masm, argc); 1574 GenerateMiss(masm, argc);
1600 1575
1601 __ bind(&index_string); 1576 __ bind(&index_string);
1602 GenerateIndexFromHash(masm, rcx, rbx); 1577 __ IndexFromHash(rbx, rcx);
1603 // Now jump to the place where smi keys are handled. 1578 // Now jump to the place where smi keys are handled.
1604 __ jmp(&index_smi); 1579 __ jmp(&index_smi);
1605 } 1580 }
1606 1581
1607 1582
1608 void KeyedCallIC::GenerateNormal(MacroAssembler* masm, int argc) { 1583 void KeyedCallIC::GenerateNormal(MacroAssembler* masm, int argc) {
1609 // ----------- S t a t e ------------- 1584 // ----------- S t a t e -------------
1610 // rcx : function name 1585 // rcx : function name
1611 // rsp[0] : return address 1586 // rsp[0] : return address
1612 // rsp[8] : argument argc 1587 // rsp[8] : argument argc
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 GenerateMiss(masm); 1893 GenerateMiss(masm);
1919 } 1894 }
1920 1895
1921 1896
1922 #undef __ 1897 #undef __
1923 1898
1924 1899
1925 } } // namespace v8::internal 1900 } } // namespace v8::internal
1926 1901
1927 #endif // V8_TARGET_ARCH_X64 1902 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698