Commit acc71c78 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[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: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67207}
parent f0b67de5
......@@ -530,19 +530,19 @@ Handle<String> Factory::InternalizeUtf8String(
Vector<const uc16>(buffer.get(), decoder.utf16_length()));
}
template <typename Char>
Handle<String> Factory::InternalizeString(const Vector<const Char>& string,
Handle<String> Factory::InternalizeString(Vector<const uint8_t> string,
bool convert_encoding) {
SequentialStringKey<Char> key(string, HashSeed(isolate()), convert_encoding);
SequentialStringKey<uint8_t> key(string, HashSeed(isolate()),
convert_encoding);
return InternalizeStringWithKey(&key);
}
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Handle<String> Factory::InternalizeString(
const Vector<const uint8_t>& string, bool convert_encoding);
template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE)
Handle<String> Factory::InternalizeString(
const Vector<const uint16_t>& string, bool convert_encoding);
Handle<String> Factory::InternalizeString(Vector<const uint16_t> string,
bool convert_encoding) {
SequentialStringKey<uint16_t> key(string, HashSeed(isolate()),
convert_encoding);
return InternalizeStringWithKey(&key);
}
template <typename SeqString>
Handle<String> Factory::InternalizeString(Handle<SeqString> string, int from,
......
......@@ -184,10 +184,14 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
return InternalizeUtf8String(CStrVector(str));
}
template <typename Char>
EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE)
Handle<String> InternalizeString(const Vector<const Char>& str,
Handle<String> InternalizeString(Vector<const uint8_t> str,
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>
Handle<String> InternalizeString(Handle<SeqString>, int from, int length,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment