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

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: fixed linter issues, use pseudo-random function in test 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
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/mips/macro-assembler-mips.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 Context::SECURITY_TOKEN_INDEX * kPointerSize; 985 Context::SECURITY_TOKEN_INDEX * kPointerSize;
986 mov(scratch, FieldOperand(scratch, token_offset)); 986 mov(scratch, FieldOperand(scratch, token_offset));
987 cmp(scratch, FieldOperand(holder_reg, token_offset)); 987 cmp(scratch, FieldOperand(holder_reg, token_offset));
988 pop(holder_reg); 988 pop(holder_reg);
989 j(not_equal, miss); 989 j(not_equal, miss);
990 990
991 bind(&same_contexts); 991 bind(&same_contexts);
992 } 992 }
993 993
994 994
995 // Compute the hash code from the untagged key. This must be kept in sync
996 // with ComputeIntegerHash in utils.h.
997 //
998 // Note: r0 will contain hash code
999 void MacroAssembler::GetNumberHash(Register r0, Register scratch) {
1000 // Xor original key with a seed.
1001 if (Serializer::enabled()) {
1002 ExternalReference roots_array_start =
1003 ExternalReference::roots_array_start(isolate());
1004 mov(scratch, Immediate(Heap::kStringHashSeedRootIndex));
1005 xor_(r0, Operand::StaticArray(scratch,
1006 times_pointer_size,
1007 roots_array_start));
1008 } else {
1009 int32_t seed = isolate()->heap()->StringHashSeed();
1010 xor_(r0, Immediate(seed));
1011 }
1012
1013 // hash = ~hash + (hash << 15);
1014 mov(scratch, r0);
1015 not_(r0);
1016 shl(scratch, 15);
1017 add(r0, scratch);
1018 // hash = hash ^ (hash >> 12);
1019 mov(scratch, r0);
1020 shr(scratch, 12);
1021 xor_(r0, scratch);
1022 // hash = hash + (hash << 2);
1023 lea(r0, Operand(r0, r0, times_4, 0));
1024 // hash = hash ^ (hash >> 4);
1025 mov(scratch, r0);
1026 shr(scratch, 4);
1027 xor_(r0, scratch);
1028 // hash = hash * 2057;
1029 imul(r0, r0, 2057);
1030 // hash = hash ^ (hash >> 16);
1031 mov(scratch, r0);
1032 shr(scratch, 16);
1033 xor_(r0, scratch);
1034 }
1035
1036
1037
995 void MacroAssembler::LoadFromNumberDictionary(Label* miss, 1038 void MacroAssembler::LoadFromNumberDictionary(Label* miss,
996 Register elements, 1039 Register elements,
997 Register key, 1040 Register key,
998 Register r0, 1041 Register r0,
999 Register r1, 1042 Register r1,
1000 Register r2, 1043 Register r2,
1001 Register result) { 1044 Register result) {
1002 // Register use: 1045 // Register use:
1003 // 1046 //
1004 // elements - holds the slow-case elements of the receiver and is unchanged. 1047 // elements - holds the slow-case elements of the receiver and is unchanged.
1005 // 1048 //
1006 // key - holds the smi key on entry and is unchanged. 1049 // key - holds the smi key on entry and is unchanged.
1007 // 1050 //
1008 // Scratch registers: 1051 // Scratch registers:
1009 // 1052 //
1010 // r0 - holds the untagged key on entry and holds the hash once computed. 1053 // r0 - holds the untagged key on entry and holds the hash once computed.
1011 // 1054 //
1012 // r1 - used to hold the capacity mask of the dictionary 1055 // r1 - used to hold the capacity mask of the dictionary
1013 // 1056 //
1014 // r2 - used for the index into the dictionary. 1057 // r2 - used for the index into the dictionary.
1015 // 1058 //
1016 // result - holds the result on exit if the load succeeds and we fall through. 1059 // result - holds the result on exit if the load succeeds and we fall through.
1017 1060
1018 Label done; 1061 Label done;
1019 1062
1020 // Compute the hash code from the untagged key. This must be kept in sync 1063 GetNumberHash(r0, r1);
1021 // with ComputeIntegerHash in utils.h.
1022 //
1023 // hash = ~hash + (hash << 15);
1024 mov(r1, r0);
1025 not_(r0);
1026 shl(r1, 15);
1027 add(r0, r1);
1028 // hash = hash ^ (hash >> 12);
1029 mov(r1, r0);
1030 shr(r1, 12);
1031 xor_(r0, r1);
1032 // hash = hash + (hash << 2);
1033 lea(r0, Operand(r0, r0, times_4, 0));
1034 // hash = hash ^ (hash >> 4);
1035 mov(r1, r0);
1036 shr(r1, 4);
1037 xor_(r0, r1);
1038 // hash = hash * 2057;
1039 imul(r0, r0, 2057);
1040 // hash = hash ^ (hash >> 16);
1041 mov(r1, r0);
1042 shr(r1, 16);
1043 xor_(r0, r1);
1044 1064
1045 // Compute capacity mask. 1065 // Compute capacity mask.
1046 mov(r1, FieldOperand(elements, NumberDictionary::kCapacityOffset)); 1066 mov(r1, FieldOperand(elements, NumberDictionary::kCapacityOffset));
1047 shr(r1, kSmiTagSize); // convert smi to int 1067 shr(r1, kSmiTagSize); // convert smi to int
1048 dec(r1); 1068 dec(r1);
1049 1069
1050 // Generate an unrolled loop that performs a few probes before giving up. 1070 // Generate an unrolled loop that performs a few probes before giving up.
1051 const int kProbes = 4; 1071 const int kProbes = 4;
1052 for (int i = 0; i < kProbes; i++) { 1072 for (int i = 0; i < kProbes; i++) {
1053 // Use r2 for index calculations and keep the hash intact in r0. 1073 // Use r2 for index calculations and keep the hash intact in r0.
(...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after
2718 cmp(length, Operand(bitmap_scratch, MemoryChunk::kSizeOffset)); 2738 cmp(length, Operand(bitmap_scratch, MemoryChunk::kSizeOffset));
2719 Check(less_equal, "Live Bytes Count overflow chunk size"); 2739 Check(less_equal, "Live Bytes Count overflow chunk size");
2720 } 2740 }
2721 2741
2722 bind(&done); 2742 bind(&done);
2723 } 2743 }
2724 2744
2725 } } // namespace v8::internal 2745 } } // namespace v8::internal
2726 2746
2727 #endif // V8_TARGET_ARCH_IA32 2747 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/mips/macro-assembler-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698