Upgrading PHP extensions from PHP5 to NG (和訳)

(まだ翻訳途中、殆どはグーグル翻訳そのもの)

PHP 拡張の PHP5 から NG へのアップデート

Many of the frequently used API functions have changed, such as the HashTable API; this page intends to document as many as possible of those changes that actually affect the way extension and core code is written. It's highly recommended to read the general information about PHPNG implementation at phpng-int, before reading this guide.

ハッシュテーブル API のような頻繁に使用される多くのAPI関数が変更されています。 ; このページは実際に書かれている拡張やコアコードに影響を与える変更の多くを可能な限り文書化する事を意図しています。このガイドを読む前に、phpng-int で PHPNG 実装についての一般的な情報を読む事を強く勧めます。

This is not a complete guide that covers every possible situation. This is a collection of prescriptions for most useful cases. I hope it must be enough for most user-level extensions. However if you did not find some information here, found a solution and think it may be useful for others - feel free to add your recipe.

これはあらゆる状況をカバーする完全なガイドではありません。これが殆どの場合に有用なケースへの処方箋を集めたものです。私はそれが殆どのユーザーレベルの機能拡張のために十分で違いないと願っています。但し、ここで何らかの情報が見つからない場合は、解決方法を見つけて下さい。それが他の人とって有益かもしれません。 - どうぞご自由にあなたのレシピを付け加えて下さい。

General Advice

一般的なアドバイス

Try to compile your extension with PHPNG. Look into compilation error and warnings. They must show you 75% of the places that have to be changed.

PHPNG を使って拡張モジュールをコンパイルしてみてください。コンパイルエラーや警告を調べてください。それらはあなたに変更しなければならない場所の75%を示さなければなりません。

Compile and test extensions in debug mode (configure PHP with –enable-debug). It'll enable catching some error in run-time using assert(). You'll also see information about memory leaks.

コンパイルデバッグモードでのテストの拡張機能(-enableデバッグを有効にしてPHPを設定する)。それは、assert() を使用して、実行時にいくつかのエラーをキャッチ可能にします。また、メモリリークに関する情報が表示されます。

zval

zval

PHPNG doesn't require any involvement of pointers to pointers to zval. Most occurrences of zval** variables and parameters have to be changes into zval*. The corresponding Z_*_PP() macros that work with such variables should be changed into Z_*_P().

PHPNG はポインタとzval型へのポインタへの少しの関与も必要としません。出現する殆どの zval **変数およびパラメータはは zval への変化である必要があります。そのような変数との動作に対応する Z_*_PP() マクロは Z_*_P() に変更するべきです。

In many places PHPNG work with zval directly (eliminating need for allocation and deallocation). In these cases corresponding zval* variable should be converted into plain zval, macros that use this variable from Z_*P() into Z_*() and corresponding creation macros from ZVAL_*(var, …) into ZVAL_*(&var, …). Be always careful about passing addresses of zval and & operator. PHPNG almost never require passing address of zval*. In some places & operator should be removed.

多くの場所で PHPNG は zval で直接動作します(割り当てと割り当て解除の必要性を排除します)。これらの場合には、対応する zval *変数は、プレーンに変換する必要がありますのzvalからこの変数を使用するマクロ、Z_ * P()へのZ _ *()とから対応する創造マクロZVAL _ *(VAR、...)へのZVAL _ *(&VAR、...)。いつものアドレスを渡すことには注意が必要にzvalと&演算子を。PHPNGはほとんどのアドレスを渡すのに * zvalを必要としません。いくつかの場所で&演算子を削除する必要があります。

zval allocation macros ALLOC_ZVAL, ALLOC_INIT_ZVAL, MAKE_STD_ZVAL are removed. In most cases their usage indicate that zval* need to be changed into plain zval. Macro INIT_PZVAL is removed as well and its usages in most cases should be just removed.

zval を割り当てるマクロは ALLOC_ZVAL、ALLOC_INIT_ZVAL、MAKE_STD_ZVALが削除されます。それらを使用する殆どのケースは、zval* を只の zval に変更する必要がある事を示します。マクロ INIT_PZVALは同様に削除され、ほとんどの場合、その利用を単に削除する必要があります。

-  zval *zv;
-  ALLOC_INIT_ZVAL();
-  ZVAL_LONG(zv, 0);
+  zval zv;
+  ZVAL_LONG(&zv, 0);

- のzval * ZV;
- ALLOC_INIT_ZVAL();
- ZVAL_LONG(ZV、0);
+ zvalをZV;
+ ZVAL_LONG(&ZV、0);

The zval struct has completely changed. Now it's defined as:

zvalの構造体は完全に変更されました。今では次のように定義だ。

struct _zval_struct {
	zend_value        value;			/* value */
	union {
		struct {
			ZEND_ENDIAN_LOHI_4(
				zend_uchar    type,			/* active type */
				zend_uchar    type_flags,
				zend_uchar    const_flags,
				zend_uchar    reserved)	    /* various IS_VAR flags */
		} v;
		zend_uint type_info;
	} u1;
	union {
		zend_uint     var_flags;
		zend_uint     next;                 /* hash collision chain */
		zend_uint     str_offset;           /* string offset */
		zend_uint     cache_slot;           /* literal cache slot */
	} u2;
};

and zend_value as

そして zend_value として

typedef union _zend_value {
	long              lval;				/* long value */
	double            dval;				/* double value */
	zend_refcounted  *counted;
	zend_string      *str;
	zend_array       *arr;
	zend_object      *obj;
	zend_resource    *res;
	zend_reference   *ref;
	zend_ast_ref     *ast;
	zval             *zv;
	void             *ptr;
	zend_class_entry *ce;
	zend_function    *func;
} zend_value;

The main difference is that now we handle scalar and complex types differently. PHP doesn't allocate scalar values in heap but do it directly on VM stack, inside HashTables and object. They are not subjects for reference counting and garbage collection anymore. Scalar values don't have reference counter and don't support Z_ADDREF*(), Z_DELREF*(), Z_REFCOUNT*() and Z_SET_REFCOUNT*() macros anymore. In most cases you should check if zval supports these macros before calling them. Otherwise you'll get an assert() or crash.

主な違いは、今は違って、スカラ型および複合型を扱うことです。PHPは、ヒープ内のスカラー値を割り当てることが、内部では、VMのスタック上で直接それをしていないのHashTable sおよびオブジェクト。彼らは、もはや参照カウントとガベージコレクションの対象者ではありません。スカラー値参照カウンタを持っていないとサポートされていませんZ_ADDREF *()を、Z_DELREF *() 、Z_REFCOUNT *() とZ_SET_REFCOUNT *() マクロはもう。zvalを、それらを呼び出す前に、これらのマクロをサポートしていればほとんどの場合、あなたがチェックする必要があります。そうしないと、assert() やクラッシュを得るでしょう。

- Z_ADDREF_P(zv)
+ if (Z_REFCOUNTED_P(zv)) {Z_ADDREF_P(zv);}
# or equivalently
+ Z_TRY_ADDREF_P(zv);

zval values should be copied using ZVAL_COPY_VALUE() macro

zvalの値は、使用してコピーする必要がありますZVAL_COPY_VALUE()マクロを

It's possible to copy and increment reference counter if necessary using ZVAL_COPY() macro

これは、コピーして使用して、必要に応じて参照カウンタをインクリメントすることが可能です()ZVAL_COPYをマクロ

Duplication of zval (zval_copy_ctor) may be done using ZVAL_DUP() macro

の複製のzval(zval_copy_ctorは)使用して行われてもよいZVAL_DUP()マクロを

If you converted a zval* into a zval and previously used NULL to indicate an undefined value, you can now use the IS_UNDEF type instead. It can be set using ZVAL_UNDEF(&zv) and checked using if (Z_ISUNDEF(zv)).

あなたが変換した場合にzval *をへのzval、以前に使用され、NULLを未定義の値を示すためには、ここで使用することができますIS_UNDEFの代わりにタイプを。これは、使用して設定できますZVAL_UNDEF(&ZV)をし、使用してチェック(Z_ISUNDEF(ZV))した場合。

If you want to get the long/double/string value of a zval using cast-semantics without modifying the original zval you can now use the zval_get_long(zv), zval_get_double(zv) and zval_get_string(zv) APIs to simplify the code:

あなたはあなたが今使用することができ、元のzval変更することなく、キャストのセマンティクスを使用してのzvalのロング/二重/文字列値を取得したい場合zval_get_long(ZV)を、(ZV)zval_get_doubleとzval_get_string(ZV) APIは、コードを簡素化する。

- zval tmp;
- ZVAL_COPY_VALUE(&tmp, zv);
- zval_copy_ctor(&tmp);
- convert_to_string(&tmp);
- // ...
- zval_dtor(&tmp);
+ zend_string *str = zval_get_string(zv);
+ // ...
+ STR_RELEASE(str);

Look into zend_types.h code for more details: https://github.com/php/php-src/blob/phpng/Zend/zend_types.h

詳細についてはzend_types.hコードを調べてください:https://github.com/php/php-src/blob/phpng/Zend/zend_types.h

References

参考文献

zval in PHPNG don't have is_ref flag anymore. References are implemented using a separate complex reference-counted type IS_REFERENCE. You may still use Z_ISREF*() macros to check if the given zval is reference. Actually, it just checks if type of the given zval equal to IS_REFERENCE. Macros that worked with is_ref flag are removed: Z_SET_ISREF*(), Z_UNSET_ISREF*() and Z_SET_ISREF_TO*(). Their usage should be changed in the following way:

zvalを PHPNGインがありませんis_refもうフラグです。参照は、独立した、複雑な参照カウント式使って実装されIS_REFERENCEを。あなたはまだ使用することができZ_ISREF *()与えられたzvalのが参照であるかどうかをチェックするためのマクロを。へのzval与えられた同じタイプの場合は、実際には、それだけでチェックしIS_REFERENCE。と協力してマクロis_refフラグが削除されます。Z_SET_ISREF *() 、Z_UNSET_ISREF *()とZ_SET_ISREF_TO *()を。その使用法は次のように変更する必要があります。

- Z_SET_ISREF_P(zv);
+ ZVAL_MAKE_REF(zv);

- Z_UNSET_ISREF_P(zv);
+ if (Z_ISREF_P(zv)) {ZVAL_UNREF(zv);}

Previously references might be directly checked for referenced type. Now we have to check it indirectly through Z_REFVAL*() macro

以前の参照は、直接参照される型をチェックしている可能性があります。今、私たちは、を介して間接的にそれをチェックする必要がZ_REFVAL *()マクロ

- if (Z_ISREF_P(zv) && Z_TYPE_P(zv) == IS_ARRAY) {
+ if (Z_ISREF_P(zv) && Z_TYPE_P(Z_REFVAL_P(zv)) == IS_ARRAY) {

or perform manual dereferencing using ZVAL_DEREF() macro

または使用して手動で参照解除を行うZVAL_DEREF()マクロを

- if (Z_ISREF_P(zv)) {...}
- if (Z_TYPE_P(zv) == IS_ARRAY) {
+ if (Z_ISREF_P(zv)) {...}
+ ZVAL_DEREF(zv);
+ if (Z_TYPE_P(zv) == IS_ARRAY) {

Booleans

ブール

IS_BOOL does not exist anymore but IS_TRUE and IS_FALSE are types on their own:

IS_BOOLはもう存在しませんが、IS_TRUEとIS_FALSEは自分自身の型を持ちます。

  • if ((Z_TYPE_PP(item) == IS_BOOL || Z_TYPE_PP(item) == IS_LONG) && Z_LVAL_PP(item) ) {
  1. if (Z_TYPE_P(item) == IS_TRUE || (Z_TYPE_P(item) == IS_LONG && Z_LVAL_P(item))) {

The Z_BVAL*() macros are removed. Be careful, the return value of Z_LVAL*() on IS_FALSE/IS_TRUE is undefined.

Z_BVAL *()マクロは削除されます。注意してください、の戻り値Z_LVAL *() IS_FALSE / IS_TRUE上に定義されていません。

Strings

ストリングス

The value/length of the string may be accessed using the same macros Z_STRVAL*() and Z_STRLEN*(). However now the underlining data structure for string representation is zend_string (it's described in separate section). The zend_string may be retrieved from zval by Z_STR*() macro. It's also possible to get the hash value of the string through Z_STRHASH*().

文字列の値/長さは、同じマクロを使用してアクセスすることができるZ_STRVAL *()とZ_STRLEN *() 。しかし今や文字列表現のためのアンダーラインデータ構造がさzend_string(それは別のセクションで説明です)。zend_stringはによってzvalをから取り出すことができるZ_STR *()マクロ。それはを通して文字列のハッシュ値を取得することも可能です)(* Z_STRHASH。

In case code needs to check if the given string is interned or not, now it should be done using zend_string (not char*)

場合のコードは、与えられた文字列が、今では使用して行われる必要があり、抑留されているかどうかを確認する必要があるzend_stringを(しないCHAR *)

  • if (IS_INTERNED(Z_STRVAL_P(zv))) {
  1. if (IS_INTERNED(Z_STR_P(zv))) {

Creation of string zvals was a little bit changed. Previously macros like ZVAL_STRING() had an additional argument that told if the given characters should be duplicated or not. Now these macros always have to create zend_string structure so this parameter became useless. However if its actual value was 0, you have free the original string to avoid memory leak.

文字列zvalsの作成 ​​を少し変更しました。以前ZVAL_STRINGようなマクロ()は、指定した文字が重複するかどう語った追加の引数を持っていた。今、これらのマクロは常に作成する必要がzend_stringこのパラメータは無用になったので、構造を。その実際の値が0であった場合ただし、メモリリークを避けるために、元の文字列を解放できます。

- ZVAL_STRING(zv, str, 1);
+ ZVAL_STRING(zv, str);

- ZVAL_STRINGL(zv, str, len, 1);
+ ZVAL_STRINGL(zv, str, len);

- ZVAL_STRING(zv, str, 0);
+ ZVAL_STRING(zv, str);
+ efree(str);

- ZVAL_STRINGL(zv, str, len, 0);
+ ZVAL_STRINGL(zv, str, len);
+ efree(str);

The same is true for similar macros like RETURN_STRING(), RETVAL_STRNGL(), etc and some internal API functions.

同じことがのような同じようなマクロの真実である)(RETURN_STRING、RETVAL_STRNGL()などといくつかの内部のAPI関数。

  • add_assoc_string(zv, key, str, 1);
  1. add_assoc_string(zv, key, str);
  • add_assoc_string(zv, key, str, 0);
  1. add_assoc_string(zv, key, str);
  2. efree(str);

The double reallocation may be avoided using zend_string API directly and creating zval directly from zend_string.

二重の再割当てを使用して回避することができるzend_string APIを直接かつから直接zvalを作成zend_string。

  • char * str = estrdup("Hello");
  • RETURN_STRING(str);
  1. zend_string *str = STR_INIT("Hello", sizeof("Hello")-1, 0);
  2. RETURN_STR(str);

Z_STRVAL*() now should be used as read-only object. It's not possible to assign anything into it. It's possible to modify spearate characters, but before doing it you must be sure that this string is not referred form everywhere else (it is not interned and its reference-counter is 1). Also after in-place string modification you might need to reset calculated hash value.

Z_STRVAL *()は現在、読み取り専用オブジェクトとして使用する必要があります。それはそこに何かを割り当てることはできません。それはspearate文字を変更することが可能だが、それを行う前に、この文字列が(それがインターンされておらず、その参照カウンタが1である)他のどこでもフォームが参照されていないことを確認する必要があります。また、インプレースの文字列の変更後には、算出したハッシュ値を再設定する必要があるかもしれません。

SEPARATE_ZVAL(zv);
Z_STRVAL_P(zv)[0] = Z_STRVAL_P(zv)[0] + ('A' - 'a');

  1. STR_FORGET_HASH_VAL(Z_STR_P(zv))

zend_string API

zend_string API

Zend has a new zend_string API, except that zend_string is underlining structure for string representation in zval, these structures are also used throughout much of the codebase where char* and int were used before.

Zendのは、新た持つzend_stringの APIをことを除いて、zend_stringは文字列表現のための構造を強調しているのzval、これらの構造はまた、コードベースの大部分全体で使用されたchar *とint型が以前に使用された。

zend_strings (not IS_STRING zvals) may be created using STR_INIT(char *val, int len, int persistent) macro. The actual characters may be accessed as str→val and string length as str→len. The hash value of the string should be accessed through STR_HASH_VAL() macro. It'll re-calculate hash value if necessary.

zend_strings(しないIS_STRING zvals)を使用して作成することができるSTR_INIT(CHAR * valに、int型のlen、int型持続的)マクロを。実際の文字は、次のようにアクセスすることができるのstr→valのような、文字列の長さが列str→lenに。文字列のハッシュ値は、を介してアクセスする必要がありSTR_HASH_VAL()マクロ。必要に応じて、ハッシュ値を再計算するだろう。

Strings should be deallocated using STR_RELEASE() macro, that doesn't necessary free memory, because the same string may be referenced from few places.

文字列は、使用して割り当てを解除する必要がありますSTR_RELEASE()と同じ文字列がいくつかの場所から参照することがありますので、必要な空きメモリがないマクロを、。

If you are going to keep zend_string pointer somewhere you should increase it reference-counter or use STR_COPY() macro that will do it for you. In many places where code copied characters just to keep value (not to modify) it's possible to use this macro instead.

あなたが維持しようとしている場合zend_stringポインタをどこかにあなたはそれを参照カウンタを増やすか、使用する必要がありますSTR_COPY()あなたのためにそれを行いますマクロを。コードをコピー文字だけの価値を維持するための多くの場所では(変更しない)、代わりにこのマクロを使用することが可能です。

  • ptr->str = estrndup(Z_STRVAL_P(zv), Z_STRLEN_P(zv));
  1. ptr->str = STR_COPY(Z_STR_P(zv));

...

  • efree(str);
  1. STR_RELEASE(str);

In case the copied string is going to be changed you may use STR_DUP() macro instead

ケースでコピーした文字列は、使用可能に変更されようとしているSTR_DUP()の ​​代わりにマクロを

  • char *str = estrndup(Z_STRVAL_P(zv), Z_STRLEN_P(zv));
  1. zend_string *str = STR_DUP(Z_STR_P(zv));

...

  • efree(str);
  1. STR_RELEASE(str);

The code with old macros must be supported as well, so switching to the new ones is not necessary.

古いマクロをコードがとても必要ではない新しいものへの切り替え、同様にサポートされなければならない。

In some cases it makes sense to allocate string buffer before the actual string data is known. You may use STR_ALLOC() and STR_REALLOC() macros to do it.

場合によっては、実際の文字列データが知られる前に、文字列バッファを割り当てることが理にかなっている。あなたが使用することができSTR_ALLOCを()とSTR_REALLOC()マクロはそれを行うには。

  • char *ret = emalloc(16+1);
  • md5(something, ret);
  • RETURN_STRINGL(ret, 16, 0);
  1. zend_string *ret = STR_ALLOC(16, 0);
  2. md5(something, ret->val);
  3. RETRUN_STR(ret);

Not all of the extensions code have to be converted to use zend_string instead of char*. It's up to extensions maintainer to decide which type is more suitable in each particular case.

拡張機能コードのすべてが使用するように変換する必要がzend_stringの代わりにchar *型。それは、それぞれの特定の場合に、より適しているタイプを決定するための拡張機能のメンテナ次第です。

Look into zend_string.h code for more details: https://github.com/php/php-src/blob/phpng/Zend/zend_string.h

詳細についてはzend_string.hコードを調べてください:https://github.com/php/php-src/blob/phpng/Zend/zend_string.h

smart_str and smart_string

smart_strとsmart_string

For consistent naming convention the old smart_str API was renamed into smart_string. it may be used as before except for new names.

一貫性のある命名規則については、旧smart_str APIは、に改名されましたsmart_string。それは、新しい名前を除いて前と同様に使用することができる。

  • smart_str str = {0};
  • smart_str_appendl(str, " ", sizeof(" ") - 1);
  • smart_str_0(str);
  • RETURN_STRINGL(implstr.c, implstr.len, 0);
  1. smart_string str = {0};
  2. smart_string_appendl(str, " ", sizeof(" ") - 1);
  3. smart_string_0(str);
  4. RETVAL_STRINGL(str.c, str.len);
  5. smart_str_free(&str);

In addition we introduced a new zend_str API that works with zend_string directly

さらに、新たに導入さzend_str APIと連携zend_stringを直接

- smart_str str = {0};
- smart_str_appendl(str, " ", sizeof(" ") - 1);
- smart_str_0(str);
- RETURN_STRINGL(implstr.c, implstr.len, 0);
+ smart_str str = {0};
+ smart_str_appendl(str, " ", sizeof(" ") - 1);
+ smart_str_0(str);
+ if (str.s) {
+   RETURN_STR(str.s);
+ } else {
+   RETURN_EMPTY_STRING();
+ }

smart_str defined as

smart_strとして定義

typedef struct {
    zend_string *s;
    size_t a;
} smart_str;

The API of both smart_str and smart_string are very similar and actually they repeat the API used in PHP5. So it must not be a big problems to adopt the code. the biggest question what AI to select for each particular case, but it depends the way the final result is used.

APIの両方のsmart_strとsmart_stringは非常に類似しており、実際に彼らは繰り返し、API PHP5で使用されています。だから、コードを採用する大きな問題であってはなりません。AIはそれぞれの特定の場合のために選択するかを最大の疑問が、それは最終的な結果が使用されている方法が異なります。

Note that the previously check for a empty smart_str might need to be changed

以前に空smart_strをチェックすることに注意してください変更する必要があるかもしれません

- if (smart_str->c) {
+ if (smart_str->s) {

strpprintf

strpprintf

In addition to spprintf() and vspprintf() functions we introduced similar functions that produce zend_string instead char*. it's up to you to decide when you should change to the new variants.

に加えてspprintf()とvspprintf()関数は私たちが生産、同様の機能が導入zend_string代わりにchar *型を。それはあなたが新しい変種に変わるべき時を決定するのはあなた次第です。

PHPAPI zend_string *vstrpprintf(size_t max_len, const char *format, va_list ap);
PHPAPI zend_string *strpprintf(size_t max_len, const char *format, ...);

Arrays

配列

Arrays implemented more or less the same, however, if previously the underlining structure was imlemented as a pointer to HashTable now we have here a pointer to zend_array that keep HashTable inside. The HashTable may be read as before using Z_ARRVAL*() macros, but now it's not possible to change pointer to HashTable. It's only possible to get/set pointer to the whole zend_array through macro Z_ARR*().

以前下線構造は体へのポインタとしてimlementedれた場合は多かれ少なかれ同じ実装配列は、しかしながら、ハッシュテーブル今、私たちはここにへのポインタがあるzend_array保つハッシュテーブルを内部。ハッシュテーブルは、使用して以前のように読むことができるZ_ARRVAL *()マクロを、今では体へのポインタを変更することはできませんハッシュテーブル。それは/全体へのポインタを設定し取得することだけが可能ですzend_arrayマクロを通して)(* Z_ARR。

The best way to create arrays is to use old array_init() function, but it's also possible to create new uninitialized arrays using ZVAL_NEW_ARR() or initialize it using zend_array structure through ZVAL_ARR()

アレイを作成するための最良の方法は、古い使用することですはarray_init()関数を、それが使用して新しい初期化されていないアレイを作成することも可能ですZVAL_NEW_ARR()を使用して、またはそれを初期化zend_arrayを通して構造を(ZVAL_ARR)

Some arrays might be immutable (may be checked using Z_IMMUTABLE() macro). And in case code need to modify them, they have to be duplicated first. Iteration through immutable arrays using internal position pointer is not possible as well. It's possible to walk through such arrays using old iteration API with external position pointer or using new HashTable iteration API described in separate section.

一部のアレイは、(使用してチェックすることができる不変かもしれないZ_IMMUTABLE()マクロ)。とケースコードで、彼らが最初に複製されなければならない、それらを変更する必要があります。内部使用して不変の配列を介して反復位置ポインタは、同様に可能ではありません。それは、昔の反復使用して、このようなアレイの中を歩くことが可能ですAPIを外部に 位置ポインタまたは新しいハッシュテーブルの反復使用してAPIに別のセクションで説明します。

HashTable API

ハッシュテーブルのAPI

HashTable API was changed significantly, and it may cause some troubles in extensions porting.

ハッシュテーブルAPIが大幅に変更したところ、拡張機能の移植でいくつかのトラブルが発生することがあります。

  • First of all now HashTables always keep zvals. Even if we store an arbitrary pointer, it's packed into zval with special type IS_PTR. Anyway, this simplifies work with zval

まず第一に、今ハッシュテーブルは常にキープzvalを秒。私たちは任意のポインタを格納しても、それがにパックだのzval特殊なタイプでIS_PTR。とにかく、これはとの作業を簡素化のzval

- zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key)+1, (void*)&zv, sizeof(zval**), NULL) == SUCCESS) {
+ if (zend_hash_update(EG(function_table), Z_STR_P(key), zv)) != NULL) {

Most API functions returns requested values directly (instead of using additional by reference argument and returning SUCCESS/FAILURE).

ほとんどのAPI(代わりに参照引数によって、追加を使用し、成功/失敗を返すの)値を直接要求された関数に戻ります。

- if (zend_hash_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key)+1, (void**)&zv_ptr) == SUCCESS) {
+ if ((zv = zend_hash_find(ht, Z_STR_P(key))) != NULL) {
  • Keys are represented as zend_string. Most functions have two forms. One receives a zend_string as key and the other a char*, length pair.
  • キーは、次のように表現されzend_string。ほとんどの関数は2つの形式があります。一つは、受信zend_stringをキーとその他としてはchar *、長さのペア。
  • Important Note: Length of the key string does not include trailing zero. In some places +1/-1 has to be removed/added:
  • 重要:キー文字列の長さがゼロの末尾が含まれていません。いくつかの場所では+1 / -1を除去しなければ/追加があります。
- if (zend_hash_find(ht, "value", sizeof("value"), (void**)&zv_ptr) == SUCCESS) {
+ if ((zv = zend_hash_str_find(ht, "value", sizeof("value")-1)) != NULL) {

This also applies to other hashtable-related APIs outside of zend_hash. For example:

これはまた、zend_hash外の他のハッシュテーブル関連のAPIに適用されます。たとえば、次のように

- add_assoc_bool_ex(&zv, "valid", sizeof("valid"), 0);
+ add_assoc_bool_ex(&zv, "valid", sizeof("valid") - 1, 0);
  • API provides a separate group of functions to work with arbitrary pointers. Such functions have the same names with _ptr suffix.
  • APIは、任意のポインタを操作する関数の別のグループを提供します。そのような機能は、同じ名前があります_ptrサフィックスを。
- if (zend_hash_find(EG(class_table), Z_STRVAL_P(key), Z_STRLEN_P(key)+1, (void**)&ce_ptr) == SUCCESS) {
+ if ((func = zend_hash_find_ptr(ht, Z_STR_P(key))) != NULL) {

- zend_hash_update(EG(class_table), Z_STRVAL_P(key), Z_STRLEN_P(key)+1, (void*)&ce, sizeof(zend_class_entry*), NULL) == SUCCESS) {
+ if (zend_hash_update_ptr(EG(class_table), Z_STR_P(key), ce)) != NULL) {
  • API provides a separate group of functions to store memory blocks of arbitrary size. Such functions have the same names with _mem suffix and they implemented as inline wrappers of corresponding _ptr functions. It doesn't mean if something was stored using _mem or _ptr variant. It always may be retrieved back using zend_hash_find_ptr().
  • APIは、任意のサイズのメモリ·ブロックを格納するための関数の別のグループを提供します。このような機能は、同じ名前を持つ_memサフィックスと彼らは、対応のインラインラッパーとして実装_ptrの機能を。何かが使用して保存した場合は意味するものではありません_memまたは_ptrバリアントを。それは、常に使用してバック検索することができる)(zend_hash_find_ptrを。
- zend_hash_update(EG(function_table), Z_STRVAL_P(key), Z_STRLEN_P(key)+1, (void*)func, sizeof(zend_function), NULL) == SUCCESS) {
+ if (zend_hash_update_mem(EG(function_table), Z_STR_P(key), func, sizeof(zend_function))) != NULL) {
  • few new optimized functions for new element insertion were added. They are intended to be used in situations when code adds only new elements, that can't overlap with already existing keys. For example when you copy some elements of one HashTable into a new one. All such functions have _new suffix.
  • 新しい要素を挿入するためのいくつかの新しい最適化された関数が追加されました。これらは、コードは既に既存のキーと重複しないことができる唯一の新しい要素を追加したときの状況で使用されることが意図される。たとえば、新しいものに1ハッシュテーブルのいくつかの要素をコピーすると。そのようなすべての機能は持って_newのサフィックスを。
zval* zend_hash_add_new(HashTable *ht, zend_string *key, zval *zv);
zval* zend_hash_str_add_new(HashTable *ht, char *key, int len, zval *zv);
zval* zend_hash_index_add_new(HashTable *ht, pzval *zv);
zval* zend_hash_next_index_insert_new(HashTable *ht, pzval *zv);
void* zend_hash_add_new_ptr(HashTable *ht, zend_string *key, void *pData);
...
  • HashTable destructors now always receive zval* (even if we use zend_hash_add_ptr or zend_hash_add_mem to add elements). Z_PTR_P() macro may be used to reach the actual pointer value in destructors. Also, if elements are added using zend_hash_add_mem, destructor is also responsible for deallocation of the pointers themselves.
  • ハッシュテーブルのデストラクタは現在、常に受信のzval *を(私たちが使用している場合でもzend_hash_add_ptrまたはzend_hash_add_memを要素を追加する)。Z_PTR_P()マクロは、デストラクタ内の実際のポインタ値に到達するために使用することができる。要素を使用して追加している場合にも、zend_hash_add_memを、デストラクタもポインタそのものの解放を担当しています。
- void my_ht_destructor(void *ptr)
+ void my_ht_destructor(zval *zv)
  {
-    my_ht_el_t *p = (my_ht_el_t*) ptr;
+    my_ht_el_t *p = (my_ht_el_t*) Z_PTR_P(zv);
     ...
+    efree(p); // this efree() is not always necessary necessary
  }
);

Callbacks for all zend_hash_apply_*() functions, as well as callbacks for zend_hash_copy() and zend_hash_merge(), should be changed to receive zval* instead of void*&& in the same way as destructors. Some of these functions also receive pointer to zend_hash_key structure. It's definition was changed in the following way. For string keys h contains a value of hash function and key the actual string. For integer keys h contains numeric key value, and key is NULL.

すべてのためのコールバックzend_hash_apply _ *()関数と同様にするためのコールバックzend_hash_copy()とzend_hash_merge() 、受信するように変更する必要がありますのzval *の代わりに、デストラクタと同様に、ボイド* &&。これらの機能のいくつかは、体へのポインタを受け取るzend_hash_key構造。それは定義には次のように変更されましたです。のために、文字列のキーhはハッシュ関数との値が含まれている重要な実際の文字列を。のために、整数のキーhの数値キー値が含まれており、キーが NULLです。

typedef struct _zend_hash_key {
	ulong        h;
	zend_string *key;
} zend_hash_key;

In some cases, it makes sense to change usage of zend_hash_apply*() functions into usage of new HashTable iteration API. This may lead to smaller and more efficient code.

いくつかのケースでは、の利用に変更することに意味がzend_hash_apply *()新しいハッシュテーブル繰り返しの使用に機能をAPI。これはより小さく、より効率的なコードにつながる可能性がある。

Reviewing zend_hash.h is a very good idea: https://github.com/php/php-src/blob/phpng/Zend/zend_hash.h

zend_hash.hの確認は非常に良いアイデアです。https://github.com/php/php-src/blob/phpng/Zend/zend_hash.h

HashTable Iteration API

ハッシュテーブル反復API

We provide few specialized macros to iterate through elements (and keys) of HashTables. The first argument of the macros is the hashtables, the others are variables to be assigned on each iteration step.

私たちは、ハッシュテーブルの要素(とキー)を反復するには、いくつかの特殊なマクロを提供します。マクロの最初の引数はハッシュテーブルで、他は各反復ステップに割り当てられる変数です。

- ZEND_HASH_FOREACH_VAL(ht, val)
- ZEND_HASH_FOREACH_KEY(ht, h, key)
- ZEND_HASH_FOREACH_PTR(ht, ptr)
- ZEND_HASH_FOREACH_NUM_KEY(ht, h)
- ZEND_HASH_FOREACH_STR_KEY(ht, key)
- ZEND_HASH_FOREACH_STR_KEY_VAL(ht, key, val)
- ZEND_HASH_FOREACH_STR_KEY_VAL(ht, h, key, val)

The best suitable macro should be used instead of the old reset, current, and move functions.

最高の適切なマクロは、現在、代わりに古いリセットの使用、および機能を移動する必要があります。

- HashPosition pos;
  ulong num_key;
- char *key;
- uint key_len;
+ zend_string *key;
- zval **pzv;
+ zval *zv;
-
- zend_hash_internal_pointer_reset_ex(&ht, &pos);
- while (zend_hash_get_current_data_ex(&ht, (void**)&ppzval, &pos) == SUCCESS) {
-   if (zend_hash_get_current_key_ex(&ht, &key, &key_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING){
-   }
+ ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, key, val) {
+   if (key) { //HASH_KEY_IS_STRING
+   }
    ........
-   zend_hash_move_forward_ex(&ht, &pos);
- }
+ } ZEND_HASH_FOREACH_END();

Objects

オブジェクト

TODO:...

Custom Objects

カスタムオブジェクト

TODO:...

zend_object struct is defined as:

zend_object構造体は次のように定義され

struct _zend_object {
    zend_refcounted   gc;
    zend_uint         handle; // TODO: may be removed ???
    zend_class_entry *ce;
    const zend_object_handlers *handlers;
    HashTable        *properties;
    HashTable        *guards; /* protects from __get/__set ... recursion */
    zval              properties_table[1];
};

We inlined the properties_table for better access performance, but that also brings a problem, we used to define a custom object like this:

私たちは、優れたアクセス性能のためproperties_tableをインライン化するだけでなく、問題をもたらしていることを、私たちは次のようにカスタムオブジェクトを定義するために使用される。

struct custom_object {
   zend_object std;
   void  *custom_data;
}
 
 
zend_object_value custom_object_new(zend_class_entry *ce TSRMLS_DC) {
 
   zend_object_value retval;
   struct custom_object *intern;
 
   intern = emalloc(sizeof(struct custom_object));
   zend_object_std_init(&intern->std, ce TSRMLS_CC);
   object_properties_init(&intern->std, ce);
   retval.handle = zend_objects_store_put(intern,
        (zend_objects_store_dtor_t)zend_objects_destroy_object,
        (zend_objects_free_object_storage_t) custom_free_storage,
        NULL TSRMLC_CC);
   intern->handle = retval.handle;
   retval.handlers = &custom_object_handlers;
   return retval;
}
 
struct custom_object* obj = (struct custom_object *)zend_objects_get_address(getThis())

but now, zend_object is variable length now(inlined properties_table). thus above codes should be changed to:

しかし今、zend_objectは(インライン化properties_table)今可変長である。したがって、上記のコードは次のように変更します。

struct custom_object {
   void  *custom_data;
   zend_object std;
}
 
zend_object * custom_object_new(zend_class_entry *ce TSRMLS_DC) {
     # Allocate sizeof(custom) + sizeof(properties table requirements)
     struct custom_object *intern = ecalloc(1,
         sizeof(struct custom_object) +
         sizeof(zval) * (ce->default_properties_count - 1));
     # Allocating:
     # struct custom_object {
     #    void *custom_data;
     #    zend_object std;
     # }
     # zval[ce->default_properties_count-1]
     zend_object_std_init(&intern->std, ce TSRMLS_CC);
     ...
     custom_object_handlers.offset = XtOffsetof(struct custom_obj, std);
     custom_object_handlers.free_obj = custom_free_storage;
 
     return &intern->std;
}
 
# Fetching the custom object:
 
#define struct custom_object * php_custom_object_fetch_object(zend_object *obj) {
      return (struct custom_object *)((char *)obj - XtOffsetOf(struct custom_object, std));
}
 
#define Z_CUSTOM_OBJ_P(zv) php_custom_object_fetch_object(Z_OBJ_P(zv));
 
struct custom_object* obj = Z_CUSTOM_OBJ_P(getThis());

zend_object_handlers

zend_object_handlers

a new item offset is added to zend_object_handlers, you should always define it as the offset of the zend_object in your custom object struct.

オフセット新しいアイテムがzend_object_handlersに追加されたカスタム·オブジェクト·構造体でzend_objectのオフセットとして、あなたは常にそれを定義する必要があります。

it is used by zend_objects_store_* to find the right start address of the allocated memory.

それは割り当てられたメモリの右スタートアドレスを見つけることがzend_objects_store_ *で使用されています。

// An example in spl_array
memcpy(&spl_handler_ArrayObject, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
spl_handler_ArrayObject.offset = XtOffsetOf(spl_array_object, std);

the memory of the object now will be released by zend_objects_store_*, thus you should not free the memory in you custom objects free_obj handler.

オブジェクトのメモリは現在、カスタムfree_objハンドラオブジェクトにこのようにしてメモリーを解放しないでください、zend_objects_store_ *でリリースされます。

Resources

資源

zvals of type IS_RESOURCE don't keep resource handle anymore. Resource handle can't be retrieved using Z_LVAL*(). Instead you should use Z_RES*() macro to retrieve the resource record directly. The resource record is represented by zend_resource structure. It contains type - resource type, ptr - pointer to actual data, handle - numeric resource index (for compatibility) and service fields for reference counter. Actually this zend_resurce structure is a replacement for indirectly referred zend_rsrc_list_entry. All occurances of zend_rsrc_list_entry should be replaced by zend_resource.

  • のzvalの型ののかどはもはやリソースハンドルを保持しません。リソースハンドルを使用して取得することができませんZ_LVAL *()を。代わりに、使用する必要がありますZ_RES *()を直接リソースレコードを取得するために、マクロを。リソースレコードは次式で表されzend_resource構造。これは、含まれているタイプのリソースタイプ、 - ptrが、実際のデータへのポインタを- ハンドル -参照カウンタの数値(互換性のために)リソースインデックスとサービスフィールドを。実はこのzend_resurceの構造は、間接的に言及に置き換わるものですzend_rsrc_list_entry。すべての回出てくるzend_rsrc_list_entryを置き換える必要がありzend_resource。
  • zend_list_find() function is removed, because resources are accessed directly.
  • zend_list_find() リソースに直接アクセスするため、関数は、除去される。
- long handle = Z_LVAL_P(zv);
- int  type;
- void *ptr = zend_list_find(handle, &type);
+ long handle = Z_RES_P(zv)->handle;
+ int  type = Z_RES_P(zv)->type;
+ void *ptr = = Z_RES_P(zv)->ptr;
  • Z_RESVAL_*() macto is removed Z_RES*() may be used instead
  • Z_RESVAL _ *()mactoが除去される)(* Z_RESを用いてもよい
- long handle = Z_RESVAL_P(zv);
+ long handle = Z_RES_P(zv)->handle;
  • ZEND_FETCH_RESOURCE() macro takes third argument as zval*
  • ZEND_FETCH_RESOURCE()マクロのように第三の引数を取ります* zvalを
- ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, &link_arg, link_id, LE_LINK, le_link, le_plink);
+ ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, link_arg, link_id, LE_LINK, le_link, le_plink);

zend_list_addref() and zend_list_delref() functions are removed. Resources use te same mechanism for reference counting as all zvals.

zend_list_addref()とzend_list_delref()関数が除去される。リソースはすべてのように、参照カウント用のTE同じメカニズムを使用zvalを秒。

- zend_list_addref(Z_LVAL_P(zv));
+ Z_ADDREF_P(zv);

it's the same

それは同じだ

- zend_list_addref(Z_LVAL_P(zv));
+ Z_RES_P(zv)->gc.refcount++;
  • zend_list_delete() takes pointer to zend_resource structure instead of resource handle<<

zend_list_delete()へのポインタを取るzend_resource構造の代わりに、リソースハンドル

- zend_list_delete(Z_LVAL_P(zv));
+ zend_list_delete(Z_RES_P(zv));
  • In most user extension functions like mysql_close(), you should use zend_list_close() instead of zend_list_delete(). This closes the actual connection and frees extension specific data structures, but doesn't free the zend_reference structure. that might be still referenced from zval(s). This also doesn't decrement the resource reference counter.

mysql_close()のようなほとんどのユーザー拡張関数で、使用すべきzend_list_close()の代わりにzend_list_deleteを() 。これは、実際の接続を閉じ、エクステンション固有のデータ構造を解放しますが、解放されませんzend_referenceの構造を。それはまだのzval(複数可)から参照される可能性があります。これは、リソース参照カウンタをデクリメントされません。

- zend_list_delete(Z_LVAL_P(zv));
+ zend_list_close(Z_RES_P(zv));

Parameters Parsing API changes

APIの変更の解析パラメータ

PHPNG doesn't work with zval** anymore, so it doesn't need 'Z' specifier anymore. It must be replaced by 'z'.

PHPNGはでは動作しません。** zvalのそれは必要としないので、もう「Z」はもう指定子を。それは、置き換える必要があります'Z' 。

- zval **pzv;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &pzv) == FAILURE) {
+ zval *zv;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zv) == FAILURE) {
  • in addition to 's' specifier that expects string, PHPNG introduced 'S' specifier that also expects string, but places argument into zend_string variable. In some cases direct usage of zend_string is preferred. (For example when received string used as a key in HashTable API.
  • に加えて、「s 'の文字列を期待指定子、PHPNG導入「S」、文字列を期待しますが、中に引数を配置指定子zend_string変数を。いくつかのケースでは直接使用zend_stringが好ましい。ハッシュテーブルのキーとして使用され(例えば、受信した文字列のAPI
- char *str;
- int len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &len) == FAILURE) {
+ zend_string *str;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str) == FAILURE) {
  • '+' and '*' specifiers now return just array of zvals (instead of array of zval**s before)
  • '+'や'*'指定子は今だけの配列が返さのzval(代わりに、アレイの複数のzval **前複数可)
- zval ***argv = NULL;
+ zval *argv = NULL;
  int argn;
  if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &argv, &argn) == FAILURE) {

arguments passed by reference should be assigned into the referenced value. It's possible to separte such arguments, to get referenced value at first place.

参照によって渡される引数は、参照値に割り当てる必要があります。それは最初の場所で参照された値を取得するには、そのような引数をseparteすることが可能です。

- zval **ret;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &ret) == FAILURE) {
+ zval *ret;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &ret) == FAILURE) {
    return;
  }
- ZVAL_LONG(*ret, 0);
+ ZVAL_LONG(ret, 0);

Call Frame Changes (zend_execute_data)

呼び出しフレームの変更(zend_execute_data)

Information about each function call recorded in a chain of zend_execute_data structures. EG(current_execute_data) points into call frame of currently executed functions (previously zend_execute_data structures were created only for user-level PHP functions). I'll try to explain the difference between old and new call frame structures field by field.

zend_execute_data構造の連鎖に記録された各関数呼び出しに関する情報。EG(current_execute_data)へのポイントの呼び出しフレームは、現在実行された関数の(以前zend_execute_data構造は、ユーザレベルのPHPの機能のためにのみ作成されました)。私はフィールドによって、新旧のコールフレーム構造のフィールドの違いを説明しようとするでしょう。

  • zend_execute_data.opline - instruction pointer of the currently executed user function. For internal functions its value is undefined. (previously for interanl functions its value was NULL)
  • zend_execute_data.opline -現在実行ユーザー関数の命令ポインタ。内部関数の場合、その値は未定義です。(以前interanlの機能のために、その値がNULLであった)
  • zend_execute_data.function_state - this field was removed. zend_execute_data.call should be used instead.
  • zend_execute_data.function_state-このフィールドは削除されました。zend_execute_data.callを代わりに使用する必要があります。
  • zend_execute_data.call - previously it was a pointer to current call_slot. Currently it's a pointer to zend_execute_data of a currently calling function. This field is initially NULL, then it's changed by ZEND_INIT_FCALL (or similar) opcodes and then restored back by ZEND_FO_FCALL. Syntactically nested functions calls, like foo($a, bar($c)), construct a chain of such structures linked through zend_execute_data.prev_nested_call

zend_execute_data.call -以前は、現在の体へのポインタだったcall_slot。現在は体へのポインタですzend_execute_data現在呼び出す関数の。このフィールドには、それがZEND_INIT_FCALL(または類似の)オペコードによって変更してからZEND_FO_FCALLによって再生復元だ、最初はNULLである。fooは($、バー別($ c)参照)のような構文的にネストされた関数呼び出しは、、を介して結合したような構造のチェーン構築zend_execute_data.prev_nested_callを

  • zend_execute_data.op_array - this field was replaced by zend_execute_data.func, because now it may represent not only user functions but also internal ones.
  • zend_execute_data.op_array-このフィールドは置き換えられましたzend_execute_data.func、今ではユーザ関数だけでなく、内部のものだけでなく、を表すことができるので、。
  • zend_execute_data.func - currently executed function
  • zend_execute_data.func -現在実行された関数
  • zend_execute_data.object - $this of the currently executed function (previously it was a zval*, now it's a zend_object*)
  • zend_execute_data.object -現在実行された機能の$この(以前はそれがあったのzvalの*今ではだ、zend_object *)
  • zend_execute_data.symbol_table - current symbol table or NULL
  • zend_execute_data.symbol_table -現在のシンボルテーブルまたはNULL
  • zend_execute_data.prev_execute_data - link of backtrace call chain
  • zend_execute_data.prev_execute_data -バックトレース呼び出しチェーンのリンク
  • original_return_value, current_scope, current_called_scope, current_this - these fields kept old values to restore them after call. Now they are removed.
  • original_return_value、current_scope、current_called_scope、current_this - これらのフィールドは、コールの後にそれらを復元するために、古い値を保った。今、彼らは削除されます。
  • zend_execute_data.scope - scope of the currently executed function (this is a new field).
  • zend_execute_data.scope -現在実行された機能の範囲(これは新しいフィールドである)。
  • zend_execute_data.called_scope - called_scope of the currently executed function (this is a new field).
  • zend_execute_data.called_scope -現在実行された機能のcalled_scope(これは新しいフィールドである)。
  • zend_execute_data.run_time_cache - run-time-cache of the currently executed function. this is a new field and actually it's a copy of op_array.run_time_cache.
  • zend_execute_data.run_time_cache - 現在実行された function の実行時キャッシュ。これは新しいフィールドであり、実際は op_array.run_time_cacheのコピーです。
  • zend_execute_data.num_args - number of arguments passed to the function (this is a new field)
  • zend_execute_data.num_args -関数に渡された引数の数(これは新しいフィールドである)
  • zend_execute_data.return_value - pointer to zval* where the currently executed op_array should store the result. It may be NULL if call doesn't care about return value. (this is a new field).
  • zend_execute_data.return_value -へのポインタ* zval型現在実行op_arrayが結果を格納する場所。呼び出しは、戻り値を気にしない場合にはNULLを指定できます。(これは新しいフィールドである)。

Arguments to functions stored in zval slots directly after zend_execute_data structure. they may be accessed using ZEND_CALL_ARG(execute_data, arg_num) macro. For user PHP functions first argument overlaps with first compiled cariable - CV0, etc. In case caller passes more arguments that callee receives, all extra arguments are copied to be after all used by calee CVs and TMP variables.

に格納された関数の引数のzval直後のスロットzend_execute_data構造。彼らが使用してアクセスすることができるZEND_CALL_ARG(execute_data、arg_num)マクロを。最初の引数が最初と重複するユーザPHPの関数ではコンパイルされcariable - CV 0など、発信者が受信した被呼複数の引数を渡す場合、すべての余分な引数はCALEEのCVSとTMP変数が使用するすべての後になるようにコピーされます。

Executor Globals - EG() Changes

エグゼキュータグローバル - EG()の変更点

EG(symbol_table) - was turned to be a zend_array (previously it was a HashTable). It's not a bog problem to reach underlining HashTable

EG(symbol_tableは)は -であるとなっていたzend_array(以前はそれがあったハッシュテーブル)。これは、下線ハッシュテーブルに到達するために沼地の問題ではありません

- symbols = zend_hash_num_elements(&EG(symbol_table));
+ symbols = zend_hash_num_elements(&EG(symbol_table).ht);
  • EG(uninitialized_zval_ptr) and EG(error_zval_ptr) were removed. Use &EG(uninitialized_zval) and &EG(error_zval) instead.
  • EG(uninitialized_zval_ptr)とEG(error_zval_ptr)除去された。利用規約EG(uninitialized_zval)および&EG(error_zval)代わりに。
  • EG(current_execute_data) - the meaning of this field was changed a bit. Previously it was a pointer to call frame of last executed PHP function. Now it's a pointer to last executed call frame (never mind if it's user or internal function). It's possible to get the zend_execute_data structure for the last op_array traversing call chain list.
  • EG(current_execute_data) -このフィールドの意味が少し変更されました。以前は、最後に実行したPHPの関数のフレームを呼び出すためのポインタでした。今では(それは、ユーザまたは内部機能の場合は、気にしない)を実行し、コールフレームを最後にポインターです。これは、取得することが可能ですzend_execute_data最後op_arrayトラバース呼び出しチェーンリストの構造を。
  zend_execute_data *ex = EG(current_execute_data);
+ while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) {
+    ex = ex->prev_execute_data;
+ }
  if (ex) {
  • EG(opline_ptr) - was removed. Use execute_data→opline instead.
  • EG(opline_ptr)-削除されました。使用execute_data→opline代わりに。
  • EG(return_value_ptr_ptr) - was removed. Use execute_data→return_value instead.
  • EG(return_value_ptr_ptr)-削除されました。使用execute_data→RETURN_VALUE代わりに。
  • EG(active_symbol_table) - was removed. Use execute_data→symbol_table instead.
  • EG(active_symbol_tableは)-削除されました。使用execute_data→symbol_tableは代わりに。
  • EG(active_op_array) - was removed. Use execute_data→func instead.
  • EG(active_op_array)-削除されました。使用execute_data→FUNC代わりに。
  • EG(called_scope) - was removed. Use execute_data→called_scope instead.
  • EG(called_scope)-削除されました。使用execute_data→called_scope代わりに。
  • EG(This) - was turned into zval, previously it was a pointer to zval. User code shouldn't modify it.
  • EG(これが) -となったのzval以前にそれはへのポインタだった、zval型。ユーザコードは、それを変更してはなりません。
  • EG(in_execution) -was removed. If EG(current_excute_data) is not NULL, we are executing something.
  • EG(in_execution)削除-was。EG(current_excute_data)がNULLでない場合、私たちは何かを実行している。
  • EG(exception) and EG(prev_exception) - were turned to be pointers to zend_object, previously they were pointers to zval.
  • EG(例外)とEG(prev_exceptionは) -へのポインタであることになったzend_object以前に、彼らはへのポインタだった、zval型。

Opcodes changes

オペコードの変更

  • ZEND_DO_FCALL_BY_NAME - was removed, ZEND_INIT_FCALL_BY_NAME was added.
  • ZEND_DO_FCALL_BY_NAME - 削除された、ZEND_INIT_FCALL_BY_NAMEが追加されました。
  • ZEND_BIND_GLOBAL - was added to handle “global $var”
  • ZEND_BIND_GLOBALは - 「グローバルの$ VAR "を処理するために追加されました
  • ZEND_STRLEN - was added to replace strlen function
  • ZEND_STRLENは - のstrlen関数を置き換えるために追加されました
  • ZEND_TYPE_CHECK - was added to replace is_array/is_int/is_* if possible
  • ZEND_TYPE_CHECKは - 置き換えるために追加されましたIS_ARRAY / is_int / is_ *のような、可能な場合
  • ZEND_DEFINED - was added to replace zif_defined if possible (if only one parameter and it's constant string and it's not in namespace style)
  • ZEND_DEFINED - 可能な場合は(一つのパラメータのみあれば、それは文字列定数だとそれは名前空間のスタイルではありません)zif_defined置き換えるために追加されました
  • ZEND_SEND_VAR_EX - was added to do more check than ZEND_SEND_VAR if the condition can not be settled in compiling time
  • ZEND_SEND_VAR_EXは - 条件は、時間をコンパイルで決済できない場合ZEND_SEND_VAR以上のチェックを行うために追加されました
  • ZEND_SEND_VAL_EX - was added to do more check than ZEND_SEND_VAL if the condition can not be settled in compiling time
  • ZEND_SEND_VAL_EXは - 条件は、時間をコンパイルで決済できない場合ZEND_SEND_VAL以上のチェックを行うために追加されました
  • ZEND_INIT_USER_CALL - was added to replace call_user_func(_array) if possible if the function can not be found in compiling time, otherwise it can convert to ZEND_INIT_FCALL
  • ZEND_INIT_USER_CALLは - 関数が時間をコンパイルするに見つからない場合、それ以外の場合は ZEND_INIT_FCALLに変換することができ、可能な場合はcall_user_func(_array)を置き換えるために追加されました
  • ZEND_SEND_ARRAY - was added to send the second parameter, the array of the call_user_func_array after it is converted to opcode
  • ZEND_SEND_ARRAY - それはオペコードに変換された後の第2のパラメータ、call_user_func_arrayの配列を送信するために追加されました
  • ZEND_SEND_USER - was added to send the the parameters of call_user_func after it is converted to opcode
  • ZEND_SEND_USER - それは、オペコードに変換した後call_user_funcのパラメータを送信するために添加した

temp_variable

temp_variable

PCRE

Some pcre APIs use or return zend_string now. F.e. php_pcre_replace returns a zend_string and takes a zend_string as 1st argument. Double check their declarations as well as compilers warnings, which are very likely about wrong arguments types.

一部のPCRE APIは使用するか、または今zend_stringを返す。鉄php_pcre_replaceはzend_stringを返し、第一引数としてzend_stringを取ります。ダブル彼らの宣言だけでなく、誤った引数の型についての可能性が非常に高いのコンパイラの警告を確認してください。

phpng-upgrading.txt ・最終更新:2014年8月23日16:11 bukka