OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 8219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8230 } | 8230 } |
8231 return true; | 8231 return true; |
8232 } | 8232 } |
8233 #endif | 8233 #endif |
8234 | 8234 |
8235 | 8235 |
8236 static bool IsIdentifier(UnicodeCache* cache, Name* name) { | 8236 static bool IsIdentifier(UnicodeCache* cache, Name* name) { |
8237 // Checks whether the buffer contains an identifier (no escape). | 8237 // Checks whether the buffer contains an identifier (no escape). |
8238 if (!name->IsString()) return false; | 8238 if (!name->IsString()) return false; |
8239 String* string = String::cast(name); | 8239 String* string = String::cast(name); |
8240 if (string->length() == 0) return false; | 8240 if (string->length() == 0) return true; |
8241 ConsStringIteratorOp op; | 8241 ConsStringIteratorOp op; |
8242 StringCharacterStream stream(string, &op); | 8242 StringCharacterStream stream(string, &op); |
8243 if (!cache->IsIdentifierStart(stream.GetNext())) { | 8243 if (!cache->IsIdentifierStart(stream.GetNext())) { |
8244 return false; | 8244 return false; |
8245 } | 8245 } |
8246 while (stream.HasMore()) { | 8246 while (stream.HasMore()) { |
8247 if (!cache->IsIdentifierPart(stream.GetNext())) { | 8247 if (!cache->IsIdentifierPart(stream.GetNext())) { |
8248 return false; | 8248 return false; |
8249 } | 8249 } |
8250 } | 8250 } |
8251 return true; | 8251 return true; |
8252 } | 8252 } |
8253 | 8253 |
8254 | 8254 |
8255 bool Name::IsCacheable(Isolate* isolate) { | 8255 bool Name::IsCacheable(Isolate* isolate) { |
8256 return IsSymbol() || | 8256 return IsSymbol() || IsIdentifier(isolate->unicode_cache(), this); |
8257 IsIdentifier(isolate->unicode_cache(), this) || | |
8258 this == isolate->heap()->hidden_string(); | |
8259 } | 8257 } |
8260 | 8258 |
8261 | 8259 |
8262 bool String::LooksValid() { | 8260 bool String::LooksValid() { |
8263 if (!GetIsolate()->heap()->Contains(this)) return false; | 8261 if (!GetIsolate()->heap()->Contains(this)) return false; |
8264 return true; | 8262 return true; |
8265 } | 8263 } |
8266 | 8264 |
8267 | 8265 |
8268 String::FlatContent String::GetFlatContent() { | 8266 String::FlatContent String::GetFlatContent() { |
(...skipping 7443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15712 if (IsKey(k)) { | 15710 if (IsKey(k)) { |
15713 Object* value = ValueAt(i); | 15711 Object* value = ValueAt(i); |
15714 Name* key; | 15712 Name* key; |
15715 if (k->IsSymbol()) { | 15713 if (k->IsSymbol()) { |
15716 key = Symbol::cast(k); | 15714 key = Symbol::cast(k); |
15717 } else { | 15715 } else { |
15718 // Ensure the key is a unique name before writing into the | 15716 // Ensure the key is a unique name before writing into the |
15719 // instance descriptor. | 15717 // instance descriptor. |
15720 MaybeObject* maybe_key = heap->InternalizeString(String::cast(k)); | 15718 MaybeObject* maybe_key = heap->InternalizeString(String::cast(k)); |
15721 if (!maybe_key->To(&key)) return maybe_key; | 15719 if (!maybe_key->To(&key)) return maybe_key; |
15722 if (key->Equals(heap->empty_string())) return this; | |
15723 } | 15720 } |
15724 | 15721 |
15725 PropertyDetails details = DetailsAt(i); | 15722 PropertyDetails details = DetailsAt(i); |
15726 int enumeration_index = details.dictionary_index(); | 15723 int enumeration_index = details.dictionary_index(); |
15727 PropertyType type = details.type(); | 15724 PropertyType type = details.type(); |
15728 | 15725 |
15729 if (value->IsJSFunction()) { | 15726 if (value->IsJSFunction()) { |
15730 ConstantDescriptor d(key, value, details.attributes()); | 15727 ConstantDescriptor d(key, value, details.attributes()); |
15731 descriptors->Set(enumeration_index - 1, &d, witness); | 15728 descriptors->Set(enumeration_index - 1, &d, witness); |
15732 } else if (type == NORMAL) { | 15729 } else if (type == NORMAL) { |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16492 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16489 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16493 static const char* error_messages_[] = { | 16490 static const char* error_messages_[] = { |
16494 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16491 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16495 }; | 16492 }; |
16496 #undef ERROR_MESSAGES_TEXTS | 16493 #undef ERROR_MESSAGES_TEXTS |
16497 return error_messages_[reason]; | 16494 return error_messages_[reason]; |
16498 } | 16495 } |
16499 | 16496 |
16500 | 16497 |
16501 } } // namespace v8::internal | 16498 } } // namespace v8::internal |
OLD | NEW |