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

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

Issue 2762008: Track ascii-ness of data in externalized strings. (Closed)
Patch Set: Extended tests. Created 10 years, 6 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/heap.cc ('k') | src/objects.h » ('j') | src/objects-inl.h » ('J')
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 12821 matching lines...) Expand 10 before | Expand all | Expand 10 after
12832 __ Set(ebx, Immediate(Smi::FromInt(2))); 12832 __ Set(ebx, Immediate(Smi::FromInt(2)));
12833 __ jmp(&make_flat_ascii_string); 12833 __ jmp(&make_flat_ascii_string);
12834 12834
12835 __ bind(&longer_than_two); 12835 __ bind(&longer_than_two);
12836 // Check if resulting string will be flat. 12836 // Check if resulting string will be flat.
12837 __ cmp(Operand(ebx), Immediate(Smi::FromInt(String::kMinNonFlatLength))); 12837 __ cmp(Operand(ebx), Immediate(Smi::FromInt(String::kMinNonFlatLength)));
12838 __ j(below, &string_add_flat_result); 12838 __ j(below, &string_add_flat_result);
12839 12839
12840 // If result is not supposed to be flat allocate a cons string object. If both 12840 // If result is not supposed to be flat allocate a cons string object. If both
12841 // strings are ascii the result is an ascii cons string. 12841 // strings are ascii the result is an ascii cons string.
12842 Label non_ascii, allocated; 12842 Label non_ascii, allocated, ascii_data;
12843 __ mov(edi, FieldOperand(eax, HeapObject::kMapOffset)); 12843 __ mov(edi, FieldOperand(eax, HeapObject::kMapOffset));
12844 __ movzx_b(ecx, FieldOperand(edi, Map::kInstanceTypeOffset)); 12844 __ movzx_b(ecx, FieldOperand(edi, Map::kInstanceTypeOffset));
12845 __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset)); 12845 __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset));
12846 __ movzx_b(edi, FieldOperand(edi, Map::kInstanceTypeOffset)); 12846 __ movzx_b(edi, FieldOperand(edi, Map::kInstanceTypeOffset));
12847 __ and_(ecx, Operand(edi)); 12847 __ and_(ecx, Operand(edi));
12848 ASSERT(kStringEncodingMask == kAsciiStringTag); 12848 ASSERT(kStringEncodingMask == kAsciiStringTag);
12849 __ test(ecx, Immediate(kAsciiStringTag)); 12849 __ test(ecx, Immediate(kAsciiStringTag));
12850 __ j(zero, &non_ascii); 12850 __ j(zero, &non_ascii);
12851 __ bind(&ascii_data);
12851 // Allocate an acsii cons string. 12852 // Allocate an acsii cons string.
12852 __ AllocateAsciiConsString(ecx, edi, no_reg, &string_add_runtime); 12853 __ AllocateAsciiConsString(ecx, edi, no_reg, &string_add_runtime);
12853 __ bind(&allocated); 12854 __ bind(&allocated);
12854 // Fill the fields of the cons string. 12855 // Fill the fields of the cons string.
12855 if (FLAG_debug_code) __ AbortIfNotSmi(ebx); 12856 if (FLAG_debug_code) __ AbortIfNotSmi(ebx);
12856 __ mov(FieldOperand(ecx, ConsString::kLengthOffset), ebx); 12857 __ mov(FieldOperand(ecx, ConsString::kLengthOffset), ebx);
12857 __ mov(FieldOperand(ecx, ConsString::kHashFieldOffset), 12858 __ mov(FieldOperand(ecx, ConsString::kHashFieldOffset),
12858 Immediate(String::kEmptyHashField)); 12859 Immediate(String::kEmptyHashField));
12859 __ mov(FieldOperand(ecx, ConsString::kFirstOffset), eax); 12860 __ mov(FieldOperand(ecx, ConsString::kFirstOffset), eax);
12860 __ mov(FieldOperand(ecx, ConsString::kSecondOffset), edx); 12861 __ mov(FieldOperand(ecx, ConsString::kSecondOffset), edx);
12861 __ mov(eax, ecx); 12862 __ mov(eax, ecx);
12862 __ IncrementCounter(&Counters::string_add_native, 1); 12863 __ IncrementCounter(&Counters::string_add_native, 1);
12863 __ ret(2 * kPointerSize); 12864 __ ret(2 * kPointerSize);
12864 __ bind(&non_ascii); 12865 __ bind(&non_ascii);
12866 // At least one of the strings is two-byte. Check whether it happens
12867 // to contain only ascii characters.
12868 // ecx: first instance type AND second instance type.
12869 // edi: second instance type.
12870 __ test(ecx, Immediate(kAsciiDataHintMask));
12871 __ j(not_zero, &ascii_data);
12872 __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset));
12873 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset));
12874 __ xor_(edi, Operand(ecx));
12875 ASSERT(kAsciiStringTag != 0 && kAsciiDataHintTag != 0);
12876 __ and_(edi, kAsciiStringTag | kAsciiDataHintTag);
12877 __ cmp(edi, kAsciiStringTag | kAsciiDataHintTag);
12878 __ j(equal, &ascii_data);
12865 // Allocate a two byte cons string. 12879 // Allocate a two byte cons string.
12866 __ AllocateConsString(ecx, edi, no_reg, &string_add_runtime); 12880 __ AllocateConsString(ecx, edi, no_reg, &string_add_runtime);
12867 __ jmp(&allocated); 12881 __ jmp(&allocated);
12868 12882
12869 // Handle creating a flat result. First check that both strings are not 12883 // Handle creating a flat result. First check that both strings are not
12870 // external strings. 12884 // external strings.
12871 // eax: first string 12885 // eax: first string
12872 // ebx: length of resulting flat string as a smi 12886 // ebx: length of resulting flat string as a smi
12873 // edx: second string 12887 // edx: second string
12874 __ bind(&string_add_flat_result); 12888 __ bind(&string_add_flat_result);
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
13700 masm.GetCode(&desc); 13714 masm.GetCode(&desc);
13701 // Call the function from C++. 13715 // Call the function from C++.
13702 return FUNCTION_CAST<MemCopyFunction>(buffer); 13716 return FUNCTION_CAST<MemCopyFunction>(buffer);
13703 } 13717 }
13704 13718
13705 #undef __ 13719 #undef __
13706 13720
13707 } } // namespace v8::internal 13721 } } // namespace v8::internal
13708 13722
13709 #endif // V8_TARGET_ARCH_IA32 13723 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/objects.h » ('j') | src/objects-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698