Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113610 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 69383 invoked from network); 19 Mar 2021 13:40:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Mar 2021 13:40:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7661B180538 for ; Fri, 19 Mar 2021 06:35:22 -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-vs1-f49.google.com (mail-vs1-f49.google.com [209.85.217.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 06:35:21 -0700 (PDT) Received: by mail-vs1-f49.google.com with SMTP id 124so3488741vsg.12 for ; Fri, 19 Mar 2021 06:35:21 -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=8LBHusDsDLFpJlJJO5WHupjvl8++BzCqDfHIwy2npYA=; b=IfDxtXEwajvZd9Xp2H6fXeKOG0JDVmthSQFJYRiipBv2li6FkeHOl+P9YBY9esJRIp fJaIBZMAQuwmUPZjT9qzfBn3HYSp4HEUkZv+Oc7EXo2xxxmjnPpPWcOdOBPJhJr5HogY B5rI9sDz2vOzMCULfHKhwZ6oxVOEsxRSnw7p9nov+NRGdiYpzAkxWse75uUl2OwucLVO wEAMlSuzFO+2TZrEfll/MSkB7xSBiIM7tUUraD1M/lhU1zo4Aiqg7V03ZyjQLWmBoPwM SMCSvQvFw88hEYgYkaZ/d2Am3m82NgnF177SsgGKF3Dt01twwqBEfQqj5iRi3nqPZKSg uGBw== 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=8LBHusDsDLFpJlJJO5WHupjvl8++BzCqDfHIwy2npYA=; b=SZUiW7Ud7dsQol5N/hpepAwRdUvZtRj6qOREGuLc2dOGM38eJ+8TnSj2Fvw26nDmVX aD/r/rW34BfnYT8objTzb8X2e5Vk3fh7rLh+g1LHN8CG/+wlcOGRu4K7HymIjdrEuQx2 kMwn02Fs9kELvvZ+C7J77NMgcX76Hnn47QGYJpQvkmfXJTEWorDt715D4vG0mw1nYkJP XH6C4pd4Xt33VyknO5m2d8FZp+PsPgoCDgwTfIT/sQHX8bwV6o1f0QhGO7Obd04oWTp6 pud9SmQoqJki17tM1+sUWBun8IKGpQijWgLHCTY2M4+nPUHEhZCDjBJHkhI8VDzkNznU lHYw== X-Gm-Message-State: AOAM532vEtkXV0hq8nqoGmhXtEaJSUvKDz3I0Q/WHlWfr30VvLRs/797 sCEpHc6r5KrlwnOSjkzI4F9kUsUeXpJXK4k+rNQ= X-Google-Smtp-Source: ABdhPJyu+mSeAQumP2IdHIof1HQb/pnfMl78WUOpyoFExIo1PopHsqlyRm5WDJgXhX2ILnHI8eYNJyvjai2ziA/GCk4= X-Received: by 2002:a67:c409:: with SMTP id c9mr2751032vsk.54.1616160917913; Fri, 19 Mar 2021 06:35:17 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 19 Mar 2021 16:35:06 +0300 Message-ID: To: Hao Sun Cc: "internals@lists.php.net" , nd Content-Type: multipart/alternative; boundary="0000000000006984c805bde3c905" Subject: Re: [PHP-DEV] RFC: PHP JIT/arm64 port From: dmitrystogov@gmail.com (Dmitry Stogov) --0000000000006984c805bde3c905 Content-Type: text/plain; charset="UTF-8" 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 and > 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 test > 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 the > 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=1203). 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=1255). 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='-d opcache.jit=1203 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 > > --0000000000006984c805bde3c905--