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

Unified Diff: runtime/vm/intrinsifier_x64.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intrinsifier_mips.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intrinsifier_x64.cc
diff --git a/runtime/vm/intrinsifier_x64.cc b/runtime/vm/intrinsifier_x64.cc
index f0ca5913f9164fb4d092aecb7eee663df629afac..47deca12fa9103cfaed05c64da6135810a2fde9d 100644
--- a/runtime/vm/intrinsifier_x64.cc
+++ b/runtime/vm/intrinsifier_x64.cc
@@ -170,9 +170,8 @@ void Intrinsifier::GrowableArray_add(Assembler* assembler) {
/* only scale by 8. */ \
scale_factor = TIMES_8; \
} \
- const intptr_t fixed_size_plus_alignment_padding = \
- sizeof(Raw##type_name) + kObjectAlignment - 1; \
- __ leaq(RDI, Address(RDI, scale_factor, fixed_size_plus_alignment_padding)); \
+ const intptr_t fixed_size = sizeof(Raw##type_name) + kObjectAlignment - 1; \
+ __ leaq(RDI, Address(RDI, scale_factor, fixed_size)); \
__ andq(RDI, Immediate(-kObjectAlignment)); \
Heap::Space space = Heap::kNew; \
__ movq(R13, Address(THR, Thread::heap_offset())); \
@@ -1743,11 +1742,9 @@ void Intrinsifier::ObjectHaveSameRuntimeType(Assembler* assembler) {
void Intrinsifier::String_getHashCode(Assembler* assembler) {
Label fall_through;
__ movq(RAX, Address(RSP, +1 * kWordSize)); // String object.
- __ movl(RAX, FieldAddress(RAX, String::hash_offset()));
- ASSERT(kSmiTag == 0);
- ASSERT(kSmiTagShift == 1);
- __ addq(RAX, RAX); // Smi tag RAX, setting Z flag.
- __ j(ZERO, &fall_through, Assembler::kNearJump);
+ __ movq(RAX, FieldAddress(RAX, String::hash_offset()));
+ __ cmpq(RAX, Immediate(0));
+ __ j(EQUAL, &fall_through, Assembler::kNearJump);
__ ret();
__ Bind(&fall_through);
// Hash not yet computed.
@@ -1914,10 +1911,9 @@ void Intrinsifier::StringBaseIsEmpty(Assembler* assembler) {
void Intrinsifier::OneByteString_getHashCode(Assembler* assembler) {
Label compute_hash;
__ movq(RBX, Address(RSP, +1 * kWordSize)); // OneByteString object.
- __ movl(RAX, FieldAddress(RBX, String::hash_offset()));
+ __ movq(RAX, FieldAddress(RBX, String::hash_offset()));
__ cmpq(RAX, Immediate(0));
__ j(EQUAL, &compute_hash, Assembler::kNearJump);
- __ SmiTag(RAX);
__ ret();
__ Bind(&compute_hash);
@@ -1975,8 +1971,8 @@ void Intrinsifier::OneByteString_getHashCode(Assembler* assembler) {
__ j(NOT_EQUAL, &set_hash_code, Assembler::kNearJump);
__ incq(RAX);
__ Bind(&set_hash_code);
- __ movl(FieldAddress(RBX, String::hash_offset()), RAX);
__ SmiTag(RAX);
+ __ StoreIntoSmiField(FieldAddress(RBX, String::hash_offset()), RAX);
__ ret();
}
@@ -1992,19 +1988,11 @@ static void TryAllocateOnebyteString(Assembler* assembler,
if (length_reg != RDI) {
__ movq(RDI, length_reg);
}
- Label pop_and_fail, not_zero_length;
+ Label pop_and_fail;
__ pushq(RDI); // Preserve length.
- __ sarq(RDI, Immediate(kSmiTagShift)); // Untag length.
- // If the length is 0 then we have to make the allocated size a bit bigger,
- // otherwise the string takes up less space than an ExternalOneByteString,
- // and cannot be externalized. TODO(erikcorry): We should probably just
- // return a static zero length string here instead.
- __ j(NOT_ZERO, &not_zero_length);
- __ addq(RDI, Immediate(1));
- __ Bind(&not_zero_length);
- const intptr_t fixed_size_plus_alignment_padding =
- sizeof(RawString) + kObjectAlignment - 1;
- __ addq(RDI, Immediate(fixed_size_plus_alignment_padding));
+ __ SmiUntag(RDI);
+ const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1;
+ __ leaq(RDI, Address(RDI, TIMES_1, fixed_size)); // RDI is a Smi.
__ andq(RDI, Immediate(-kObjectAlignment));
const intptr_t cid = kOneByteStringCid;
@@ -2046,7 +2034,6 @@ static void TryAllocateOnebyteString(Assembler* assembler,
__ Bind(&done);
// Get the class index and insert it into the tags.
- // This also clears the hash, which is in the high bits of the tags.
__ orq(RDI, Immediate(RawObject::ClassIdTag::encode(cid)));
__ movq(FieldAddress(RAX, String::tags_offset()), RDI); // Tags.
}
@@ -2055,6 +2042,8 @@ static void TryAllocateOnebyteString(Assembler* assembler,
__ popq(RDI);
__ StoreIntoObjectNoBarrier(RAX, FieldAddress(RAX, String::length_offset()),
RDI);
+ // Clear hash.
+ __ ZeroInitSmiField(FieldAddress(RAX, String::hash_offset()));
__ jmp(ok, Assembler::kNearJump);
__ Bind(&pop_and_fail);
« no previous file with comments | « runtime/vm/intrinsifier_mips.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698