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