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

Side by Side Diff: src/ia32/ic-ia32.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/ia32/full-codegen-ia32.cc ('k') | src/ia32/macro-assembler-ia32.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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 __ test(hash, Immediate(String::kContainsCachedArrayIndexMask)); 512 __ test(hash, Immediate(String::kContainsCachedArrayIndexMask));
513 __ j(zero, index_string, not_taken); 513 __ j(zero, index_string, not_taken);
514 514
515 // Is the string a symbol? 515 // Is the string a symbol?
516 ASSERT(kSymbolTag != 0); 516 ASSERT(kSymbolTag != 0);
517 __ test_b(FieldOperand(map, Map::kInstanceTypeOffset), kIsSymbolMask); 517 __ test_b(FieldOperand(map, Map::kInstanceTypeOffset), kIsSymbolMask);
518 __ j(zero, not_symbol, not_taken); 518 __ j(zero, not_symbol, not_taken);
519 } 519 }
520 520
521 521
522 // Picks out an array index from the hash field.
523 static void GenerateIndexFromHash(MacroAssembler* masm,
524 Register key,
525 Register hash) {
526 // Register use:
527 // key - holds the overwritten key on exit.
528 // hash - holds the key's hash. Clobbered.
529
530 // The assert checks that the constants for the maximum number of digits
531 // for an array index cached in the hash field and the number of bits
532 // reserved for it does not conflict.
533 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
534 (1 << String::kArrayIndexValueBits));
535 // We want the smi-tagged index in key. kArrayIndexValueMask has zeros in
536 // the low kHashShift bits.
537 ASSERT(String::kHashShift >= kSmiTagSize);
538 __ and_(hash, String::kArrayIndexValueMask);
539 __ shr(hash, String::kHashShift - kSmiTagSize);
540 // Here we actually clobber the key which will be used if calling into
541 // runtime later. However as the new key is the numeric value of a string key
542 // there is no difference in using either key.
543 __ mov(key, hash);
544 }
545
546
547 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { 522 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
548 // ----------- S t a t e ------------- 523 // ----------- S t a t e -------------
549 // -- eax : key 524 // -- eax : key
550 // -- edx : receiver 525 // -- edx : receiver
551 // -- esp[0] : return address 526 // -- esp[0] : return address
552 // ----------------------------------- 527 // -----------------------------------
553 Label slow, check_string, index_smi, index_string, property_array_property; 528 Label slow, check_string, index_smi, index_string, property_array_property;
554 Label check_pixel_array, probe_dictionary, check_number_dictionary; 529 Label check_pixel_array, probe_dictionary, check_number_dictionary;
555 530
556 // Check that the key is a smi. 531 // Check that the key is a smi.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 672
698 __ mov(ecx, FieldOperand(edx, JSObject::kMapOffset)); 673 __ mov(ecx, FieldOperand(edx, JSObject::kMapOffset));
699 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); 674 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset));
700 GenerateGlobalInstanceTypeCheck(masm, ecx, &slow); 675 GenerateGlobalInstanceTypeCheck(masm, ecx, &slow);
701 676
702 GenerateDictionaryLoad(masm, &slow, ebx, eax, ecx, edi, eax); 677 GenerateDictionaryLoad(masm, &slow, ebx, eax, ecx, edi, eax);
703 __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1); 678 __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1);
704 __ ret(0); 679 __ ret(0);
705 680
706 __ bind(&index_string); 681 __ bind(&index_string);
707 GenerateIndexFromHash(masm, eax, ebx); 682 __ IndexFromHash(ebx, eax);
708 // Now jump to the place where smi keys are handled. 683 // Now jump to the place where smi keys are handled.
709 __ jmp(&index_smi); 684 __ jmp(&index_smi);
710 } 685 }
711 686
712 687
713 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { 688 void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
714 // ----------- S t a t e ------------- 689 // ----------- S t a t e -------------
715 // -- eax : key (index) 690 // -- eax : key (index)
716 // -- edx : receiver 691 // -- edx : receiver
717 // -- esp[0] : return address 692 // -- esp[0] : return address
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 // This branch is taken if: 1533 // This branch is taken if:
1559 // - the receiver requires boxing or access check, 1534 // - the receiver requires boxing or access check,
1560 // - the key is neither smi nor symbol, 1535 // - the key is neither smi nor symbol,
1561 // - the value loaded is not a function, 1536 // - the value loaded is not a function,
1562 // - there is hope that the runtime will create a monomorphic call stub 1537 // - there is hope that the runtime will create a monomorphic call stub
1563 // that will get fetched next time. 1538 // that will get fetched next time.
1564 __ IncrementCounter(&Counters::keyed_call_generic_slow, 1); 1539 __ IncrementCounter(&Counters::keyed_call_generic_slow, 1);
1565 GenerateMiss(masm, argc); 1540 GenerateMiss(masm, argc);
1566 1541
1567 __ bind(&index_string); 1542 __ bind(&index_string);
1568 GenerateIndexFromHash(masm, ecx, ebx); 1543 __ IndexFromHash(ebx, ecx);
1569 // Now jump to the place where smi keys are handled. 1544 // Now jump to the place where smi keys are handled.
1570 __ jmp(&index_smi); 1545 __ jmp(&index_smi);
1571 } 1546 }
1572 1547
1573 1548
1574 void KeyedCallIC::GenerateNormal(MacroAssembler* masm, int argc) { 1549 void KeyedCallIC::GenerateNormal(MacroAssembler* masm, int argc) {
1575 // ----------- S t a t e ------------- 1550 // ----------- S t a t e -------------
1576 // -- ecx : name 1551 // -- ecx : name
1577 // -- esp[0] : return address 1552 // -- esp[0] : return address
1578 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 1553 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 ExternalReference ref = ExternalReference(IC_Utility(kKeyedStoreIC_Miss)); 1953 ExternalReference ref = ExternalReference(IC_Utility(kKeyedStoreIC_Miss));
1979 __ TailCallExternalReference(ref, 3, 1); 1954 __ TailCallExternalReference(ref, 3, 1);
1980 } 1955 }
1981 1956
1982 #undef __ 1957 #undef __
1983 1958
1984 1959
1985 } } // namespace v8::internal 1960 } } // namespace v8::internal
1986 1961
1987 #endif // V8_TARGET_ARCH_IA32 1962 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698