OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1917 } | 1917 } |
1918 __ bind(&runtime); | 1918 __ bind(&runtime); |
1919 __ PrepareCallCFunction(2, scratch); | 1919 __ PrepareCallCFunction(2, scratch); |
1920 __ mov(r1, Operand(index)); | 1920 __ mov(r1, Operand(index)); |
1921 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); | 1921 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); |
1922 __ bind(&done); | 1922 __ bind(&done); |
1923 } | 1923 } |
1924 } | 1924 } |
1925 | 1925 |
1926 | 1926 |
| 1927 MemOperand LCodeGen::BuildSeqStringOperand(Register string, |
| 1928 LOperand* index, |
| 1929 String::Encoding encoding) { |
| 1930 if (index->IsConstantOperand()) { |
| 1931 int offset = ToInteger32(LConstantOperand::cast(index)); |
| 1932 if (encoding == String::TWO_BYTE_ENCODING) { |
| 1933 offset *= kUC16Size; |
| 1934 } |
| 1935 STATIC_ASSERT(kCharSize == 1); |
| 1936 return FieldMemOperand(string, SeqString::kHeaderSize + offset); |
| 1937 } |
| 1938 Register scratch = scratch0(); |
| 1939 ASSERT(!scratch.is(string)); |
| 1940 ASSERT(!scratch.is(ToRegister(index))); |
| 1941 if (encoding == String::ONE_BYTE_ENCODING) { |
| 1942 __ add(scratch, string, Operand(ToRegister(index))); |
| 1943 } else { |
| 1944 STATIC_ASSERT(kUC16Size == 2); |
| 1945 __ add(scratch, string, Operand(ToRegister(index), LSL, 1)); |
| 1946 } |
| 1947 return FieldMemOperand(scratch, SeqString::kHeaderSize); |
| 1948 } |
| 1949 |
| 1950 |
1927 void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) { | 1951 void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) { |
| 1952 String::Encoding encoding = instr->hydrogen()->encoding(); |
1928 Register string = ToRegister(instr->string()); | 1953 Register string = ToRegister(instr->string()); |
1929 LOperand* index_op = instr->index(); | |
1930 Register value = ToRegister(instr->value()); | 1954 Register value = ToRegister(instr->value()); |
1931 Register scratch = scratch0(); | |
1932 String::Encoding encoding = instr->encoding(); | |
1933 | 1955 |
1934 if (FLAG_debug_code) { | 1956 if (FLAG_debug_code) { |
| 1957 Register scratch = scratch0(); |
1935 __ ldr(scratch, FieldMemOperand(string, HeapObject::kMapOffset)); | 1958 __ ldr(scratch, FieldMemOperand(string, HeapObject::kMapOffset)); |
1936 __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); | 1959 __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); |
1937 | 1960 |
1938 __ and_(scratch, scratch, | 1961 __ and_(scratch, scratch, |
1939 Operand(kStringRepresentationMask | kStringEncodingMask)); | 1962 Operand(kStringRepresentationMask | kStringEncodingMask)); |
1940 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; | 1963 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; |
1941 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; | 1964 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; |
1942 __ cmp(scratch, Operand(encoding == String::ONE_BYTE_ENCODING | 1965 __ cmp(scratch, Operand(encoding == String::ONE_BYTE_ENCODING |
1943 ? one_byte_seq_type : two_byte_seq_type)); | 1966 ? one_byte_seq_type : two_byte_seq_type)); |
1944 __ Check(eq, kUnexpectedStringType); | 1967 __ Check(eq, kUnexpectedStringType); |
1945 } | 1968 } |
1946 | 1969 |
1947 if (index_op->IsConstantOperand()) { | 1970 MemOperand operand = BuildSeqStringOperand(string, instr->index(), encoding); |
1948 int constant_index = ToInteger32(LConstantOperand::cast(index_op)); | 1971 if (encoding == String::ONE_BYTE_ENCODING) { |
1949 if (encoding == String::ONE_BYTE_ENCODING) { | 1972 __ strb(value, operand); |
1950 __ strb(value, | |
1951 FieldMemOperand(string, SeqString::kHeaderSize + constant_index)); | |
1952 } else { | |
1953 __ strh(value, | |
1954 FieldMemOperand(string, SeqString::kHeaderSize + constant_index * 2)); | |
1955 } | |
1956 } else { | 1973 } else { |
1957 Register index = ToRegister(index_op); | 1974 __ strh(value, operand); |
1958 if (encoding == String::ONE_BYTE_ENCODING) { | |
1959 __ add(scratch, string, Operand(index)); | |
1960 __ strb(value, FieldMemOperand(scratch, SeqString::kHeaderSize)); | |
1961 } else { | |
1962 __ add(scratch, string, Operand(index, LSL, 1)); | |
1963 __ strh(value, FieldMemOperand(scratch, SeqString::kHeaderSize)); | |
1964 } | |
1965 } | 1975 } |
1966 } | 1976 } |
1967 | 1977 |
1968 | 1978 |
1969 void LCodeGen::DoThrow(LThrow* instr) { | 1979 void LCodeGen::DoThrow(LThrow* instr) { |
1970 Register input_reg = EmitLoadRegister(instr->value(), ip); | 1980 Register input_reg = EmitLoadRegister(instr->value(), ip); |
1971 __ push(input_reg); | 1981 __ push(input_reg); |
1972 ASSERT(ToRegister(instr->context()).is(cp)); | 1982 ASSERT(ToRegister(instr->context()).is(cp)); |
1973 CallRuntime(Runtime::kThrow, 1, instr); | 1983 CallRuntime(Runtime::kThrow, 1, instr); |
1974 | 1984 |
(...skipping 3851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5826 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 5836 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
5827 __ ldr(result, FieldMemOperand(scratch, | 5837 __ ldr(result, FieldMemOperand(scratch, |
5828 FixedArray::kHeaderSize - kPointerSize)); | 5838 FixedArray::kHeaderSize - kPointerSize)); |
5829 __ bind(&done); | 5839 __ bind(&done); |
5830 } | 5840 } |
5831 | 5841 |
5832 | 5842 |
5833 #undef __ | 5843 #undef __ |
5834 | 5844 |
5835 } } // namespace v8::internal | 5845 } } // namespace v8::internal |
OLD | NEW |