Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79126 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64491 invoked from network); 24 Nov 2014 14:56:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Nov 2014 14:56:41 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.171 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.171 mail-vc0-f171.google.com Received: from [209.85.220.171] ([209.85.220.171:63748] helo=mail-vc0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AB/F4-33396-72743745 for ; Mon, 24 Nov 2014 09:56:39 -0500 Received: by mail-vc0-f171.google.com with SMTP id hy4so2162814vcb.30 for ; Mon, 24 Nov 2014 06:56:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=TPl0fvfWgUKwovVdaZcU3wAN92aK5f7sJRKEy78n45I=; b=UWqE1J5vflU3vlE/y0GIUMB/YUPoFCDZZgtiJiYdo2c1OFnlTgTRPNaYnfPhx3pA9n 68lqyh6rWi4Zdj/ww5u2stv9ZaUlyNCLhDRm1LQ9q/Yt9XhERbJ/EaKi46fiUxAOzHHU eWbn3GTTBxp3uduJY19QYbzuzC5OCKZz3i63ys/Ja2CrMWQM8iN2u9f74z4wHzO7E3DH P2p18OR4Vn/IcnT3kjGtFl9VH1rUPwPzaatIXS04fPuhSwPMPUntboJrJSMJxgOuIKWl 9tILATmM1g9Df5/IeLVDgWrpIjYOQ23oG2QqZuXqa1jhcQhhNacs2k3kih1wKU7yRjss v6RA== X-Gm-Message-State: ALoCoQlF5YPdkqzWkHsPGLKwHeCdw8SrqusMkFQdpZrMNDZ9N7pSS5SLCmhW8HP+Z6QV3XBMmsXrvy+chhCLLMhmMZBWqppqrH18i2Nvh8ifuJijfq0ugP2GyVVLpdYQAjiwQ+V7HU7DzNnB2wg1kJ+VVilwlYb0+g== MIME-Version: 1.0 X-Received: by 10.220.143.16 with SMTP id s16mr12147902vcu.53.1416840996115; Mon, 24 Nov 2014 06:56:36 -0800 (PST) Received: by 10.52.176.231 with HTTP; Mon, 24 Nov 2014 06:56:36 -0800 (PST) In-Reply-To: References: Date: Mon, 24 Nov 2014 18:56:36 +0400 Message-ID: To: Nikita Popov Cc: Xinchen Hui , Anatol Belski , PHP Internals Content-Type: multipart/alternative; boundary=047d7b33db6a46f0fd05089c005a Subject: Re: Use zend_string* for op_array->arg_info[].name and class_name From: dmitry@zend.com (Dmitry Stogov) --047d7b33db6a46f0fd05089c005a Content-Type: text/plain; charset=UTF-8 Hi Nikita, Thanks for review. I already thought about both approaches and failed as well (the second also doesn't work with C++). The proposed patch doesn't complicate engine a lot (may be only the inheritance code), but I afraid about problems in some edge cases. Thanks. Dmitry. On Mon, Nov 24, 2014 at 5:27 PM, Nikita Popov wrote: > On Mon, Nov 17, 2014 at 10:25 AM, Dmitry Stogov wrote: > >> Hi, >> >> Please review the patch >> https://gist.github.com/dstogov/47a39aff37f0a6441ea0 >> >> Thanks. Dmitry. >> > > Hi Dmitry, sorry for late reply. > > The problem we're trying to solve here is lack of ability to create a > zend_string at compile time. I just tried two ideas how we might be able to > do that, to avoid introducing different arginfos for internal/userland > functions. > > My first approach was to create a zend_string as a string literal using > (zend_string *) ("\1\0\0\0" "\6\1\0\0" "\0\0\0\0" "\0\0\0\0" str) (for > 32bit LE) and then update the length in zend_register_functions. However > this didn't work because the string literal ends up in readonly > memprotected memory, so this causes a segfault. > > My second approach was to use a C99 compound literal to create a temporary > zend_string-like structure with the correct length: > > #define ZEND_STRING_CT(str) \ > (zend_string *) (struct { \ > uint32_t refcount; uint32_t type_info; \ > zend_ulong h; size_t len; \ > char val[sizeof(str)]; \ > }[1]) {{ 1, IS_STRING | (IS_STR_PERSISTENT << 8), 0, sizeof(str)-1, > str }} > > This seems to work fine (patch > https://github.com/nikic/php-src/commit/5d49321cd9728e0cc1c2939432e46159f9a78472). > However it requires C99, which we're currently not allowed to use. > > Maybe someone has an idea how this can be done in C89? > > Nikita > --047d7b33db6a46f0fd05089c005a--