OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 __ PrepareCallCFunction(2); | 1625 __ PrepareCallCFunction(2); |
1626 __ movq(arg_reg_1, object); | 1626 __ movq(arg_reg_1, object); |
1627 __ movq(arg_reg_2, index, RelocInfo::NONE64); | 1627 __ movq(arg_reg_2, index, RelocInfo::NONE64); |
1628 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); | 1628 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); |
1629 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 1629 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
1630 __ bind(&done); | 1630 __ bind(&done); |
1631 } | 1631 } |
1632 } | 1632 } |
1633 | 1633 |
1634 | 1634 |
| 1635 Operand LCodeGen::BuildSeqStringOperand(Register string, |
| 1636 LOperand* index, |
| 1637 String::Encoding encoding) { |
| 1638 if (index->IsConstantOperand()) { |
| 1639 int offset = ToInteger32(LConstantOperand::cast(index)); |
| 1640 if (encoding == String::TWO_BYTE_ENCODING) { |
| 1641 offset *= kUC16Size; |
| 1642 } |
| 1643 STATIC_ASSERT(kCharSize == 1); |
| 1644 return FieldOperand(string, SeqString::kHeaderSize + offset); |
| 1645 } |
| 1646 return FieldOperand( |
| 1647 string, ToRegister(index), |
| 1648 encoding == String::ONE_BYTE_ENCODING ? times_1 : times_2, |
| 1649 SeqString::kHeaderSize); |
| 1650 } |
| 1651 |
| 1652 |
1635 void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) { | 1653 void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) { |
| 1654 String::Encoding encoding = instr->hydrogen()->encoding(); |
1636 Register string = ToRegister(instr->string()); | 1655 Register string = ToRegister(instr->string()); |
1637 Register index = ToRegister(instr->index()); | |
1638 Register value = ToRegister(instr->value()); | |
1639 String::Encoding encoding = instr->encoding(); | |
1640 | 1656 |
1641 if (FLAG_debug_code) { | 1657 if (FLAG_debug_code) { |
1642 __ push(value); | 1658 __ push(string); |
1643 __ movq(value, FieldOperand(string, HeapObject::kMapOffset)); | 1659 __ movq(string, FieldOperand(string, HeapObject::kMapOffset)); |
1644 __ movzxbq(value, FieldOperand(value, Map::kInstanceTypeOffset)); | 1660 __ movzxbq(string, FieldOperand(string, Map::kInstanceTypeOffset)); |
1645 | 1661 |
1646 __ andb(value, Immediate(kStringRepresentationMask | kStringEncodingMask)); | 1662 __ andb(string, Immediate(kStringRepresentationMask | kStringEncodingMask)); |
1647 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; | 1663 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; |
1648 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; | 1664 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; |
1649 __ cmpq(value, Immediate(encoding == String::ONE_BYTE_ENCODING | 1665 __ cmpq(string, Immediate(encoding == String::ONE_BYTE_ENCODING |
1650 ? one_byte_seq_type : two_byte_seq_type)); | 1666 ? one_byte_seq_type : two_byte_seq_type)); |
1651 __ Check(equal, kUnexpectedStringType); | 1667 __ Check(equal, kUnexpectedStringType); |
1652 __ pop(value); | 1668 __ pop(string); |
1653 } | 1669 } |
1654 | 1670 |
1655 if (encoding == String::ONE_BYTE_ENCODING) { | 1671 Operand operand = BuildSeqStringOperand(string, instr->index(), encoding); |
1656 __ movb(FieldOperand(string, index, times_1, SeqString::kHeaderSize), | 1672 if (instr->value()->IsConstantOperand()) { |
1657 value); | 1673 int value = ToInteger32(LConstantOperand::cast(instr->value())); |
| 1674 ASSERT_LE(0, value); |
| 1675 if (encoding == String::ONE_BYTE_ENCODING) { |
| 1676 ASSERT_LE(value, String::kMaxOneByteCharCode); |
| 1677 __ movb(operand, Immediate(value)); |
| 1678 } else { |
| 1679 ASSERT_LE(value, String::kMaxUtf16CodeUnit); |
| 1680 __ movw(operand, Immediate(value)); |
| 1681 } |
1658 } else { | 1682 } else { |
1659 __ movw(FieldOperand(string, index, times_2, SeqString::kHeaderSize), | 1683 Register value = ToRegister(instr->value()); |
1660 value); | 1684 if (encoding == String::ONE_BYTE_ENCODING) { |
| 1685 __ movb(operand, value); |
| 1686 } else { |
| 1687 __ movw(operand, value); |
| 1688 } |
1661 } | 1689 } |
1662 } | 1690 } |
1663 | 1691 |
1664 | 1692 |
1665 void LCodeGen::DoThrow(LThrow* instr) { | 1693 void LCodeGen::DoThrow(LThrow* instr) { |
1666 __ push(ToRegister(instr->value())); | 1694 __ push(ToRegister(instr->value())); |
1667 CallRuntime(Runtime::kThrow, 1, instr); | 1695 CallRuntime(Runtime::kThrow, 1, instr); |
1668 | 1696 |
1669 if (FLAG_debug_code) { | 1697 if (FLAG_debug_code) { |
1670 Comment("Unreachable code."); | 1698 Comment("Unreachable code."); |
(...skipping 3800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5471 FixedArray::kHeaderSize - kPointerSize)); | 5499 FixedArray::kHeaderSize - kPointerSize)); |
5472 __ bind(&done); | 5500 __ bind(&done); |
5473 } | 5501 } |
5474 | 5502 |
5475 | 5503 |
5476 #undef __ | 5504 #undef __ |
5477 | 5505 |
5478 } } // namespace v8::internal | 5506 } } // namespace v8::internal |
5479 | 5507 |
5480 #endif // V8_TARGET_ARCH_X64 | 5508 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |