Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93389 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64468 invoked from network); 18 May 2016 02:51:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 May 2016 02:51:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=jesseschalken@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jesseschalken@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.174 as permitted sender) X-PHP-List-Original-Sender: jesseschalken@gmail.com X-Host-Fingerprint: 209.85.223.174 mail-io0-f174.google.com Received: from [209.85.223.174] ([209.85.223.174:33407] helo=mail-io0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 87/37-11000-1A8DB375 for ; Tue, 17 May 2016 22:51:14 -0400 Received: by mail-io0-f174.google.com with SMTP id f89so48526667ioi.0 for ; Tue, 17 May 2016 19:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=V0X11XmWhNXn+qLXo2fE/T+X8WGN2G90jmXUNG2P/rc=; b=gHLFFcMxtgZ3JUvpYUN/r5cAozsZbNovbKxsh5CsFHUDkqfacaznY22frO4e511jTi XkPjXwXw1grs229pvF+RxwaPIyktsxzY3Rtk2bpKgdwnj92hJzwTYmOypxwu65NUToza V7eOAsFOIuh+y5cEkEBnL4qgX7WYqmtZEzBMQCpdSpRQu8er/3cqUkHcoDAjYplzUi1D akaNYzzt6inEOpVSo5w4SQQ4t0vl8tIgLQXOpSk45QzMym53fO8xjJKdEp9N9k8f+htE e05hvDha+qs2VGja4eWLrI7abn1AnpPwY6OsUWOJapcMJQKhIuuRv1HaIQuyFPVy9ycr Xp6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=V0X11XmWhNXn+qLXo2fE/T+X8WGN2G90jmXUNG2P/rc=; b=fM6mvMcw+vqfiYK9/Rq6ACu2/tbh3m2qGrMRnUXXb6grefj844yqsI5HoREREn2SOF 5NcNEMKPAOaPGJRudLf2YCgw11n5X7xZW1QH4q+HYulfBZJ6U+SiBT5XUlJbzQtXvmrd ml58gVjwSQz5LQ2Dw88tqvUd56ZN3hQpnohPLgF3D3YllzkM5e/Iy5YqbMhClFq2WeU6 y/yQtgremOQuYu4qLM5amJ4GOvYmVBBkJtLkCDcO9mq2/vvVUJiFfGueOhf+uoHcMXm0 0kxnt9sLNXcpQ3DArtrtg68OI2RcqHH+1WGs9FdBaLkKA0okcaIw8PGY5z/QdOKeEulV n0cw== X-Gm-Message-State: AOPr4FUUnryhDLtOdLcVpdIiovS5txeRcnd/JM1O9qlCkP2l/WaJeSolWvVF4avAJho6SrsX9IQzCRltfu2HwA== MIME-Version: 1.0 X-Received: by 10.107.180.194 with SMTP id d185mr3560230iof.151.1463539870909; Tue, 17 May 2016 19:51:10 -0700 (PDT) Sender: jesseschalken@gmail.com Received: by 10.79.139.197 with HTTP; Tue, 17 May 2016 19:51:10 -0700 (PDT) In-Reply-To: References: Date: Wed, 18 May 2016 12:51:10 +1000 X-Google-Sender-Auth: v_QedS_kwoXyPuMHr5SIQzoy8vI Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary=001a114f7dbe1ecdce053314ee84 Subject: Re: [PHP-DEV] Do symbol references always go through a hash table? From: me@jesseschalken.com (Jesse Schalken) --001a114f7dbe1ecdce053314ee84 Content-Type: text/plain; charset=UTF-8 Thanks Nikita, Does that mean a function which accepts an instance of an interface and calls a method on it will have to do a full lookup of the method whenever the concrete class isn't the same as when that function was first executed? (or was last executed, depending on how the cache works) On Wed, May 18, 2016 at 12:28 AM, Nikita Popov wrote: > On Tue, May 17, 2016 at 3:03 PM, Jesse Schalken > wrote: > >> Hi Internals, >> >> I'd like to know whether references to >> classes/functions/methods/properties/variables always go through a hash >> table at runtime, or if the name is optimised into a pointer or fixed >> offset. I recall seeing such an optimisation for local variables, but what >> about the others? >> >> Thanks >> > > A property access $foo->bar (where "bar" is a literal and not the result > of an expression) uses a polymorphic runtime cache, which will store the > class entry and property offset the first time the instruction is executed. > Afterwards, if $foo is an instance of the same class, we will directly use > this offset. Otherwise, a full lookup from the property name table with > visibility checks and all those other bells an whistles has to be performed. > > The same holds for pretty much all other symbol references as well, so > classes, functions, methods, etc. > > Nikita > > --001a114f7dbe1ecdce053314ee84--