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

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

Issue 661469: Port of changes from r3842 (symbol table probing for two character strings) t... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 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/arm/macro-assembler-arm.cc ('k') | src/objects.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 10696 matching lines...) Expand 10 before | Expand all | Expand 10 after
10707 10707
10708 // Get the two characters forming the sub string. 10708 // Get the two characters forming the sub string.
10709 __ movzx_b(ebx, FieldOperand(eax, SeqAsciiString::kHeaderSize)); 10709 __ movzx_b(ebx, FieldOperand(eax, SeqAsciiString::kHeaderSize));
10710 __ movzx_b(ecx, FieldOperand(edx, SeqAsciiString::kHeaderSize)); 10710 __ movzx_b(ecx, FieldOperand(edx, SeqAsciiString::kHeaderSize));
10711 10711
10712 // Try to lookup two character string in symbol table. If it is not found 10712 // Try to lookup two character string in symbol table. If it is not found
10713 // just allocate a new one. 10713 // just allocate a new one.
10714 Label make_two_character_string, make_flat_ascii_string; 10714 Label make_two_character_string, make_flat_ascii_string;
10715 GenerateTwoCharacterSymbolTableProbe(masm, ebx, ecx, eax, edx, edi, 10715 GenerateTwoCharacterSymbolTableProbe(masm, ebx, ecx, eax, edx, edi,
10716 &make_two_character_string); 10716 &make_two_character_string);
10717 __ IncrementCounter(&Counters::string_add_native, 1);
10717 __ ret(2 * kPointerSize); 10718 __ ret(2 * kPointerSize);
10718 10719
10719 __ bind(&make_two_character_string); 10720 __ bind(&make_two_character_string);
10720 __ Set(ebx, Immediate(2)); 10721 __ Set(ebx, Immediate(2));
10721 __ jmp(&make_flat_ascii_string); 10722 __ jmp(&make_flat_ascii_string);
10722 10723
10723 __ bind(&longer_than_two); 10724 __ bind(&longer_than_two);
10724 // Check if resulting string will be flat. 10725 // Check if resulting string will be flat.
10725 __ cmp(ebx, String::kMinNonFlatLength); 10726 __ cmp(ebx, String::kMinNonFlatLength);
10726 __ j(below, &string_add_flat_result); 10727 __ j(below, &string_add_flat_result);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
10987 10988
10988 // Load the symbol table. 10989 // Load the symbol table.
10989 Register symbol_table = c2; 10990 Register symbol_table = c2;
10990 ExternalReference roots_address = ExternalReference::roots_address(); 10991 ExternalReference roots_address = ExternalReference::roots_address();
10991 __ mov(scratch, Immediate(Heap::kSymbolTableRootIndex)); 10992 __ mov(scratch, Immediate(Heap::kSymbolTableRootIndex));
10992 __ mov(symbol_table, 10993 __ mov(symbol_table,
10993 Operand::StaticArray(scratch, times_pointer_size, roots_address)); 10994 Operand::StaticArray(scratch, times_pointer_size, roots_address));
10994 10995
10995 // Calculate capacity mask from the symbol table capacity. 10996 // Calculate capacity mask from the symbol table capacity.
10996 Register mask = scratch2; 10997 Register mask = scratch2;
10997 static const int kCapacityOffset = 10998 __ mov(mask, FieldOperand(symbol_table, SymbolTable::kCapacityOffset));
10998 FixedArray::kHeaderSize +
10999 SymbolTable::kCapacityIndex * kPointerSize;
11000 __ mov(mask, FieldOperand(symbol_table, kCapacityOffset));
11001 __ SmiUntag(mask); 10999 __ SmiUntag(mask);
11002 __ sub(Operand(mask), Immediate(1)); 11000 __ sub(Operand(mask), Immediate(1));
11003 11001
11004 // Registers 11002 // Registers
11005 // chars: two character string, char 1 in byte 0 and char 2 in byte 1. 11003 // chars: two character string, char 1 in byte 0 and char 2 in byte 1.
11006 // hash: hash of two character string 11004 // hash: hash of two character string
11007 // symbol_table: symbol table 11005 // symbol_table: symbol table
11008 // mask: capacity mask 11006 // mask: capacity mask
11009 // scratch: - 11007 // scratch: -
11010 11008
11011 // Perform a number of probes in the symbol table. 11009 // Perform a number of probes in the symbol table.
11012 static const int kProbes = 4; 11010 static const int kProbes = 4;
11013 Label found_in_symbol_table; 11011 Label found_in_symbol_table;
11014 Label next_probe[kProbes], next_probe_pop_mask[kProbes]; 11012 Label next_probe[kProbes], next_probe_pop_mask[kProbes];
11015 for (int i = 0; i < kProbes; i++) { 11013 for (int i = 0; i < kProbes; i++) {
11016 // Calculate entry in symbol table. 11014 // Calculate entry in symbol table.
11017 __ mov(scratch, hash); 11015 __ mov(scratch, hash);
11018 if (i > 0) { 11016 if (i > 0) {
11019 __ add(Operand(scratch), Immediate(SymbolTable::GetProbeOffset(i))); 11017 __ add(Operand(scratch), Immediate(SymbolTable::GetProbeOffset(i)));
11020 } 11018 }
11021 __ and_(scratch, Operand(mask)); 11019 __ and_(scratch, Operand(mask));
11022 11020
11023 // Load the entry from the symble table. 11021 // Load the entry from the symble table.
11024 Register candidate = scratch; // Scratch register contains candidate. 11022 Register candidate = scratch; // Scratch register contains candidate.
11025 ASSERT_EQ(1, SymbolTableShape::kEntrySize); 11023 ASSERT_EQ(1, SymbolTable::kEntrySize);
11026 static const int kFirstElementOffset =
11027 FixedArray::kHeaderSize +
11028 SymbolTable::kPrefixStartIndex * kPointerSize +
11029 SymbolTableShape::kPrefixSize * kPointerSize;
11030 __ mov(candidate, 11024 __ mov(candidate,
11031 FieldOperand(symbol_table, 11025 FieldOperand(symbol_table,
11032 scratch, 11026 scratch,
11033 times_pointer_size, 11027 times_pointer_size,
11034 kFirstElementOffset)); 11028 SymbolTable::kElementsStartOffset));
11035 11029
11036 // If entry is undefined no string with this hash can be found. 11030 // If entry is undefined no string with this hash can be found.
11037 __ cmp(candidate, Factory::undefined_value()); 11031 __ cmp(candidate, Factory::undefined_value());
11038 __ j(equal, not_found); 11032 __ j(equal, not_found);
11039 11033
11040 // If length is not 2 the string is not a candidate. 11034 // If length is not 2 the string is not a candidate.
11041 __ cmp(FieldOperand(candidate, String::kLengthOffset), Immediate(2)); 11035 __ cmp(FieldOperand(candidate, String::kLengthOffset), Immediate(2));
11042 __ j(not_equal, &next_probe[i]); 11036 __ j(not_equal, &next_probe[i]);
11043 11037
11044 // As we are out of registers save the mask on the stack and use that 11038 // As we are out of registers save the mask on the stack and use that
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
11178 // Get the two characters forming the sub string. 11172 // Get the two characters forming the sub string.
11179 __ SmiUntag(edx); // From index is no longer smi. 11173 __ SmiUntag(edx); // From index is no longer smi.
11180 __ movzx_b(ebx, FieldOperand(eax, edx, times_1, SeqAsciiString::kHeaderSize)); 11174 __ movzx_b(ebx, FieldOperand(eax, edx, times_1, SeqAsciiString::kHeaderSize));
11181 __ movzx_b(ecx, 11175 __ movzx_b(ecx,
11182 FieldOperand(eax, edx, times_1, SeqAsciiString::kHeaderSize + 1)); 11176 FieldOperand(eax, edx, times_1, SeqAsciiString::kHeaderSize + 1));
11183 11177
11184 // Try to lookup two character string in symbol table. 11178 // Try to lookup two character string in symbol table.
11185 Label make_two_character_string; 11179 Label make_two_character_string;
11186 GenerateTwoCharacterSymbolTableProbe(masm, ebx, ecx, eax, edx, edi, 11180 GenerateTwoCharacterSymbolTableProbe(masm, ebx, ecx, eax, edx, edi,
11187 &make_two_character_string); 11181 &make_two_character_string);
11188 __ ret(2 * kPointerSize); 11182 __ ret(3 * kPointerSize);
11189 11183
11190 __ bind(&make_two_character_string); 11184 __ bind(&make_two_character_string);
11191 // Setup registers for allocating the two character string. 11185 // Setup registers for allocating the two character string.
11192 __ mov(eax, Operand(esp, 3 * kPointerSize)); 11186 __ mov(eax, Operand(esp, 3 * kPointerSize));
11193 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); 11187 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
11194 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); 11188 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset));
11195 __ Set(ecx, Immediate(2)); 11189 __ Set(ecx, Immediate(2));
11196 11190
11197 __ bind(&result_longer_than_two); 11191 __ bind(&result_longer_than_two);
11198 // eax: string 11192 // eax: string
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
11384 11378
11385 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 11379 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
11386 // tagged as a small integer. 11380 // tagged as a small integer.
11387 __ bind(&runtime); 11381 __ bind(&runtime);
11388 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 11382 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
11389 } 11383 }
11390 11384
11391 #undef __ 11385 #undef __
11392 11386
11393 } } // namespace v8::internal 11387 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698