# Please expose zend_vm_get_opcde_handler

- Thread: https://externals.io/message/57833
- Original archive: https://news-web.php.net/php.internals/57833
- Started by Xinchen Hui on 2012-02-13T17:13:32+00:00
- Messages: 11
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #57833 — Xinchen Hui — 2012-02-13T17:13:32+00:00

URL: https://externals.io/message/57833#57833

Hi:
      As dmitry said today, there is no way to get a user opcode
handler which can be called *after* a specific built-in handler.

      So please expose zend_vm_get_opcde_handler.  Before 5.4 release. :)

       Thanks.

Sent from my iPad

---

## #57842 — Xinchen Hui — 2012-02-14T05:01:18+00:00

URL: https://externals.io/message/57833#57842 · In reply to: #57833

Hi:
  a patch for this proposal:

Index: zend_vm_gen.php
===================================================================
--- zend_vm_gen.php	(revision 323168)
+++ zend_vm_gen.php	(working copy)
@@ -797,7 +797,7 @@
 					if (ZEND_VM_OLD_EXECUTOR && $spec) {
 						out($f,"static int zend_vm_old_executor = 0;\n\n");
 					}
-					out($f,"static opcode_handler_t
zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* op);\n\n");
+					out($f,"ZEND_API opcode_handler_t
zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* op);\n\n");
 					switch ($kind) {
 						case ZEND_VM_KIND_CALL:
 							out($f,"\n");								
@@ -1243,7 +1243,7 @@
 	}

 	// Generate zend_vm_get_opcode_handler() function
-	out($f, "static opcode_handler_t
zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* op)\n");
+	out($f, "ZEND_API opcode_handler_t
zend_vm_get_opcode_handler(zend_uchar opcode, zend_op* op)\n");
 	out($f, "{\n");
 	if (!ZEND_VM_SPEC) {
 		out($f, "\treturn zend_opcode_handlers[opcode];\n");
Index: zend_vm_execute.h
===================================================================
--- zend_vm_execute.h	(revision 323168)
+++ zend_vm_execute.h	(working copy)
@@ -299,7 +299,7 @@
 	241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
 };

-static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode,
zend_op* op);
+ZEND_API opcode_handler_t zend_vm_get_opcode_handler(zend_uchar
opcode, zend_op* op);


 #undef OPLINE
@@ -40192,7 +40192,7 @@
   };
   zend_opcode_handlers = (opcode_handler_t*)labels;
 }
-static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode,
zend_op* op)
+ZEND_API opcode_handler_t zend_vm_get_opcode_handler(zend_uchar
opcode, zend_op* op)
 {
 		static const int zend_vm_decode[] = {
 			_UNUSED_CODE, /* 0              */


thanks


> Hi:
>      As dmitry said today, there is no way to get a user opcode
> handler which can be called *after* a specific built-in handler.
>
>      So please expose zend_vm_get_opcde_handler.  Before 5.4 release. :)
>
>       Thanks.
>
> Sent from my iPad



-- 
惠新宸        laruence
Senior PHP Engineer
http://www.laruence.com

---

## #57843 — Stas Malyshev — 2012-02-14T06:43:14+00:00

URL: https://externals.io/message/57833#57843 · In reply to: #57842

Hi!

> Hi:
>    a patch for this proposal:

Don't see any problem with it. Dmitry, any issues you see with it?
If not, we can commit it.

-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #57844 — Dmitry Stogov — 2012-02-14T07:00:21+00:00

URL: https://externals.io/message/57833#57844 · In reply to: #57843

In general exposing zend_vm_get_opcode_handler() can't help.
You know that executor might be generated/compiled not only using 
call-treading but also using switch or goto. In these cases 
zend_vm_get_opcode_handler() won't return a function that could be called.

Thanks. Dmitry.


> Hi!
>
> > […]
>
> Don't see any problem with it. Dmitry, any issues you see with it?
> If not, we can commit it.

---

## #57846 — Xinchen Hui — 2012-02-14T07:02:15+00:00

URL: https://externals.io/message/57833#57846 · In reply to: #57844

> In general exposing zend_vm_get_opcode_handler() can't help.
> You know that executor might be generated/compiled not only using
> call-treading but also using switch or goto. In these cases
> zend_vm_get_opcode_handler() won't return a function that could be called.
Hi:
  sure,  but I really need a way (even it's narrow) for my new extension..

 or, should I make a patch to add a ZEND_USER_OPCODE_CALL_ME_LATER ?

thanks
>
> Thanks. Dmitry.
>
>
> 
> > […]
>



-- 
惠新宸        laruence
Senior PHP Engineer
http://www.laruence.com

---

## #57848 — Xinchen Hui — 2012-02-14T07:07:54+00:00

URL: https://externals.io/message/57833#57848 · In reply to: #57846

> 
> > […]
> Hi:
>  sure,  but I really need a way (even it's narrow) for my new extension..
>
Why I insistent this is there might be more than 80% php running
with-vm-kind=CALL

so expose this make sense for most of us.

but you really remind me, that I shoud also add a flag to detect what
the vm-kind now...

thanks
>  or, should I make a patch to add a ZEND_USER_OPCODE_CALL_ME_LATER ?
>
> thanks
> > […]
>
>
>
> --
> 惠新宸        laruence
> Senior PHP Engineer
> http://www.laruence.com



-- 
惠新宸        laruence
Senior PHP Engineer
http://www.laruence.com

---

## #57849 — Stas Malyshev — 2012-02-14T07:10:25+00:00

URL: https://externals.io/message/57833#57849 · In reply to: #57848

Hi!

> but you really remind me, that I shoud also add a flag to detect what
> the vm-kind now...

Adding ZEND_API in one place is no problem, but any messing with the 
engine is out of the question now.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #57850 — Xinchen Hui — 2012-02-14T07:11:33+00:00

URL: https://externals.io/message/57833#57850 · In reply to: #57849

> Hi!
>
>
> > […]
>
>
> Adding ZEND_API in one place is no problem, but any messing with the engine
> is out of the question now.
okey, let's just talk about adding ZEND_API. :)

thanks
>
> --
> Stanislav Malyshev, Software Architect
> SugarCRM: http://www.sugarcrm.com/
> (408)454-6900 ext. 227



-- 
惠新宸        laruence
Senior PHP Engineer
http://www.laruence.com

---

## #57851 — Stas Malyshev — 2012-02-14T07:13:31+00:00

URL: https://externals.io/message/57833#57851 · In reply to: #57850

Hi!

> okey, let's just talk about adding ZEND_API. :)

But as Dmitry noted, it's only present in one model, so how useful would 
it be? I don't want to add patches that are not beneficial for anything 
but a very narrow use case. Could you explain what are you trying to do?
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #57852 — Xinchen Hui — 2012-02-14T07:17:57+00:00

URL: https://externals.io/message/57833#57852 · In reply to: #57851

> Hi!
>
>
> > […]
>
>
> But as Dmitry noted, it's only present in one model, so how useful would it
> be? I don't want to add patches that are not beneficial for anything but a
> very narrow use case. Could you explain what are you trying to do?
okey,  I am woking on a extension : taint
(https://github.com/laruence/php-ext-taint) ,  I need find a way to
set a handler which will be called after some built-in handler

like:
   $a  = "taint string";
then
  $b .= $a ; //should also be a taint string.

 as the code above shows,  I need call ASSIGN_CONCAT first then edit
the result of the last opline.


 but now I can not do it unless copy the origin handler and all it
denpend codes, then call it myself (which is what I did now)...


thanks
>
> --
> Stanislav Malyshev, Software Architect
> SugarCRM: http://www.sugarcrm.com/
> (408)454-6900 ext. 227



-- 
惠新宸        laruence
Senior PHP Engineer
http://www.laruence.com

---

## #57854 — Xinchen Hui — 2012-02-14T07:45:40+00:00

URL: https://externals.io/message/57833#57854 · In reply to: #57852

Hi:
  after got some advise of dmitry on IRC,  I decide to drawback this proposal.

  and try to find a much  better patch later.

  thanks very much, and sorry for noise.

thanks


> 
> > […]
> okey,  I am woking on a extension : taint
> (https://github.com/laruence/php-ext-taint) ,  I need find a way to
> set a handler which will be called after some built-in handler
>
> like:
>   $a  = "taint string";
> then
>  $b .= $a ; //should also be a taint string.
>
>  as the code above shows,  I need call ASSIGN_CONCAT first then edit
> the result of the last opline.
>
>
>  but now I can not do it unless copy the origin handler and all it
> denpend codes, then call it myself (which is what I did now)...
>
>
> thanks
> > […]
>
>
>
> --
> 惠新宸        laruence
> Senior PHP Engineer
> http://www.laruence.com



-- 
惠新宸        laruence
Senior PHP Engineer
http://www.laruence.com
