Revert "Avoiding re-externalization of strings."
This reverts commit 2c4c2ad694
.
Reason for revert: Speculatively revert CL, as it seems to break blink debug bots:
https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8-Blink%20Linux%2064%20(dbg)/12756
https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8-Blink%20Linux%2064%20(dbg)/12764
# Fatal error in ../../v8/src/api.cc, line 5960
# Check failed: expected == value ((nil) vs. 0x176ae0f70a48).
Original change's description:
> Avoiding re-externalization of strings.
>
> Bug: chromium:845409
> Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
> Change-Id: I75bddcf0e8879d2161486f24d1cd4e46d8fe008d
> Reviewed-on: https://chromium-review.googlesource.com/1139056
> Commit-Queue: Rodrigo Bruno <rfbpb@google.com>
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#54599}
TBR=ulan@chromium.org,jkummerow@chromium.org,hpayer@chromium.org,mlippautz@chromium.org,rfbpb@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:845409
Change-Id: Ie172148c0bdef71c0cf9819e63a66aec09d6888d
Reviewed-on: https://chromium-review.googlesource.com/1146582
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54611}
This commit is contained in:
parent
4a28271fee
commit
367815ea13
17
include/v8.h
17
include/v8.h
@ -3048,12 +3048,6 @@ class V8_EXPORT String : public Name {
|
||||
void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
|
||||
Encoding encoding) const;
|
||||
void VerifyExternalStringResource(ExternalStringResource* val) const;
|
||||
ExternalStringResource* GetExternalStringResourceSlow() const;
|
||||
ExternalStringResourceBase* GetExternalStringResourceBaseSlow(
|
||||
String::Encoding* encoding_out) const;
|
||||
const ExternalOneByteStringResource* GetExternalOneByteStringResourceSlow()
|
||||
const;
|
||||
|
||||
static void CheckCast(v8::Value* obj);
|
||||
};
|
||||
|
||||
@ -10188,13 +10182,12 @@ String::ExternalStringResource* String::GetExternalStringResource() const {
|
||||
typedef internal::Object O;
|
||||
typedef internal::Internals I;
|
||||
O* obj = *reinterpret_cast<O* const*>(this);
|
||||
|
||||
ExternalStringResource* result;
|
||||
String::ExternalStringResource* result;
|
||||
if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
|
||||
void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
|
||||
result = reinterpret_cast<String::ExternalStringResource*>(value);
|
||||
} else {
|
||||
result = GetExternalStringResourceSlow();
|
||||
result = NULL;
|
||||
}
|
||||
#ifdef V8_ENABLE_CHECKS
|
||||
VerifyExternalStringResource(result);
|
||||
@ -10210,16 +10203,14 @@ String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
|
||||
O* obj = *reinterpret_cast<O* const*>(this);
|
||||
int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
|
||||
*encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
|
||||
ExternalStringResourceBase* resource;
|
||||
ExternalStringResourceBase* resource = NULL;
|
||||
if (type == I::kExternalOneByteRepresentationTag ||
|
||||
type == I::kExternalTwoByteRepresentationTag) {
|
||||
void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
|
||||
resource = static_cast<ExternalStringResourceBase*>(value);
|
||||
} else {
|
||||
resource = GetExternalStringResourceBaseSlow(encoding_out);
|
||||
}
|
||||
#ifdef V8_ENABLE_CHECKS
|
||||
VerifyExternalStringResourceBase(resource, *encoding_out);
|
||||
VerifyExternalStringResourceBase(resource, *encoding_out);
|
||||
#endif
|
||||
return resource;
|
||||
}
|
||||
|
77
src/api.cc
77
src/api.cc
@ -5961,74 +5961,15 @@ void v8::String::VerifyExternalStringResourceBase(
|
||||
CHECK_EQ(expectedEncoding, encoding);
|
||||
}
|
||||
|
||||
String::ExternalStringResource* String::GetExternalStringResourceSlow() const {
|
||||
typedef internal::Internals I;
|
||||
i::Handle<i::String> str = Utils::OpenHandle(this);
|
||||
ExternalStringResource* result = nullptr;
|
||||
internal::Object* obj;
|
||||
|
||||
if (str->IsThinString()) {
|
||||
obj = i::Handle<i::ThinString>::cast(str)->actual();
|
||||
} else {
|
||||
obj = *str;
|
||||
}
|
||||
|
||||
if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
|
||||
void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
|
||||
result = reinterpret_cast<String::ExternalStringResource*>(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
String::ExternalStringResourceBase* String::GetExternalStringResourceBaseSlow(
|
||||
String::Encoding* encoding_out) const {
|
||||
typedef internal::Internals I;
|
||||
i::Handle<i::String> str = Utils::OpenHandle(this);
|
||||
ExternalStringResourceBase* resource = nullptr;
|
||||
internal::Object* obj;
|
||||
|
||||
if (str->IsThinString()) {
|
||||
obj = i::Handle<i::ThinString>::cast(str)->actual();
|
||||
} else {
|
||||
obj = *str;
|
||||
}
|
||||
|
||||
int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
|
||||
*encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
|
||||
|
||||
if (type == I::kExternalOneByteRepresentationTag ||
|
||||
type == I::kExternalTwoByteRepresentationTag) {
|
||||
void* value = I::ReadField<void*>(obj, I::kStringResourceOffset);
|
||||
resource = static_cast<ExternalStringResourceBase*>(value);
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
|
||||
const String::ExternalOneByteStringResource*
|
||||
String::GetExternalOneByteStringResourceSlow() const {
|
||||
i::Handle<i::String> str = Utils::OpenHandle(this);
|
||||
if (str->IsThinString()) {
|
||||
i::MemoryChunk* chunk = i::MemoryChunk::FromHeapObject(*str);
|
||||
str = i::Handle<i::String>(i::Handle<i::ThinString>::cast(str)->actual(),
|
||||
chunk->heap()->isolate());
|
||||
}
|
||||
if (i::StringShape(*str).IsExternalOneByte()) {
|
||||
const void* resource =
|
||||
i::Handle<i::ExternalOneByteString>::cast(str)->resource();
|
||||
return reinterpret_cast<const ExternalOneByteStringResource*>(resource);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const v8::String::ExternalOneByteStringResource*
|
||||
v8::String::GetExternalOneByteStringResource() const {
|
||||
i::Handle<i::String> str = Utils::OpenHandle(this);
|
||||
if (i::StringShape(*str).IsExternalOneByte()) {
|
||||
const void* value =
|
||||
const void* resource =
|
||||
i::Handle<i::ExternalOneByteString>::cast(str)->resource();
|
||||
return reinterpret_cast<const ExternalOneByteStringResource*>(value);
|
||||
return reinterpret_cast<const ExternalOneByteStringResource*>(resource);
|
||||
} else {
|
||||
return GetExternalOneByteStringResourceSlow();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6923,10 +6864,6 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj->IsThinString()) {
|
||||
obj = i::Handle<i::String>(i::ThinString::cast(*obj)->actual(), isolate);
|
||||
}
|
||||
|
||||
if (i::StringShape(*obj).IsExternal()) {
|
||||
return false; // Already an external string.
|
||||
}
|
||||
@ -6938,7 +6875,7 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
|
||||
|
||||
bool result = obj->MakeExternal(resource);
|
||||
// Assert that if CanMakeExternal(), then externalizing actually succeeds.
|
||||
DCHECK(!Utils::ToLocal(obj)->CanMakeExternal() || result);
|
||||
DCHECK(!CanMakeExternal() || result);
|
||||
if (result) {
|
||||
DCHECK(obj->IsExternalString());
|
||||
}
|
||||
@ -6956,10 +6893,6 @@ bool v8::String::MakeExternal(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj->IsThinString()) {
|
||||
obj = i::Handle<i::String>(i::ThinString::cast(*obj)->actual(), isolate);
|
||||
}
|
||||
|
||||
if (i::StringShape(*obj).IsExternal()) {
|
||||
return false; // Already an external string.
|
||||
}
|
||||
@ -6971,7 +6904,7 @@ bool v8::String::MakeExternal(
|
||||
|
||||
bool result = obj->MakeExternal(resource);
|
||||
// Assert that if CanMakeExternal(), then externalizing actually succeeds.
|
||||
DCHECK(!Utils::ToLocal(obj)->CanMakeExternal() || result);
|
||||
DCHECK(!CanMakeExternal() || result);
|
||||
if (result) {
|
||||
DCHECK(obj->IsExternalString());
|
||||
}
|
||||
|
@ -530,8 +530,6 @@ Isolate* Heap::isolate() {
|
||||
|
||||
void Heap::ExternalStringTable::AddString(String* string) {
|
||||
DCHECK(string->IsExternalString());
|
||||
DCHECK(!Contains(string));
|
||||
|
||||
if (InNewSpace(string)) {
|
||||
new_space_strings_.push_back(string);
|
||||
} else {
|
||||
|
@ -2296,16 +2296,6 @@ void Heap::ProtectUnprotectedMemoryChunks() {
|
||||
unprotected_memory_chunks_.clear();
|
||||
}
|
||||
|
||||
bool Heap::ExternalStringTable::Contains(HeapObject* obj) {
|
||||
for (size_t i = 0; i < new_space_strings_.size(); ++i) {
|
||||
if (new_space_strings_[i] == obj) return true;
|
||||
}
|
||||
for (size_t i = 0; i < old_space_strings_.size(); ++i) {
|
||||
if (old_space_strings_[i] == obj) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap,
|
||||
Object** p) {
|
||||
MapWord first_word = HeapObject::cast(*p)->map_word();
|
||||
|
@ -1481,7 +1481,6 @@ class Heap {
|
||||
|
||||
// Registers an external string.
|
||||
inline void AddString(String* string);
|
||||
bool Contains(HeapObject* obj);
|
||||
|
||||
void IterateAll(RootVisitor* v);
|
||||
void IterateNewSpaceStrings(RootVisitor* v);
|
||||
|
Loading…
Reference in New Issue
Block a user