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

Side by Side Diff: src/arm/lithium-codegen-arm.cc

Issue 23890007: ARM: Improve SeqStringSetChar implementation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 | « src/arm/lithium-arm.cc ('k') | test/mjsunit/lithium/SeqStringSetChar.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 __ PrepareCallCFunction(2, scratch); 1953 __ PrepareCallCFunction(2, scratch);
1954 __ mov(r1, Operand(index)); 1954 __ mov(r1, Operand(index));
1955 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); 1955 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
1956 __ bind(&done); 1956 __ bind(&done);
1957 } 1957 }
1958 } 1958 }
1959 1959
1960 1960
1961 void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) { 1961 void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) {
1962 Register string = ToRegister(instr->string()); 1962 Register string = ToRegister(instr->string());
1963 Register index = ToRegister(instr->index()); 1963 LOperand* index_op = instr->index();
1964 Register value = ToRegister(instr->value()); 1964 Register value = ToRegister(instr->value());
1965 Register scratch = scratch0();
1965 String::Encoding encoding = instr->encoding(); 1966 String::Encoding encoding = instr->encoding();
1966 1967
1967 if (FLAG_debug_code) { 1968 if (FLAG_debug_code) {
1968 __ ldr(ip, FieldMemOperand(string, HeapObject::kMapOffset)); 1969 __ ldr(scratch, FieldMemOperand(string, HeapObject::kMapOffset));
1969 __ ldrb(ip, FieldMemOperand(ip, Map::kInstanceTypeOffset)); 1970 __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset));
1970 1971
1971 __ and_(ip, ip, Operand(kStringRepresentationMask | kStringEncodingMask)); 1972 __ and_(scratch, scratch,
1973 Operand(kStringRepresentationMask | kStringEncodingMask));
1972 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; 1974 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag;
1973 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; 1975 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag;
1974 __ cmp(ip, Operand(encoding == String::ONE_BYTE_ENCODING 1976 __ cmp(scratch, Operand(encoding == String::ONE_BYTE_ENCODING
1975 ? one_byte_seq_type : two_byte_seq_type)); 1977 ? one_byte_seq_type : two_byte_seq_type));
1976 __ Check(eq, kUnexpectedStringType); 1978 __ Check(eq, kUnexpectedStringType);
1977 } 1979 }
1978 1980
1979 __ add(ip, 1981 if (index_op->IsConstantOperand()) {
1980 string, 1982 int constant_index = ToInteger32(LConstantOperand::cast(index_op));
1981 Operand(SeqString::kHeaderSize - kHeapObjectTag)); 1983 if (encoding == String::ONE_BYTE_ENCODING) {
1982 if (encoding == String::ONE_BYTE_ENCODING) { 1984 __ strb(value,
1983 __ strb(value, MemOperand(ip, index)); 1985 FieldMemOperand(string, SeqString::kHeaderSize + constant_index));
Benedikt Meurer 2013/09/09 06:05:31 Is that safe for arbitrary constant_index'es?
vincent.belliard.fr 2013/09/09 08:29:55 As long as you don't use ip, it's safe (and you sh
1986 } else {
1987 __ strh(value,
1988 FieldMemOperand(string, SeqString::kHeaderSize + constant_index * 2));
1989 }
1984 } else { 1990 } else {
1985 // MemOperand with ip as the base register is not allowed for strh, so 1991 Register index = ToRegister(index_op);
1986 // we do the address calculation explicitly. 1992 if (encoding == String::ONE_BYTE_ENCODING) {
1987 __ add(ip, ip, Operand(index, LSL, 1)); 1993 __ add(scratch, string, Operand(index));
1988 __ strh(value, MemOperand(ip)); 1994 __ strb(value, FieldMemOperand(scratch, SeqString::kHeaderSize));
1995 } else {
1996 __ add(scratch, string, Operand(index, LSL, 1));
1997 __ strh(value, FieldMemOperand(scratch, SeqString::kHeaderSize));
1998 }
1989 } 1999 }
1990 } 2000 }
1991 2001
1992 2002
1993 void LCodeGen::DoThrow(LThrow* instr) { 2003 void LCodeGen::DoThrow(LThrow* instr) {
1994 Register input_reg = EmitLoadRegister(instr->value(), ip); 2004 Register input_reg = EmitLoadRegister(instr->value(), ip);
1995 __ push(input_reg); 2005 __ push(input_reg);
1996 CallRuntime(Runtime::kThrow, 1, instr); 2006 CallRuntime(Runtime::kThrow, 1, instr);
1997 2007
1998 if (FLAG_debug_code) { 2008 if (FLAG_debug_code) {
(...skipping 3781 matching lines...) Expand 10 before | Expand all | Expand 10 after
5780 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); 5790 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index));
5781 __ ldr(result, FieldMemOperand(scratch, 5791 __ ldr(result, FieldMemOperand(scratch,
5782 FixedArray::kHeaderSize - kPointerSize)); 5792 FixedArray::kHeaderSize - kPointerSize));
5783 __ bind(&done); 5793 __ bind(&done);
5784 } 5794 }
5785 5795
5786 5796
5787 #undef __ 5797 #undef __
5788 5798
5789 } } // namespace v8::internal 5799 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | test/mjsunit/lithium/SeqStringSetChar.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698