[heap] Fix {InternalizeString} for char vectors

Even though {Factory::InternalizeString} was declared as a template,
only two instantiations exists: uint8_t and uint16_t. Using any other
type leads to link-time errors, which is inconvenient.

This CL implements the two instantiations explicitly, and provides a
third implementation taking a {Vector<const char>}. This will be used
after the next CL, which changes {StaticCharVector} to actually return a
{Vector<const char>}.

This also avoid the cumbersome template exports.

R=leszeks@chromium.org

Bug: v8:10426
Change-Id: I3f669fae2c711ade6f5a087e59210ad457423a66
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2152837
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67207}
This commit is contained in:
Clemens Backes 2020-04-17 15:08:44 +02:00 committed by Commit Bot
parent f0b67de54d
commit acc71c78b5
2 changed files with 16 additions and 12 deletions

View File

@ -530,19 +530,19 @@ Handle<String> Factory::InternalizeUtf8String(
Vector<const uc16>(buffer.get(), decoder.utf16_length())); Vector<const uc16>(buffer.get(), decoder.utf16_length()));
} }
template <typename Char> Handle<String> Factory::InternalizeString(Vector<const uint8_t> string,
Handle<String> Factory::InternalizeString(const Vector<const Char>& string,
bool convert_encoding) { bool convert_encoding) {
SequentialStringKey<Char> key(string, HashSeed(isolate()), convert_encoding); SequentialStringKey<uint8_t> key(string, HashSeed(isolate()),
convert_encoding);
return InternalizeStringWithKey(&key); return InternalizeStringWithKey(&key);
} }
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) Handle<String> Factory::InternalizeString(Vector<const uint16_t> string,
Handle<String> Factory::InternalizeString( bool convert_encoding) {
const Vector<const uint8_t>& string, bool convert_encoding); SequentialStringKey<uint16_t> key(string, HashSeed(isolate()),
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) convert_encoding);
Handle<String> Factory::InternalizeString( return InternalizeStringWithKey(&key);
const Vector<const uint16_t>& string, bool convert_encoding); }
template <typename SeqString> template <typename SeqString>
Handle<String> Factory::InternalizeString(Handle<SeqString> string, int from, Handle<String> Factory::InternalizeString(Handle<SeqString> string, int from,

View File

@ -184,10 +184,14 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
return InternalizeUtf8String(CStrVector(str)); return InternalizeUtf8String(CStrVector(str));
} }
template <typename Char> Handle<String> InternalizeString(Vector<const uint8_t> str,
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
Handle<String> InternalizeString(const Vector<const Char>& str,
bool convert_encoding = false); bool convert_encoding = false);
Handle<String> InternalizeString(Vector<const uint16_t> str,
bool convert_encoding = false);
Handle<String> InternalizeString(Vector<const char> str,
bool convert_encoding = false) {
return InternalizeString(Vector<const uint8_t>::cast(str));
}
template <typename SeqString> template <typename SeqString>
Handle<String> InternalizeString(Handle<SeqString>, int from, int length, Handle<String> InternalizeString(Handle<SeqString>, int from, int length,