OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "accessors.h" | 7 #include "accessors.h" |
8 #include "allocation-site-scopes.h" | 8 #include "allocation-site-scopes.h" |
9 #include "api.h" | 9 #include "api.h" |
10 #include "arguments.h" | 10 #include "arguments.h" |
(...skipping 15404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15415 return MaybeHandle<Object>().ToHandleChecked(); | 15415 return MaybeHandle<Object>().ToHandleChecked(); |
15416 } | 15416 } |
15417 | 15417 |
15418 private: | 15418 private: |
15419 uint16_t c1_; | 15419 uint16_t c1_; |
15420 uint16_t c2_; | 15420 uint16_t c2_; |
15421 uint32_t hash_; | 15421 uint32_t hash_; |
15422 }; | 15422 }; |
15423 | 15423 |
15424 | 15424 |
15425 bool StringTable::LookupStringIfExists(String* string, String** result) { | 15425 MaybeHandle<String> StringTable::InternalizeStringIfExists( |
15426 SLOW_ASSERT(this == HeapObject::cast(this)->GetHeap()->string_table()); | 15426 Isolate* isolate, |
15427 DisallowHeapAllocation no_alloc; | 15427 Handle<String> string) { |
15428 // TODO(ishell): Handlify all the callers and remove this scope. | 15428 if (string->IsInternalizedString()) { |
15429 HandleScope scope(GetIsolate()); | 15429 return string; |
15430 InternalizedStringKey key(handle(string)); | 15430 } |
15431 int entry = FindEntry(&key); | 15431 return LookupStringIfExists(isolate, string); |
| 15432 } |
| 15433 |
| 15434 |
| 15435 MaybeHandle<String> StringTable::LookupStringIfExists( |
| 15436 Isolate* isolate, |
| 15437 Handle<String> string) { |
| 15438 Handle<StringTable> string_table = isolate->factory()->string_table(); |
| 15439 InternalizedStringKey key(string); |
| 15440 int entry = string_table->FindEntry(&key); |
15432 if (entry == kNotFound) { | 15441 if (entry == kNotFound) { |
15433 return false; | 15442 return MaybeHandle<String>(); |
15434 } else { | 15443 } else { |
15435 *result = String::cast(KeyAt(entry)); | 15444 Handle<String> result(String::cast(string_table->KeyAt(entry)), isolate); |
15436 ASSERT(StringShape(*result).IsInternalized()); | 15445 ASSERT(StringShape(*result).IsInternalized()); |
15437 return true; | 15446 return result; |
15438 } | 15447 } |
15439 } | 15448 } |
15440 | 15449 |
15441 | 15450 |
15442 bool StringTable::LookupTwoCharsStringIfExists(uint16_t c1, | 15451 MaybeHandle<String> StringTable::LookupTwoCharsStringIfExists( |
15443 uint16_t c2, | 15452 Isolate* isolate, |
15444 String** result) { | 15453 uint16_t c1, |
15445 SLOW_ASSERT(this == HeapObject::cast(this)->GetHeap()->string_table()); | 15454 uint16_t c2) { |
15446 TwoCharHashTableKey key(c1, c2, GetHeap()->HashSeed()); | 15455 Handle<StringTable> string_table = isolate->factory()->string_table(); |
15447 int entry = FindEntry(&key); | 15456 TwoCharHashTableKey key(c1, c2, isolate->heap()->HashSeed()); |
| 15457 int entry = string_table->FindEntry(&key); |
15448 if (entry == kNotFound) { | 15458 if (entry == kNotFound) { |
15449 return false; | 15459 return MaybeHandle<String>(); |
15450 } else { | 15460 } else { |
15451 *result = String::cast(KeyAt(entry)); | 15461 Handle<String> result(String::cast(string_table->KeyAt(entry)), isolate); |
15452 ASSERT(StringShape(*result).IsInternalized()); | 15462 ASSERT(StringShape(*result).IsInternalized()); |
15453 return true; | 15463 return result; |
15454 } | 15464 } |
15455 } | 15465 } |
15456 | 15466 |
15457 | 15467 |
15458 Handle<String> StringTable::LookupString(Isolate* isolate, | 15468 Handle<String> StringTable::LookupString(Isolate* isolate, |
15459 Handle<String> string) { | 15469 Handle<String> string) { |
15460 InternalizedStringKey key(string); | 15470 InternalizedStringKey key(string); |
15461 return LookupKey(isolate, &key); | 15471 return LookupKey(isolate, &key); |
15462 } | 15472 } |
15463 | 15473 |
(...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17219 #define ERROR_MESSAGES_TEXTS(C, T) T, | 17229 #define ERROR_MESSAGES_TEXTS(C, T) T, |
17220 static const char* error_messages_[] = { | 17230 static const char* error_messages_[] = { |
17221 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 17231 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
17222 }; | 17232 }; |
17223 #undef ERROR_MESSAGES_TEXTS | 17233 #undef ERROR_MESSAGES_TEXTS |
17224 return error_messages_[reason]; | 17234 return error_messages_[reason]; |
17225 } | 17235 } |
17226 | 17236 |
17227 | 17237 |
17228 } } // namespace v8::internal | 17238 } } // namespace v8::internal |
OLD | NEW |