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

[wasm] [cleanup] Fix WasmCode::Kind enum names

According to the style guide, enum names they must either be
capitalized, or start with a "k". I prefer the kFoo syntax.

R=mtrofin@chromium.org

Bug: v8:7109
Change-Id: I9c06c4cb05b05ec50de8d68d118f1a0807938426
Reviewed-on: https://chromium-review.googlesource.com/796856Reviewed-by: 's avatarMircea Trofin <mtrofin@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49733}
parent c08ab6da
......@@ -442,16 +442,16 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
iterator->isolate()->wasm_code_manager()->LookupCode(pc);
if (wasm_code != nullptr) {
switch (wasm_code->kind()) {
case wasm::WasmCode::InterpreterStub:
case wasm::WasmCode::kInterpreterStub:
return WASM_INTERPRETER_ENTRY;
case wasm::WasmCode::Function:
case wasm::WasmCode::CopiedStub:
case wasm::WasmCode::kFunction:
case wasm::WasmCode::kCopiedStub:
return WASM_COMPILED;
case wasm::WasmCode::LazyStub:
case wasm::WasmCode::kLazyStub:
if (StackFrame::IsTypeMarker(marker)) break;
return BUILTIN;
case wasm::WasmCode::WasmToJsWrapper:
case wasm::WasmCode::WasmToWasmWrapper:
case wasm::WasmCode::kWasmToJsWrapper:
case wasm::WasmCode::kWasmToWasmWrapper:
return WASM_TO_JS;
default:
UNREACHABLE();
......@@ -789,7 +789,7 @@ void StandardFrame::IterateCompiledFrame(RootVisitor* v) const {
wasm_code->stack_slots());
safepoint_entry = table.FindEntry(inner_pointer);
stack_slots = wasm_code->stack_slots();
has_tagged_params = wasm_code->kind() != wasm::WasmCode::Function;
has_tagged_params = wasm_code->kind() != wasm::WasmCode::kFunction;
} else {
InnerPointerToCodeCache::InnerPointerToCodeCacheEntry* entry =
isolate()->inner_pointer_to_code_cache()->GetCacheEntry(inner_pointer);
......@@ -1767,7 +1767,7 @@ bool WasmCompiledFrame::at_to_number_conversion() const {
wasm::WasmCode* code =
callee_pc ? isolate()->wasm_code_manager()->LookupCode(callee_pc)
: nullptr;
if (!code || code->kind() != wasm::WasmCode::WasmToJsWrapper) return false;
if (!code || code->kind() != wasm::WasmCode::kWasmToJsWrapper) return false;
int offset = static_cast<int>(callee_pc - code->instructions().start());
pos = FrameSummary::WasmCompiledFrameSummary::GetWasmSourcePosition(code,
offset);
......@@ -2075,7 +2075,7 @@ void InternalFrame::Iterate(RootVisitor* v) const {
FLAG_wasm_jit_to_native ? isolate()->wasm_code_manager()->LookupCode(pc())
: nullptr;
if (wasm_code != nullptr) {
DCHECK(wasm_code->kind() == wasm::WasmCode::LazyStub);
DCHECK(wasm_code->kind() == wasm::WasmCode::kLazyStub);
} else {
Code* code = LookupCode();
IteratePc(v, pc_address(), constant_pool_address(), code);
......
......@@ -429,7 +429,7 @@ class FrameArrayBuilder {
//====================================================================
const auto& summary = summ.AsWasmCompiled();
if (!summary.code().IsCodeObject() &&
summary.code().GetWasmCode()->kind() != wasm::WasmCode::Function) {
summary.code().GetWasmCode()->kind() != wasm::WasmCode::kFunction) {
continue;
}
Handle<WasmInstanceObject> instance = summary.wasm_instance();
......
......@@ -500,7 +500,7 @@ RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) {
if (FLAG_wasm_jit_to_native) {
wasm::WasmCode* target =
isolate->wasm_code_manager()->LookupCode(target_address);
if (target->kind() == wasm::WasmCode::Function) {
if (target->kind() == wasm::WasmCode::kFunction) {
++count;
export_fct = target;
}
......@@ -524,7 +524,7 @@ RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) {
Address target_address = rinfo->target_address();
wasm::WasmCode* target =
isolate->wasm_code_manager()->LookupCode(target_address);
if (target->kind() == wasm::WasmCode::Function) {
if (target->kind() == wasm::WasmCode::kFunction) {
++count;
intermediate_fct = target;
}
......@@ -549,8 +549,8 @@ RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) {
count = 0;
if (FLAG_wasm_jit_to_native) {
wasm::WasmCode::Kind target_kind = type->value() == 0
? wasm::WasmCode::WasmToWasmWrapper
: wasm::WasmCode::WasmToJsWrapper;
? wasm::WasmCode::kWasmToWasmWrapper
: wasm::WasmCode::kWasmToJsWrapper;
for (RelocIterator it(intermediate_fct->instructions(),
intermediate_fct->reloc_info(),
intermediate_fct->constant_pool(),
......
......@@ -738,7 +738,7 @@ Address CompileLazy(Isolate* isolate) {
Handle<Object> exp_deopt_data_entry;
const wasm::WasmCode* lazy_stub_or_copy =
isolate->wasm_code_manager()->LookupCode(it.frame()->pc());
DCHECK_EQ(wasm::WasmCode::LazyStub, lazy_stub_or_copy->kind());
DCHECK_EQ(wasm::WasmCode::kLazyStub, lazy_stub_or_copy->kind());
if (!lazy_stub_or_copy->IsAnonymous()) {
// Then it's an indirect call or via JS->wasm wrapper.
instance = lazy_stub_or_copy->owner()->compiled_module()->owning_instance();
......@@ -882,7 +882,7 @@ const wasm::WasmCode* LazyCompilationOrchestrator::CompileFunction(
wasm::WasmCode* existing_code = compiled_module->GetNativeModule()->GetCode(
static_cast<uint32_t>(func_index));
if (existing_code != nullptr &&
existing_code->kind() == wasm::WasmCode::Function) {
existing_code->kind() == wasm::WasmCode::kFunction) {
TRACE_LAZY("Function %d already compiled.\n", func_index);
return existing_code;
}
......@@ -1199,7 +1199,7 @@ const wasm::WasmCode* LazyCompilationOrchestrator::CompileFromJsToWasm(
wasm::WasmCode* ret =
compiled_module->GetNativeModule()->GetCode(exported_func_index);
DCHECK_NOT_NULL(ret);
DCHECK_EQ(wasm::WasmCode::Function, ret->kind());
DCHECK_EQ(wasm::WasmCode::kFunction, ret->kind());
return ret;
}
......@@ -1243,7 +1243,7 @@ const wasm::WasmCode* LazyCompilationOrchestrator::CompileDirectCall(
!it.done(); it.next()) {
const WasmCode* callee = isolate->wasm_code_manager()->LookupCode(
it.rinfo()->target_address());
if (callee->kind() != WasmCode::LazyStub) {
if (callee->kind() != WasmCode::kLazyStub) {
non_compiled_functions.push_back(Nothing<WasmDirectCallData>());
continue;
}
......@@ -1302,7 +1302,7 @@ const wasm::WasmCode* LazyCompilationOrchestrator::CompileDirectCall(
uint32_t lookup = info.ToChecked().func_index;
const WasmCode* callee_compiled =
compiled_module->GetNativeModule()->GetCode(lookup);
if (callee_compiled->kind() != WasmCode::Function) continue;
if (callee_compiled->kind() != WasmCode::kFunction) continue;
it.rinfo()->set_wasm_call_address(
isolate, callee_compiled->instructions().start());
++patched;
......@@ -1721,7 +1721,7 @@ WasmCodeWrapper EnsureExportedLazyDeoptData(Isolate* isolate,
} else {
wasm::WasmCode* code = native_module->GetCode(func_index);
// {code} will be nullptr when exporting imports.
if (code == nullptr || code->kind() != wasm::WasmCode::LazyStub ||
if (code == nullptr || code->kind() != wasm::WasmCode::kLazyStub ||
!code->IsAnonymous()) {
return WasmCodeWrapper(code);
}
......@@ -1787,7 +1787,7 @@ WasmCodeWrapper EnsureTableExportLazyDeoptData(
EnsureExportedLazyDeoptData(isolate, instance, code_table,
native_module, func_index)
.GetWasmCode();
if (code == nullptr || code->kind() != wasm::WasmCode::LazyStub)
if (code == nullptr || code->kind() != wasm::WasmCode::kLazyStub)
return WasmCodeWrapper(code);
// deopt_data:
......@@ -1866,7 +1866,7 @@ WasmCodeWrapper MakeWasmToWasmWrapper(
new_wasm_context_address);
return WasmCodeWrapper(
instance->compiled_module()->GetNativeModule()->AddCodeCopy(
code, wasm::WasmCode::WasmToWasmWrapper, index));
code, wasm::WasmCode::kWasmToWasmWrapper, index));
}
}
......@@ -1888,7 +1888,7 @@ WasmCodeWrapper UnwrapExportOrCompileImportWrapper(
isolate, target, sig, import_index, origin, js_imports_table);
return WasmCodeWrapper(
instance->compiled_module()->GetNativeModule()->AddCodeCopy(
temp_code, wasm::WasmCode::WasmToJsWrapper, import_index));
temp_code, wasm::WasmCode::kWasmToJsWrapper, import_index));
} else {
return WasmCodeWrapper(compiler::CompileWasmToJSWrapper(
isolate, target, sig, import_index, origin, js_imports_table));
......@@ -3405,8 +3405,8 @@ void InstanceBuilder::LoadTableSegments(Handle<FixedArray> code_table,
const wasm::WasmCode* code = native_module->GetCode(func_index);
// Only increase the counter for lazy compile builtins (it's not
// needed otherwise).
if (code->kind() == wasm::WasmCode::Function) continue;
DCHECK_EQ(wasm::WasmCode::LazyStub, code->kind());
if (code->kind() == wasm::WasmCode::kFunction) continue;
DCHECK_EQ(wasm::WasmCode::kLazyStub, code->kind());
}
++num_table_exports[func_index];
}
......
......@@ -131,7 +131,7 @@ bool CodeSpecialization::ApplyToWholeInstance(
WasmCodeWrapper wrapper;
if (FLAG_wasm_jit_to_native) {
const WasmCode* wasm_function = native_module->GetCode(func_index);
if (wasm_function->kind() != WasmCode::Function) {
if (wasm_function->kind() != WasmCode::kFunction) {
continue;
}
wrapper = WasmCodeWrapper(wasm_function);
......@@ -206,7 +206,7 @@ bool CodeSpecialization::ApplyToWasmCode(WasmCodeWrapper code,
if (code.IsCodeObject()) {
DCHECK_EQ(Code::WASM_FUNCTION, code.GetCode()->kind());
} else {
DCHECK_EQ(wasm::WasmCode::Function, code.GetWasmCode()->kind());
DCHECK_EQ(wasm::WasmCode::kFunction, code.GetWasmCode()->kind());
}
bool patch_table_size = old_function_table_size || new_function_table_size;
......
......@@ -192,19 +192,19 @@ void WasmCode::Print(Isolate* isolate) const {
const char* GetWasmCodeKindAsString(WasmCode::Kind kind) {
switch (kind) {
case WasmCode::Function:
case WasmCode::kFunction:
return "wasm function";
case WasmCode::WasmToWasmWrapper:
case WasmCode::kWasmToWasmWrapper:
return "wasm-to-wasm";
case WasmCode::WasmToJsWrapper:
case WasmCode::kWasmToJsWrapper:
return "wasm-to-js";
case WasmCode::LazyStub:
case WasmCode::kLazyStub:
return "lazy-compile";
case WasmCode::InterpreterStub:
case WasmCode::kInterpreterStub:
return "interpreter-entry";
case WasmCode::CopiedStub:
case WasmCode::kCopiedStub:
return "copied stub";
case WasmCode::Trampoline:
case WasmCode::kTrampoline:
return "trampoline";
}
return "unknown kind";
......@@ -307,14 +307,14 @@ WasmCode* NativeModule::AddCodeCopy(Handle<Code> code, WasmCode::Kind kind,
WasmCode* NativeModule::AddInterpreterWrapper(Handle<Code> code,
uint32_t index) {
WasmCode* ret = AddAnonymousCode(code, WasmCode::InterpreterStub);
WasmCode* ret = AddAnonymousCode(code, WasmCode::kInterpreterStub);
ret->index_ = Just(index);
return ret;
}
WasmCode* NativeModule::SetLazyBuiltin(Handle<Code> code) {
DCHECK_NULL(lazy_builtin_);
lazy_builtin_ = AddAnonymousCode(code, WasmCode::LazyStub);
lazy_builtin_ = AddAnonymousCode(code, WasmCode::kLazyStub);
for (uint32_t i = num_imported_functions(), e = FunctionCount(); i < e; ++i) {
SetCodeTable(i, lazy_builtin_);
......@@ -388,7 +388,7 @@ WasmCode* NativeModule::AddCode(
WasmCode* ret = AddOwnedCode(
{desc.buffer, static_cast<size_t>(desc.instr_size)},
std::move(reloc_info), static_cast<size_t>(desc.reloc_size), Just(index),
WasmCode::Function, desc.instr_size - desc.constant_pool_size,
WasmCode::kFunction, desc.instr_size - desc.constant_pool_size,
frame_slots, safepoint_table_offset, protected_instructions, is_liftoff);
if (ret == nullptr) return nullptr;
......@@ -437,7 +437,7 @@ Address NativeModule::CreateTrampolineTo(Handle<Code> code) {
masm.GetCode(nullptr, &code_desc);
WasmCode* wasm_code = AddOwnedCode(
{code_desc.buffer, static_cast<size_t>(code_desc.instr_size)}, nullptr, 0,
Nothing<uint32_t>(), WasmCode::Trampoline, 0, 0, 0, {});
Nothing<uint32_t>(), WasmCode::kTrampoline, 0, 0, 0, {});
if (wasm_code == nullptr) return nullptr;
Address ret = wasm_code->instructions().start();
trampolines_.emplace(std::make_pair(dest, ret));
......@@ -458,7 +458,7 @@ Address NativeModule::GetLocalAddressFor(Handle<Code> code) {
uint32_t key = code->stub_key();
auto copy = stubs_.find(key);
if (copy == stubs_.end()) {
WasmCode* ret = AddAnonymousCode(code, WasmCode::CopiedStub);
WasmCode* ret = AddAnonymousCode(code, WasmCode::kCopiedStub);
copy = stubs_.emplace(std::make_pair(key, ret)).first;
}
return copy->second->instructions().start();
......@@ -482,7 +482,7 @@ WasmCode* NativeModule::GetExportedWrapper(uint32_t index) {
}
WasmCode* NativeModule::AddExportedWrapper(Handle<Code> code, uint32_t index) {
WasmCode* ret = AddAnonymousCode(code, WasmCode::WasmToWasmWrapper);
WasmCode* ret = AddAnonymousCode(code, WasmCode::kWasmToWasmWrapper);
ret->index_ = Just(index);
exported_wasm_to_wasm_wrappers_.insert(std::make_pair(index, ret));
return ret;
......@@ -822,14 +822,14 @@ std::unique_ptr<NativeModule> NativeModule::Clone() {
for (uint32_t i = num_imported_functions(), e = FunctionCount(); i < e; ++i) {
const WasmCode* original_code = GetCode(i);
switch (original_code->kind()) {
case WasmCode::LazyStub: {
case WasmCode::kLazyStub: {
if (original_code->IsAnonymous()) {
ret->SetCodeTable(i, ret->lazy_builtin());
} else {
if (!ret->CloneLazyBuiltinInto(i)) return nullptr;
}
} break;
case WasmCode::Function: {
case WasmCode::kFunction: {
WasmCode* new_code = ret->CloneCode(original_code);
if (new_code == nullptr) return nullptr;
PatchTrampolineAndStubCalls(original_code, new_code, reverse_lookup);
......
......@@ -88,13 +88,13 @@ using ProtectedInstructions =
class V8_EXPORT_PRIVATE WasmCode final {
public:
enum Kind {
Function,
WasmToWasmWrapper,
WasmToJsWrapper,
LazyStub,
InterpreterStub,
CopiedStub,
Trampoline
kFunction,
kWasmToWasmWrapper,
kWasmToJsWrapper,
kLazyStub,
kInterpreterStub,
kCopiedStub,
kTrampoline
};
Vector<byte> instructions() const { return instructions_; }
......
......@@ -643,7 +643,7 @@ Handle<HeapObject> UnwrapWasmToJSWrapper(Isolate* isolate,
DCHECK_GT(js_imports_table->length(), index);
} else {
const wasm::WasmCode* wasm_code = wrapper.GetWasmCode();
DCHECK_EQ(wasm::WasmCode::WasmToJsWrapper, wasm_code->kind());
DCHECK_EQ(wasm::WasmCode::kWasmToJsWrapper, wasm_code->kind());
js_imports_table = Handle<FixedArray>(wasm_code->owner()
->compiled_module()
->owning_instance()
......@@ -2423,14 +2423,14 @@ class ThreadImpl {
DCHECK(AllowHandleAllocation::IsAllowed());
DCHECK(AllowHeapAllocation::IsAllowed());
if (code->kind() == wasm::WasmCode::Function) {
if (code->kind() == wasm::WasmCode::kFunction) {
DCHECK_EQ(*code->owner()->compiled_module()->owning_instance(),
codemap()->instance());
return {ExternalCallResult::INTERNAL, codemap()->GetCode(code->index())};
}
if (code->kind() == wasm::WasmCode::WasmToJsWrapper) {
if (code->kind() == wasm::WasmCode::kWasmToJsWrapper) {
return CallExternalJSFunction(isolate, WasmCodeWrapper(code), signature);
} else if (code->kind() == wasm::WasmCode::WasmToWasmWrapper) {
} else if (code->kind() == wasm::WasmCode::kWasmToWasmWrapper) {
return CallExternalWasmFunction(isolate, WasmCodeWrapper(code),
signature);
}
......
......@@ -118,7 +118,7 @@ void UnpackAndRegisterProtectedInstructions(Isolate* isolate,
i < e; ++i) {
wasm::WasmCode* code = native_module->GetCode(i);
if (code == nullptr || code->kind() != wasm::WasmCode::Function) {
if (code == nullptr || code->kind() != wasm::WasmCode::kFunction) {
continue;
}
......
......@@ -614,8 +614,8 @@ WasmInstanceObject* WasmInstanceObject::GetOwningInstance(
const wasm::WasmCode* code) {
DisallowHeapAllocation no_gc;
Object* weak_link = nullptr;
DCHECK(code->kind() == wasm::WasmCode::Function ||
code->kind() == wasm::WasmCode::InterpreterStub);
DCHECK(code->kind() == wasm::WasmCode::kFunction ||
code->kind() == wasm::WasmCode::kInterpreterStub);
weak_link = code->owner()->compiled_module()->ptr_to_weak_owning_instance();
DCHECK(weak_link->IsWeakCell());
WeakCell* cell = WeakCell::cast(weak_link);
......@@ -1307,7 +1307,7 @@ void WasmCompiledModule::Reset(Isolate* isolate,
i < end; ++i) {
wasm::WasmCode* code = native_module->GetCode(i);
// Skip lazy compile stubs.
if (code == nullptr || code->kind() != wasm::WasmCode::Function) continue;
if (code == nullptr || code->kind() != wasm::WasmCode::kFunction) continue;
bool changed = code_specialization.ApplyToWasmCode(WasmCodeWrapper(code),
SKIP_ICACHE_FLUSH);
// TODO(wasm): Check if this is faster than passing FLUSH_ICACHE_IF_NEEDED
......
......@@ -279,7 +279,7 @@ void NativeModuleSerializer::BufferCopiedStubs() {
FixedArray* NativeModuleSerializer::GetHandlerTable(
const WasmCode* code) const {
if (code->kind() != WasmCode::Function) return nullptr;
if (code->kind() != WasmCode::kFunction) return nullptr;
uint32_t index = code->index();
// We write the address, the size, and then copy the code as-is, followed
// by reloc info, followed by handler table and source positions.
......@@ -294,7 +294,7 @@ FixedArray* NativeModuleSerializer::GetHandlerTable(
ByteArray* NativeModuleSerializer::GetSourcePositions(
const WasmCode* code) const {
if (code->kind() != WasmCode::Function) return nullptr;
if (code->kind() != WasmCode::kFunction) return nullptr;
uint32_t index = code->index();
Object* source_positions_entry =
native_module_->compiled_module()->source_positions()->get(
......@@ -558,7 +558,7 @@ bool NativeModuleDeserializer::ReadCode() {
}
WasmCode* ret = native_module_->AddOwnedCode(
code_buffer, std::move(reloc_info), reloc_size, Just(index_),
WasmCode::Function, constant_pool_offset, stack_slot_count,
WasmCode::kFunction, constant_pool_offset, stack_slot_count,
safepoint_table_offset, protected_instructions, is_liftoff);
if (ret == nullptr) return false;
native_module_->SetCodeTable(index_, ret);
......
......@@ -101,7 +101,7 @@ uint32_t TestingModuleBuilder::AddJsFunction(
native_module_->ResizeCodeTableForTest(index);
Handle<Code> wrapper = compiler::CompileWasmToJSWrapper(
isolate_, jsfunc, sig, index, test_module_.origin(), js_imports_table);
native_module_->AddCodeCopy(wrapper, wasm::WasmCode::WasmToJsWrapper,
native_module_->AddCodeCopy(wrapper, wasm::WasmCode::kWasmToJsWrapper,
index);
} else {
// TODO(6792): No longer needed once WebAssembly code is off heap.
......
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