Commit c5f5b93d authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

Remove Vector constructor accepting static array

Use the existing {ArrayVector} method for this, which reads nicer. In
some places, I replaced a stack-allocated array by {EmbeddedVector} to
avoid the {ArrayVector} call.

R=mstarzinger@chromium.org

Bug: v8:8834
Change-Id: I5560c07f2775338fefd11acf67a540e003428e74
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1578899Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60975}
parent 5f652b84
...@@ -168,14 +168,13 @@ void CodeStubAssembler::FailAssert( ...@@ -168,14 +168,13 @@ void CodeStubAssembler::FailAssert(
const char* extra_node4_name, Node* extra_node5, const char* extra_node4_name, Node* extra_node5,
const char* extra_node5_name) { const char* extra_node5_name) {
DCHECK_NOT_NULL(message); DCHECK_NOT_NULL(message);
char chars[1024]; EmbeddedVector<char, 1024> chars;
Vector<char> buffer(chars);
if (file != nullptr) { if (file != nullptr) {
SNPrintF(buffer, "CSA_ASSERT failed: %s [%s:%d]\n", message, file, line); SNPrintF(chars, "CSA_ASSERT failed: %s [%s:%d]\n", message, file, line);
} else { } else {
SNPrintF(buffer, "CSA_ASSERT failed: %s\n", message); SNPrintF(chars, "CSA_ASSERT failed: %s\n", message);
} }
Node* message_node = StringConstant(&(buffer[0])); Node* message_node = StringConstant(chars.begin());
#ifdef DEBUG #ifdef DEBUG
// Only print the extra nodes in debug builds. // Only print the extra nodes in debug builds.
......
...@@ -129,10 +129,10 @@ void EmbeddedFileWriter::PrepareBuiltinSourcePositionMap(Builtins* builtins) { ...@@ -129,10 +129,10 @@ void EmbeddedFileWriter::PrepareBuiltinSourcePositionMap(Builtins* builtins) {
#if defined(V8_OS_WIN_X64) #if defined(V8_OS_WIN_X64)
std::string EmbeddedFileWriter::BuiltinsUnwindInfoLabel() const { std::string EmbeddedFileWriter::BuiltinsUnwindInfoLabel() const {
char embedded_blob_data_symbol[kTemporaryStringLength]; i::EmbeddedVector<char, kTemporaryStringLength> embedded_blob_data_symbol;
i::SNPrintF(i::Vector<char>(embedded_blob_data_symbol), i::SNPrintF(embedded_blob_data_symbol, "%s_Builtins_UnwindInfo",
"%s_Builtins_UnwindInfo", embedded_variant_); embedded_variant_);
return embedded_blob_data_symbol; return std::string{embedded_blob_data_symbol.begin()};
} }
void EmbeddedFileWriter::SetBuiltinUnwindData( void EmbeddedFileWriter::SetBuiltinUnwindData(
......
...@@ -212,10 +212,10 @@ class EmbeddedFileWriter : public EmbeddedFileWriterInterface { ...@@ -212,10 +212,10 @@ class EmbeddedFileWriter : public EmbeddedFileWriterInterface {
static constexpr int kTemporaryStringLength = 256; static constexpr int kTemporaryStringLength = 256;
std::string EmbeddedBlobDataSymbol() const { std::string EmbeddedBlobDataSymbol() const {
char embedded_blob_data_symbol[kTemporaryStringLength]; i::EmbeddedVector<char, kTemporaryStringLength> embedded_blob_data_symbol;
i::SNPrintF(i::Vector<char>(embedded_blob_data_symbol), i::SNPrintF(embedded_blob_data_symbol, "v8_%s_embedded_blob_data_",
"v8_%s_embedded_blob_data_", embedded_variant_); embedded_variant_);
return embedded_blob_data_symbol; return std::string{embedded_blob_data_symbol.begin()};
} }
void WriteMetadataSection(PlatformDependentEmbeddedFileWriter* w, void WriteMetadataSection(PlatformDependentEmbeddedFileWriter* w,
...@@ -235,21 +235,20 @@ class EmbeddedFileWriter : public EmbeddedFileWriterInterface { ...@@ -235,21 +235,20 @@ class EmbeddedFileWriter : public EmbeddedFileWriterInterface {
const bool is_default_variant = const bool is_default_variant =
std::strcmp(embedded_variant_, kDefaultEmbeddedVariant) == 0; std::strcmp(embedded_variant_, kDefaultEmbeddedVariant) == 0;
char builtin_symbol[kTemporaryStringLength]; i::EmbeddedVector<char, kTemporaryStringLength> builtin_symbol;
if (is_default_variant) { if (is_default_variant) {
// Create nicer symbol names for the default mode. // Create nicer symbol names for the default mode.
i::SNPrintF(i::Vector<char>(builtin_symbol), "Builtins_%s", i::SNPrintF(builtin_symbol, "Builtins_%s", i::Builtins::name(builtin_id));
i::Builtins::name(builtin_id));
} else { } else {
i::SNPrintF(i::Vector<char>(builtin_symbol), "%s_Builtins_%s", i::SNPrintF(builtin_symbol, "%s_Builtins_%s", embedded_variant_,
embedded_variant_, i::Builtins::name(builtin_id)); i::Builtins::name(builtin_id));
} }
// Labels created here will show up in backtraces. We check in // Labels created here will show up in backtraces. We check in
// Isolate::SetEmbeddedBlob that the blob layout remains unchanged, i.e. // Isolate::SetEmbeddedBlob that the blob layout remains unchanged, i.e.
// that labels do not insert bytes into the middle of the blob byte // that labels do not insert bytes into the middle of the blob byte
// stream. // stream.
w->DeclareFunctionBegin(builtin_symbol); w->DeclareFunctionBegin(builtin_symbol.begin());
const std::vector<byte>& current_positions = source_positions_[builtin_id]; const std::vector<byte>& current_positions = source_positions_[builtin_id];
// The code below interleaves bytes of assembly code for the builtin // The code below interleaves bytes of assembly code for the builtin
...@@ -280,7 +279,7 @@ class EmbeddedFileWriter : public EmbeddedFileWriterInterface { ...@@ -280,7 +279,7 @@ class EmbeddedFileWriter : public EmbeddedFileWriterInterface {
i = next_offset; i = next_offset;
} }
w->DeclareFunctionEnd(builtin_symbol); w->DeclareFunctionEnd(builtin_symbol.begin());
} }
void WriteInstructionStreams(PlatformDependentEmbeddedFileWriter* w, void WriteInstructionStreams(PlatformDependentEmbeddedFileWriter* w,
...@@ -296,27 +295,27 @@ class EmbeddedFileWriter : public EmbeddedFileWriterInterface { ...@@ -296,27 +295,27 @@ class EmbeddedFileWriter : public EmbeddedFileWriterInterface {
void WriteFileEpilogue(PlatformDependentEmbeddedFileWriter* w, void WriteFileEpilogue(PlatformDependentEmbeddedFileWriter* w,
const i::EmbeddedData* blob) const { const i::EmbeddedData* blob) const {
{ {
char embedded_blob_symbol[kTemporaryStringLength]; i::EmbeddedVector<char, kTemporaryStringLength> embedded_blob_symbol;
i::SNPrintF(i::Vector<char>(embedded_blob_symbol), "v8_%s_embedded_blob_", i::SNPrintF(embedded_blob_symbol, "v8_%s_embedded_blob_",
embedded_variant_); embedded_variant_);
w->Comment("Pointer to the beginning of the embedded blob."); w->Comment("Pointer to the beginning of the embedded blob.");
w->SectionData(); w->SectionData();
w->AlignToDataAlignment(); w->AlignToDataAlignment();
w->DeclarePointerToSymbol(embedded_blob_symbol, w->DeclarePointerToSymbol(embedded_blob_symbol.begin(),
EmbeddedBlobDataSymbol().c_str()); EmbeddedBlobDataSymbol().c_str());
w->Newline(); w->Newline();
} }
{ {
char embedded_blob_size_symbol[kTemporaryStringLength]; i::EmbeddedVector<char, kTemporaryStringLength> embedded_blob_size_symbol;
i::SNPrintF(i::Vector<char>(embedded_blob_size_symbol), i::SNPrintF(embedded_blob_size_symbol, "v8_%s_embedded_blob_size_",
"v8_%s_embedded_blob_size_", embedded_variant_); embedded_variant_);
w->Comment("The size of the embedded blob in bytes."); w->Comment("The size of the embedded blob in bytes.");
w->SectionRoData(); w->SectionRoData();
w->AlignToDataAlignment(); w->AlignToDataAlignment();
w->DeclareUint32(embedded_blob_size_symbol, blob->size()); w->DeclareUint32(embedded_blob_size_symbol.begin(), blob->size());
w->Newline(); w->Newline();
} }
......
...@@ -28,9 +28,6 @@ class Vector { ...@@ -28,9 +28,6 @@ class Vector {
#endif #endif
} }
template <size_t N>
explicit constexpr Vector(T (&arr)[N]) : start_(arr), length_(N) {}
static Vector<T> New(size_t length) { static Vector<T> New(size_t length) {
return Vector<T>(NewArray<T>(length), length); return Vector<T>(NewArray<T>(length), length);
} }
......
...@@ -589,9 +589,9 @@ TEST(TryToName) { ...@@ -589,9 +589,9 @@ TEST(TryToName) {
if (FLAG_thin_strings) { if (FLAG_thin_strings) {
// TryToName(<thin two-byte string>) => internalized version. // TryToName(<thin two-byte string>) => internalized version.
uc16 array1[] = {2001, 2002, 2003}; uc16 array1[] = {2001, 2002, 2003};
Vector<const uc16> str1(array1); Handle<String> s = isolate->factory()
Handle<String> s = ->NewStringFromTwoByte(ArrayVector(array1))
isolate->factory()->NewStringFromTwoByte(str1).ToHandleChecked(); .ToHandleChecked();
Handle<String> internalized = isolate->factory()->InternalizeString(s); Handle<String> internalized = isolate->factory()->InternalizeString(s);
ft.CheckTrue(s, expect_unique, internalized); ft.CheckTrue(s, expect_unique, internalized);
} }
...@@ -1794,9 +1794,9 @@ TEST(OneToTwoByteStringCopy) { ...@@ -1794,9 +1794,9 @@ TEST(OneToTwoByteStringCopy) {
Handle<String> string1 = isolate->factory()->InternalizeUtf8String("abcde"); Handle<String> string1 = isolate->factory()->InternalizeUtf8String("abcde");
uc16 array[] = {1000, 1001, 1002, 1003, 1004}; uc16 array[] = {1000, 1001, 1002, 1003, 1004};
Vector<const uc16> str(array); Handle<String> string2 = isolate->factory()
Handle<String> string2 = ->NewStringFromTwoByte(ArrayVector(array))
isolate->factory()->NewStringFromTwoByte(str).ToHandleChecked(); .ToHandleChecked();
FunctionTester ft(asm_tester.GenerateCode(), kNumParams); FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
ft.Call(string1, string2); ft.Call(string1, string2);
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
...@@ -1826,9 +1826,9 @@ TEST(OneToOneByteStringCopy) { ...@@ -1826,9 +1826,9 @@ TEST(OneToOneByteStringCopy) {
Handle<String> string1 = isolate->factory()->InternalizeUtf8String("abcde"); Handle<String> string1 = isolate->factory()->InternalizeUtf8String("abcde");
uint8_t array[] = {100, 101, 102, 103, 104}; uint8_t array[] = {100, 101, 102, 103, 104};
Vector<const uint8_t> str(array); Handle<String> string2 = isolate->factory()
Handle<String> string2 = ->NewStringFromOneByte(ArrayVector(array))
isolate->factory()->NewStringFromOneByte(str).ToHandleChecked(); .ToHandleChecked();
FunctionTester ft(asm_tester.GenerateCode(), kNumParams); FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
ft.Call(string1, string2); ft.Call(string1, string2);
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
...@@ -1858,9 +1858,9 @@ TEST(OneToOneByteStringCopyNonZeroStart) { ...@@ -1858,9 +1858,9 @@ TEST(OneToOneByteStringCopyNonZeroStart) {
Handle<String> string1 = isolate->factory()->InternalizeUtf8String("abcde"); Handle<String> string1 = isolate->factory()->InternalizeUtf8String("abcde");
uint8_t array[] = {100, 101, 102, 103, 104}; uint8_t array[] = {100, 101, 102, 103, 104};
Vector<const uint8_t> str(array); Handle<String> string2 = isolate->factory()
Handle<String> string2 = ->NewStringFromOneByte(ArrayVector(array))
isolate->factory()->NewStringFromOneByte(str).ToHandleChecked(); .ToHandleChecked();
FunctionTester ft(asm_tester.GenerateCode(), kNumParams); FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
ft.Call(string1, string2); ft.Call(string1, string2);
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
...@@ -1886,13 +1886,13 @@ TEST(TwoToTwoByteStringCopy) { ...@@ -1886,13 +1886,13 @@ TEST(TwoToTwoByteStringCopy) {
m.Return(m.SmiConstant(Smi::FromInt(0))); m.Return(m.SmiConstant(Smi::FromInt(0)));
uc16 array1[] = {2000, 2001, 2002, 2003, 2004}; uc16 array1[] = {2000, 2001, 2002, 2003, 2004};
Vector<const uc16> str1(array1); Handle<String> string1 = isolate->factory()
Handle<String> string1 = ->NewStringFromTwoByte(ArrayVector(array1))
isolate->factory()->NewStringFromTwoByte(str1).ToHandleChecked(); .ToHandleChecked();
uc16 array2[] = {1000, 1001, 1002, 1003, 1004}; uc16 array2[] = {1000, 1001, 1002, 1003, 1004};
Vector<const uc16> str2(array2); Handle<String> string2 = isolate->factory()
Handle<String> string2 = ->NewStringFromTwoByte(ArrayVector(array2))
isolate->factory()->NewStringFromTwoByte(str2).ToHandleChecked(); .ToHandleChecked();
FunctionTester ft(asm_tester.GenerateCode(), kNumParams); FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
ft.Call(string1, string2); ft.Call(string1, string2);
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
......
...@@ -50,7 +50,7 @@ WASM_EXEC_TEST(MemoryInit) { ...@@ -50,7 +50,7 @@ WASM_EXEC_TEST(MemoryInit) {
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier); WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize); r.builder().AddMemory(kWasmPageSize);
const byte data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; const byte data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
r.builder().AddPassiveDataSegment(Vector<const byte>(data)); r.builder().AddPassiveDataSegment(ArrayVector(data));
BUILD(r, BUILD(r,
WASM_MEMORY_INIT(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), WASM_MEMORY_INIT(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1),
WASM_GET_LOCAL(2)), WASM_GET_LOCAL(2)),
...@@ -87,7 +87,7 @@ WASM_EXEC_TEST(MemoryInitOutOfBoundsData) { ...@@ -87,7 +87,7 @@ WASM_EXEC_TEST(MemoryInitOutOfBoundsData) {
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier); WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize); r.builder().AddMemory(kWasmPageSize);
const byte data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; const byte data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
r.builder().AddPassiveDataSegment(Vector<const byte>(data)); r.builder().AddPassiveDataSegment(ArrayVector(data));
BUILD(r, BUILD(r,
WASM_MEMORY_INIT(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), WASM_MEMORY_INIT(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1),
WASM_GET_LOCAL(2)), WASM_GET_LOCAL(2)),
...@@ -110,7 +110,7 @@ WASM_EXEC_TEST(MemoryInitOutOfBounds) { ...@@ -110,7 +110,7 @@ WASM_EXEC_TEST(MemoryInitOutOfBounds) {
WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier); WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize); r.builder().AddMemory(kWasmPageSize);
const byte data[kWasmPageSize] = {}; const byte data[kWasmPageSize] = {};
r.builder().AddPassiveDataSegment(Vector<const byte>(data)); r.builder().AddPassiveDataSegment(ArrayVector(data));
BUILD(r, BUILD(r,
WASM_MEMORY_INIT(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), WASM_MEMORY_INIT(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1),
WASM_GET_LOCAL(2)), WASM_GET_LOCAL(2)),
...@@ -331,7 +331,7 @@ WASM_EXEC_TEST(DataDropTwice) { ...@@ -331,7 +331,7 @@ WASM_EXEC_TEST(DataDropTwice) {
WasmRunner<uint32_t> r(execution_tier); WasmRunner<uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize); r.builder().AddMemory(kWasmPageSize);
const byte data[] = {0}; const byte data[] = {0};
r.builder().AddPassiveDataSegment(Vector<const byte>(data)); r.builder().AddPassiveDataSegment(ArrayVector(data));
BUILD(r, WASM_DATA_DROP(0), kExprI32Const, 0); BUILD(r, WASM_DATA_DROP(0), kExprI32Const, 0);
CHECK_EQ(0, r.Call()); CHECK_EQ(0, r.Call());
...@@ -343,7 +343,7 @@ WASM_EXEC_TEST(DataDropThenMemoryInit) { ...@@ -343,7 +343,7 @@ WASM_EXEC_TEST(DataDropThenMemoryInit) {
WasmRunner<uint32_t> r(execution_tier); WasmRunner<uint32_t> r(execution_tier);
r.builder().AddMemory(kWasmPageSize); r.builder().AddMemory(kWasmPageSize);
const byte data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; const byte data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
r.builder().AddPassiveDataSegment(Vector<const byte>(data)); r.builder().AddPassiveDataSegment(ArrayVector(data));
BUILD(r, WASM_DATA_DROP(0), BUILD(r, WASM_DATA_DROP(0),
WASM_MEMORY_INIT(0, WASM_I32V_1(0), WASM_I32V_1(1), WASM_I32V_1(2)), WASM_MEMORY_INIT(0, WASM_I32V_1(0), WASM_I32V_1(1), WASM_I32V_1(2)),
kExprI32Const, 0); kExprI32Const, 0);
......
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