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

Unified Diff: src/objects.cc

Issue 265553003: StringTable::Lookup*IfExist() handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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/objects.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 3ce0bfce7daaf27773f2b3ad820d3d63b2806a72..60f0b44262c975127b0208d58388d9a1c8cb3ff4 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -15422,35 +15422,45 @@ class TwoCharHashTableKey : public HashTableKey {
};
-bool StringTable::LookupStringIfExists(String* string, String** result) {
- SLOW_ASSERT(this == HeapObject::cast(this)->GetHeap()->string_table());
- DisallowHeapAllocation no_alloc;
- // TODO(ishell): Handlify all the callers and remove this scope.
- HandleScope scope(GetIsolate());
- InternalizedStringKey key(handle(string));
- int entry = FindEntry(&key);
+MaybeHandle<String> StringTable::InternalizeStringIfExists(
+ Isolate* isolate,
+ Handle<String> string) {
+ if (string->IsInternalizedString()) {
+ return string;
+ }
+ return LookupStringIfExists(isolate, string);
+}
+
+
+MaybeHandle<String> StringTable::LookupStringIfExists(
+ Isolate* isolate,
+ Handle<String> string) {
+ Handle<StringTable> string_table = isolate->factory()->string_table();
+ InternalizedStringKey key(string);
+ int entry = string_table->FindEntry(&key);
if (entry == kNotFound) {
- return false;
+ return MaybeHandle<String>();
} else {
- *result = String::cast(KeyAt(entry));
+ Handle<String> result(String::cast(string_table->KeyAt(entry)), isolate);
ASSERT(StringShape(*result).IsInternalized());
- return true;
+ return result;
}
}
-bool StringTable::LookupTwoCharsStringIfExists(uint16_t c1,
- uint16_t c2,
- String** result) {
- SLOW_ASSERT(this == HeapObject::cast(this)->GetHeap()->string_table());
- TwoCharHashTableKey key(c1, c2, GetHeap()->HashSeed());
- int entry = FindEntry(&key);
+MaybeHandle<String> StringTable::LookupTwoCharsStringIfExists(
+ Isolate* isolate,
+ uint16_t c1,
+ uint16_t c2) {
+ Handle<StringTable> string_table = isolate->factory()->string_table();
+ TwoCharHashTableKey key(c1, c2, isolate->heap()->HashSeed());
+ int entry = string_table->FindEntry(&key);
if (entry == kNotFound) {
- return false;
+ return MaybeHandle<String>();
} else {
- *result = String::cast(KeyAt(entry));
+ Handle<String> result(String::cast(string_table->KeyAt(entry)), isolate);
ASSERT(StringShape(*result).IsInternalized());
- return true;
+ return result;
}
}
« no previous file with comments | « src/objects.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698