Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:26
erlang
1131-AArch64-Slightly-optimize-BIF-dispatch.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1131-AArch64-Slightly-optimize-BIF-dispatch.patch of Package erlang
From 0de80a567f493807c0b1130a0e08199d0706123b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Sat, 26 Aug 2023 08:38:40 +0200 Subject: [PATCH 01/25] AArch64: Slightly optimize BIF dispatch No BIFs have more than four arguments, so there is no need to save and restore {x,4} and {x,5}. --- erts/emulator/beam/emu/beam_emu.c | 2 ++ erts/emulator/beam/erl_vm.h | 2 ++ erts/emulator/beam/jit/arm/instr_bif.cpp | 11 ++++++----- erts/emulator/beam/jit/beam_jit_main.cpp | 2 ++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/erts/emulator/beam/emu/beam_emu.c b/erts/emulator/beam/emu/beam_emu.c index c2081ab3d0..bdc0173bed 100644 --- a/erts/emulator/beam/emu/beam_emu.c +++ b/erts/emulator/beam/emu/beam_emu.c @@ -631,6 +631,8 @@ static void install_bifs(void) { entry = &bif_table[i]; + ERTS_ASSERT(entry->arity <= MAX_BIF_ARITY); + ep = erts_export_put(entry->module, entry->name, entry->arity); ep->info.u.op = BeamOpCodeAddr(op_i_func_info_IaaI); diff --git a/erts/emulator/beam/erl_vm.h b/erts/emulator/beam/erl_vm.h index faf6190e39..a7b4b86516 100644 --- a/erts/emulator/beam/erl_vm.h +++ b/erts/emulator/beam/erl_vm.h @@ -53,6 +53,8 @@ #define MAX_REG 1024 /* Max number of x(N) registers used */ #define REG_MASK (MAX_REG - 1) +#define MAX_BIF_ARITY 4 /* Maximum allowed arguments for C-based BIFs. */ + /* * Guard BIFs and the new trapping length/1 implementation need 3 extra * registers in the register array. diff --git a/erts/emulator/beam/jit/arm/instr_bif.cpp b/erts/emulator/beam/jit/arm/instr_bif.cpp index b210bfada9..ca6db3e6e8 100644 --- a/erts/emulator/beam/jit/arm/instr_bif.cpp +++ b/erts/emulator/beam/jit/arm/instr_bif.cpp @@ -387,7 +387,7 @@ void BeamGlobalAssembler::emit_call_light_bif_shared() { emit_enter_runtime_frame(); emit_enter_runtime<Update::eReductions | Update::eStack | - Update::eHeap | Update::eXRegs>(); + Update::eHeap | Update::eXRegs>(MAX_BIF_ARITY); #ifdef ERTS_MSACC_EXTENDED_STATES { @@ -460,7 +460,8 @@ void BeamGlobalAssembler::emit_call_light_bif_shared() { * after seeing a later timestamp from its own call to * erlang:monotonic_time/0. */ emit_leave_runtime<Update::eReductions | Update::eCodeIndex | - Update::eHeap | Update::eStack | Update::eXRegs>(); + Update::eHeap | Update::eStack | Update::eXRegs>( + MAX_BIF_ARITY); emit_leave_runtime_frame(); /* ERTS_IS_GC_DESIRED_INTERNAL */ @@ -528,7 +529,7 @@ void BeamGlobalAssembler::emit_call_light_bif_shared() { { emit_enter_runtime_frame(); emit_enter_runtime<Update::eReductions | Update::eStack | - Update::eHeap | Update::eXRegs>(); + Update::eHeap | Update::eXRegs>(MAX_BIF_ARITY); a.mov(ARG3, ARG1); @@ -540,7 +541,7 @@ void BeamGlobalAssembler::emit_call_light_bif_shared() { runtime_call<5>(erts_gc_after_bif_call_lhf); emit_leave_runtime<Update::eReductions | Update::eStack | - Update::eHeap | Update::eXRegs>(); + Update::eHeap | Update::eXRegs>(MAX_BIF_ARITY); emit_leave_runtime_frame(); a.b(check_bif_return); @@ -568,6 +569,7 @@ void BeamGlobalAssembler::emit_call_light_bif_shared() { void BeamModuleAssembler::emit_call_light_bif(const ArgWord &Bif, const ArgExport &Exp) { Label entry = a.newLabel(); + BeamFile_ImportEntry *e = &beam->imports.entries[Exp.get()]; a.bind(entry); @@ -576,7 +578,6 @@ void BeamModuleAssembler::emit_call_light_bif(const ArgWord &Bif, a.adr(ARG3, entry); if (logger.file()) { - BeamFile_ImportEntry *e = &beam->imports.entries[Exp.get()]; comment("BIF: %T:%T/%d", e->module, e->function, e->arity); } fragment_call(ga->get_call_light_bif_shared()); diff --git a/erts/emulator/beam/jit/beam_jit_main.cpp b/erts/emulator/beam/jit/beam_jit_main.cpp index 7692e4b2d9..40679e8be5 100644 --- a/erts/emulator/beam/jit/beam_jit_main.cpp +++ b/erts/emulator/beam/jit/beam_jit_main.cpp @@ -124,6 +124,8 @@ static void install_bifs(void) { entry = &bif_table[i]; + ERTS_ASSERT(entry->arity <= MAX_BIF_ARITY); + ep = erts_export_put(entry->module, entry->name, entry->arity); sys_memset(&ep->info.u, 0, sizeof(ep->info.u)); -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor