Commit 771e86fd authored by bbudge's avatar bbudge Committed by Commit bot

Remove Factory::NewStringFromASCII method.

BUG=none

Review-Url: https://codereview.chromium.org/2759513002
Cr-Commit-Position: refs/heads/master@{#43913}
parent 4acdb5ee
......@@ -48,7 +48,9 @@ class SourceCodeCache final BASE_EMBEDDED {
cache_->CopyTo(0, *new_array, 0, cache_->length());
cache_ = *new_array;
Handle<String> str =
factory->NewStringFromAscii(name, TENURED).ToHandleChecked();
factory
->NewStringFromOneByte(Vector<const uint8_t>::cast(name), TENURED)
.ToHandleChecked();
DCHECK(!str.is_null());
cache_->set(length, *str);
cache_->set(length + 1, *shared);
......
......@@ -166,29 +166,6 @@ class V8_EXPORT_PRIVATE Factory final {
OneByteVector(str), pretenure).ToHandleChecked();
}
// Allocates and fully initializes a String. There are two String encodings:
// one-byte and two-byte. One should choose between the threestring
// allocation functions based on the encoding of the string buffer used to
// initialized the string.
// - ...FromOneByte initializes the string from a buffer that is Latin1
// encoded (it does not check that the buffer is Latin1 encoded) and the
// result will be Latin1 encoded.
// - ...FromUTF8 initializes the string from a buffer that is UTF-8
// encoded. If the characters are all ASCII characters, the result
// will be Latin1 encoded, otherwise it will converted to two-byte.
// - ...FromTwoByte initializes the string from a buffer that is two-byte
// encoded. If the characters are all Latin1 characters, the
// result will be converted to Latin1, otherwise it will be left as
// two-byte.
// TODO(dcarney): remove this function.
MUST_USE_RESULT inline MaybeHandle<String> NewStringFromAscii(
Vector<const char> str,
PretenureFlag pretenure = NOT_TENURED) {
return NewStringFromOneByte(Vector<const uint8_t>::cast(str), pretenure);
}
// UTF8 strings are pretenured when used for regexp literal patterns and
// flags in the parser.
MUST_USE_RESULT MaybeHandle<String> NewStringFromUtf8(
......
......@@ -136,7 +136,10 @@ bool RegExpParser::IsSyntaxCharacterOrSlash(uc32 c) {
RegExpTree* RegExpParser::ReportError(Vector<const char> message) {
if (failed_) return NULL; // Do not overwrite any existing error.
failed_ = true;
*error_ = isolate()->factory()->NewStringFromAscii(message).ToHandleChecked();
*error_ = isolate()
->factory()
->NewStringFromOneByte(Vector<const uint8_t>::cast(message))
.ToHandleChecked();
// Zip to the end to make sure the no more input is read.
current_ = kEndMarker;
next_pos_ = in()->length();
......
......@@ -492,8 +492,8 @@ Handle<WasmExportedFunction> WasmExportedFunction::New(
EmbeddedVector<char, 16> buffer;
int length = SNPrintF(buffer, "%d", func_index);
name = isolate->factory()
->NewStringFromAscii(
Vector<const char>::cast(buffer.SubVector(0, length)))
->NewStringFromOneByte(
Vector<uint8_t>::cast(buffer.SubVector(0, length)))
.ToHandleChecked();
} else {
name = maybe_name.ToHandleChecked();
......
......@@ -311,10 +311,10 @@ void TestCharacterStreams(const char* one_byte_source, unsigned length,
}
// 1-byte external string
i::Vector<const char> one_byte_vector(one_byte_source,
static_cast<int>(length));
i::Vector<const uint8_t> one_byte_vector =
i::OneByteVector(one_byte_source, static_cast<int>(length));
i::Handle<i::String> one_byte_string =
factory->NewStringFromAscii(one_byte_vector).ToHandleChecked();
factory->NewStringFromOneByte(one_byte_vector).ToHandleChecked();
{
TestExternalOneByteResource one_byte_resource(one_byte_source, length);
i::Handle<i::String> ext_one_byte_string(
......@@ -350,10 +350,8 @@ void TestCharacterStreams(const char* one_byte_source, unsigned length,
// 1-byte streaming stream, single + many chunks.
{
const uint8_t* data =
reinterpret_cast<const uint8_t*>(one_byte_vector.begin());
const uint8_t* data_end =
reinterpret_cast<const uint8_t*>(one_byte_vector.end());
const uint8_t* data = one_byte_vector.begin();
const uint8_t* data_end = one_byte_vector.end();
ChunkSource single_chunk(data, data_end - data, false);
std::unique_ptr<i::Utf16CharacterStream> one_byte_streaming_stream(
......@@ -372,10 +370,8 @@ void TestCharacterStreams(const char* one_byte_source, unsigned length,
// UTF-8 streaming stream, single + many chunks.
{
const uint8_t* data =
reinterpret_cast<const uint8_t*>(one_byte_vector.begin());
const uint8_t* data_end =
reinterpret_cast<const uint8_t*>(one_byte_vector.end());
const uint8_t* data = one_byte_vector.begin();
const uint8_t* data_end = one_byte_vector.end();
ChunkSource chunks(data, data_end - data, false);
std::unique_ptr<i::Utf16CharacterStream> utf8_streaming_stream(
i::ScannerStream::For(&chunks, v8::ScriptCompiler::StreamedSource::UTF8,
......
......@@ -180,8 +180,9 @@ static void InitializeBuildingBlocks(Handle<String>* building_blocks,
for (int j = 0; j < len; j++) {
buf[j] = rng->next(0x80);
}
building_blocks[i] = factory->NewStringFromAscii(
Vector<const char>(buf, len)).ToHandleChecked();
building_blocks[i] =
factory->NewStringFromOneByte(OneByteVector(buf, len))
.ToHandleChecked();
for (int j = 0; j < len; j++) {
CHECK_EQ(buf[j], building_blocks[i]->Get(j));
}
......@@ -1585,7 +1586,6 @@ TEST(InvalidExternalString) {
dummy.Dispose(); \
}
INVALID_STRING_TEST(NewStringFromAscii, char)
INVALID_STRING_TEST(NewStringFromUtf8, char)
INVALID_STRING_TEST(NewStringFromOneByte, uint8_t)
......
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