Commit 493bc1bb authored by Igor Sheludko's avatar Igor Sheludko Committed by V8 LUCI CQ

[ext-code-space][wasm] Remove Code <-> CodeT roundtrips

Drive-by: don't record builtins into wasm generated code sizes.

Bug: v8:11880
Change-Id: I02085c36e1831b26d7537c16be047345a0d4bca3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3684410
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80925}
parent a52b44f0
......@@ -286,10 +286,9 @@ RUNTIME_FUNCTION(Runtime_WasmCompileWrapper) {
return ReadOnlyRoots(isolate).undefined_value();
}
Handle<CodeT> wrapper_code = ToCodeT(
Handle<CodeT> wrapper_code =
wasm::JSToWasmWrapperCompilationUnit::CompileSpecificJSToWasmWrapper(
isolate, sig, module),
isolate);
isolate, sig, module);
// Replace the wrapper for the function that triggered the tier-up.
// This is to verify that the wrapper is replaced, even if the function
......
......@@ -236,11 +236,9 @@ void JSToWasmWrapperCompilationUnit::Execute() {
}
}
Handle<Code> JSToWasmWrapperCompilationUnit::Finalize() {
Handle<CodeT> JSToWasmWrapperCompilationUnit::Finalize() {
if (use_generic_wrapper_) {
return FromCodeT(
isolate_->builtins()->code_handle(Builtin::kGenericJSToWasmWrapper),
isolate_);
return isolate_->builtins()->code_handle(Builtin::kGenericJSToWasmWrapper);
}
CompilationJob::Status status = job_->FinalizeJob(isolate_);
......@@ -253,11 +251,11 @@ Handle<Code> JSToWasmWrapperCompilationUnit::Finalize() {
PROFILE(isolate_, CodeCreateEvent(LogEventListener::STUB_TAG,
Handle<AbstractCode>::cast(code), name));
}
return code;
return ToCodeT(code, isolate_);
}
// static
Handle<Code> JSToWasmWrapperCompilationUnit::CompileJSToWasmWrapper(
Handle<CodeT> JSToWasmWrapperCompilationUnit::CompileJSToWasmWrapper(
Isolate* isolate, const FunctionSig* sig, const WasmModule* module,
bool is_import) {
// Run the compilation unit synchronously.
......@@ -269,7 +267,7 @@ Handle<Code> JSToWasmWrapperCompilationUnit::CompileJSToWasmWrapper(
}
// static
Handle<Code> JSToWasmWrapperCompilationUnit::CompileSpecificJSToWasmWrapper(
Handle<CodeT> JSToWasmWrapperCompilationUnit::CompileSpecificJSToWasmWrapper(
Isolate* isolate, const FunctionSig* sig, const WasmModule* module) {
// Run the compilation unit synchronously.
const bool is_import = false;
......
......@@ -115,22 +115,22 @@ class V8_EXPORT_PRIVATE JSToWasmWrapperCompilationUnit final {
Isolate* isolate() const { return isolate_; }
void Execute();
Handle<Code> Finalize();
Handle<CodeT> Finalize();
bool is_import() const { return is_import_; }
const FunctionSig* sig() const { return sig_; }
// Run a compilation unit synchronously.
static Handle<Code> CompileJSToWasmWrapper(Isolate* isolate,
const FunctionSig* sig,
const WasmModule* module,
bool is_import);
static Handle<CodeT> CompileJSToWasmWrapper(Isolate* isolate,
const FunctionSig* sig,
const WasmModule* module,
bool is_import);
// Run a compilation unit synchronously, but ask for the specific
// wrapper.
static Handle<Code> CompileSpecificJSToWasmWrapper(Isolate* isolate,
const FunctionSig* sig,
const WasmModule* module);
static Handle<CodeT> CompileSpecificJSToWasmWrapper(Isolate* isolate,
const FunctionSig* sig,
const WasmModule* module);
private:
// Wrapper compilation is bound to an isolate. Concurrent accesses to the
......
......@@ -1467,7 +1467,9 @@ void TriggerTierUp(WasmInstanceObject instance, int func_index) {
namespace {
void RecordStats(const Code code, Counters* counters) {
void RecordStats(CodeT codet, Counters* counters) {
if (codet.is_off_heap_trampoline()) return;
Code code = FromCodeT(codet);
counters->wasm_generated_code_size()->Increment(code.raw_body_size());
counters->wasm_reloc_size()->Increment(code.relocation_info().length());
}
......@@ -3499,10 +3501,10 @@ void CompilationStateImpl::FinalizeJSToWasmWrappers(
CodePageCollectionMemoryModificationScope modification_scope(isolate->heap());
for (auto& unit : js_to_wasm_wrapper_units_) {
DCHECK_EQ(isolate, unit->isolate());
Handle<Code> code = unit->Finalize();
Handle<CodeT> code = unit->Finalize();
int wrapper_index =
GetExportWrapperIndex(module, unit->sig(), unit->is_import());
(*export_wrappers_out)->set(wrapper_index, ToCodeT(*code));
(*export_wrappers_out)->set(wrapper_index, *code);
RecordStats(*code, isolate->counters());
}
}
......@@ -3956,9 +3958,9 @@ void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module,
JSToWasmWrapperKey key = pair.first;
JSToWasmWrapperCompilationUnit* unit = pair.second.get();
DCHECK_EQ(isolate, unit->isolate());
Handle<Code> code = unit->Finalize();
Handle<CodeT> code = unit->Finalize();
int wrapper_index = GetExportWrapperIndex(module, &key.second, key.first);
(*export_wrappers_out)->set(wrapper_index, ToCodeT(*code));
(*export_wrappers_out)->set(wrapper_index, *code);
RecordStats(*code, isolate->counters());
}
}
......
......@@ -771,9 +771,8 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
int start_index = module_->start_function_index;
auto& function = module_->functions[start_index];
Handle<CodeT> wrapper_code =
ToCodeT(JSToWasmWrapperCompilationUnit::CompileJSToWasmWrapper(
isolate_, function.sig, module_, function.imported),
isolate_);
JSToWasmWrapperCompilationUnit::CompileJSToWasmWrapper(
isolate_, function.sig, module_, function.imported);
// TODO(clemensb): Don't generate an exported function for the start
// function. Use CWasmEntry instead.
start_function_ = WasmExportedFunction::New(
......
......@@ -1410,10 +1410,8 @@ WasmInstanceObject::GetOrCreateWasmInternalFunction(
// The wrapper may not exist yet if no function in the exports section has
// this signature. We compile it and store the wrapper in the module for
// later use.
wrapper = ToCodeT(
wasm::JSToWasmWrapperCompilationUnit::CompileJSToWasmWrapper(
isolate, function.sig, instance->module(), function.imported),
isolate);
wrapper = wasm::JSToWasmWrapperCompilationUnit::CompileJSToWasmWrapper(
isolate, function.sig, instance->module(), function.imported);
module_object->export_wrappers().set(wrapper_index, *wrapper);
}
auto external = Handle<WasmExternalFunction>::cast(WasmExportedFunction::New(
......
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