| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 length) == 0; | 149 length) == 0; |
| 150 } else { | 150 } else { |
| 151 return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), | 151 return CompareCharsUnsigned(reinterpret_cast<const uint16_t*>(l), |
| 152 reinterpret_cast<const uint16_t*>(r), | 152 reinterpret_cast<const uint16_t*>(r), |
| 153 length) == 0; | 153 length) == 0; |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 | 157 |
| 158 void AstConsString::Internalize(Isolate* isolate) { | 158 void AstConsString::Internalize(Isolate* isolate) { |
| 159 Handle<String> tmp(isolate->factory()->empty_string()); | 159 if (IsEmpty()) { |
| 160 for (const AstRawString* current : strings_) { | 160 set_string(isolate->factory()->empty_string()); |
| 161 // AstRawStrings are internalized before AstConsStrings, so *current is | 161 return; |
| 162 // already internalized. | 162 } |
| 163 // AstRawStrings are internalized before AstConsStrings, so |
| 164 // AstRawString::string() will just work. |
| 165 Handle<String> tmp(segment_.string->string()); |
| 166 for (AstConsString::Segment* current = segment_.next; current != nullptr; |
| 167 current = current->next) { |
| 163 tmp = isolate->factory() | 168 tmp = isolate->factory() |
| 164 ->NewConsString(tmp, current->string()) | 169 ->NewConsString(current->string->string(), tmp) |
| 165 .ToHandleChecked(); | 170 .ToHandleChecked(); |
| 166 } | 171 } |
| 167 set_string(tmp); | 172 set_string(tmp); |
| 168 } | 173 } |
| 169 | 174 |
| 170 bool AstValue::IsPropertyName() const { | 175 bool AstValue::IsPropertyName() const { |
| 171 if (type_ == STRING) { | 176 if (type_ == STRING) { |
| 172 uint32_t index; | 177 uint32_t index; |
| 173 return !string_->AsArrayIndex(&index); | 178 return !string_->AsArrayIndex(&index); |
| 174 } | 179 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 if (content.IsOneByte()) { | 283 if (content.IsOneByte()) { |
| 279 result = GetOneByteStringInternal(content.ToOneByteVector()); | 284 result = GetOneByteStringInternal(content.ToOneByteVector()); |
| 280 } else { | 285 } else { |
| 281 DCHECK(content.IsTwoByte()); | 286 DCHECK(content.IsTwoByte()); |
| 282 result = GetTwoByteStringInternal(content.ToUC16Vector()); | 287 result = GetTwoByteStringInternal(content.ToUC16Vector()); |
| 283 } | 288 } |
| 284 return result; | 289 return result; |
| 285 } | 290 } |
| 286 | 291 |
| 287 AstConsString* AstValueFactory::NewConsString() { | 292 AstConsString* AstValueFactory::NewConsString() { |
| 288 AstConsString* new_string = new (zone_) AstConsString(zone_); | 293 AstConsString* new_string = new (zone_) AstConsString; |
| 289 DCHECK_NOT_NULL(new_string); | 294 DCHECK_NOT_NULL(new_string); |
| 290 AddConsString(new_string); | 295 AddConsString(new_string); |
| 291 return new_string; | 296 return new_string; |
| 292 } | 297 } |
| 293 | 298 |
| 294 AstConsString* AstValueFactory::NewConsString(const AstRawString* str) { | 299 AstConsString* AstValueFactory::NewConsString(const AstRawString* str) { |
| 295 return NewConsString()->AddString(str); | 300 return NewConsString()->AddString(zone_, str); |
| 296 } | 301 } |
| 297 | 302 |
| 298 AstConsString* AstValueFactory::NewConsString(const AstRawString* str1, | 303 AstConsString* AstValueFactory::NewConsString(const AstRawString* str1, |
| 299 const AstRawString* str2) { | 304 const AstRawString* str2) { |
| 300 return NewConsString()->AddString(str1)->AddString(str2); | 305 return NewConsString()->AddString(zone_, str1)->AddString(zone_, str2); |
| 301 } | 306 } |
| 302 | 307 |
| 303 void AstValueFactory::Internalize(Isolate* isolate) { | 308 void AstValueFactory::Internalize(Isolate* isolate) { |
| 304 // Strings need to be internalized before values, because values refer to | 309 // Strings need to be internalized before values, because values refer to |
| 305 // strings. | 310 // strings. |
| 306 for (AstRawString* current = strings_; current != nullptr;) { | 311 for (AstRawString* current = strings_; current != nullptr;) { |
| 307 AstRawString* next = current->next(); | 312 AstRawString* next = current->next(); |
| 308 current->Internalize(isolate); | 313 current->Internalize(isolate); |
| 309 current = next; | 314 current = next; |
| 310 } | 315 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 CHECK_NOT_NULL(new_string); | 407 CHECK_NOT_NULL(new_string); |
| 403 AddString(new_string); | 408 AddString(new_string); |
| 404 entry->key = new_string; | 409 entry->key = new_string; |
| 405 entry->value = reinterpret_cast<void*>(1); | 410 entry->value = reinterpret_cast<void*>(1); |
| 406 } | 411 } |
| 407 return reinterpret_cast<AstRawString*>(entry->key); | 412 return reinterpret_cast<AstRawString*>(entry->key); |
| 408 } | 413 } |
| 409 | 414 |
| 410 } // namespace internal | 415 } // namespace internal |
| 411 } // namespace v8 | 416 } // namespace v8 |
| OLD | NEW |