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

Side by Side Diff: src/ia32/macro-assembler-ia32.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 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 Context::SECURITY_TOKEN_INDEX * kPointerSize; 952 Context::SECURITY_TOKEN_INDEX * kPointerSize;
953 mov(scratch, FieldOperand(scratch, token_offset)); 953 mov(scratch, FieldOperand(scratch, token_offset));
954 cmp(scratch, FieldOperand(holder_reg, token_offset)); 954 cmp(scratch, FieldOperand(holder_reg, token_offset));
955 pop(holder_reg); 955 pop(holder_reg);
956 j(not_equal, miss); 956 j(not_equal, miss);
957 957
958 bind(&same_contexts); 958 bind(&same_contexts);
959 } 959 }
960 960
961 961
962 // Compute the hash code from the untagged key. This must be kept in sync
963 // with ComputeIntegerHash in utils.h.
964 //
965 // Note: r0 will contain hash code
966 void MacroAssembler::GetNumberHash(Register r0, Register scratch) {
967 // First of all we assign the hash seed to scratch.
968 if (Serializer::enabled()) {
969 ExternalReference roots_array_start =
970 ExternalReference::roots_array_start(isolate());
971 mov(scratch, Immediate(Heap::kStringHashSeedRootIndex));
972 mov(scratch, Operand::StaticArray(scratch,
973 times_pointer_size,
974 roots_array_start));
975 } else {
976 int32_t seed = isolate()->heap()->StringHashSeed();
977 mov(scratch, Immediate(seed));
978 }
979
980 // Xor original key with a seed
981 xor_(r0, scratch);
Erik Corry 2012/01/10 11:53:16 You should move this xor up into the if above, bec
982
983 // hash = ~hash + (hash << 15);
984 mov(scratch, r0);
985 not_(r0);
986 shl(scratch, 15);
987 add(r0, scratch);
988 // hash = hash ^ (hash >> 12);
989 mov(scratch, r0);
990 shr(scratch, 12);
991 xor_(r0, scratch);
992 // hash = hash + (hash << 2);
993 lea(r0, Operand(r0, r0, times_4, 0));
994 // hash = hash ^ (hash >> 4);
995 mov(scratch, r0);
996 shr(scratch, 4);
997 xor_(r0, scratch);
998 // hash = hash * 2057;
999 imul(r0, r0, 2057);
1000 // hash = hash ^ (hash >> 16);
1001 mov(scratch, r0);
1002 shr(scratch, 16);
1003 xor_(r0, scratch);
1004 }
1005
1006
1007
962 void MacroAssembler::LoadFromNumberDictionary(Label* miss, 1008 void MacroAssembler::LoadFromNumberDictionary(Label* miss,
963 Register elements, 1009 Register elements,
964 Register key, 1010 Register key,
965 Register r0, 1011 Register r0,
966 Register r1, 1012 Register r1,
967 Register r2, 1013 Register r2,
968 Register result) { 1014 Register result) {
969 // Register use: 1015 // Register use:
970 // 1016 //
971 // elements - holds the slow-case elements of the receiver and is unchanged. 1017 // elements - holds the slow-case elements of the receiver and is unchanged.
972 // 1018 //
973 // key - holds the smi key on entry and is unchanged. 1019 // key - holds the smi key on entry and is unchanged.
974 // 1020 //
975 // Scratch registers: 1021 // Scratch registers:
976 // 1022 //
977 // r0 - holds the untagged key on entry and holds the hash once computed. 1023 // r0 - holds the untagged key on entry and holds the hash once computed.
978 // 1024 //
979 // r1 - used to hold the capacity mask of the dictionary 1025 // r1 - used to hold the capacity mask of the dictionary
980 // 1026 //
981 // r2 - used for the index into the dictionary. 1027 // r2 - used for the index into the dictionary.
982 // 1028 //
983 // result - holds the result on exit if the load succeeds and we fall through. 1029 // result - holds the result on exit if the load succeeds and we fall through.
984 1030
985 Label done; 1031 Label done;
986 1032
987 // Compute the hash code from the untagged key. This must be kept in sync 1033 GetNumberHash(r0, r1);
988 // with ComputeIntegerHash in utils.h.
989 //
990 // hash = ~hash + (hash << 15);
991 mov(r1, r0);
992 not_(r0);
993 shl(r1, 15);
994 add(r0, r1);
995 // hash = hash ^ (hash >> 12);
996 mov(r1, r0);
997 shr(r1, 12);
998 xor_(r0, r1);
999 // hash = hash + (hash << 2);
1000 lea(r0, Operand(r0, r0, times_4, 0));
1001 // hash = hash ^ (hash >> 4);
1002 mov(r1, r0);
1003 shr(r1, 4);
1004 xor_(r0, r1);
1005 // hash = hash * 2057;
1006 imul(r0, r0, 2057);
1007 // hash = hash ^ (hash >> 16);
1008 mov(r1, r0);
1009 shr(r1, 16);
1010 xor_(r0, r1);
1011 1034
1012 // Compute capacity mask. 1035 // Compute capacity mask.
1013 mov(r1, FieldOperand(elements, NumberDictionary::kCapacityOffset)); 1036 mov(r1, FieldOperand(elements, NumberDictionary::kCapacityOffset));
1014 shr(r1, kSmiTagSize); // convert smi to int 1037 shr(r1, kSmiTagSize); // convert smi to int
1015 dec(r1); 1038 dec(r1);
1016 1039
1017 // Generate an unrolled loop that performs a few probes before giving up. 1040 // Generate an unrolled loop that performs a few probes before giving up.
1018 const int kProbes = 4; 1041 const int kProbes = 4;
1019 for (int i = 0; i < kProbes; i++) { 1042 for (int i = 0; i < kProbes; i++) {
1020 // Use r2 for index calculations and keep the hash intact in r0. 1043 // Use r2 for index calculations and keep the hash intact in r0.
(...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after
2685 cmp(length, Operand(bitmap_scratch, MemoryChunk::kSizeOffset)); 2708 cmp(length, Operand(bitmap_scratch, MemoryChunk::kSizeOffset));
2686 Check(less_equal, "Live Bytes Count overflow chunk size"); 2709 Check(less_equal, "Live Bytes Count overflow chunk size");
2687 } 2710 }
2688 2711
2689 bind(&done); 2712 bind(&done);
2690 } 2713 }
2691 2714
2692 } } // namespace v8::internal 2715 } } // namespace v8::internal
2693 2716
2694 #endif // V8_TARGET_ARCH_IA32 2717 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698