From 8f78eb7d4cb76df45f30a765f0a3c3ad6881e452 Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Tue, 1 Mar 2011 08:17:13 +0000 Subject: [PATCH] Minor change to FullCodeGenerator::EmitFastAsciiArrayJoin The counting loop is always run at least once, and checking the loop condition once is sufficient. Review URL: http://codereview.chromium.org/6592010 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6979 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/ia32/full-codegen-ia32.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc index 4255347..563af3d 100644 --- a/src/ia32/full-codegen-ia32.cc +++ b/src/ia32/full-codegen-ia32.cc @@ -3418,7 +3418,7 @@ void FullCodeGenerator::EmitGetCachedArrayIndex(ZoneList* args) { void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList* args) { Label bailout, done, one_char_separator, long_separator, - non_trivial_array, not_size_one_array, loop, loop_condition, + non_trivial_array, not_size_one_array, loop, loop_1, loop_1_condition, loop_2, loop_2_entry, loop_3, loop_3_entry; ASSERT(args->length() == 2); @@ -3460,7 +3460,7 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList* args) { // If the array has length zero, return the empty string. __ mov(array_length, FieldOperand(array, JSArray::kLengthOffset)); - __ sar(array_length, 1); + __ SmiUntag(array_length); __ j(not_zero, &non_trivial_array); __ mov(result_operand, Factory::empty_string()); __ jmp(&done); @@ -3483,14 +3483,15 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList* args) { // Loop condition: while (index < length). // Live loop registers: index, array_length, string, // scratch, string_length, elements. - __ jmp(&loop_condition); + if (FLAG_debug_code) { + __ cmp(index, Operand(array_length)); + __ Assert(less, "No empty arrays here in EmitFastAsciiArrayJoin"); + } __ bind(&loop); - __ cmp(index, Operand(array_length)); - __ j(greater_equal, &done); - - __ mov(string, FieldOperand(elements, index, - times_pointer_size, - FixedArray::kHeaderSize)); + __ mov(string, FieldOperand(elements, + index, + times_pointer_size, + FixedArray::kHeaderSize)); __ test(string, Immediate(kSmiTagMask)); __ j(zero, &bailout); __ mov(scratch, FieldOperand(string, HeapObject::kMapOffset)); @@ -3503,7 +3504,6 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList* args) { FieldOperand(string, SeqAsciiString::kLengthOffset)); __ j(overflow, &bailout); __ add(Operand(index), Immediate(1)); - __ bind(&loop_condition); __ cmp(index, Operand(array_length)); __ j(less, &loop); @@ -3532,7 +3532,7 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList* args) { __ movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); __ and_(scratch, Immediate( kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask)); - __ cmp(scratch, kStringTag | kAsciiStringTag | kSeqStringTag); + __ cmp(scratch, ASCII_STRING_TYPE); __ j(not_equal, &bailout); // Add (separator length times array_length) - separator length -- 2.7.4