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

Side by Side Diff: runtime/vm/intrinsifier_arm64.cc

Issue 2889723005: Revert "More compact string representation on 64 bit." (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « runtime/vm/intrinsifier_arm.cc ('k') | runtime/vm/intrinsifier_ia32.cc » ('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 (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64.
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
7 7
8 #include "vm/intrinsifier.h" 8 #include "vm/intrinsifier.h"
9 9
10 #include "vm/assembler.h" 10 #include "vm/assembler.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 __ tsti(R2, Immediate(kSmiTagMask)); \ 189 __ tsti(R2, Immediate(kSmiTagMask)); \
190 __ b(&fall_through, NE); \ 190 __ b(&fall_through, NE); \
191 __ CompareRegisters(R2, ZR); \ 191 __ CompareRegisters(R2, ZR); \
192 __ b(&fall_through, LT); \ 192 __ b(&fall_through, LT); \
193 __ SmiUntag(R2); \ 193 __ SmiUntag(R2); \
194 /* Check for maximum allowed length. */ \ 194 /* Check for maximum allowed length. */ \
195 /* R2: untagged array length. */ \ 195 /* R2: untagged array length. */ \
196 __ CompareImmediate(R2, max_len); \ 196 __ CompareImmediate(R2, max_len); \
197 __ b(&fall_through, GT); \ 197 __ b(&fall_through, GT); \
198 __ LslImmediate(R2, R2, scale_shift); \ 198 __ LslImmediate(R2, R2, scale_shift); \
199 const intptr_t fixed_size_plus_alignment_padding = \ 199 const intptr_t fixed_size = sizeof(Raw##type_name) + kObjectAlignment - 1; \
200 sizeof(Raw##type_name) + kObjectAlignment - 1; \ 200 __ AddImmediate(R2, fixed_size); \
201 __ AddImmediate(R2, fixed_size_plus_alignment_padding); \
202 __ andi(R2, R2, Immediate(~(kObjectAlignment - 1))); \ 201 __ andi(R2, R2, Immediate(~(kObjectAlignment - 1))); \
203 Heap::Space space = Heap::kNew; \ 202 Heap::Space space = Heap::kNew; \
204 __ ldr(R3, Address(THR, Thread::heap_offset())); \ 203 __ ldr(R3, Address(THR, Thread::heap_offset())); \
205 __ ldr(R0, Address(R3, Heap::TopOffset(space))); \ 204 __ ldr(R0, Address(R3, Heap::TopOffset(space))); \
206 \ 205 \
207 /* R2: allocation size. */ \ 206 /* R2: allocation size. */ \
208 __ adds(R1, R0, Operand(R2)); \ 207 __ adds(R1, R0, Operand(R2)); \
209 __ b(&fall_through, CS); /* Fail on unsigned overflow. */ \ 208 __ b(&fall_through, CS); /* Fail on unsigned overflow. */ \
210 \ 209 \
211 /* Check if the allocation fits into the remaining space. */ \ 210 /* Check if the allocation fits into the remaining space. */ \
(...skipping 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 __ LoadObject(R0, Bool::False()); 1815 __ LoadObject(R0, Bool::False());
1817 __ ret(); 1816 __ ret();
1818 1817
1819 __ Bind(&fall_through); 1818 __ Bind(&fall_through);
1820 } 1819 }
1821 1820
1822 1821
1823 void Intrinsifier::String_getHashCode(Assembler* assembler) { 1822 void Intrinsifier::String_getHashCode(Assembler* assembler) {
1824 Label fall_through; 1823 Label fall_through;
1825 __ ldr(R0, Address(SP, 0 * kWordSize)); 1824 __ ldr(R0, Address(SP, 0 * kWordSize));
1826 __ ldr(R0, FieldAddress(R0, String::hash_offset()), kUnsignedWord); 1825 __ ldr(R0, FieldAddress(R0, String::hash_offset()));
1827 __ adds(R0, R0, Operand(R0)); // Smi tag the hash code, setting Z flag. 1826 __ CompareRegisters(R0, ZR);
1828 __ b(&fall_through, EQ); 1827 __ b(&fall_through, EQ);
1829 __ ret(); 1828 __ ret();
1830 // Hash not yet computed. 1829 // Hash not yet computed.
1831 __ Bind(&fall_through); 1830 __ Bind(&fall_through);
1832 } 1831 }
1833 1832
1834 1833
1835 void GenerateSubstringMatchesSpecialization(Assembler* assembler, 1834 void GenerateSubstringMatchesSpecialization(Assembler* assembler,
1836 intptr_t receiver_cid, 1835 intptr_t receiver_cid,
1837 intptr_t other_cid, 1836 intptr_t other_cid,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 __ LoadObject(R0, Bool::True()); 1988 __ LoadObject(R0, Bool::True());
1990 __ LoadObject(TMP, Bool::False()); 1989 __ LoadObject(TMP, Bool::False());
1991 __ csel(R0, TMP, R0, NE); 1990 __ csel(R0, TMP, R0, NE);
1992 __ ret(); 1991 __ ret();
1993 } 1992 }
1994 1993
1995 1994
1996 void Intrinsifier::OneByteString_getHashCode(Assembler* assembler) { 1995 void Intrinsifier::OneByteString_getHashCode(Assembler* assembler) {
1997 Label compute_hash; 1996 Label compute_hash;
1998 __ ldr(R1, Address(SP, 0 * kWordSize)); // OneByteString object. 1997 __ ldr(R1, Address(SP, 0 * kWordSize)); // OneByteString object.
1999 __ ldr(R0, FieldAddress(R1, String::hash_offset()), kUnsignedWord); 1998 __ ldr(R0, FieldAddress(R1, String::hash_offset()));
2000 __ adds(R0, R0, Operand(R0)); // Smi tag the hash code, setting Z flag. 1999 __ CompareRegisters(R0, ZR);
2001 __ b(&compute_hash, EQ); 2000 __ b(&compute_hash, EQ);
2002 __ ret(); // Return if already computed. 2001 __ ret(); // Return if already computed.
2003 2002
2004 __ Bind(&compute_hash); 2003 __ Bind(&compute_hash);
2005 __ ldr(R2, FieldAddress(R1, String::length_offset())); 2004 __ ldr(R2, FieldAddress(R1, String::length_offset()));
2006 __ SmiUntag(R2); 2005 __ SmiUntag(R2);
2007 2006
2008 Label done; 2007 Label done;
2009 // If the string is empty, set the hash to 1, and return. 2008 // If the string is empty, set the hash to 1, and return.
2010 __ CompareRegisters(R2, ZR); 2009 __ CompareRegisters(R2, ZR);
(...skipping 29 matching lines...) Expand all
2040 // hash_ += hash_ << 15; 2039 // hash_ += hash_ << 15;
2041 __ addw(R0, R0, Operand(R0, LSL, 3)); 2040 __ addw(R0, R0, Operand(R0, LSL, 3));
2042 __ eorw(R0, R0, Operand(R0, LSR, 11)); 2041 __ eorw(R0, R0, Operand(R0, LSR, 11));
2043 __ addw(R0, R0, Operand(R0, LSL, 15)); 2042 __ addw(R0, R0, Operand(R0, LSL, 15));
2044 // hash_ = hash_ & ((static_cast<intptr_t>(1) << bits) - 1); 2043 // hash_ = hash_ & ((static_cast<intptr_t>(1) << bits) - 1);
2045 __ AndImmediate(R0, R0, (static_cast<intptr_t>(1) << String::kHashBits) - 1); 2044 __ AndImmediate(R0, R0, (static_cast<intptr_t>(1) << String::kHashBits) - 1);
2046 __ CompareRegisters(R0, ZR); 2045 __ CompareRegisters(R0, ZR);
2047 // return hash_ == 0 ? 1 : hash_; 2046 // return hash_ == 0 ? 1 : hash_;
2048 __ Bind(&done); 2047 __ Bind(&done);
2049 __ csinc(R0, R0, ZR, NE); // R0 <- (R0 != 0) ? R0 : (ZR + 1). 2048 __ csinc(R0, R0, ZR, NE); // R0 <- (R0 != 0) ? R0 : (ZR + 1).
2050 __ str(R0, FieldAddress(R1, String::hash_offset()), kUnsignedWord);
2051 __ SmiTag(R0); 2049 __ SmiTag(R0);
2050 __ str(R0, FieldAddress(R1, String::hash_offset()));
2052 __ ret(); 2051 __ ret();
2053 } 2052 }
2054 2053
2055 2054
2056 // Allocates one-byte string of length 'end - start'. The content is not 2055 // Allocates one-byte string of length 'end - start'. The content is not
2057 // initialized. 2056 // initialized.
2058 // 'length-reg' (R2) contains tagged length. 2057 // 'length-reg' (R2) contains tagged length.
2059 // Returns new string as tagged pointer in R0. 2058 // Returns new string as tagged pointer in R0.
2060 static void TryAllocateOnebyteString(Assembler* assembler, 2059 static void TryAllocateOnebyteString(Assembler* assembler,
2061 Label* ok, 2060 Label* ok,
2062 Label* failure) { 2061 Label* failure) {
2063 const Register length_reg = R2; 2062 const Register length_reg = R2;
2064 Label fail; 2063 Label fail;
2065 NOT_IN_PRODUCT(__ MaybeTraceAllocation(kOneByteStringCid, R0, failure)); 2064 NOT_IN_PRODUCT(__ MaybeTraceAllocation(kOneByteStringCid, R0, failure));
2066 __ mov(R6, length_reg); // Save the length register. 2065 __ mov(R6, length_reg); // Save the length register.
2067 // TODO(koda): Protect against negative length and overflow here. 2066 // TODO(koda): Protect against negative length and overflow here.
2068 __ adds(length_reg, ZR, Operand(length_reg, ASR, kSmiTagSize)); // Smi untag. 2067 __ SmiUntag(length_reg);
2069 // If the length is 0 then we have to make the allocated size a bit bigger, 2068 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1;
2070 // otherwise the string takes up less space than an ExternalOneByteString, 2069 __ AddImmediate(length_reg, fixed_size);
2071 // and cannot be externalized. TODO(erikcorry): We should probably just
2072 // return a static zero length string here instead.
2073 // length <- (length != 0) ? length : (ZR + 1).
2074 __ csinc(length_reg, length_reg, ZR, NE);
2075 const intptr_t fixed_size_plus_alignment_padding =
2076 sizeof(RawString) + kObjectAlignment - 1;
2077 __ AddImmediate(length_reg, fixed_size_plus_alignment_padding);
2078 __ andi(length_reg, length_reg, Immediate(~(kObjectAlignment - 1))); 2070 __ andi(length_reg, length_reg, Immediate(~(kObjectAlignment - 1)));
2079 2071
2080 const intptr_t cid = kOneByteStringCid; 2072 const intptr_t cid = kOneByteStringCid;
2081 Heap::Space space = Heap::kNew; 2073 Heap::Space space = Heap::kNew;
2082 __ ldr(R3, Address(THR, Thread::heap_offset())); 2074 __ ldr(R3, Address(THR, Thread::heap_offset()));
2083 __ ldr(R0, Address(R3, Heap::TopOffset(space))); 2075 __ ldr(R0, Address(R3, Heap::TopOffset(space)));
2084 2076
2085 // length_reg: allocation size. 2077 // length_reg: allocation size.
2086 __ adds(R1, R0, Operand(length_reg)); 2078 __ adds(R1, R0, Operand(length_reg));
2087 __ b(&fail, CS); // Fail on unsigned overflow. 2079 __ b(&fail, CS); // Fail on unsigned overflow.
(...skipping 19 matching lines...) Expand all
2107 // R2: allocation size. 2099 // R2: allocation size.
2108 { 2100 {
2109 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2; 2101 const intptr_t shift = RawObject::kSizeTagPos - kObjectAlignmentLog2;
2110 2102
2111 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag); 2103 __ CompareImmediate(R2, RawObject::SizeTag::kMaxSizeTag);
2112 __ LslImmediate(R2, R2, shift); 2104 __ LslImmediate(R2, R2, shift);
2113 __ csel(R2, R2, ZR, LS); 2105 __ csel(R2, R2, ZR, LS);
2114 2106
2115 // Get the class index and insert it into the tags. 2107 // Get the class index and insert it into the tags.
2116 // R2: size and bit tags. 2108 // R2: size and bit tags.
2117 // This also clears the hash, which is in the high word of the tags.
2118 __ LoadImmediate(TMP, RawObject::ClassIdTag::encode(cid)); 2109 __ LoadImmediate(TMP, RawObject::ClassIdTag::encode(cid));
2119 __ orr(R2, R2, Operand(TMP)); 2110 __ orr(R2, R2, Operand(TMP));
2120 __ str(R2, FieldAddress(R0, String::tags_offset())); // Store tags. 2111 __ str(R2, FieldAddress(R0, String::tags_offset())); // Store tags.
2121 } 2112 }
2122 2113
2123 // Set the length field using the saved length (R6). 2114 // Set the length field using the saved length (R6).
2124 __ StoreIntoObjectNoBarrier(R0, FieldAddress(R0, String::length_offset()), 2115 __ StoreIntoObjectNoBarrier(R0, FieldAddress(R0, String::length_offset()),
2125 R6); 2116 R6);
2117 // Clear hash.
2118 __ mov(TMP, ZR);
2119 __ str(TMP, FieldAddress(R0, String::hash_offset()));
2126 __ b(ok); 2120 __ b(ok);
2127 2121
2128 __ Bind(&fail); 2122 __ Bind(&fail);
2129 __ b(failure); 2123 __ b(failure);
2130 } 2124 }
2131 2125
2132 2126
2133 // Arg0: OneByteString (receiver). 2127 // Arg0: OneByteString (receiver).
2134 // Arg1: Start index as Smi. 2128 // Arg1: Start index as Smi.
2135 // Arg2: End index as Smi. 2129 // Arg2: End index as Smi.
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2383 2377
2384 void Intrinsifier::SetAsyncThreadStackTrace(Assembler* assembler) { 2378 void Intrinsifier::SetAsyncThreadStackTrace(Assembler* assembler) {
2385 __ ldr(R0, Address(THR, Thread::async_stack_trace_offset())); 2379 __ ldr(R0, Address(THR, Thread::async_stack_trace_offset()));
2386 __ LoadObject(R0, Object::null_object()); 2380 __ LoadObject(R0, Object::null_object());
2387 __ ret(); 2381 __ ret();
2388 } 2382 }
2389 2383
2390 } // namespace dart 2384 } // namespace dart
2391 2385
2392 #endif // defined TARGET_ARCH_ARM64 2386 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier_arm.cc ('k') | runtime/vm/intrinsifier_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698