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

Unified Diff: src/factory.cc

Issue 249103002: StringTable::LookupKey() and all callers handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing review notes 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/factory.h ('k') | src/heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 3aacc59d503673d627955e79d590acb3a1f066bb..2f5d1bd939cf20ef8ab666b5e08fa8d3f1646676 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -242,9 +242,8 @@ Handle<String> Factory::InternalizeUtf8String(Vector<const char> string) {
// Internalized strings are created in the old generation (data space).
Handle<String> Factory::InternalizeString(Handle<String> string) {
- CALL_HEAP_FUNCTION(isolate(),
- isolate()->heap()->InternalizeString(*string),
- String);
+ if (string->IsInternalizedString()) return string;
+ return StringTable::LookupString(isolate(), string);
}
@@ -269,9 +268,7 @@ Handle<String> Factory::InternalizeTwoByteString(Vector<const uc16> string) {
template<class StringTableKey>
Handle<String> Factory::InternalizeStringWithKey(StringTableKey* key) {
- CALL_HEAP_FUNCTION(isolate(),
- isolate()->heap()->InternalizeStringWithKey(key),
- String);
+ return StringTable::LookupKey(isolate(), key);
}
@@ -350,11 +347,27 @@ MaybeHandle<SeqTwoByteString> Factory::NewRawTwoByteString(
}
-Handle<String> Factory::LookupSingleCharacterStringFromCode(uint32_t index) {
- CALL_HEAP_FUNCTION(
- isolate(),
- isolate()->heap()->LookupSingleCharacterStringFromCode(index),
- String);
+Handle<String> Factory::LookupSingleCharacterStringFromCode(uint32_t code) {
+ if (code <= String::kMaxOneByteCharCodeU) {
+ {
+ DisallowHeapAllocation no_allocation;
+ Object* value = single_character_string_cache()->get(code);
+ if (value != *undefined_value()) {
+ return handle(String::cast(value), isolate());
+ }
+ }
+ uint8_t buffer[1];
+ buffer[0] = static_cast<uint8_t>(code);
+ Handle<String> result =
+ InternalizeOneByteString(Vector<const uint8_t>(buffer, 1));
+ single_character_string_cache()->set(code, *result);
+ return result;
+ }
+ ASSERT(code <= String::kMaxUtf16CodeUnitU);
+
+ Handle<SeqTwoByteString> result = NewRawTwoByteString(1).ToHandleChecked();
+ result->SeqTwoByteStringSet(0, static_cast<uint16_t>(code));
+ return result;
}
« no previous file with comments | « src/factory.h ('k') | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698