Commit 38ddf33c authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[vector] Rename {is_empty} to {empty}

All standard containers provide a method named {empty} to check whether
the container is empty. On {base::Vector}, that method is named
{is_empty}, while {empty} is an unused factory method for creating an
empty {Vector}.
This CL renames {is_empty} to {empty} and removes the unused factory
method.

R=leszeks@chromium.org

Bug: v8:8834
Change-Id: I686bd07527801fbe783c412bc241221d8ec3660a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1547862
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60584}
parent cb68c2e3
...@@ -234,7 +234,7 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag, ...@@ -234,7 +234,7 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
const wasm::WasmCode* code, const wasm::WasmCode* code,
wasm::WasmName name) { wasm::WasmName name) {
name_buffer_->Init(tag); name_buffer_->Init(tag);
if (name.is_empty()) { if (name.empty()) {
name_buffer_->AppendBytes("<wasm-unknown>"); name_buffer_->AppendBytes("<wasm-unknown>");
} else { } else {
name_buffer_->AppendBytes(name.start(), name.length()); name_buffer_->AppendBytes(name.start(), name.length());
...@@ -1228,7 +1228,7 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, ...@@ -1228,7 +1228,7 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AppendCodeCreateHeader(msg, tag, AbstractCode::Kind::WASM_FUNCTION, AppendCodeCreateHeader(msg, tag, AbstractCode::Kind::WASM_FUNCTION,
code->instructions().start(), code->instructions().start(),
code->instructions().length(), &timer_); code->instructions().length(), &timer_);
if (name.is_empty()) { if (name.empty()) {
msg << "<unknown wasm>"; msg << "<unknown wasm>";
} else { } else {
msg.AppendString(name); msg.AppendString(name);
......
...@@ -154,7 +154,7 @@ std::unique_ptr<char[]> OptimizedCompilationInfo::GetDebugName() const { ...@@ -154,7 +154,7 @@ std::unique_ptr<char[]> OptimizedCompilationInfo::GetDebugName() const {
return shared_info()->DebugName()->ToCString(); return shared_info()->DebugName()->ToCString();
} }
Vector<const char> name_vec = debug_name_; Vector<const char> name_vec = debug_name_;
if (name_vec.is_empty()) name_vec = ArrayVector("unknown"); if (name_vec.empty()) name_vec = ArrayVector("unknown");
std::unique_ptr<char[]> name(new char[name_vec.length() + 1]); std::unique_ptr<char[]> name(new char[name_vec.length() + 1]);
memcpy(name.get(), name_vec.start(), name_vec.length()); memcpy(name.get(), name_vec.start(), name_vec.length());
name[name_vec.length()] = '\0'; name[name_vec.length()] = '\0';
......
...@@ -69,7 +69,7 @@ class FunctionEntry { ...@@ -69,7 +69,7 @@ class FunctionEntry {
} }
int num_inner_functions() const { return backing_[kNumInnerFunctionsIndex]; } int num_inner_functions() const { return backing_[kNumInnerFunctionsIndex]; }
bool is_valid() const { return !backing_.is_empty(); } bool is_valid() const { return !backing_.empty(); }
private: private:
Vector<unsigned> backing_; Vector<unsigned> backing_;
......
...@@ -229,7 +229,7 @@ void PreparseDataBuilder::DataGatheringScope::SetSkippableFunction( ...@@ -229,7 +229,7 @@ void PreparseDataBuilder::DataGatheringScope::SetSkippableFunction(
} }
bool PreparseDataBuilder::HasInnerFunctions() const { bool PreparseDataBuilder::HasInnerFunctions() const {
return !children_.is_empty(); return !children_.empty();
} }
bool PreparseDataBuilder::HasData() const { return !bailed_out_ && has_data_; } bool PreparseDataBuilder::HasData() const { return !bailed_out_ && has_data_; }
......
...@@ -51,7 +51,7 @@ class Vector { ...@@ -51,7 +51,7 @@ class Vector {
constexpr size_t size() const { return length_; } constexpr size_t size() const { return length_; }
// Returns whether or not the vector is empty. // Returns whether or not the vector is empty.
constexpr bool is_empty() const { return length_ == 0; } constexpr bool empty() const { return length_ == 0; }
// Returns the pointer to the start of the data in the vector. // Returns the pointer to the start of the data in the vector.
constexpr T* start() const { return start_; } constexpr T* start() const { return start_; }
...@@ -140,9 +140,6 @@ class Vector { ...@@ -140,9 +140,6 @@ class Vector {
return Vector<const T>::cast(*this); return Vector<const T>::cast(*this);
} }
// Factory method for creating empty vectors.
static Vector<T> empty() { return Vector<T>(nullptr, 0); }
template <typename S> template <typename S>
static constexpr Vector<T> cast(Vector<S> input) { static constexpr Vector<T> cast(Vector<S> input) {
return Vector<T>(reinterpret_cast<T*>(input.start()), return Vector<T>(reinterpret_cast<T*>(input.start()),
...@@ -214,7 +211,7 @@ class OwnedVector { ...@@ -214,7 +211,7 @@ class OwnedVector {
constexpr size_t size() const { return length_; } constexpr size_t size() const { return length_; }
// Returns whether or not the vector is empty. // Returns whether or not the vector is empty.
constexpr bool is_empty() const { return length_ == 0; } constexpr bool empty() const { return length_ == 0; }
// Returns the pointer to the start of the data in the vector. // Returns the pointer to the start of the data in the vector.
T* start() const { T* start() const {
......
...@@ -256,7 +256,7 @@ class V8_EXPORT_PRIVATE StreamingDecoder { ...@@ -256,7 +256,7 @@ class V8_EXPORT_PRIVATE StreamingDecoder {
uint32_t module_offset() const { return module_offset_; } uint32_t module_offset() const { return module_offset_; }
bool deserializing() const { return !compiled_module_bytes_.is_empty(); } bool deserializing() const { return !compiled_module_bytes_.empty(); }
std::unique_ptr<StreamingProcessor> processor_; std::unique_ptr<StreamingProcessor> processor_;
std::unique_ptr<DecodingState> state_; std::unique_ptr<DecodingState> state_;
......
...@@ -126,7 +126,7 @@ void WasmCode::set_trap_handler_index(size_t value) { ...@@ -126,7 +126,7 @@ void WasmCode::set_trap_handler_index(size_t value) {
void WasmCode::RegisterTrapHandlerData() { void WasmCode::RegisterTrapHandlerData() {
DCHECK(!HasTrapHandlerIndex()); DCHECK(!HasTrapHandlerIndex());
if (kind() != WasmCode::kFunction) return; if (kind() != WasmCode::kFunction) return;
if (protected_instructions_.is_empty()) return; if (protected_instructions_.empty()) return;
Address base = instruction_start(); Address base = instruction_start();
...@@ -159,7 +159,7 @@ void WasmCode::LogCode(Isolate* isolate) const { ...@@ -159,7 +159,7 @@ void WasmCode::LogCode(Isolate* isolate) const {
WireBytesRef name_ref = WireBytesRef name_ref =
native_module()->module()->LookupFunctionName(wire_bytes, index()); native_module()->module()->LookupFunctionName(wire_bytes, index());
WasmName name_vec = wire_bytes.GetNameOrNull(name_ref); WasmName name_vec = wire_bytes.GetNameOrNull(name_ref);
if (!name_vec.is_empty()) { if (!name_vec.empty()) {
HandleScope scope(isolate); HandleScope scope(isolate);
MaybeHandle<String> maybe_name = isolate->factory()->NewStringFromUtf8( MaybeHandle<String> maybe_name = isolate->factory()->NewStringFromUtf8(
Vector<const char>::cast(name_vec)); Vector<const char>::cast(name_vec));
...@@ -182,7 +182,7 @@ void WasmCode::LogCode(Isolate* isolate) const { ...@@ -182,7 +182,7 @@ void WasmCode::LogCode(Isolate* isolate) const {
generated_name)); generated_name));
} }
if (!source_positions().is_empty()) { if (!source_positions().empty()) {
LOG_CODE_EVENT(isolate, CodeLinePosInfoRecordEvent(instruction_start(), LOG_CODE_EVENT(isolate, CodeLinePosInfoRecordEvent(instruction_start(),
source_positions())); source_positions()));
} }
...@@ -289,7 +289,7 @@ void WasmCode::Disassemble(const char* name, std::ostream& os, ...@@ -289,7 +289,7 @@ void WasmCode::Disassemble(const char* name, std::ostream& os,
os << "\n"; os << "\n";
} }
if (!protected_instructions_.is_empty()) { if (!protected_instructions_.empty()) {
os << "Protected instructions:\n pc offset land pad\n"; os << "Protected instructions:\n pc offset land pad\n";
for (auto& data : protected_instructions()) { for (auto& data : protected_instructions()) {
os << std::setw(10) << std::hex << data.instr_offset << std::setw(10) os << std::setw(10) << std::hex << data.instr_offset << std::setw(10)
...@@ -298,7 +298,7 @@ void WasmCode::Disassemble(const char* name, std::ostream& os, ...@@ -298,7 +298,7 @@ void WasmCode::Disassemble(const char* name, std::ostream& os,
os << "\n"; os << "\n";
} }
if (!source_positions().is_empty()) { if (!source_positions().empty()) {
os << "Source positions:\n pc offset position\n"; os << "Source positions:\n pc offset position\n";
for (SourcePositionTableIterator it(source_positions()); !it.done(); for (SourcePositionTableIterator it(source_positions()); !it.done();
it.Advance()) { it.Advance()) {
...@@ -954,7 +954,7 @@ void NativeModule::SetWireBytes(OwnedVector<const uint8_t> wire_bytes) { ...@@ -954,7 +954,7 @@ void NativeModule::SetWireBytes(OwnedVector<const uint8_t> wire_bytes) {
auto shared_wire_bytes = auto shared_wire_bytes =
std::make_shared<OwnedVector<const uint8_t>>(std::move(wire_bytes)); std::make_shared<OwnedVector<const uint8_t>>(std::move(wire_bytes));
wire_bytes_ = shared_wire_bytes; wire_bytes_ = shared_wire_bytes;
if (!shared_wire_bytes->is_empty()) { if (!shared_wire_bytes->empty()) {
compilation_state_->SetWireBytesStorage( compilation_state_->SetWireBytesStorage(
std::make_shared<NativeModuleWireBytesStorage>( std::make_shared<NativeModuleWireBytesStorage>(
std::move(shared_wire_bytes))); std::move(shared_wire_bytes)));
...@@ -1302,7 +1302,7 @@ WasmCodeUpdate NativeModule::AddCompiledCode(WasmCompilationResult result) { ...@@ -1302,7 +1302,7 @@ WasmCodeUpdate NativeModule::AddCompiledCode(WasmCompilationResult result) {
std::vector<WasmCodeUpdate> NativeModule::AddCompiledCode( std::vector<WasmCodeUpdate> NativeModule::AddCompiledCode(
Vector<WasmCompilationResult> results) { Vector<WasmCompilationResult> results) {
DCHECK(!results.is_empty()); DCHECK(!results.empty());
// First, allocate code space for all the results. // First, allocate code space for all the results.
size_t total_code_space = 0; size_t total_code_space = 0;
for (auto& result : results) { for (auto& result : results) {
......
...@@ -363,7 +363,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const { ...@@ -363,7 +363,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const {
buffer.write_size(functions_.size()); buffer.write_size(functions_.size());
for (auto function : functions_) { for (auto function : functions_) {
function->WriteSignature(buffer); function->WriteSignature(buffer);
if (!function->name_.is_empty()) ++num_function_names; if (!function->name_.empty()) ++num_function_names;
} }
FixupSection(buffer, start); FixupSection(buffer, start);
} }
...@@ -544,7 +544,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const { ...@@ -544,7 +544,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const {
uint32_t function_index = 0; uint32_t function_index = 0;
for (; function_index < num_imports; ++function_index) { for (; function_index < num_imports; ++function_index) {
const WasmFunctionImport* import = &function_imports_[function_index]; const WasmFunctionImport* import = &function_imports_[function_index];
DCHECK(!import->name.is_empty()); DCHECK(!import->name.empty());
buffer.write_u32v(function_index); buffer.write_u32v(function_index);
buffer.write_string(import->name); buffer.write_string(import->name);
} }
...@@ -552,7 +552,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const { ...@@ -552,7 +552,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const {
for (auto function : functions_) { for (auto function : functions_) {
DCHECK_EQ(function_index, DCHECK_EQ(function_index,
function->func_index() + function_imports_.size()); function->func_index() + function_imports_.size());
if (!function->name_.is_empty()) { if (!function->name_.empty()) {
buffer.write_u32v(function_index); buffer.write_u32v(function_index);
buffer.write_string(function->name_); buffer.write_string(function->name_);
} }
......
...@@ -63,7 +63,7 @@ WasmName ModuleWireBytes::GetNameOrNull(const WasmFunction* function, ...@@ -63,7 +63,7 @@ WasmName ModuleWireBytes::GetNameOrNull(const WasmFunction* function,
std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name) { std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name) {
os << "#" << name.function_->func_index; os << "#" << name.function_->func_index;
if (!name.name_.is_empty()) { if (!name.name_.empty()) {
if (name.name_.start()) { if (name.name_.start()) {
os << ":"; os << ":";
os.write(name.name_.start(), name.name_.length()); os.write(name.name_.start(), name.name_.length());
......
...@@ -20,7 +20,7 @@ namespace wasm { ...@@ -20,7 +20,7 @@ namespace wasm {
namespace { namespace {
bool IsValidFunctionName(const Vector<const char> &name) { bool IsValidFunctionName(const Vector<const char> &name) {
if (name.is_empty()) return false; if (name.empty()) return false;
const char *special_chars = "_.+-*/\\^~=<>!?@#$%&|:'`"; const char *special_chars = "_.+-*/\\^~=<>!?@#$%&|:'`";
for (char c : name) { for (char c : name) {
bool valid_char = (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || bool valid_char = (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') ||
......
...@@ -275,8 +275,8 @@ void WasmExecutionFuzzer::FuzzWasmModule(Vector<const uint8_t> data, ...@@ -275,8 +275,8 @@ void WasmExecutionFuzzer::FuzzWasmModule(Vector<const uint8_t> data,
std::unique_ptr<Handle<Object>[]> compiler_args; std::unique_ptr<Handle<Object>[]> compiler_args;
// The first byte builds the bitmask to control which function will be // The first byte builds the bitmask to control which function will be
// compiled with Turbofan and which one with Liftoff. // compiled with Turbofan and which one with Liftoff.
uint8_t tier_mask = data.is_empty() ? 0 : data[0]; uint8_t tier_mask = data.empty() ? 0 : data[0];
if (!data.is_empty()) data += 1; if (!data.empty()) data += 1;
if (!GenerateModule(i_isolate, &zone, data, buffer, num_args, if (!GenerateModule(i_isolate, &zone, data, buffer, num_args,
interpreter_args, compiler_args)) { interpreter_args, compiler_args)) {
return; return;
......
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