Skip to content

Commit 7f5383e

Browse files
danelphickV8 LUCI CQ
authored andcommitted
[base] Move utils/vector.h to base/vector.h
The adding of base:: was mostly prepared using git grep and sed: git grep -l <pattern> | grep -v base/vector.h | \ xargs sed -i 's/\b<pattern>\b/base::<pattern>/ with lots of manual clean-ups due to the resulting v8::internal::base::Vectors. #includes were fixed using: git grep -l "src/utils/vector.h" | \ axargs sed -i 's!src/utils/vector.h!src/base/vector.h!' Bug: v8:11879 Change-Id: I3e6d622987fee4478089c40539724c19735bd625 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2968412 Reviewed-by: Clemens Backes <[email protected]> Reviewed-by: Hannes Payer <[email protected]> Commit-Queue: Dan Elphick <[email protected]> Cr-Commit-Position: refs/heads/master@{#75243}
1 parent 3296de2 commit 7f5383e

359 files changed

Lines changed: 2656 additions & 2425 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ filegroup(
246246
"src/base/type-traits.h",
247247
"src/base/utils/random-number-generator.cc",
248248
"src/base/utils/random-number-generator.h",
249+
"src/base/vector.h",
249250
"src/base/v8-fallthrough.h",
250251
"src/base/vlq-base64.cc",
251252
"src/base/vlq-base64.h",
@@ -1599,7 +1600,6 @@ filegroup(
15991600
"src/utils/utils-inl.h",
16001601
"src/utils/utils.cc",
16011602
"src/utils/utils.h",
1602-
"src/utils/vector.h",
16031603
"src/utils/version.cc",
16041604
"src/utils/version.h",
16051605
"src/web-snapshot/web-snapshot.h",

BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3131,7 +3131,6 @@ v8_header_set("v8_internal_headers") {
31313131
"src/utils/scoped-list.h",
31323132
"src/utils/utils-inl.h",
31333133
"src/utils/utils.h",
3134-
"src/utils/vector.h",
31353134
"src/utils/version.h",
31363135
"src/zone/accounting-allocator.h",
31373136
"src/zone/compressed-zone-ptr.h",
@@ -4705,6 +4704,7 @@ v8_component("v8_libbase") {
47054704
"src/base/type-traits.h",
47064705
"src/base/utils/random-number-generator.cc",
47074706
"src/base/utils/random-number-generator.h",
4707+
"src/base/vector.h",
47084708
"src/base/vlq-base64.cc",
47094709
"src/base/vlq-base64.h",
47104710
"src/base/vlq.h",

src/api/api.cc

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3255,7 +3255,8 @@ ValueDeserializer::Delegate::GetSharedArrayBufferFromId(Isolate* v8_isolate,
32553255
}
32563256

32573257
struct ValueDeserializer::PrivateData {
3258-
PrivateData(i::Isolate* i, i::Vector<const uint8_t> data, Delegate* delegate)
3258+
PrivateData(i::Isolate* i, base::Vector<const uint8_t> data,
3259+
Delegate* delegate)
32593260
: isolate(i), deserializer(i, data, delegate) {}
32603261
i::Isolate* isolate;
32613262
i::ValueDeserializer deserializer;
@@ -3272,10 +3273,11 @@ ValueDeserializer::ValueDeserializer(Isolate* isolate, const uint8_t* data,
32723273
if (base::IsValueInRangeForNumericType<int>(size)) {
32733274
private_ = new PrivateData(
32743275
reinterpret_cast<i::Isolate*>(isolate),
3275-
i::Vector<const uint8_t>(data, static_cast<int>(size)), delegate);
3276+
base::Vector<const uint8_t>(data, static_cast<int>(size)), delegate);
32763277
} else {
3277-
private_ = new PrivateData(reinterpret_cast<i::Isolate*>(isolate),
3278-
i::Vector<const uint8_t>(nullptr, 0), nullptr);
3278+
private_ =
3279+
new PrivateData(reinterpret_cast<i::Isolate*>(isolate),
3280+
base::Vector<const uint8_t>(nullptr, 0), nullptr);
32793281
private_->has_aborted = true;
32803282
}
32813283
}
@@ -5351,7 +5353,7 @@ namespace {
53515353
// units until the buffer capacity is reached, would be exceeded by the next
53525354
// unit, or all code units have been written out.
53535355
template <typename Char>
5354-
static int WriteUtf8Impl(i::Vector<const Char> string, char* write_start,
5356+
static int WriteUtf8Impl(base::Vector<const Char> string, char* write_start,
53555357
int write_capacity, int options,
53565358
int* utf16_chars_read_out) {
53575359
bool write_null = !(options & v8::String::NO_NULL_TERMINATION);
@@ -6533,7 +6535,7 @@ inline int StringLength(const uint16_t* string) {
65336535
V8_WARN_UNUSED_RESULT
65346536
inline i::MaybeHandle<i::String> NewString(i::Factory* factory,
65356537
NewStringType type,
6536-
i::Vector<const char> string) {
6538+
base::Vector<const char> string) {
65376539
if (type == NewStringType::kInternalized) {
65386540
return factory->InternalizeUtf8String(string);
65396541
}
@@ -6543,17 +6545,17 @@ inline i::MaybeHandle<i::String> NewString(i::Factory* factory,
65436545
V8_WARN_UNUSED_RESULT
65446546
inline i::MaybeHandle<i::String> NewString(i::Factory* factory,
65456547
NewStringType type,
6546-
i::Vector<const uint8_t> string) {
6548+
base::Vector<const uint8_t> string) {
65476549
if (type == NewStringType::kInternalized) {
65486550
return factory->InternalizeString(string);
65496551
}
65506552
return factory->NewStringFromOneByte(string);
65516553
}
65526554

65536555
V8_WARN_UNUSED_RESULT
6554-
inline i::MaybeHandle<i::String> NewString(i::Factory* factory,
6555-
NewStringType type,
6556-
i::Vector<const uint16_t> string) {
6556+
inline i::MaybeHandle<i::String> NewString(
6557+
i::Factory* factory, NewStringType type,
6558+
base::Vector<const uint16_t> string) {
65576559
if (type == NewStringType::kInternalized) {
65586560
return factory->InternalizeString(string);
65596561
}
@@ -6579,7 +6581,7 @@ STATIC_ASSERT(v8::String::kMaxLength == i::String::kMaxLength);
65796581
if (length < 0) length = StringLength(data); \
65806582
i::Handle<i::String> handle_result = \
65816583
NewString(i_isolate->factory(), type, \
6582-
i::Vector<const Char>(data, length)) \
6584+
base::Vector<const Char>(data, length)) \
65836585
.ToHandleChecked(); \
65846586
result = Utils::ToLocal(handle_result); \
65856587
}
@@ -6592,7 +6594,7 @@ Local<String> String::NewFromUtf8Literal(Isolate* isolate, const char* literal,
65926594
LOG_API(i_isolate, String, NewFromUtf8Literal);
65936595
i::Handle<i::String> handle_result =
65946596
NewString(i_isolate->factory(), type,
6595-
i::Vector<const char>(literal, length))
6597+
base::Vector<const char>(literal, length))
65966598
.ToHandleChecked();
65976599
return Utils::ToLocal(handle_result);
65986600
}
@@ -7538,7 +7540,7 @@ OwnedBuffer CompiledWasmModule::Serialize() {
75387540

75397541
MemorySpan<const uint8_t> CompiledWasmModule::GetWireBytesRef() {
75407542
#if V8_ENABLE_WEBASSEMBLY
7541-
i::Vector<const uint8_t> bytes_vec = native_module_->wire_bytes();
7543+
base::Vector<const uint8_t> bytes_vec = native_module_->wire_bytes();
75427544
return {bytes_vec.begin(), bytes_vec.size()};
75437545
#else
75447546
UNREACHABLE();
@@ -7577,7 +7579,7 @@ MaybeLocal<WasmModuleObject> WasmModuleObject::FromCompiledModule(
75777579
i::Handle<i::WasmModuleObject> module_object =
75787580
i_isolate->wasm_engine()->ImportNativeModule(
75797581
i_isolate, compiled_module.native_module_,
7580-
i::VectorOf(compiled_module.source_url()));
7582+
base::VectorOf(compiled_module.source_url()));
75817583
return Local<WasmModuleObject>::Cast(
75827584
Utils::ToLocal(i::Handle<i::JSObject>::cast(module_object)));
75837585
#else

src/asmjs/asm-js.cc

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "src/ast/ast.h"
1010
#include "src/base/optional.h"
1111
#include "src/base/platform/elapsed-timer.h"
12+
#include "src/base/vector.h"
1213
#include "src/codegen/compiler.h"
1314
#include "src/codegen/unoptimized-compilation-info.h"
1415
#include "src/common/assert-scope.h"
@@ -23,8 +24,6 @@
2324
#include "src/parsing/parse-info.h"
2425
#include "src/parsing/scanner-character-streams.h"
2526
#include "src/parsing/scanner.h"
26-
#include "src/utils/vector.h"
27-
2827
#include "src/wasm/wasm-engine.h"
2928
#include "src/wasm/wasm-js.h"
3029
#include "src/wasm/wasm-limits.h"
@@ -42,7 +41,7 @@ namespace {
4241
Handle<Object> StdlibMathMember(Isolate* isolate, Handle<JSReceiver> stdlib,
4342
Handle<Name> name) {
4443
Handle<Name> math_name(
45-
isolate->factory()->InternalizeString(StaticCharVector("Math")));
44+
isolate->factory()->InternalizeString(base::StaticCharVector("Math")));
4645
Handle<Object> math = JSReceiver::GetDataProperty(stdlib, math_name);
4746
if (!math->IsJSReceiver()) return isolate->factory()->undefined_value();
4847
Handle<JSReceiver> math_receiver = Handle<JSReceiver>::cast(math);
@@ -68,8 +67,8 @@ bool AreStdlibMembersValid(Isolate* isolate, Handle<JSReceiver> stdlib,
6867
#define STDLIB_MATH_FUNC(fname, FName, ignore1, ignore2) \
6968
if (members.contains(wasm::AsmJsParser::StandardMember::kMath##FName)) { \
7069
members.Remove(wasm::AsmJsParser::StandardMember::kMath##FName); \
71-
Handle<Name> name( \
72-
isolate->factory()->InternalizeString(StaticCharVector(#fname))); \
70+
Handle<Name> name(isolate->factory()->InternalizeString( \
71+
base::StaticCharVector(#fname))); \
7372
Handle<Object> value = StdlibMathMember(isolate, stdlib, name); \
7473
if (!value->IsJSFunction()) return false; \
7574
SharedFunctionInfo shared = Handle<JSFunction>::cast(value)->shared(); \
@@ -85,23 +84,23 @@ bool AreStdlibMembersValid(Isolate* isolate, Handle<JSReceiver> stdlib,
8584
#define STDLIB_MATH_CONST(cname, const_value) \
8685
if (members.contains(wasm::AsmJsParser::StandardMember::kMath##cname)) { \
8786
members.Remove(wasm::AsmJsParser::StandardMember::kMath##cname); \
88-
Handle<Name> name( \
89-
isolate->factory()->InternalizeString(StaticCharVector(#cname))); \
87+
Handle<Name> name(isolate->factory()->InternalizeString( \
88+
base::StaticCharVector(#cname))); \
9089
Handle<Object> value = StdlibMathMember(isolate, stdlib, name); \
9190
if (!value->IsNumber() || value->Number() != const_value) return false; \
9291
}
9392
STDLIB_MATH_VALUE_LIST(STDLIB_MATH_CONST)
9493
#undef STDLIB_MATH_CONST
95-
#define STDLIB_ARRAY_TYPE(fname, FName) \
96-
if (members.contains(wasm::AsmJsParser::StandardMember::k##FName)) { \
97-
members.Remove(wasm::AsmJsParser::StandardMember::k##FName); \
98-
*is_typed_array = true; \
99-
Handle<Name> name( \
100-
isolate->factory()->InternalizeString(StaticCharVector(#FName))); \
101-
Handle<Object> value = JSReceiver::GetDataProperty(stdlib, name); \
102-
if (!value->IsJSFunction()) return false; \
103-
Handle<JSFunction> func = Handle<JSFunction>::cast(value); \
104-
if (!func.is_identical_to(isolate->fname())) return false; \
94+
#define STDLIB_ARRAY_TYPE(fname, FName) \
95+
if (members.contains(wasm::AsmJsParser::StandardMember::k##FName)) { \
96+
members.Remove(wasm::AsmJsParser::StandardMember::k##FName); \
97+
*is_typed_array = true; \
98+
Handle<Name> name(isolate->factory()->InternalizeString( \
99+
base::StaticCharVector(#FName))); \
100+
Handle<Object> value = JSReceiver::GetDataProperty(stdlib, name); \
101+
if (!value->IsJSFunction()) return false; \
102+
Handle<JSFunction> func = Handle<JSFunction>::cast(value); \
103+
if (!func.is_identical_to(isolate->fname())) return false; \
105104
}
106105
STDLIB_ARRAY_TYPE(int8_array_fun, Int8Array)
107106
STDLIB_ARRAY_TYPE(uint8_array_fun, Uint8Array)
@@ -117,7 +116,7 @@ bool AreStdlibMembersValid(Isolate* isolate, Handle<JSReceiver> stdlib,
117116
return true;
118117
}
119118

120-
void Report(Handle<Script> script, int position, Vector<const char> text,
119+
void Report(Handle<Script> script, int position, base::Vector<const char> text,
121120
MessageTemplate message_template,
122121
v8::Isolate::MessageErrorLevel level) {
123122
Isolate* isolate = script->GetIsolate();
@@ -134,7 +133,7 @@ void Report(Handle<Script> script, int position, Vector<const char> text,
134133
void ReportCompilationSuccess(Handle<Script> script, int position,
135134
double compile_time, size_t module_size) {
136135
if (FLAG_suppress_asm_messages || !FLAG_trace_asm_time) return;
137-
EmbeddedVector<char, 100> text;
136+
base::EmbeddedVector<char, 100> text;
138137
int length = SNPrintF(text, "success, compile time %0.3f ms, %zu bytes",
139138
compile_time, module_size);
140139
CHECK_NE(-1, length);
@@ -155,7 +154,7 @@ void ReportCompilationFailure(ParseInfo* parse_info, int position,
155154
void ReportInstantiationSuccess(Handle<Script> script, int position,
156155
double instantiate_time) {
157156
if (FLAG_suppress_asm_messages || !FLAG_trace_asm_time) return;
158-
EmbeddedVector<char, 50> text;
157+
base::EmbeddedVector<char, 50> text;
159158
int length = SNPrintF(text, "success, %0.3f ms", instantiate_time);
160159
CHECK_NE(-1, length);
161160
text.Truncate(length);
@@ -167,7 +166,7 @@ void ReportInstantiationSuccess(Handle<Script> script, int position,
167166
void ReportInstantiationFailure(Handle<Script> script, int position,
168167
const char* reason) {
169168
if (FLAG_suppress_asm_messages) return;
170-
Vector<const char> text = CStrVector(reason);
169+
base::Vector<const char> text = base::CStrVector(reason);
171170
Report(script, position, text, MessageTemplate::kAsmJsLinkingFailed,
172171
v8::Isolate::kMessageWarning);
173172
}
@@ -270,7 +269,7 @@ UnoptimizedCompilationJob::Status AsmJsCompilationJob::FinalizeJobImpl(
270269
->SyncCompileTranslatedAsmJs(
271270
isolate, &thrower,
272271
wasm::ModuleWireBytes(module_->begin(), module_->end()),
273-
VectorOf(*asm_offsets_), uses_bitset,
272+
base::VectorOf(*asm_offsets_), uses_bitset,
274273
shared_info->language_mode())
275274
.ToHandleChecked();
276275
DCHECK(!thrower.error());
@@ -392,7 +391,7 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(Isolate* isolate,
392391
// and bypass the {ErrorThrower}, this happens in case of a stack overflow.
393392
if (isolate->has_pending_exception()) isolate->clear_pending_exception();
394393
if (thrower.error()) {
395-
ScopedVector<char> error_reason(100);
394+
base::ScopedVector<char> error_reason(100);
396395
SNPrintF(error_reason, "Internal wasm failure: %s", thrower.error_msg());
397396
ReportInstantiationFailure(script, position, error_reason.begin());
398397
} else {

src/asmjs/asm-parser.cc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,16 @@ wasm::AsmJsParser::VarInfo* AsmJsParser::GetVarInfo(
200200
AsmJsScanner::token_t token) {
201201
const bool is_global = AsmJsScanner::IsGlobal(token);
202202
DCHECK(is_global || AsmJsScanner::IsLocal(token));
203-
Vector<VarInfo>& var_info = is_global ? global_var_info_ : local_var_info_;
203+
base::Vector<VarInfo>& var_info =
204+
is_global ? global_var_info_ : local_var_info_;
204205
size_t old_capacity = var_info.size();
205206
size_t index = is_global ? AsmJsScanner::GlobalIndex(token)
206207
: AsmJsScanner::LocalIndex(token);
207208
if (is_global && index + 1 > num_globals_) num_globals_ = index + 1;
208209
if (index + 1 > old_capacity) {
209210
size_t new_size = std::max(2 * old_capacity, index + 1);
210-
Vector<VarInfo> new_info{zone_->NewArray<VarInfo>(new_size), new_size};
211+
base::Vector<VarInfo> new_info{zone_->NewArray<VarInfo>(new_size),
212+
new_size};
211213
std::uninitialized_fill(new_info.begin(), new_info.end(), VarInfo{});
212214
std::copy(var_info.begin(), var_info.end(), new_info.begin());
213215
var_info = new_info;
@@ -220,7 +222,7 @@ uint32_t AsmJsParser::VarIndex(VarInfo* info) {
220222
return info->index + static_cast<uint32_t>(global_imports_.size());
221223
}
222224

223-
void AsmJsParser::AddGlobalImport(Vector<const char> name, AsmType* type,
225+
void AsmJsParser::AddGlobalImport(base::Vector<const char> name, AsmType* type,
224226
ValueType vtype, bool mutable_variable,
225227
VarInfo* info) {
226228
// Allocate a separate variable for the import.
@@ -256,11 +258,11 @@ uint32_t AsmJsParser::TempVariable(int index) {
256258
return function_temp_locals_offset_ + index;
257259
}
258260

259-
Vector<const char> AsmJsParser::CopyCurrentIdentifierString() {
261+
base::Vector<const char> AsmJsParser::CopyCurrentIdentifierString() {
260262
const std::string& str = scanner_.GetIdentifierString();
261263
char* buffer = zone()->NewArray<char>(str.size());
262264
str.copy(buffer, str.size());
263-
return Vector<const char>(buffer, static_cast<int>(str.size()));
265+
return base::Vector<const char>(buffer, static_cast<int>(str.size()));
264266
}
265267

266268
void AsmJsParser::SkipSemicolon() {
@@ -539,13 +541,13 @@ void AsmJsParser::ValidateModuleVarImport(VarInfo* info,
539541
if (Check('+')) {
540542
EXPECT_TOKEN(foreign_name_);
541543
EXPECT_TOKEN('.');
542-
Vector<const char> name = CopyCurrentIdentifierString();
544+
base::Vector<const char> name = CopyCurrentIdentifierString();
543545
AddGlobalImport(name, AsmType::Double(), kWasmF64, mutable_variable, info);
544546
scanner_.Next();
545547
} else {
546548
EXPECT_TOKEN(foreign_name_);
547549
EXPECT_TOKEN('.');
548-
Vector<const char> name = CopyCurrentIdentifierString();
550+
base::Vector<const char> name = CopyCurrentIdentifierString();
549551
scanner_.Next();
550552
if (Check('|')) {
551553
if (!CheckForZero()) {
@@ -626,7 +628,7 @@ void AsmJsParser::ValidateExport() {
626628
// clang-format on
627629
if (Check('{')) {
628630
for (;;) {
629-
Vector<const char> name = CopyCurrentIdentifierString();
631+
base::Vector<const char> name = CopyCurrentIdentifierString();
630632
if (!scanner_.IsGlobal() && !scanner_.IsLocal()) {
631633
FAIL("Illegal export name");
632634
}
@@ -656,7 +658,7 @@ void AsmJsParser::ValidateExport() {
656658
if (info->kind != VarKind::kFunction) {
657659
FAIL("Single function export must be a function");
658660
}
659-
module_builder_->AddExport(CStrVector(AsmJs::kSingleFunctionName),
661+
module_builder_->AddExport(base::CStrVector(AsmJs::kSingleFunctionName),
660662
info->function_builder);
661663
}
662664
}
@@ -725,7 +727,7 @@ void AsmJsParser::ValidateFunction() {
725727
FAIL("Expected function name");
726728
}
727729

728-
Vector<const char> function_name_str = CopyCurrentIdentifierString();
730+
base::Vector<const char> function_name_str = CopyCurrentIdentifierString();
729731
AsmJsScanner::token_t function_name = Consume();
730732
VarInfo* function_info = GetVarInfo(function_name);
731733
if (function_info->kind == VarKind::kUnused) {

0 commit comments

Comments
 (0)