Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27470 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20925 invoked by uid 1010); 15 Jan 2007 21:50:18 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 20909 invoked from network); 15 Jan 2007 21:50:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jan 2007 21:50:18 -0000 Authentication-Results: pb1.pair.com header.from=pollita@php.net; sender-id=unknown; domainkeys=good Authentication-Results: pb1.pair.com smtp.mail=pollita@php.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain php.net from 140.211.166.39 cause and error) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pollita@php.net X-Host-Fingerprint: 140.211.166.39 osu1.php.net Linux 2.4/2.6 Received: from [140.211.166.39] ([140.211.166.39:48296] helo=osu1.php.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EC/01-33655-A17FBA54 for ; Mon, 15 Jan 2007 16:50:18 -0500 X-DomainKeys: Ecelerity dk_sign implementing draft-delany-domainkeys-base-01 DomainKey-Signature: q=dns; a=rsa-sha1; c=nofws; s=mx; d=php.net; h=From:Subject:To:Date; b=F59GJhDSPR5l8d53kdgLy2ihpgvCKFBRDQZs0QWXTnHDBK8Jdg90UTIdhatINF8k jAK33ITqWK9TItNeEnczPUSq6KOxqqdXGBDy1N67dH5oOCz+14MCme/6EDNnAHA+ Authentication-Results: osu1.php.net smtp.user=pollita; auth=pass (LOGIN) X-Host-Fingerprint: 207.126.230.225 unknown Received: from [207.126.230.225] ([207.126.230.225:26858] helo=[10.72.106.237]) by osu1.php.net (ecelerity 2.1.1.11-rc1 r(13363/13364M)) with ESMTPSA (cipher=AES256-SHA) id E1/8D-21910-467FBA54 for ; Mon, 15 Jan 2007 13:51:32 -0800 Message-ID: <45ABF710.4090804@php.net> Date: Mon, 15 Jan 2007 13:50:08 -0800 User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: Sara Golemon CC: internals@lists.php.net References: <45AB0207.5080505@php.net> In-Reply-To: <45AB0207.5080505@php.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: Runtime JIT Proposals From: pollita@php.net (Sara Golemon) > Option 4: > Include fetchtype and subelement during runtime JIT callback allowing > JIT callback to only do work necessary to prepare for the read/write > call being performed. > > e.g. > > int php_example_jit_callback(int str_type, zstr str, int str_len, > int stage, zval *container, int fetch_type, zval *element); > > Where str_type/str/str_len indicate the name of the variable being > JITed, stage is one of COMPILETIME or RUNTIME, container is the > autoglobal itself. > Fetch_type is ZEND_FETCH_(DIM_|OBJ_)?_(R|W|RW), and element is the > specific property/offset (only applicable for DIM/OBJ fetches, NULL for > plain fetch. > > Advantages: Gives maximum flexibility to the implementation. In the > case of http request encoding, it allows the decoder to differentiate > between requests for a single element and fetches which want to retreive > the entire array (e.g. foreach). > > Disadvantages: Adds a lot of complexity to the fetching of autoglobals > and qand effectively doubles the amount of callback work being done for > autoglobal objects. Will also confuse implementers on what the > difference between this fetch callback is and the > (read|write)_(dimension|property) callbacks used by objects. > > Okay, in attempting an implementation of this, I got reminded none-too-gently by the engine that it's not quite as simple as I'd remembered: compiled vars: !0 = $g, !1 = $f line # op fetch operands ---------------------------------------------- 2 0 FETCH_R global $0, '_GET' 1 ASSIGN $1, !0, $0 3 2 FETCH_R global $2, '_POST' 3 FETCH_DIM_R $3, $2, 'foo' 4 ASSIGN $4, !1, $3 Autoglobals aren't treated as CVs (as, for some reason, I was thinking they were) so at the time of initial fetch, it's difficult to know if the whole var is being fetched (as in the case of the line 2 assignment, or if it's being fetched so that a subelement can be fetched later (as in the case of the line 3 assignment). The solution I'm tempted to pursue for this is to back up yet another step and make autoglobals be CVs by extending the zend_compiled_variable struct to contain a flag indicating how the var should be fetched (the determination for which happens during fetch_simple_var during the compilation. This would then yield an opcode stack like the following: compiled vars: !0* = $_GET, !1 = $g, !2* = $_POST, !3 = $f line # op fetch operands ---------------------------------------------- 2 0 ASSIGN $0, !1, !0* 3 1 FETCH_DIM_R $1, !2*, 'foo' 2 ASSIGN $2, !3, $1 (The * notation indicating that cv->fetch_type == ZEND_FETCH_GLOBAL) Once that's applied (basicly as a stand-alone speed improvement, since globals are turned into CV fetches), the RT-JIT can be done using the plan I'd already formulated for Option 4. *THEN* we can apply runtime-JIT to http input encoding detection. Just keeping the conversation in the open and hoping anyone which critiques will voice them sooner rather than later. -Sara Two steps forward, one step back.