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

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

Issue 436001: Remove the different length string types... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years 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/codegen-ia32.cc ('k') | src/ia32/stub-cache-ia32.cc » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "codegen-inl.h" 30 #include "codegen-inl.h"
31 #include "ic-inl.h" 31 #include "ic-inl.h"
32 #include "runtime.h" 32 #include "runtime.h"
33 #include "stub-cache.h" 33 #include "stub-cache.h"
34 #include "utils.h"
34 35
35 namespace v8 { 36 namespace v8 {
36 namespace internal { 37 namespace internal {
37 38
38 // ---------------------------------------------------------------------------- 39 // ----------------------------------------------------------------------------
39 // Static IC stub generators. 40 // Static IC stub generators.
40 // 41 //
41 42
42 #define __ ACCESS_MASM(masm) 43 #define __ ACCESS_MASM(masm)
43 44
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 102
102 // Generate an unrolled loop that performs a few probes before 103 // Generate an unrolled loop that performs a few probes before
103 // giving up. Measurements done on Gmail indicate that 2 probes 104 // giving up. Measurements done on Gmail indicate that 2 probes
104 // cover ~93% of loads from dictionaries. 105 // cover ~93% of loads from dictionaries.
105 static const int kProbes = 4; 106 static const int kProbes = 4;
106 const int kElementsStartOffset = 107 const int kElementsStartOffset =
107 StringDictionary::kHeaderSize + 108 StringDictionary::kHeaderSize +
108 StringDictionary::kElementsStartIndex * kPointerSize; 109 StringDictionary::kElementsStartIndex * kPointerSize;
109 for (int i = 0; i < kProbes; i++) { 110 for (int i = 0; i < kProbes; i++) {
110 // Compute the masked index: (hash + i + i * i) & mask. 111 // Compute the masked index: (hash + i + i * i) & mask.
111 __ mov(r1, FieldOperand(name, String::kLengthOffset)); 112 __ mov(r1, FieldOperand(name, String::kHashFieldOffset));
112 __ shr(r1, String::kHashShift); 113 __ shr(r1, String::kHashShift);
113 if (i > 0) { 114 if (i > 0) {
114 __ add(Operand(r1), Immediate(StringDictionary::GetProbeOffset(i))); 115 __ add(Operand(r1), Immediate(StringDictionary::GetProbeOffset(i)));
115 } 116 }
116 __ and_(r1, Operand(r2)); 117 __ and_(r1, Operand(r2));
117 118
118 // Scale the index by multiplying by the entry size. 119 // Scale the index by multiplying by the entry size.
119 ASSERT(StringDictionary::kEntrySize == 3); 120 ASSERT(StringDictionary::kEntrySize == 3);
120 __ lea(r1, Operand(r1, r1, times_2, 0)); // r1 = r1 * 3 121 __ lea(r1, Operand(r1, r1, times_2, 0)); // r1 = r1 * 3
121 122
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 Label miss; 210 Label miss;
210 211
211 __ mov(eax, Operand(esp, kPointerSize)); 212 __ mov(eax, Operand(esp, kPointerSize));
212 213
213 StubCompiler::GenerateLoadFunctionPrototype(masm, eax, edx, ebx, &miss); 214 StubCompiler::GenerateLoadFunctionPrototype(masm, eax, edx, ebx, &miss);
214 __ bind(&miss); 215 __ bind(&miss);
215 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC); 216 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC);
216 } 217 }
217 218
218 219
219 #ifdef DEBUG
220 // For use in assert below.
221 static int TenToThe(int exponent) {
222 ASSERT(exponent <= 9);
223 ASSERT(exponent >= 1);
224 int answer = 10;
225 for (int i = 1; i < exponent; i++) answer *= 10;
226 return answer;
227 }
228 #endif
229
230
231 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { 220 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
232 // ----------- S t a t e ------------- 221 // ----------- S t a t e -------------
233 // -- esp[0] : return address 222 // -- esp[0] : return address
234 // -- esp[4] : name 223 // -- esp[4] : name
235 // -- esp[8] : receiver 224 // -- esp[8] : receiver
236 // ----------------------------------- 225 // -----------------------------------
237 Label slow, check_string, index_int, index_string, check_pixel_array; 226 Label slow, check_string, index_int, index_string, check_pixel_array;
238 227
239 // Load name and receiver. 228 // Load name and receiver.
240 __ mov(eax, Operand(esp, kPointerSize)); 229 __ mov(eax, Operand(esp, kPointerSize));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 __ bind(&slow); 291 __ bind(&slow);
303 __ IncrementCounter(&Counters::keyed_load_generic_slow, 1); 292 __ IncrementCounter(&Counters::keyed_load_generic_slow, 1);
304 Generate(masm, ExternalReference(Runtime::kKeyedGetProperty)); 293 Generate(masm, ExternalReference(Runtime::kKeyedGetProperty));
305 294
306 __ bind(&check_string); 295 __ bind(&check_string);
307 // The key is not a smi. 296 // The key is not a smi.
308 // Is it a string? 297 // Is it a string?
309 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edx); 298 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edx);
310 __ j(above_equal, &slow); 299 __ j(above_equal, &slow);
311 // Is the string an array index, with cached numeric value? 300 // Is the string an array index, with cached numeric value?
312 __ mov(ebx, FieldOperand(eax, String::kLengthOffset)); 301 __ mov(ebx, FieldOperand(eax, String::kHashFieldOffset));
313 __ test(ebx, Immediate(String::kIsArrayIndexMask)); 302 __ test(ebx, Immediate(String::kIsArrayIndexMask));
314 __ j(not_zero, &index_string, not_taken); 303 __ j(not_zero, &index_string, not_taken);
315 304
316 // If the string is a symbol, do a quick inline probe of the receiver's 305 // If the string is a symbol, do a quick inline probe of the receiver's
317 // dictionary, if it exists. 306 // dictionary, if it exists.
318 __ movzx_b(ebx, FieldOperand(edx, Map::kInstanceTypeOffset)); 307 __ movzx_b(ebx, FieldOperand(edx, Map::kInstanceTypeOffset));
319 __ test(ebx, Immediate(kIsSymbolMask)); 308 __ test(ebx, Immediate(kIsSymbolMask));
320 __ j(zero, &slow, not_taken); 309 __ j(zero, &slow, not_taken);
321 // Probe the dictionary leaving result in ecx. 310 // Probe the dictionary leaving result in ecx.
322 GenerateDictionaryLoad(masm, &slow, ebx, ecx, edx, eax); 311 GenerateDictionaryLoad(masm, &slow, ebx, ecx, edx, eax);
323 GenerateCheckNonObjectOrLoaded(masm, &slow, ecx, edx); 312 GenerateCheckNonObjectOrLoaded(masm, &slow, ecx, edx);
324 __ mov(eax, Operand(ecx)); 313 __ mov(eax, Operand(ecx));
325 __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1); 314 __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1);
326 __ ret(0); 315 __ ret(0);
327 // Array index string: If short enough use cache in length/hash field (ebx). 316 // If the hash field contains an array index pick it out. The assert checks
328 // We assert that there are enough bits in an int32_t after the hash shift 317 // that the constants for the maximum number of digits for an array index
329 // bits have been subtracted to allow space for the length and the cached 318 // cached in the hash field and the number of bits reserved for it does not
330 // array index. 319 // conflict.
331 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < 320 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
332 (1 << (String::kShortLengthShift - String::kHashShift))); 321 (1 << String::kArrayIndexValueBits));
333 __ bind(&index_string); 322 __ bind(&index_string);
334 const int kLengthFieldLimit =
335 (String::kMaxCachedArrayIndexLength + 1) << String::kShortLengthShift;
336 __ cmp(ebx, kLengthFieldLimit);
337 __ j(above_equal, &slow);
338 __ mov(eax, Operand(ebx)); 323 __ mov(eax, Operand(ebx));
339 __ and_(eax, (1 << String::kShortLengthShift) - 1); 324 __ and_(eax, String::kArrayIndexHashMask);
340 __ shr(eax, String::kLongLengthShift); 325 __ shr(eax, String::kHashShift);
341 __ jmp(&index_int); 326 __ jmp(&index_int);
342 } 327 }
343 328
344 329
345 void KeyedLoadIC::GenerateExternalArray(MacroAssembler* masm, 330 void KeyedLoadIC::GenerateExternalArray(MacroAssembler* masm,
346 ExternalArrayType array_type) { 331 ExternalArrayType array_type) {
347 // ----------- S t a t e ------------- 332 // ----------- S t a t e -------------
348 // -- esp[0] : return address 333 // -- esp[0] : return address
349 // -- esp[4] : key 334 // -- esp[4] : key
350 // -- esp[8] : receiver 335 // -- esp[8] : receiver
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 1362
1378 // Do tail-call to runtime routine. 1363 // Do tail-call to runtime routine.
1379 __ TailCallRuntime( 1364 __ TailCallRuntime(
1380 ExternalReference(IC_Utility(kSharedStoreIC_ExtendStorage)), 3, 1); 1365 ExternalReference(IC_Utility(kSharedStoreIC_ExtendStorage)), 3, 1);
1381 } 1366 }
1382 1367
1383 #undef __ 1368 #undef __
1384 1369
1385 1370
1386 } } // namespace v8::internal 1371 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698