[prev in list] [next in list] [prev in thread] [next in thread]
List: php-cvs
Subject: [PHP-CVS] [php-src] jit-arm64: Use B/BL intead of BR/BLR if possible
From: Dmitry Stogov <noreply () php ! net>
Date: 2021-04-30 16:36:50
Message-ID: Jo0DdAs8kjPQ9IJPRQ6BVIHJtuH3NLCCmeqOZekNSY () main ! php ! net
[Download RAW message or body]
Author: Dmitry Stogov (dstogov)
Date: 2021-04-30T19:36:21+03:00
Commit: https://github.com/php/php-src/commit/72152839626052569c5af1b086cda8bb5604e4c4
Raw diff: https://github.com/php/php-src/commit/72152839626052569c5af1b086cda8bb5604e4c4.diff
Use B/BL intead of BR/BLR if possible
Changed paths:
M ext/opcache/jit/zend_jit_arm64.dasc
Diff:
diff --git a/ext/opcache/jit/zend_jit_arm64.dasc b/ext/opcache/jit/zend_jit_arm64.dasc
index 66042b2afe4a..69ee2f6cd301 100644
--- a/ext/opcache/jit/zend_jit_arm64.dasc
+++ b/ext/opcache/jit/zend_jit_arm64.dasc
@@ -103,6 +103,20 @@
#define LDR_STR_PIMM32 (MAX_IMM12*4) // ldr/str insn for 32-bit register: pimm is imm12 * 4
#define LDRB_STRB_PIMM MAX_IMM12 // ldrb/strb insn
+#define B_IMM26 (((1<<26)-1)*4)
+
+static bool arm64_may_use_b(void *addr)
+{
+ if (addr >= dasm_buf && addr < dasm_end) {
+ return (((char*)dasm_end - (char*)dasm_buf) < B_IMM26);
+ } else if (addr >= dasm_end) {
+ return (((char*)addr - (char*)dasm_buf) < B_IMM26);
+ } else if (addr < dasm_buf) {
+ return (((char*)dasm_end - (char*)addr) < B_IMM26);
+ }
+ return 0;
+}
+
#include "Zend/zend_cpuinfo.h"
#ifdef HAVE_VALGRIND
@@ -609,13 +623,21 @@ static int logical_immediate_p (uint64_t value, uint32_t reg_size)
|.endmacro
|.macro EXT_CALL, func, tmp_reg
-| LOAD_ADDR tmp_reg, func
-| blr tmp_reg
+|| if (arm64_may_use_b(func)) {
+| bl &func
+|| } else {
+| LOAD_ADDR tmp_reg, func
+| blr tmp_reg
+|| }
|.endmacro
|.macro EXT_JMP, func, tmp_reg
-| LOAD_ADDR tmp_reg, func
-| br tmp_reg
+|| if (arm64_may_use_b(func)) {
+| b &func
+|| } else {
+| LOAD_ADDR tmp_reg, func
+| br tmp_reg
+|| }
|.endmacro
|.macro SAVE_IP
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic