Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113616 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 81015 invoked from network); 19 Mar 2021 14:50:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Mar 2021 14:50:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 147411804DC for ; Fri, 19 Mar 2021 07:44:41 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ua1-f49.google.com (mail-ua1-f49.google.com [209.85.222.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 19 Mar 2021 07:44:40 -0700 (PDT) Received: by mail-ua1-f49.google.com with SMTP id h34so3100432uah.5 for ; Fri, 19 Mar 2021 07:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q1+kueoacMqSyLADDJs6B4JSPSWKR1qgqo+PDV3w9zk=; b=SW3xn2egVJP92LzYm1Y9fZjfqk8pKU+lUKeuaH9kfnpOrdXCPHRoFJtYFjObwtijdu 7ipaxqJ3ZWpxg+xBqWNHhnIFKs88jZ639w66uRq2Haraqym+14aLw/cyuAY3BJwoV+8c /ctIlnyVhA2WUxLwMRaUvaUcS3LUsGm5CyWkUZyzIdlZ85zZ4QkXxxoRpl3q4xXqem2p Lk8yKbHh6U8VyNQqO6CcMCKA7/FiomR7QMWyLWMSjjiJfHcRbxK+IILwIquikryaxULE pkFC/8D5fhPZEZiuEFacwLiKa1BprfqkQZsaR9Rwm2M53H4Z9V0SFmDAMXh4+ycGzP7Y OPmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q1+kueoacMqSyLADDJs6B4JSPSWKR1qgqo+PDV3w9zk=; b=Dwzaqf5cLkUMv+tGu8mElFhp8REqGtxNGgAFRv04foHyP52c6kUNXUWp7fcQA8SP8y KjfOd8ko1eClqEaKkwLbxEKwx/RTvvCQ92JGEF8Z7h46976wKC+bWTG8c4bOgbVx7a1E /Mdvh03YF95GtXx9XPSHkD7m3sGDiUraUELPdCtYjqwpPEhoma5Hc8cXkdVU5YS7mrjS og9++WikzzhQIdvdtPf6ChZTKMXNG+uBXVqnMkhkRZLVAqhCT/tGRorqqdQNfzBNmV62 HNFZsx/PtmH32vY4mtqg/+pOwwM2zErBuDqXO1Y4JJb+qEjGtxhkChiejMioC5plKN55 npuQ== X-Gm-Message-State: AOAM5322p0b1t7Tl17cZ1MxBdt75/cdsR7kbY9lgzhjXFhKc9Gnv6s+I yY0M5cwBa9WpJVzR+HWoENZcdY6zagMDEj6KQJOAsljr7v8= X-Google-Smtp-Source: ABdhPJxTmOzk6dRkzWYMY+FAkjvbmzg56kjE21jspAmJl3aBfu+Vf+Vn53huOsy97U84ZJbihWoFn+H4RQF8Pv2ealE= X-Received: by 2002:a9f:2d90:: with SMTP id v16mr1191219uaj.138.1616165078823; Fri, 19 Mar 2021 07:44:38 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 19 Mar 2021 17:44:27 +0300 Message-ID: To: Hao Sun Cc: "internals@lists.php.net" , nd Content-Type: multipart/alternative; boundary="0000000000006bf71f05bde4c134" Subject: Re: [PHP-DEV] RFC: PHP JIT/arm64 port From: dmitrystogov@gmail.com (Dmitry Stogov) --0000000000006bf71f05bde4c134 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Yeah, I suppose this is going to be a big task and we will have to collaborate a lot. anyway, next week... It's already Friday evening. Thanks. Dmitry. On Fri, Mar 19, 2021 at 5:20 PM Hao Sun wrote: > Hi Dmitry, > > Thanks for your reply. > > > > Yes. Sure. I will CC you next time. > > > > As I mentioned in the previous email, this is our (ARM) initial effort to > enable JIT/arm64 port and there might exist some potential bugs in > implementation or something we haven=E2=80=99t considered/designed soundl= y. > > Please let us know if you have any question. > > > > Thanks, > > Hao > > > > > > *From:* Dmitry Stogov > *Sent:* Friday, March 19, 2021 9:35 PM > *To:* Hao Sun > *Cc:* internals@lists.php.net; nd > *Subject:* Re: [PHP-DEV] RFC: PHP JIT/arm64 port > > > > Hi Hao, > > > > I'm the author of JIT for PHP. Please CC me next time, I read @internals > only from time to time... > > I'll try to take a look into your implementation next week. > > I'm not sure how much time I'll be able to invest yet, I'll have to > discuss this with my management. > > > > Thanks. Dmitry. > > > > > > > > > > > > On Wed, Mar 17, 2021 at 6:28 AM Hao Sun wrote: > > Hi Internals, > > Currently PHP JIT only supports x86 and x86_64 CPUs on POSIX platforms an= d > Windows.[1] With the prevalence of PHP language and the notable > growth of ARM-based servers market, we believe JIT/arm64 would be in > urgent need in the near future. > > As an initial effort to enable PHP JIT/arm64, we (ARM) have supported the > basic functionality, and (partially) implemented the compilation for > several opcodes. Currently a number of simple JIT test cases from PHP tes= t > framework can be passed on ARM-based machine. There are still a lot > of missing parts, such as hot loops, class/object/array operations, > exception handling, etc, and we will continue working on them. > > We would like to share our work with you (See the draft patch > https://github.com/shqking/php-src/commit/6aaf935). > Any feedback would be greatly appreciated, and please let we know if > anyone wants to contribute to this port. > > Thanks, > Hao SUN > Email: hao.sun@arm.com > > ------------------------------------------------------- > Main updates: > 1. JIT backend for AArch64 > A new alternative, i.e. AArch64, was added while building PHP JIT. See th= e > updates in the following files. Note that we adopt capstone[2] for > disassembly on AArch64. > > build/Makefile.global > ext/opcache/config.m4 > ext/opcache/config.w32 > ext/opcache/jit/Makefile.frag > ext/opcache/jit/zend_jit.c > ext/opcache/jit/zend_jit_vm_helpers.c > ext/opcache/jit/zend_jit_disasm_arm64.c > ext/opcache/jit/zend_jit_gdb.c > ext/opcache/jit/zend_jit_perf_dump.c > > 2. DynASM library > PHP JIT uses DynASM[3] (developed for LuaJIT project) to generate native > code on the fly. We added two useful but missing features, global label > reference and dynamic register names, into DynASM/arm64. See the updates > in files: > > ext/opcache/jit/dynasm/dasm_arm64.h > ext/opcache/jit/dynasm/dasm_arm64.lua > > Note that these two features are available on DynASM/x86. > > 3. compilation for opcodes on AArch64 > Our main work falls in the following files. > > ext/opcache/jit/zend_jit_arm64.h > ext/opcache/jit/zend_jit_arm64.dasc > ext/opcache/jit/zend_jit_internal.h > Zend/zend_vm_opcodes.h > > * AArch64 registers and calling conventions are defined. > > * Instruction cache must be flushed for the JIT-ed code on AArch64. See > macro JIT_CACHE_FLUSH in file 'zend_jit_internal.h'. > > * We have (partially) implemented the compilation for several opcodes, > mainly for the function-based JIT (with opcache.jit=3D1203). Currently, > test cases involving internal function call (e.g. var_dump), additions > with integers/floating-point numbers, integer overflows and simple > exception, can be supported now. See our newly added test cases under > directory 'ext/opcache/tests/jit/arm64/'. > > * Trace counter stubs are implemented for tracing JIT (with > opcache.jit=3D1255). See zend_jit_hybrid_trace_counter_stub() and > zend_jit_hybrid_hot_trace_stub() in file 'zend_jit_arm64.dasc'. Hot > functions can be recognized and compiled successfully. See the test case > 'hot_func_002.phpt'. > > How to build and test: > Our local test environment is an ARM-based server with Ubuntu 20.04 and > GCC-10. We follow the building commands as shown in the readme file [4]. > Note that library capstone should be installed in advance. > > We suggest running the JIT test cases using the following command. In our > local test, 59 out of all 128 cases can be passed currently. > $ make test TESTS=3D'-d opcache.jit=3D1203 ext/opcache/tests/jit/' > > [1] https://wiki.php.net/rfc/jit > [2] https://www.capstone-engine.org/ > [3] https://luajit.org/dynasm.html > [4] https://github.com/php/php-src > > --0000000000006bf71f05bde4c134--