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

Unified Diff: src/ast/ast-value-factory.cc

Issue 2220363002: De-virtualize AstString. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rearranging Created 4 years, 4 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 | « src/ast/ast-value-factory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast-value-factory.cc
diff --git a/src/ast/ast-value-factory.cc b/src/ast/ast-value-factory.cc
index 63b40d2286a82cbe1ff7a939eaf89b731c3870ff..29a6d951d1f4fa5f1dabdbc9adc13d26d3fdaf39 100644
--- a/src/ast/ast-value-factory.cc
+++ b/src/ast/ast-value-factory.cc
@@ -58,7 +58,7 @@ class AstRawStringInternalizationKey : public HashTableKey {
: string_(string) {}
bool IsMatch(Object* other) override {
- if (string_->is_one_byte_)
+ if (string_->is_one_byte())
return String::cast(other)->IsOneByteEqualTo(string_->literal_bytes_);
return String::cast(other)->IsTwoByteEqualTo(
Vector<const uint16_t>::cast(string_->literal_bytes_));
@@ -71,7 +71,7 @@ class AstRawStringInternalizationKey : public HashTableKey {
}
Handle<Object> AsHandle(Isolate* isolate) override {
- if (string_->is_one_byte_)
+ if (string_->is_one_byte())
return isolate->factory()->NewOneByteInternalizedString(
string_->literal_bytes_, string_->hash());
return isolate->factory()->NewTwoByteInternalizedString(
@@ -82,6 +82,19 @@ class AstRawStringInternalizationKey : public HashTableKey {
const AstRawString* string_;
};
+int AstString::length() const {
+ if (IsRawStringBits::decode(bit_field_)) {
+ return reinterpret_cast<const AstRawString*>(this)->length();
+ }
+ return reinterpret_cast<const AstConsString*>(this)->length();
+}
+
+void AstString::Internalize(Isolate* isolate) {
+ if (IsRawStringBits::decode(bit_field_)) {
+ return reinterpret_cast<AstRawString*>(this)->Internalize(isolate);
+ }
+ return reinterpret_cast<AstConsString*>(this)->Internalize(isolate);
+}
void AstRawString::Internalize(Isolate* isolate) {
if (!string_.is_null()) return;
@@ -97,7 +110,7 @@ void AstRawString::Internalize(Isolate* isolate) {
bool AstRawString::AsArrayIndex(uint32_t* index) const {
if (!string_.is_null())
return string_->AsArrayIndex(index);
- if (!is_one_byte_ || literal_bytes_.length() == 0 ||
+ if (!is_one_byte() || literal_bytes_.length() == 0 ||
literal_bytes_.length() > String::kMaxArrayIndexSize)
return false;
OneByteStringStream stream(literal_bytes_);
@@ -107,7 +120,7 @@ bool AstRawString::AsArrayIndex(uint32_t* index) const {
bool AstRawString::IsOneByteEqualTo(const char* data) const {
int length = static_cast<int>(strlen(data));
- if (is_one_byte_ && literal_bytes_.length() == length) {
+ if (is_one_byte() && literal_bytes_.length() == length) {
const char* token = reinterpret_cast<const char*>(literal_bytes_.start());
return !strncmp(token, data, length);
}
« no previous file with comments | « src/ast/ast-value-factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698