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

Side by Side Diff: src/ia32/stub-cache-ia32.cc

Issue 6932010: Unroll more StringDictionary lookup probes both for positive and negative dictionary lookups. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: ported to arm&x64, cleaned up ia32 impl Created 9 years, 7 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
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 Label* miss_label, 111 Label* miss_label,
112 Register receiver, 112 Register receiver,
113 String* name, 113 String* name,
114 Register r0, 114 Register r0,
115 Register r1) { 115 Register r1) {
116 ASSERT(name->IsSymbol()); 116 ASSERT(name->IsSymbol());
117 Counters* counters = masm->isolate()->counters(); 117 Counters* counters = masm->isolate()->counters();
118 __ IncrementCounter(counters->negative_lookups(), 1); 118 __ IncrementCounter(counters->negative_lookups(), 1);
119 __ IncrementCounter(counters->negative_lookups_miss(), 1); 119 __ IncrementCounter(counters->negative_lookups_miss(), 1);
120 120
121 Label done;
122 __ mov(r0, FieldOperand(receiver, HeapObject::kMapOffset)); 121 __ mov(r0, FieldOperand(receiver, HeapObject::kMapOffset));
123 122
124 const int kInterceptorOrAccessCheckNeededMask = 123 const int kInterceptorOrAccessCheckNeededMask =
125 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); 124 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded);
126 125
127 // Bail out if the receiver has a named interceptor or requires access checks. 126 // Bail out if the receiver has a named interceptor or requires access checks.
128 __ test_b(FieldOperand(r0, Map::kBitFieldOffset), 127 __ test_b(FieldOperand(r0, Map::kBitFieldOffset),
129 kInterceptorOrAccessCheckNeededMask); 128 kInterceptorOrAccessCheckNeededMask);
130 __ j(not_zero, miss_label, not_taken); 129 __ j(not_zero, miss_label, not_taken);
131 130
132 // Check that receiver is a JSObject. 131 // Check that receiver is a JSObject.
133 __ CmpInstanceType(r0, FIRST_JS_OBJECT_TYPE); 132 __ CmpInstanceType(r0, FIRST_JS_OBJECT_TYPE);
134 __ j(below, miss_label, not_taken); 133 __ j(below, miss_label, not_taken);
135 134
136 // Load properties array. 135 // Load properties array.
137 Register properties = r0; 136 Register properties = r0;
138 __ mov(properties, FieldOperand(receiver, JSObject::kPropertiesOffset)); 137 __ mov(properties, FieldOperand(receiver, JSObject::kPropertiesOffset));
139 138
140 // Check that the properties array is a dictionary. 139 // Check that the properties array is a dictionary.
141 __ cmp(FieldOperand(properties, HeapObject::kMapOffset), 140 __ cmp(FieldOperand(properties, HeapObject::kMapOffset),
142 Immediate(masm->isolate()->factory()->hash_table_map())); 141 Immediate(masm->isolate()->factory()->hash_table_map()));
143 __ j(not_equal, miss_label); 142 __ j(not_equal, miss_label);
144 143
145 // Compute the capacity mask. 144 Label done;
146 const int kCapacityOffset = 145 StringDictionaryLookupStub::GenerateNegativeLookup(masm,
147 StringDictionary::kHeaderSize + 146 miss_label,
148 StringDictionary::kCapacityIndex * kPointerSize; 147 &done,
149 148 properties,
150 // Generate an unrolled loop that performs a few probes before 149 name,
151 // giving up. 150 r1);
152 static const int kProbes = 4;
153 const int kElementsStartOffset =
154 StringDictionary::kHeaderSize +
155 StringDictionary::kElementsStartIndex * kPointerSize;
156
157 // If names of slots in range from 1 to kProbes - 1 for the hash value are
158 // not equal to the name and kProbes-th slot is not used (its name is the
159 // undefined value), it guarantees the hash table doesn't contain the
160 // property. It's true even if some slots represent deleted properties
161 // (their names are the null value).
162 for (int i = 0; i < kProbes; i++) {
163 // r0 points to properties hash.
164 // Compute the masked index: (hash + i + i * i) & mask.
165 Register index = r1;
166 // Capacity is smi 2^n.
167 __ mov(index, FieldOperand(properties, kCapacityOffset));
168 __ dec(index);
169 __ and_(Operand(index),
170 Immediate(Smi::FromInt(name->Hash() +
171 StringDictionary::GetProbeOffset(i))));
172
173 // Scale the index by multiplying by the entry size.
174 ASSERT(StringDictionary::kEntrySize == 3);
175 __ lea(index, Operand(index, index, times_2, 0)); // index *= 3.
176
177 Register entity_name = r1;
178 // Having undefined at this place means the name is not contained.
179 ASSERT_EQ(kSmiTagSize, 1);
180 __ mov(entity_name, Operand(properties, index, times_half_pointer_size,
181 kElementsStartOffset - kHeapObjectTag));
182 __ cmp(entity_name, masm->isolate()->factory()->undefined_value());
183 if (i != kProbes - 1) {
184 __ j(equal, &done, taken);
185
186 // Stop if found the property.
187 __ cmp(entity_name, Handle<String>(name));
188 __ j(equal, miss_label, not_taken);
189
190 // Check if the entry name is not a symbol.
191 __ mov(entity_name, FieldOperand(entity_name, HeapObject::kMapOffset));
192 __ test_b(FieldOperand(entity_name, Map::kInstanceTypeOffset),
193 kIsSymbolMask);
194 __ j(zero, miss_label, not_taken);
195 } else {
196 // Give up probing if still not found the undefined value.
197 __ j(not_equal, miss_label, not_taken);
198 }
199 }
200
201 __ bind(&done); 151 __ bind(&done);
202 __ DecrementCounter(counters->negative_lookups_miss(), 1); 152 __ DecrementCounter(counters->negative_lookups_miss(), 1);
203 } 153 }
204 154
205 155
206 void StubCache::GenerateProbe(MacroAssembler* masm, 156 void StubCache::GenerateProbe(MacroAssembler* masm,
207 Code::Flags flags, 157 Code::Flags flags,
208 Register receiver, 158 Register receiver,
209 Register name, 159 Register name,
210 Register scratch, 160 Register scratch,
(...skipping 3504 matching lines...) Expand 10 before | Expand all | Expand 10 after
3715 3665
3716 return GetCode(flags); 3666 return GetCode(flags);
3717 } 3667 }
3718 3668
3719 3669
3720 #undef __ 3670 #undef __
3721 3671
3722 } } // namespace v8::internal 3672 } } // namespace v8::internal
3723 3673
3724 #endif // V8_TARGET_ARCH_IA32 3674 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698