Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32577 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30885 invoked by uid 1010); 3 Oct 2007 01:31:19 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 30870 invoked from network); 3 Oct 2007 01:31:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Oct 2007 01:31:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=planetbeing@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=planetbeing@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.182.188 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: planetbeing@gmail.com X-Host-Fingerprint: 64.233.182.188 nf-out-0910.google.com Received: from [64.233.182.188] ([64.233.182.188:40937] helo=nf-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FE/0C-49174-6E0F2074 for ; Tue, 02 Oct 2007 21:31:18 -0400 Received: by nf-out-0910.google.com with SMTP id e27so2926124nfd for ; Tue, 02 Oct 2007 18:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=oP/MMrqgb/UZ7KJl1+LlsxqZeIExyIYseAO8/x4fz0w=; b=EHkMNUrpmV+qi+M73D3qkrRQS2PBYjOhzetOzhs0ZhuQiZ2Tdhy3wf1VsakXbdoJaXLxwXaX8OWEySvkUsZDaTtkEPPf+JnnjMXMBC2y4IgxJ+AZinQ7w0CiwQJbTDopAmg1I88hTmk3wKFjrtd5m1v/ube79ta265NoSnH65gw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=FS23bZm+3OgquPSpyTxvzvodsOZnCpRP9hORxN5tEacbdrOiOygLgdaPV3kACx3T08ODuuABbIDW0y8NE3pKJzRzYGpfABFIuMJKdCHxQyTyNxvtCQTKRz5BaVbbIFnV+9g2g65tJFSHl0nLCtdyvIApNYt95FCL35OEnQOUwUU= Received: by 10.78.184.2 with SMTP id h2mr4823609huf.1191375074628; Tue, 02 Oct 2007 18:31:14 -0700 (PDT) Received: by 10.78.135.16 with HTTP; Tue, 2 Oct 2007 18:31:14 -0700 (PDT) Message-ID: Date: Tue, 2 Oct 2007 18:31:14 -0700 To: "Wietse Venema" Cc: internals@lists.php.net In-Reply-To: <20071003003533.EAE341F3E99@spike.porcupine.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20071003003533.EAE341F3E99@spike.porcupine.org> Subject: Re: [PHP-DEV] PHP taint support: first results From: planetbeing@gmail.com ("David Wang") On 10/2/07, Wietse Venema wrote: > Low-level implementation > ------------------------ > > Taint support is implemented with some of the unused bits in the > zval data structure. The zval is the PHP equivalent of a memory > cell. Besides a type (string, number etc.) and value, each zval has > a reference count and a flag that says whether the zval is a reference > to yet another zval that contains the actual value. One possible problem area is that I'm using some of those very same bits for storing GC information. I'm not using very many, so there should be plenty to go around, but I'm currently using 3 bits in is_ref. 2 for the "color" (the GC state of the object) and 1 for whether or not the object is internally buffered. Just a heads up. Some details: I have the leftmost bit in is_ref be the indicator of is_ref. This is so I can test is_ref by just testing (z->is_ref >= 0x80). The reason I'm doing it like this is because I find that this comparison test is a lot faster than doing a bitwise test. I then use the other top three bits for what I need, so the bottom 4 bits are free. We really should conserve space, though. The biggest problem with increasing the size of the zval struct seems to be (incredibly) L1 cache misses, as verified with cachegrind. Even increasing the size of the current zval struct by one byte has a measurable impact (my goal was to keep Zend/bench.php from showing any hit at all). David