Index: src/full-codegen/x64/full-codegen-x64.cc |
diff --git a/src/full-codegen/x64/full-codegen-x64.cc b/src/full-codegen/x64/full-codegen-x64.cc |
index 6b99d730c8e32a3bc6df415b1b863a9d33eeff5c..69ca48ff0cbe05739a9218bd48335ca21e49803f 100644 |
--- a/src/full-codegen/x64/full-codegen-x64.cc |
+++ b/src/full-codegen/x64/full-codegen-x64.cc |
@@ -3309,296 +3309,6 @@ void FullCodeGenerator::EmitGetSuperConstructor(CallRuntime* expr) { |
} |
-void FullCodeGenerator::EmitFastOneByteArrayJoin(CallRuntime* expr) { |
- Label bailout, return_result, done, one_char_separator, long_separator, |
- non_trivial_array, not_size_one_array, loop, |
- loop_1, loop_1_condition, loop_2, loop_2_entry, loop_3, loop_3_entry; |
- ZoneList<Expression*>* args = expr->arguments(); |
- DCHECK(args->length() == 2); |
- // We will leave the separator on the stack until the end of the function. |
- VisitForStackValue(args->at(1)); |
- // Load this to rax (= array) |
- VisitForAccumulatorValue(args->at(0)); |
- // All aliases of the same register have disjoint lifetimes. |
- Register array = rax; |
- Register elements = no_reg; // Will be rax. |
- |
- Register index = rdx; |
- |
- Register string_length = rcx; |
- |
- Register string = rsi; |
- |
- Register scratch = rbx; |
- |
- Register array_length = rdi; |
- Register result_pos = no_reg; // Will be rdi. |
- |
- Operand separator_operand = Operand(rsp, 2 * kPointerSize); |
- Operand result_operand = Operand(rsp, 1 * kPointerSize); |
- Operand array_length_operand = Operand(rsp, 0 * kPointerSize); |
- // Separator operand is already pushed. Make room for the two |
- // other stack fields, and clear the direction flag in anticipation |
- // of calling CopyBytes. |
- __ subp(rsp, Immediate(2 * kPointerSize)); |
- __ cld(); |
- // Check that the array is a JSArray |
- __ JumpIfSmi(array, &bailout); |
- __ CmpObjectType(array, JS_ARRAY_TYPE, scratch); |
- __ j(not_equal, &bailout); |
- |
- // Check that the array has fast elements. |
- __ CheckFastElements(scratch, &bailout); |
- |
- // Array has fast elements, so its length must be a smi. |
- // If the array has length zero, return the empty string. |
- __ movp(array_length, FieldOperand(array, JSArray::kLengthOffset)); |
- __ SmiCompare(array_length, Smi::FromInt(0)); |
- __ j(not_zero, &non_trivial_array); |
- __ LoadRoot(rax, Heap::kempty_stringRootIndex); |
- __ jmp(&return_result); |
- |
- // Save the array length on the stack. |
- __ bind(&non_trivial_array); |
- __ SmiToInteger32(array_length, array_length); |
- __ movl(array_length_operand, array_length); |
- |
- // Save the FixedArray containing array's elements. |
- // End of array's live range. |
- elements = array; |
- __ movp(elements, FieldOperand(array, JSArray::kElementsOffset)); |
- array = no_reg; |
- |
- |
- // Check that all array elements are sequential one-byte strings, and |
- // accumulate the sum of their lengths, as a smi-encoded value. |
- __ Set(index, 0); |
- __ Set(string_length, 0); |
- // Loop condition: while (index < array_length). |
- // Live loop registers: index(int32), array_length(int32), string(String*), |
- // scratch, string_length(int32), elements(FixedArray*). |
- if (generate_debug_code_) { |
- __ cmpp(index, array_length); |
- __ Assert(below, kNoEmptyArraysHereInEmitFastOneByteArrayJoin); |
- } |
- __ bind(&loop); |
- __ movp(string, FieldOperand(elements, |
- index, |
- times_pointer_size, |
- FixedArray::kHeaderSize)); |
- __ JumpIfSmi(string, &bailout); |
- __ movp(scratch, FieldOperand(string, HeapObject::kMapOffset)); |
- __ movzxbl(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); |
- __ andb(scratch, Immediate( |
- kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask)); |
- __ cmpb(scratch, Immediate(kStringTag | kOneByteStringTag | kSeqStringTag)); |
- __ j(not_equal, &bailout); |
- __ AddSmiField(string_length, |
- FieldOperand(string, SeqOneByteString::kLengthOffset)); |
- __ j(overflow, &bailout); |
- __ incl(index); |
- __ cmpl(index, array_length); |
- __ j(less, &loop); |
- |
- // Live registers: |
- // string_length: Sum of string lengths. |
- // elements: FixedArray of strings. |
- // index: Array length. |
- // array_length: Array length. |
- |
- // If array_length is 1, return elements[0], a string. |
- __ cmpl(array_length, Immediate(1)); |
- __ j(not_equal, ¬_size_one_array); |
- __ movp(rax, FieldOperand(elements, FixedArray::kHeaderSize)); |
- __ jmp(&return_result); |
- |
- __ bind(¬_size_one_array); |
- |
- // End of array_length live range. |
- result_pos = array_length; |
- array_length = no_reg; |
- |
- // Live registers: |
- // string_length: Sum of string lengths. |
- // elements: FixedArray of strings. |
- // index: Array length. |
- |
- // Check that the separator is a sequential one-byte string. |
- __ movp(string, separator_operand); |
- __ JumpIfSmi(string, &bailout); |
- __ movp(scratch, FieldOperand(string, HeapObject::kMapOffset)); |
- __ movzxbl(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); |
- __ andb(scratch, Immediate( |
- kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask)); |
- __ cmpb(scratch, Immediate(kStringTag | kOneByteStringTag | kSeqStringTag)); |
- __ j(not_equal, &bailout); |
- |
- // Live registers: |
- // string_length: Sum of string lengths. |
- // elements: FixedArray of strings. |
- // index: Array length. |
- // string: Separator string. |
- |
- // Add (separator length times (array_length - 1)) to string_length. |
- __ SmiToInteger32(scratch, |
- FieldOperand(string, SeqOneByteString::kLengthOffset)); |
- __ decl(index); |
- __ imull(scratch, index); |
- __ j(overflow, &bailout); |
- __ addl(string_length, scratch); |
- __ j(overflow, &bailout); |
- __ jmp(&bailout); |
- |
- // Bailout for large object allocations. |
- __ cmpl(string_length, Immediate(Page::kMaxRegularHeapObjectSize)); |
- __ j(greater, &bailout); |
- |
- // Live registers and stack values: |
- // string_length: Total length of result string. |
- // elements: FixedArray of strings. |
- __ AllocateOneByteString(result_pos, string_length, scratch, index, string, |
- &bailout); |
- __ movp(result_operand, result_pos); |
- __ leap(result_pos, FieldOperand(result_pos, SeqOneByteString::kHeaderSize)); |
- |
- __ movp(string, separator_operand); |
- __ SmiCompare(FieldOperand(string, SeqOneByteString::kLengthOffset), |
- Smi::FromInt(1)); |
- __ j(equal, &one_char_separator); |
- __ j(greater, &long_separator); |
- |
- |
- // Empty separator case: |
- __ Set(index, 0); |
- __ movl(scratch, array_length_operand); |
- __ jmp(&loop_1_condition); |
- // Loop condition: while (index < array_length). |
- __ bind(&loop_1); |
- // Each iteration of the loop concatenates one string to the result. |
- // Live values in registers: |
- // index: which element of the elements array we are adding to the result. |
- // result_pos: the position to which we are currently copying characters. |
- // elements: the FixedArray of strings we are joining. |
- // scratch: array length. |
- |
- // Get string = array[index]. |
- __ movp(string, FieldOperand(elements, index, |
- times_pointer_size, |
- FixedArray::kHeaderSize)); |
- __ SmiToInteger32(string_length, |
- FieldOperand(string, String::kLengthOffset)); |
- __ leap(string, |
- FieldOperand(string, SeqOneByteString::kHeaderSize)); |
- __ CopyBytes(result_pos, string, string_length); |
- __ incl(index); |
- __ bind(&loop_1_condition); |
- __ cmpl(index, scratch); |
- __ j(less, &loop_1); // Loop while (index < array_length). |
- __ jmp(&done); |
- |
- // Generic bailout code used from several places. |
- __ bind(&bailout); |
- __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
- __ jmp(&return_result); |
- |
- |
- // One-character separator case |
- __ bind(&one_char_separator); |
- // Get the separator one-byte character value. |
- // Register "string" holds the separator. |
- __ movzxbl(scratch, FieldOperand(string, SeqOneByteString::kHeaderSize)); |
- __ Set(index, 0); |
- // Jump into the loop after the code that copies the separator, so the first |
- // element is not preceded by a separator |
- __ jmp(&loop_2_entry); |
- // Loop condition: while (index < length). |
- __ bind(&loop_2); |
- // Each iteration of the loop concatenates one string to the result. |
- // Live values in registers: |
- // elements: The FixedArray of strings we are joining. |
- // index: which element of the elements array we are adding to the result. |
- // result_pos: the position to which we are currently copying characters. |
- // scratch: Separator character. |
- |
- // Copy the separator character to the result. |
- __ movb(Operand(result_pos, 0), scratch); |
- __ incp(result_pos); |
- |
- __ bind(&loop_2_entry); |
- // Get string = array[index]. |
- __ movp(string, FieldOperand(elements, index, |
- times_pointer_size, |
- FixedArray::kHeaderSize)); |
- __ SmiToInteger32(string_length, |
- FieldOperand(string, String::kLengthOffset)); |
- __ leap(string, |
- FieldOperand(string, SeqOneByteString::kHeaderSize)); |
- __ CopyBytes(result_pos, string, string_length); |
- __ incl(index); |
- __ cmpl(index, array_length_operand); |
- __ j(less, &loop_2); // End while (index < length). |
- __ jmp(&done); |
- |
- |
- // Long separator case (separator is more than one character). |
- __ bind(&long_separator); |
- |
- // Make elements point to end of elements array, and index |
- // count from -array_length to zero, so we don't need to maintain |
- // a loop limit. |
- __ movl(index, array_length_operand); |
- __ leap(elements, FieldOperand(elements, index, times_pointer_size, |
- FixedArray::kHeaderSize)); |
- __ negq(index); |
- |
- // Replace separator string with pointer to its first character, and |
- // make scratch be its length. |
- __ movp(string, separator_operand); |
- __ SmiToInteger32(scratch, |
- FieldOperand(string, String::kLengthOffset)); |
- __ leap(string, |
- FieldOperand(string, SeqOneByteString::kHeaderSize)); |
- __ movp(separator_operand, string); |
- |
- // Jump into the loop after the code that copies the separator, so the first |
- // element is not preceded by a separator |
- __ jmp(&loop_3_entry); |
- // Loop condition: while (index < length). |
- __ bind(&loop_3); |
- // Each iteration of the loop concatenates one string to the result. |
- // Live values in registers: |
- // index: which element of the elements array we are adding to the result. |
- // result_pos: the position to which we are currently copying characters. |
- // scratch: Separator length. |
- // separator_operand (rsp[0x10]): Address of first char of separator. |
- |
- // Copy the separator to the result. |
- __ movp(string, separator_operand); |
- __ movl(string_length, scratch); |
- __ CopyBytes(result_pos, string, string_length, 2); |
- |
- __ bind(&loop_3_entry); |
- // Get string = array[index]. |
- __ movp(string, Operand(elements, index, times_pointer_size, 0)); |
- __ SmiToInteger32(string_length, |
- FieldOperand(string, String::kLengthOffset)); |
- __ leap(string, |
- FieldOperand(string, SeqOneByteString::kHeaderSize)); |
- __ CopyBytes(result_pos, string, string_length); |
- __ incq(index); |
- __ j(not_equal, &loop_3); // Loop while (index < 0). |
- |
- __ bind(&done); |
- __ movp(rax, result_operand); |
- |
- __ bind(&return_result); |
- // Drop temp values from the stack, and restore context register. |
- __ addp(rsp, Immediate(3 * kPointerSize)); |
- __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
- context()->Plug(rax); |
-} |
- |
- |
void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) { |
DCHECK(expr->arguments()->length() == 0); |
ExternalReference debug_is_active = |