OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 // Distinguish sequential and external strings. Only these two string | 515 // Distinguish sequential and external strings. Only these two string |
516 // representations can reach here (slices and flat cons strings have been | 516 // representations can reach here (slices and flat cons strings have been |
517 // reduced to the underlying sequential or external string). | 517 // reduced to the underlying sequential or external string). |
518 Label seq_string; | 518 Label seq_string; |
519 __ bind(&check_sequential); | 519 __ bind(&check_sequential); |
520 STATIC_ASSERT(kSeqStringTag == 0); | 520 STATIC_ASSERT(kSeqStringTag == 0); |
521 __ testb(result, Immediate(kStringRepresentationMask)); | 521 __ testb(result, Immediate(kStringRepresentationMask)); |
522 __ j(zero, &seq_string, Label::kNear); | 522 __ j(zero, &seq_string, Label::kNear); |
523 | 523 |
524 // Handle external strings. | 524 // Handle external strings. |
525 Label ascii_external, done; | 525 Label one_byte_external, done; |
526 if (FLAG_debug_code) { | 526 if (FLAG_debug_code) { |
527 // Assert that we do not have a cons or slice (indirect strings) here. | 527 // Assert that we do not have a cons or slice (indirect strings) here. |
528 // Sequential strings have already been ruled out. | 528 // Sequential strings have already been ruled out. |
529 __ testb(result, Immediate(kIsIndirectStringMask)); | 529 __ testb(result, Immediate(kIsIndirectStringMask)); |
530 __ Assert(zero, kExternalStringExpectedButNotFound); | 530 __ Assert(zero, kExternalStringExpectedButNotFound); |
531 } | 531 } |
532 // Rule out short external strings. | 532 // Rule out short external strings. |
533 STATIC_ASSERT(kShortExternalStringTag != 0); | 533 STATIC_ASSERT(kShortExternalStringTag != 0); |
534 __ testb(result, Immediate(kShortExternalStringTag)); | 534 __ testb(result, Immediate(kShortExternalStringTag)); |
535 __ j(not_zero, call_runtime); | 535 __ j(not_zero, call_runtime); |
536 // Check encoding. | 536 // Check encoding. |
537 STATIC_ASSERT(kTwoByteStringTag == 0); | 537 STATIC_ASSERT(kTwoByteStringTag == 0); |
538 __ testb(result, Immediate(kStringEncodingMask)); | 538 __ testb(result, Immediate(kStringEncodingMask)); |
539 __ movp(result, FieldOperand(string, ExternalString::kResourceDataOffset)); | 539 __ movp(result, FieldOperand(string, ExternalString::kResourceDataOffset)); |
540 __ j(not_equal, &ascii_external, Label::kNear); | 540 __ j(not_equal, &one_byte_external, Label::kNear); |
541 // Two-byte string. | 541 // Two-byte string. |
542 __ movzxwl(result, Operand(result, index, times_2, 0)); | 542 __ movzxwl(result, Operand(result, index, times_2, 0)); |
543 __ jmp(&done, Label::kNear); | 543 __ jmp(&done, Label::kNear); |
544 __ bind(&ascii_external); | 544 __ bind(&one_byte_external); |
545 // Ascii string. | 545 // One-byte string. |
546 __ movzxbl(result, Operand(result, index, times_1, 0)); | 546 __ movzxbl(result, Operand(result, index, times_1, 0)); |
547 __ jmp(&done, Label::kNear); | 547 __ jmp(&done, Label::kNear); |
548 | 548 |
549 // Dispatch on the encoding: ASCII or two-byte. | 549 // Dispatch on the encoding: one-byte or two-byte. |
550 Label ascii; | 550 Label one_byte; |
551 __ bind(&seq_string); | 551 __ bind(&seq_string); |
552 STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0); | 552 STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0); |
553 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); | 553 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); |
554 __ testb(result, Immediate(kStringEncodingMask)); | 554 __ testb(result, Immediate(kStringEncodingMask)); |
555 __ j(not_zero, &ascii, Label::kNear); | 555 __ j(not_zero, &one_byte, Label::kNear); |
556 | 556 |
557 // Two-byte string. | 557 // Two-byte string. |
558 // Load the two-byte character code into the result register. | 558 // Load the two-byte character code into the result register. |
559 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); | 559 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); |
560 __ movzxwl(result, FieldOperand(string, | 560 __ movzxwl(result, FieldOperand(string, |
561 index, | 561 index, |
562 times_2, | 562 times_2, |
563 SeqTwoByteString::kHeaderSize)); | 563 SeqTwoByteString::kHeaderSize)); |
564 __ jmp(&done, Label::kNear); | 564 __ jmp(&done, Label::kNear); |
565 | 565 |
566 // ASCII string. | 566 // One-byte string. |
567 // Load the byte into the result register. | 567 // Load the byte into the result register. |
568 __ bind(&ascii); | 568 __ bind(&one_byte); |
569 __ movzxbl(result, FieldOperand(string, | 569 __ movzxbl(result, FieldOperand(string, |
570 index, | 570 index, |
571 times_1, | 571 times_1, |
572 SeqOneByteString::kHeaderSize)); | 572 SeqOneByteString::kHeaderSize)); |
573 __ bind(&done); | 573 __ bind(&done); |
574 } | 574 } |
575 | 575 |
576 | 576 |
577 void MathExpGenerator::EmitMathExp(MacroAssembler* masm, | 577 void MathExpGenerator::EmitMathExp(MacroAssembler* masm, |
578 XMMRegister input, | 578 XMMRegister input, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 // argument_count_reg_ * times_pointer_size + (receiver - 1) * kPointerSize. | 706 // argument_count_reg_ * times_pointer_size + (receiver - 1) * kPointerSize. |
707 return Operand(base_reg_, argument_count_reg_, times_pointer_size, | 707 return Operand(base_reg_, argument_count_reg_, times_pointer_size, |
708 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); | 708 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); |
709 } | 709 } |
710 } | 710 } |
711 | 711 |
712 | 712 |
713 } } // namespace v8::internal | 713 } } // namespace v8::internal |
714 | 714 |
715 #endif // V8_TARGET_ARCH_X64 | 715 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |