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

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

Issue 6592010: Minor change to FullCodeGenerator::EmitFastAsciiArrayJoin... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 10 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3399 matching lines...) Expand 10 before | Expand all | Expand 10 after
3410 3410
3411 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset)); 3411 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset));
3412 __ IndexFromHash(eax, eax); 3412 __ IndexFromHash(eax, eax);
3413 3413
3414 context()->Plug(eax); 3414 context()->Plug(eax);
3415 } 3415 }
3416 3416
3417 3417
3418 void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList<Expression*>* args) { 3418 void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList<Expression*>* args) {
3419 Label bailout, done, one_char_separator, long_separator, 3419 Label bailout, done, one_char_separator, long_separator,
3420 non_trivial_array, not_size_one_array, loop, loop_condition, 3420 non_trivial_array, not_size_one_array, loop,
3421 loop_1, loop_1_condition, loop_2, loop_2_entry, loop_3, loop_3_entry; 3421 loop_1, loop_1_condition, loop_2, loop_2_entry, loop_3, loop_3_entry;
3422 3422
3423 ASSERT(args->length() == 2); 3423 ASSERT(args->length() == 2);
3424 // We will leave the separator on the stack until the end of the function. 3424 // We will leave the separator on the stack until the end of the function.
3425 VisitForStackValue(args->at(1)); 3425 VisitForStackValue(args->at(1));
3426 // Load this to eax (= array) 3426 // Load this to eax (= array)
3427 VisitForAccumulatorValue(args->at(0)); 3427 VisitForAccumulatorValue(args->at(0));
3428 // All aliases of the same register have disjoint lifetimes. 3428 // All aliases of the same register have disjoint lifetimes.
3429 Register array = eax; 3429 Register array = eax;
3430 Register elements = no_reg; // Will be eax. 3430 Register elements = no_reg; // Will be eax.
(...skipping 21 matching lines...) Expand all
3452 __ CmpObjectType(array, JS_ARRAY_TYPE, scratch); 3452 __ CmpObjectType(array, JS_ARRAY_TYPE, scratch);
3453 __ j(not_equal, &bailout); 3453 __ j(not_equal, &bailout);
3454 3454
3455 // Check that the array has fast elements. 3455 // Check that the array has fast elements.
3456 __ test_b(FieldOperand(scratch, Map::kBitField2Offset), 3456 __ test_b(FieldOperand(scratch, Map::kBitField2Offset),
3457 1 << Map::kHasFastElements); 3457 1 << Map::kHasFastElements);
3458 __ j(zero, &bailout); 3458 __ j(zero, &bailout);
3459 3459
3460 // If the array has length zero, return the empty string. 3460 // If the array has length zero, return the empty string.
3461 __ mov(array_length, FieldOperand(array, JSArray::kLengthOffset)); 3461 __ mov(array_length, FieldOperand(array, JSArray::kLengthOffset));
3462 __ sar(array_length, 1); 3462 __ SmiUntag(array_length);
3463 __ j(not_zero, &non_trivial_array); 3463 __ j(not_zero, &non_trivial_array);
3464 __ mov(result_operand, Factory::empty_string()); 3464 __ mov(result_operand, Factory::empty_string());
3465 __ jmp(&done); 3465 __ jmp(&done);
3466 3466
3467 // Save the array length. 3467 // Save the array length.
3468 __ bind(&non_trivial_array); 3468 __ bind(&non_trivial_array);
3469 __ mov(array_length_operand, array_length); 3469 __ mov(array_length_operand, array_length);
3470 3470
3471 // Save the FixedArray containing array's elements. 3471 // Save the FixedArray containing array's elements.
3472 // End of array's live range. 3472 // End of array's live range.
3473 elements = array; 3473 elements = array;
3474 __ mov(elements, FieldOperand(array, JSArray::kElementsOffset)); 3474 __ mov(elements, FieldOperand(array, JSArray::kElementsOffset));
3475 array = no_reg; 3475 array = no_reg;
3476 3476
3477 3477
3478 // Check that all array elements are sequential ASCII strings, and 3478 // Check that all array elements are sequential ASCII strings, and
3479 // accumulate the sum of their lengths, as a smi-encoded value. 3479 // accumulate the sum of their lengths, as a smi-encoded value.
3480 __ Set(index, Immediate(0)); 3480 __ Set(index, Immediate(0));
3481 __ Set(string_length, Immediate(0)); 3481 __ Set(string_length, Immediate(0));
3482 // Loop condition: while (index < length). 3482 // Loop condition: while (index < length).
3483 // Live loop registers: index, array_length, string, 3483 // Live loop registers: index, array_length, string,
3484 // scratch, string_length, elements. 3484 // scratch, string_length, elements.
3485 __ jmp(&loop_condition); 3485 if (FLAG_debug_code) {
3486 __ cmp(index, Operand(array_length));
3487 __ Assert(less, "No empty arrays here in EmitFastAsciiArrayJoin");
3488 }
3486 __ bind(&loop); 3489 __ bind(&loop);
3487 __ cmp(index, Operand(array_length)); 3490 __ mov(string, FieldOperand(elements,
3488 __ j(greater_equal, &done); 3491 index,
3489 3492 times_pointer_size,
3490 __ mov(string, FieldOperand(elements, index, 3493 FixedArray::kHeaderSize));
3491 times_pointer_size,
3492 FixedArray::kHeaderSize));
3493 __ test(string, Immediate(kSmiTagMask)); 3494 __ test(string, Immediate(kSmiTagMask));
3494 __ j(zero, &bailout); 3495 __ j(zero, &bailout);
3495 __ mov(scratch, FieldOperand(string, HeapObject::kMapOffset)); 3496 __ mov(scratch, FieldOperand(string, HeapObject::kMapOffset));
3496 __ movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); 3497 __ movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset));
3497 __ and_(scratch, Immediate( 3498 __ and_(scratch, Immediate(
3498 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask)); 3499 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask));
3499 __ cmp(scratch, kStringTag | kAsciiStringTag | kSeqStringTag); 3500 __ cmp(scratch, kStringTag | kAsciiStringTag | kSeqStringTag);
3500 __ j(not_equal, &bailout); 3501 __ j(not_equal, &bailout);
3501 __ add(string_length, 3502 __ add(string_length,
3502 FieldOperand(string, SeqAsciiString::kLengthOffset)); 3503 FieldOperand(string, SeqAsciiString::kLengthOffset));
3503 __ j(overflow, &bailout); 3504 __ j(overflow, &bailout);
3504 __ add(Operand(index), Immediate(1)); 3505 __ add(Operand(index), Immediate(1));
3505 __ bind(&loop_condition);
3506 __ cmp(index, Operand(array_length)); 3506 __ cmp(index, Operand(array_length));
3507 __ j(less, &loop); 3507 __ j(less, &loop);
3508 3508
3509 // If array_length is 1, return elements[0], a string. 3509 // If array_length is 1, return elements[0], a string.
3510 __ cmp(array_length, 1); 3510 __ cmp(array_length, 1);
3511 __ j(not_equal, &not_size_one_array); 3511 __ j(not_equal, &not_size_one_array);
3512 __ mov(scratch, FieldOperand(elements, FixedArray::kHeaderSize)); 3512 __ mov(scratch, FieldOperand(elements, FixedArray::kHeaderSize));
3513 __ mov(result_operand, scratch); 3513 __ mov(result_operand, scratch);
3514 __ jmp(&done); 3514 __ jmp(&done);
3515 3515
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
4435 // And return. 4435 // And return.
4436 __ ret(0); 4436 __ ret(0);
4437 } 4437 }
4438 4438
4439 4439
4440 #undef __ 4440 #undef __
4441 4441
4442 } } // namespace v8::internal 4442 } } // namespace v8::internal
4443 4443
4444 #endif // V8_TARGET_ARCH_IA32 4444 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698