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

Unified Diff: runtime/vm/clustered_snapshot.cc

Issue 2893553002: 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
Index: runtime/vm/clustered_snapshot.cc
diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc
index 5c911c71474b275f2f7fd5b001f6b2d53252956f..2d8d008819a9aa8fa2ba3c7a25e44b466a620478 100644
--- a/runtime/vm/clustered_snapshot.cc
+++ b/runtime/vm/clustered_snapshot.cc
@@ -1911,20 +1911,20 @@ class RODataSerializationCluster : public SerializationCluster {
// will be loaded into read-only memory.
if (cid_ == kOneByteStringCid) {
RawOneByteString* str = static_cast<RawOneByteString*>(object);
- if (str->ptr()->hash_ == Smi::New(0)) {
+ if (str->GetRawHash() == 0) {
intptr_t hash =
String::Hash(str->ptr()->data(), Smi::Value(str->ptr()->length_));
- str->ptr()->hash_ = Smi::New(hash);
+ str->SetRawHash(hash);
}
- ASSERT(str->ptr()->hash_ != Smi::New(0));
+ ASSERT(str->GetRawHash() != 0);
} else if (cid_ == kTwoByteStringCid) {
RawTwoByteString* str = static_cast<RawTwoByteString*>(object);
- if (str->ptr()->hash_ == Smi::New(0)) {
+ if (str->GetRawHash() == 0) {
intptr_t hash = String::Hash(str->ptr()->data(),
Smi::Value(str->ptr()->length_) * 2);
- str->ptr()->hash_ = Smi::New(hash);
+ str->SetRawHash(hash);
}
- ASSERT(str->ptr()->hash_ != Smi::New(0));
+ ASSERT(str->GetRawHash() != 0);
}
}
@@ -4359,7 +4359,7 @@ class OneByteStringSerializationCluster : public SerializationCluster {
intptr_t length = Smi::Value(str->ptr()->length_);
s->Write<int32_t>(length);
s->Write<bool>(str->IsCanonical());
- intptr_t hash = Smi::Value(str->ptr()->hash_);
+ intptr_t hash = str->GetRawHash();
s->Write<int32_t>(hash);
s->WriteBytes(str->ptr()->data(), length);
}
@@ -4399,7 +4399,7 @@ class OneByteStringDeserializationCluster : public DeserializationCluster {
OneByteString::InstanceSize(length),
is_vm_object, is_canonical);
str->ptr()->length_ = Smi::New(length);
- str->ptr()->hash_ = Smi::New(d->Read<int32_t>());
+ str->SetRawHash(d->Read<int32_t>());
for (intptr_t j = 0; j < length; j++) {
str->ptr()->data()[j] = d->Read<uint8_t>();
}
@@ -4438,7 +4438,7 @@ class TwoByteStringSerializationCluster : public SerializationCluster {
intptr_t length = Smi::Value(str->ptr()->length_);
s->Write<int32_t>(length);
s->Write<bool>(str->IsCanonical());
- intptr_t hash = Smi::Value(str->ptr()->hash_);
+ intptr_t hash = str->GetRawHash();
s->Write<int32_t>(hash);
s->WriteBytes(reinterpret_cast<uint8_t*>(str->ptr()->data()), length * 2);
}
@@ -4478,7 +4478,7 @@ class TwoByteStringDeserializationCluster : public DeserializationCluster {
TwoByteString::InstanceSize(length),
is_vm_object, is_canonical);
str->ptr()->length_ = Smi::New(length);
- str->ptr()->hash_ = Smi::New(d->Read<int32_t>());
+ str->SetRawHash(d->Read<int32_t>());
uint8_t* cdata = reinterpret_cast<uint8_t*>(str->ptr()->data());
d->ReadBytes(cdata, length * 2);
}

Powered by Google App Engine
This is Rietveld 408576698