Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109849 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62191 invoked from network); 25 Apr 2020 19:06:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Apr 2020 19:06:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9BA0C1804F2 for ; Sat, 25 Apr 2020 10:38:32 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8075 40.64.0.0/10 X-Spam-Virus: No X-Envelope-From: Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12olkn2022.outbound.protection.outlook.com [40.92.22.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 25 Apr 2020 10:38:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kWscZN+8Dv7yUctzN4MBJ+anglsj6sJgNZjPbayFLUC8+CgMofi1SiO8rnY5yZL4JZ1AjJPSnb0jAGOjc7cX2IL6igIPjk2C4opT3MAos2JQN7fzBrKv7KtZAUUu2XngeqsUl3M1nptz5Fql2rD6AThDAx0v+WWUccZGQPz9mxTCax82Q7jRBcShVYX4o0aeF8yWqvVM5/tTZOxXj/wIJiKrydlJwg6CT77wR3rU9Mt8uHsK+VBW3BZ+/j/otIJwyXCzSw3GXPMdZVYRr6I+n/4aEJHkfxXNOH+LytvsACB/W6W3uJB+uiZvY7+3ao7dSNm6gx3ifQ+D4DZHV+nXQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oLvPVE+hDqgeihgmRfsY81kfGX7UkXHVjLmNw0rLUf8=; b=ZGZaLnHAUSaM5GdPI00aLSvpH0FQkY9KKC3o9gD1kABdjRTGBsZpjtVQgzWM1ZvgksnaUtvhAcOqKP0CPB2bdfTixZ+QkmTVCbTGmIr2h8DXIA31WqkUB2jEWpNFteowqq/nDGz6sHGhSO2tnrtXxIS5pgXCpKvMpOwHFyUkdNGpSN9ndaJFcQx206r4i2LPffYBlIebJYie4T+lJdUdXVReIGZWGYvsmPsHRwkMQbEmFFTsuBgo96Ho+KnhQiDhdyvK2l7SlS5EYXtiaAVfImW5TOt+cbLBuypCyB+8+StUfb9m7Lv+JyQ6vwD04bwxmwivZs/MMumoMc8qBpj9Jg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oLvPVE+hDqgeihgmRfsY81kfGX7UkXHVjLmNw0rLUf8=; b=QfJfe7Ols/ZgXMeh/GEqF+Ib8hChcbrrB6JJ8XB5zVQv0MGohkozUU53Atd46WsJZBOXtiSxQtNuSdXJ7j8tghTguti50/SD87GrJtacJNiT1knund/G9rzMZEEoMJRBybwPXd5AECF+MO+h2VXMQODSqs4rbEXBoUrkX2M2V/GP8TwGHXGr0GIhoHyP31V5MOB/UrMyUTqULbpxmmV5/RgyYy6SRNSqJje2jAXhaHretsbxufAXxwp99N7YaWLaiH3BS81x0ZwGKnCcjrNzH5wic3Hzsh5fJ0sU1vAo9n9D4ayGjZl3Tqjk2woBSNBPiIzliA5MhWHbZ9Vb3hO4BA== Received: from DM6NAM12FT038.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc64::45) by DM6NAM12HT170.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc64::124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.12; Sat, 25 Apr 2020 17:38:30 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:fc64::51) by DM6NAM12FT038.mail.protection.outlook.com (2a01:111:e400:fc64::113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.12 via Frontend Transport; Sat, 25 Apr 2020 17:38:30 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::e553:b74f:bf64:30c5]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::e553:b74f:bf64:30c5%4]) with mapi id 15.20.2921.036; Sat, 25 Apr 2020 17:38:30 +0000 To: Nikita Popov CC: "internals@lists.php.net" Thread-Topic: [PHP-DEV] Optimizing assembly for spl_object_id(), fdiv(), etc in the JIT? Thread-Index: AQHWGxz5+Txr028sTUe2R2cg2slM+KiKDdsAgAAG/cg= Date: Sat, 25 Apr 2020 17:38:30 +0000 Message-ID: References: , In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:7B1BE4E4D6DD2154A031A0D0D2CF6F6914B7071536863D08269A5C8B49CE3F08;UpperCasedChecksum:7D61CC1D01A2305D50825C7701E2E83A4EF12752AE8FE95E9C3916AF2B2D567E;SizeAsReceived:7130;Count:46 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [2wJOHmjraGBsPLpDR2WKLaoyHmxX1I3n] x-ms-publictraffictype: Email x-incomingheadercount: 46 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 62e96f03-e1ec-4383-9ed4-08d7e93f7872 x-ms-traffictypediagnostic: DM6NAM12HT170: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: KdLGiTUJAJHXUSCfQt5e1S2aCpNphAeV0Afc9KPHVhcmaPAs0ypCQ4Xcpdty/RJxut9hRCQnWBg2LPFevJysDsdxVUZZwEIdWpS8QL/K3ZEesjMB7yT/oifPQoGun6/txNNR2Mclv+4IKlyBpdPIKH98NcJvO1WS67Dg+wbfq9YojJZW1D3C9+gV4tR4iGQa2ceysEpRAuIAoH1JEHBz9w== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR07MB6618.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; x-ms-exchange-antispam-messagedata: SNECCKCwA2mGN1E14GIQzfKh4KtkB3Z28GM1uH/vxyIIaC9S2DUh9bLg2Vn9QKxYNfgDkpjtSm3TAd2cYycuLpdETSh5qTwLpVGksPCIOokQqckQI1OYD9pvu3c+W6+7/dQPZ9biPlEEY2mAI9IzFg== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 62e96f03-e1ec-4383-9ed4-08d7e93f7872 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Apr 2020 17:38:30.8604 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6NAM12HT170 Subject: Re: [PHP-DEV] Optimizing assembly for spl_object_id(), fdiv(), etc in the JIT? From: tysonandre775@hotmail.com (tyson andre) Hi Nikita,=0A= =0A= > Our general approach to this is to first add a VM opcode for the operatio= n,=0A= > which will also provide a benefit if the JIT is not used.=0A= > There's already plenty of those, see ZEND_STRLEN for example.=0A= > Adding JIT support for the opcode would then be the natural second step.= =0A= =0A= I've seen those - I'd assume there'd be a long tail of functions such as pr= eg_match()=0A= without references, spl_object_id(), substr(), etc, that are called frequen= tly, but not often enough to have their own opcodes.=0A= =0A= What about adding a new opcode types that combines INIT_FCALL, SEND_VAR (or= SEND_VAL for constants), and DO_ICALL for known internal functions?=0A= Has that been proposed before?=0A= This could be used when the arguments were inferred by opcache to have corr= ect types.=0A= =0A= ```=0A= Old (in function where $x is known to be a non-reference object):=0A= 0001 INIT_FCALL 1 96 string("spl_object_id")=0A= 0002 SEND_VAR CV0($x) 1=0A= 0003 V2 =3D DO_ICALL=0A= 0004 T1 =3D INIT_ARRAY 1 (packed) CV0($x) V2=0A= 0005 RETURN T1=0A= =0A= New (after opcache):=0A= 0001 T1 =3D INIT_AND_DO_ICALL_1_ARG $x // op1=3D$x, op2 is unused, extended= _value =3D enum value corresponding to spl_object_id()=0A= 0002 RETURN T1=0A= ```=0A= =0A= And fdiv() could become INIT_AND_DO_ICALL_2_ARG $x $y op1=3D$x, op2 is $y,= extended_value =3D enum value corresponding to fdiv=0A= This should give opcache the information it needs to continue tracking the = definitions and uses of variables, as well as function return types.=0A= =0A= - I'd hope there'd be a performance improvement, due to not needing to look= up zend_function, using the native C stack for zvals instead of a dynamic = stack, perform param type checks, etc.=0A= =0A= This would only accept constants and compiled variables of known good types= for functions that wouldn't emit notices or cause re-entry - temporary val= ues (e.g. spl_object_id(some_function())) wouldn't be accepted.=0A= =0A= The C implementation for the new opcode could be a switch on extended_value= with enum values for dozens of commonly used functions=0A= that weren't common enough for individual opcodes.=0A= =0A= Thanks,=0A= - Tyson=