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 10394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10405 return false; | 10405 return false; |
10406 } | 10406 } |
10407 | 10407 |
10408 | 10408 |
10409 void Oddball::Initialize(Isolate* isolate, | 10409 void Oddball::Initialize(Isolate* isolate, |
10410 Handle<Oddball> oddball, | 10410 Handle<Oddball> oddball, |
10411 const char* to_string, | 10411 const char* to_string, |
10412 Handle<Object> to_number, | 10412 Handle<Object> to_number, |
10413 byte kind) { | 10413 byte kind) { |
10414 Handle<String> internalized_to_string = | 10414 Handle<String> internalized_to_string = |
10415 isolate->factory()->InternalizeUtf8String(CStrVector(to_string)); | 10415 isolate->factory()->InternalizeUtf8String(to_string); |
10416 oddball->set_to_string(*internalized_to_string); | 10416 oddball->set_to_string(*internalized_to_string); |
10417 oddball->set_to_number(*to_number); | 10417 oddball->set_to_number(*to_number); |
10418 oddball->set_kind(kind); | 10418 oddball->set_kind(kind); |
10419 } | 10419 } |
10420 | 10420 |
10421 | 10421 |
10422 void Script::InitLineEnds(Handle<Script> script) { | 10422 void Script::InitLineEnds(Handle<Script> script) { |
10423 if (!script->line_ends()->IsUndefined()) return; | 10423 if (!script->line_ends()->IsUndefined()) return; |
10424 | 10424 |
10425 Isolate* isolate = script->GetIsolate(); | 10425 Isolate* isolate = script->GetIsolate(); |
(...skipping 5163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15589 } | 15589 } |
15590 | 15590 |
15591 | 15591 |
15592 Handle<String> StringTable::LookupString(Isolate* isolate, | 15592 Handle<String> StringTable::LookupString(Isolate* isolate, |
15593 Handle<String> string) { | 15593 Handle<String> string) { |
15594 InternalizedStringKey key(string); | 15594 InternalizedStringKey key(string); |
15595 return LookupKey(isolate, &key); | 15595 return LookupKey(isolate, &key); |
15596 } | 15596 } |
15597 | 15597 |
15598 | 15598 |
15599 // TODO(ishell): Maybehandlify callers. | |
15600 Handle<String> StringTable::LookupKey(Isolate* isolate, HashTableKey* key) { | 15599 Handle<String> StringTable::LookupKey(Isolate* isolate, HashTableKey* key) { |
15601 Handle<StringTable> table = isolate->factory()->string_table(); | 15600 Handle<StringTable> table = isolate->factory()->string_table(); |
15602 int entry = table->FindEntry(key); | 15601 int entry = table->FindEntry(key); |
15603 | 15602 |
15604 // String already in table. | 15603 // String already in table. |
15605 if (entry != kNotFound) { | 15604 if (entry != kNotFound) { |
15606 return handle(String::cast(table->KeyAt(entry)), isolate); | 15605 return handle(String::cast(table->KeyAt(entry)), isolate); |
15607 } | 15606 } |
15608 | 15607 |
15609 // Adding new string. Grow table if needed. | 15608 // Adding new string. Grow table if needed. |
15610 table = StringTable::EnsureCapacity(table, 1, key); | 15609 table = StringTable::EnsureCapacity(table, 1, key); |
15611 | 15610 |
15612 // Create string object. | 15611 // Create string object. |
15613 Handle<Object> string = key->AsHandle(isolate); | 15612 Handle<Object> string = key->AsHandle(isolate); |
15614 // TODO(ishell): Maybehandlify this. | 15613 // There must be no attempts to internalize strings that could throw |
15615 if (string.is_null()) return Handle<String>(); | 15614 // InvalidStringLength error. |
| 15615 CHECK(!string.is_null()); |
15616 | 15616 |
15617 // Add the new string and return it along with the string table. | 15617 // Add the new string and return it along with the string table. |
15618 entry = table->FindInsertionEntry(key->Hash()); | 15618 entry = table->FindInsertionEntry(key->Hash()); |
15619 table->set(EntryToIndex(entry), *string); | 15619 table->set(EntryToIndex(entry), *string); |
15620 table->ElementAdded(); | 15620 table->ElementAdded(); |
15621 | 15621 |
15622 isolate->factory()->set_string_table(table); | 15622 isolate->factory()->set_string_table(table); |
15623 return Handle<String>::cast(string); | 15623 return Handle<String>::cast(string); |
15624 } | 15624 } |
15625 | 15625 |
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17428 #define ERROR_MESSAGES_TEXTS(C, T) T, | 17428 #define ERROR_MESSAGES_TEXTS(C, T) T, |
17429 static const char* error_messages_[] = { | 17429 static const char* error_messages_[] = { |
17430 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 17430 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
17431 }; | 17431 }; |
17432 #undef ERROR_MESSAGES_TEXTS | 17432 #undef ERROR_MESSAGES_TEXTS |
17433 return error_messages_[reason]; | 17433 return error_messages_[reason]; |
17434 } | 17434 } |
17435 | 17435 |
17436 | 17436 |
17437 } } // namespace v8::internal | 17437 } } // namespace v8::internal |
OLD | NEW |