diff options
33 files changed, 4052 insertions, 2951 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 5d71383860..b74fb65c14 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1211,7 +1211,7 @@ ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC for (i = 0; i < class_type->default_properties_count; i++) { if (Z_TYPE(class_type->default_properties_table[i]) != IS_UNDEF) { - zval_update_class_constant(&class_type->default_properties_table[i], 0, i TSRMLS_CC); + zval_update_class_constant(&class_type->default_properties_table[i], 0, OBJ_PROP_TO_OFFSET(i) TSRMLS_CC); } } @@ -1255,8 +1255,9 @@ ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properti if (property_info != ZEND_WRONG_PROPERTY_INFO && property_info && (property_info->flags & ZEND_ACC_STATIC) == 0) { - ZVAL_COPY_VALUE(&object->properties_table[property_info->offset], prop); - ZVAL_INDIRECT(prop, &object->properties_table[property_info->offset]); + zval *slot = OBJ_PROP(object, property_info->offset); + ZVAL_COPY_VALUE(slot, prop); + ZVAL_INDIRECT(prop, slot); } } ZEND_HASH_FOREACH_END(); } @@ -1274,11 +1275,12 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties if (property_info != ZEND_WRONG_PROPERTY_INFO && property_info && (property_info->flags & ZEND_ACC_STATIC) == 0) { - zval_ptr_dtor(&object->properties_table[property_info->offset]); - ZVAL_COPY_VALUE(&object->properties_table[property_info->offset], prop); - zval_add_ref(&object->properties_table[property_info->offset]); + zval *slot = OBJ_PROP(object, property_info->offset); + zval_ptr_dtor(slot); + ZVAL_COPY_VALUE(slot, prop); + zval_add_ref(slot); if (object->properties) { - ZVAL_INDIRECT(&tmp, &object->properties_table[property_info->offset]); + ZVAL_INDIRECT(&tmp, slot); zend_hash_update(object->properties, key, &tmp); } } else { @@ -3622,13 +3624,14 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, z if ((property_info_ptr = zend_hash_find_ptr(&ce->properties_info, name)) != NULL && (property_info_ptr->flags & ZEND_ACC_STATIC) == 0) { property_info->offset = property_info_ptr->offset; - zval_ptr_dtor(&ce->default_properties_table[property_info->offset]); + zval_ptr_dtor(&ce->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]); zend_hash_del(&ce->properties_info, name); } else { - property_info->offset = ce->default_properties_count++; + property_info->offset = OBJ_PROP_TO_OFFSET(ce->default_properties_count); + ce->default_properties_count++; ce->default_properties_table = perealloc(ce->default_properties_table, sizeof(zval) * ce->default_properties_count, ce->type == ZEND_INTERNAL_CLASS); } - ZVAL_COPY_VALUE(&ce->default_properties_table[property_info->offset], property); + ZVAL_COPY_VALUE(&ce->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)], property); } if (ce->type & ZEND_INTERNAL_CLASS) { switch(Z_TYPE_P(property)) { diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index ddec6a7ddb..ecb8f4e0d1 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -954,12 +954,10 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value continue; } prop = NULL; - if (prop_info->offset >= 0) { - if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) { - prop = &ce->default_static_members_table[prop_info->offset]; - } else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) { - prop = &ce->default_properties_table[prop_info->offset]; - } + if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) { + prop = &ce->default_static_members_table[prop_info->offset]; + } else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) { + prop = &ce->default_properties_table[OBJ_PROP_TO_NUM(prop_info->offset)]; } if (!prop || Z_TYPE_P(prop) == IS_UNDEF) { continue; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index bc9b88227f..f9a66a37d8 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -227,13 +227,23 @@ typedef struct _zend_try_catch_element { char *zend_visibility_string(uint32_t fn_flags); typedef struct _zend_property_info { + uint32_t offset; /* property offset for object properties or + property index for static properties */ uint32_t flags; - int offset; zend_string *name; zend_string *doc_comment; zend_class_entry *ce; } zend_property_info; +#define OBJ_PROP(obj, offset) \ + ((zval*)((char*)(obj) + offset)) +#define OBJ_PROP_NUM(obj, num) \ + (&(obj)->properties_table[(num)]) +#define OBJ_PROP_TO_OFFSET(num) \ + ((uint32_t)(zend_uintptr_t)OBJ_PROP_NUM(((zend_object*)NULL), num)) +#define OBJ_PROP_TO_NUM(offset) \ + ((offset - OBJ_PROP_TO_OFFSET(0)) / sizeof(zval)) + typedef struct _zend_arg_info { const char *name; // TODO: convert into zend_string ??? uint32_t name_len; diff --git a/Zend/zend_config.w32.h b/Zend/zend_config.w32.h index 6ea67602b4..5353064be1 100644 --- a/Zend/zend_config.w32.h +++ b/Zend/zend_config.w32.h @@ -47,7 +47,9 @@ typedef unsigned int uint; #define HAVE_CLASS_ISTDIOSTREAM #define istdiostream stdiostream +#if _MSC_VER < 1900 #define snprintf _snprintf +#endif #if _MSC_VER < 1500 #define vsnprintf _vsnprintf #endif diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 61a605971e..1551789c48 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1292,7 +1292,7 @@ ZEND_API void zend_fetch_dimension_by_zval(zval *result, zval *container, zval * zend_fetch_dimension_address_read_R(result, container, dim, IS_TMP_VAR TSRMLS_CC); } -static zend_always_inline void zend_fetch_property_address(zval *result, zval *container, uint32_t container_op_type, zval *prop_ptr, void **cache_slot, int type TSRMLS_DC) +static zend_always_inline void zend_fetch_property_address(zval *result, zval *container, uint32_t container_op_type, zval *prop_ptr, uint32_t prop_op_type, void **cache_slot, int type TSRMLS_DC) { if (container_op_type != IS_UNUSED) { ZVAL_DEREF(container); @@ -1316,6 +1316,26 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c } } } + if (prop_op_type == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR_EX(cache_slot))) { + zend_property_info *prop_info = CACHED_PTR_EX(cache_slot + 1); + zend_object *zobj = Z_OBJ_P(container); + zval *retval; + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_INDIRECT(result, retval); + return; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(prop_ptr)); + if (EXPECTED(retval)) { + ZVAL_INDIRECT(result, retval); + return; + } + } + } if (EXPECTED(Z_OBJ_HT_P(container)->get_property_ptr_ptr)) { zval *ptr = Z_OBJ_HT_P(container)->get_property_ptr_ptr(container, prop_ptr, type, cache_slot TSRMLS_CC); if (NULL == ptr) { diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 6dc0941c6f..5577194b0c 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -100,7 +100,7 @@ static const uint32_t uninitialized_bucket = {INVALID_IDX}; ZEND_API void _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC) { /* Use big enough power of 2 */ -#ifdef PHP_WIN32 +#if defined(PHP_WIN32) && !defined(__clang__) if (nSize <= 8) { ht->nTableSize = 8; } else if (nSize >= 0x80000000) { @@ -269,14 +269,12 @@ static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_s IS_CONSISTENT(ht); - CHECK_INIT(ht, 0); - if (ht->u.flags & HASH_FLAG_PACKED) { + if (UNEXPECTED(ht->nTableMask == 0)) { + CHECK_INIT(ht, 0); + goto add_to_hash; + } else if (ht->u.flags & HASH_FLAG_PACKED) { zend_hash_packed_to_hash(ht); - } - - h = zend_string_hash_val(key); - - if ((flag & HASH_ADD_NEW) == 0) { + } else if ((flag & HASH_ADD_NEW) == 0) { p = zend_hash_find_bucket(ht, key); if (p) { @@ -302,6 +300,7 @@ static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_s ZEND_HASH_IF_FULL_DO_RESIZE(ht); /* If the Hash table is full, resize it */ +add_to_hash: HANDLE_BLOCK_INTERRUPTIONS(); idx = ht->nNumUsed++; ht->nNumOfElements++; @@ -309,7 +308,7 @@ static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_s ht->nInternalPointer = idx; } p = ht->arData + idx; - p->h = h; + p->h = h = zend_string_hash_val(key); p->key = key; zend_string_addref(key); ZVAL_COPY_VALUE(&p->val, pData); @@ -423,9 +422,15 @@ static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht, #endif IS_CONSISTENT(ht); - CHECK_INIT(ht, h < ht->nTableSize); - if (ht->u.flags & HASH_FLAG_PACKED) { + if (UNEXPECTED(ht->nTableMask == 0)) { + CHECK_INIT(ht, h < ht->nTableSize); + if (h < ht->nTableSize) { + p = ht->arData + h; + goto add_to_packed; + } + goto add_to_hash; + } else if (ht->u.flags & HASH_FLAG_PACKED) { if (h < ht->nNumUsed) { p = ht->arData + h; if (Z_TYPE(p->val) != IS_UNDEF) { @@ -453,6 +458,7 @@ static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht, goto convert_to_hash; } +add_to_packed: HANDLE_BLOCK_INTERRUPTIONS(); /* incremental initialization of empty Buckets */ if ((flag & (HASH_ADD_NEW|HASH_ADD_NEXT)) == (HASH_ADD_NEW|HASH_ADD_NEXT)) { @@ -477,7 +483,6 @@ static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht, p->h = h; p->key = NULL; ZVAL_COPY_VALUE(&p->val, pData); - Z_NEXT(p->val) = INVALID_IDX; HANDLE_UNBLOCK_INTERRUPTIONS(); @@ -485,9 +490,7 @@ static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht, convert_to_hash: zend_hash_packed_to_hash(ht); - } - - if ((flag & HASH_ADD_NEW) == 0) { + } else if ((flag & HASH_ADD_NEW) == 0) { p = zend_hash_index_find_bucket(ht, h); if (p) { if (flag & HASH_ADD) { @@ -509,6 +512,7 @@ convert_to_hash: ZEND_HASH_IF_FULL_DO_RESIZE(ht); /* If the Hash table is full, resize it */ +add_to_hash: HANDLE_BLOCK_INTERRUPTIONS(); idx = ht->nNumUsed++; ht->nNumOfElements++; diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index c6f8c6ae15..7d9d1aade8 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -602,9 +602,12 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro if ((child_info->flags & ZEND_ACC_PPP_MASK) > (parent_info->flags & ZEND_ACC_PPP_MASK)) { zend_error_noreturn(E_COMPILE_ERROR, "Access level to %s::$%s must be %s (as in class %s)%s", ce->name->val, key->val, zend_visibility_string(parent_info->flags), parent_ce->name->val, (parent_info->flags&ZEND_ACC_PUBLIC) ? "" : " or weaker"); } else if ((child_info->flags & ZEND_ACC_STATIC) == 0) { - zval_ptr_dtor(&(ce->default_properties_table[parent_info->offset])); - ce->default_properties_table[parent_info->offset] = ce->default_properties_table[child_info->offset]; - ZVAL_UNDEF(&ce->default_properties_table[child_info->offset]); + int parent_num = OBJ_PROP_TO_NUM(parent_info->offset); + int child_num = OBJ_PROP_TO_NUM(child_info->offset); + + zval_ptr_dtor(&(ce->default_properties_table[parent_num])); + ce->default_properties_table[parent_num] = ce->default_properties_table[child_num]; + ZVAL_UNDEF(&ce->default_properties_table[child_num]); child_info->offset = parent_info->offset; } return 0; /* Don't copy from parent */ @@ -797,7 +800,7 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent if (property_info->flags & ZEND_ACC_STATIC) { property_info->offset += parent_ce->default_static_members_count; } else { - property_info->offset += parent_ce->default_properties_count; + property_info->offset += parent_ce->default_properties_count * sizeof(zval); } } } ZEND_HASH_FOREACH_END(); @@ -1421,8 +1424,8 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* { || (Z_LVAL(compare_result) != 0); } else { not_compatible = (FAILURE == compare_function(&compare_result, - &ce->default_properties_table[coliding_prop->offset], - &ce->traits[i]->default_properties_table[property_info->offset] TSRMLS_CC)) + &ce->default_properties_table[OBJ_PROP_TO_NUM(coliding_prop->offset)], + &ce->traits[i]->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)] TSRMLS_CC)) || (Z_LVAL(compare_result) != 0); } } else { @@ -1454,7 +1457,7 @@ static void zend_do_traits_property_binding(zend_class_entry *ce TSRMLS_DC) /* { if (flags & ZEND_ACC_STATIC) { prop_value = &ce->traits[i]->default_static_members_table[property_info->offset]; } else { - prop_value = &ce->traits[i]->default_properties_table[property_info->offset]; + prop_value = &ce->traits[i]->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]; } if (Z_REFCOUNTED_P(prop_value)) Z_ADDREF_P(prop_value); diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 6b4e8f1a97..ad5a55510b 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -80,11 +80,10 @@ ZEND_API void rebuild_object_properties(zend_object *zobj) /* {{{ */ ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) { if (/*prop_info->ce == ce &&*/ (prop_info->flags & ZEND_ACC_STATIC) == 0 && - prop_info->offset >= 0 && - Z_TYPE(zobj->properties_table[prop_info->offset]) != IS_UNDEF) { + Z_TYPE_P(OBJ_PROP(zobj, prop_info->offset)) != IS_UNDEF) { zval zv; - ZVAL_INDIRECT(&zv, &zobj->properties_table[prop_info->offset]); + ZVAL_INDIRECT(&zv, OBJ_PROP(zobj, prop_info->offset)); zend_hash_add_new(zobj->properties, prop_info->name, &zv); } } ZEND_HASH_FOREACH_END(); @@ -94,11 +93,10 @@ ZEND_API void rebuild_object_properties(zend_object *zobj) /* {{{ */ if (prop_info->ce == ce && (prop_info->flags & ZEND_ACC_STATIC) == 0 && (prop_info->flags & ZEND_ACC_PRIVATE) != 0 && - prop_info->offset >= 0 && - Z_TYPE(zobj->properties_table[prop_info->offset]) != IS_UNDEF) { + Z_TYPE_P(OBJ_PROP(zobj, prop_info->offset)) != IS_UNDEF) { zval zv; - ZVAL_INDIRECT(&zv, &zobj->properties_table[prop_info->offset]); + ZVAL_INDIRECT(&zv, OBJ_PROP(zobj, prop_info->offset)); zend_hash_add(zobj->properties, prop_info->name, &zv); } } ZEND_HASH_FOREACH_END(); @@ -288,7 +286,7 @@ static zend_always_inline zend_bool is_derived_class(zend_class_entry *child_cla } /* }}} */ -static zend_always_inline zend_property_info *zend_get_property_info_quick(zend_class_entry *ce, zend_string *member, int silent, void **cache_slot TSRMLS_DC) /* {{{ */ +static zend_always_inline zend_property_info *zend_get_property_info_quick(zend_class_entry *ce, zend_string *member, int silent, int allow_static, void **cache_slot TSRMLS_DC) /* {{{ */ { zval *zv; zend_property_info *property_info = NULL; @@ -324,8 +322,13 @@ static zend_always_inline zend_property_info *zend_get_property_info_quick(zend_ if (EXPECTED(zend_verify_property_access(property_info, ce TSRMLS_CC) != 0)) { if (UNEXPECTED(!(flags & ZEND_ACC_CHANGED)) || UNEXPECTED((flags & ZEND_ACC_PRIVATE))) { - if (UNEXPECTED((flags & ZEND_ACC_STATIC) != 0) && !silent) { - zend_error(E_STRICT, "Accessing static property %s::$%s as non static", ce->name->val, member->val); + if (UNEXPECTED((flags & ZEND_ACC_STATIC) != 0)) { + if (!silent) { + zend_error(E_STRICT, "Accessing static property %s::$%s as non static", ce->name->val, member->val); + } + if (!allow_static) { + return NULL; + } } goto exit; } @@ -342,7 +345,9 @@ static zend_always_inline zend_property_info *zend_get_property_info_quick(zend_ && (zv = zend_hash_find(&EG(scope)->properties_info, member)) != NULL && ((zend_property_info*)Z_PTR_P(zv))->flags & ZEND_ACC_PRIVATE) { property_info = (zend_property_info*)Z_PTR_P(zv); - goto exit; + if (!allow_static && UNEXPECTED((property_info->flags & ZEND_ACC_STATIC) != 0)) { + return NULL; + } } else if (UNEXPECTED(property_info == NULL)) { exit_dynamic: if (cache_slot) { @@ -354,9 +359,6 @@ exit_dynamic: if (!silent) { zend_error_noreturn(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(flags), ce->name->val, member->val); } - if (cache_slot) { - CACHE_POLYMORPHIC_PTR_EX(cache_slot, ce, ZEND_WRONG_PROPERTY_INFO); - } return ZEND_WRONG_PROPERTY_INFO; } @@ -370,7 +372,7 @@ exit: ZEND_API zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, int silent TSRMLS_DC) /* {{{ */ { - return zend_get_property_info_quick(ce, member, silent, NULL TSRMLS_CC); + return zend_get_property_info_quick(ce, member, silent, 1, NULL TSRMLS_CC); } /* }}} */ @@ -388,7 +390,7 @@ ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_inf } else { member = zend_string_copy(prop_info_name); } - property_info = zend_get_property_info_quick(zobj->ce, member, 1, NULL TSRMLS_CC); + property_info = zend_get_property_info_quick(zobj->ce, member, 1, 1, NULL TSRMLS_CC); zend_string_release(member); if (property_info == NULL) { /* undefined public property */ @@ -451,13 +453,11 @@ zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_ #endif /* make zend_get_property_info silent if we have getter - we may want to use it */ - property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (type == BP_VAR_IS) || (zobj->ce->__get != NULL), cache_slot TSRMLS_CC); + property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (type == BP_VAR_IS) || (zobj->ce->__get != NULL), 0, cache_slot TSRMLS_CC); if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { - if (EXPECTED(property_info != NULL) && - EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0)) { - - retval = &zobj->properties_table[property_info->offset]; + if (EXPECTED(property_info != NULL)) { + retval = OBJ_PROP(zobj, property_info->offset); if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { goto exit; } @@ -534,13 +534,11 @@ ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, v cache_slot = NULL; } - property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (zobj->ce->__set != NULL), cache_slot TSRMLS_CC); + property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (zobj->ce->__set != NULL), 0, cache_slot TSRMLS_CC); if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { - if (EXPECTED(property_info != NULL) && - EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0)) { - - variable_ptr = &zobj->properties_table[property_info->offset]; + if (EXPECTED(property_info != NULL)) { + variable_ptr = OBJ_PROP(zobj, property_info->offset); if (Z_TYPE_P(variable_ptr) != IS_UNDEF) { goto found; } @@ -638,12 +636,12 @@ write_std_property: if (EXPECTED(property_info != NULL) && EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0)) { - ZVAL_COPY_VALUE(&zobj->properties_table[property_info->offset], value); + ZVAL_COPY_VALUE(OBJ_PROP(zobj, property_info->offset), value); } else { if (!zobj->properties) { rebuild_object_properties(zobj); } - zend_hash_update(zobj->properties, Z_STR_P(member), value); + zend_hash_add_new(zobj->properties, Z_STR_P(member), value); } } @@ -754,13 +752,11 @@ static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type, fprintf(stderr, "Ptr object #%d property: %s\n", Z_OBJ_HANDLE_P(object), name->val); #endif - property_info = zend_get_property_info_quick(zobj->ce, name, (zobj->ce->__get != NULL), cache_slot TSRMLS_CC); + property_info = zend_get_property_info_quick(zobj->ce, name, (zobj->ce->__get != NULL), 0, cache_slot TSRMLS_CC); if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { - if (EXPECTED(property_info != NULL) && - EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0)) { - - retval = &zobj->properties_table[property_info->offset]; + if (EXPECTED(property_info != NULL)) { + retval = OBJ_PROP(zobj, property_info->offset); if (UNEXPECTED(Z_TYPE_P(retval) == IS_UNDEF)) { if (EXPECTED(!zobj->ce->__get) || UNEXPECTED((*zend_get_property_guard(zobj, name)) & IN_GET)) { @@ -816,15 +812,15 @@ static void zend_std_unset_property(zval *object, zval *member, void **cache_slo cache_slot = NULL; } - property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (zobj->ce->__unset != NULL), cache_slot TSRMLS_CC); + property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), (zobj->ce->__unset != NULL), 0, cache_slot TSRMLS_CC); if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { - if (EXPECTED(property_info != NULL) && - EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0)) { + if (EXPECTED(property_info != NULL)) { + zval *slot = OBJ_PROP(zobj, property_info->offset); - if (Z_TYPE(zobj->properties_table[property_info->offset]) != IS_UNDEF) { - zval_ptr_dtor(&zobj->properties_table[property_info->offset]); - ZVAL_UNDEF(&zobj->properties_table[property_info->offset]); + if (Z_TYPE_P(slot) != IS_UNDEF) { + zval_ptr_dtor(slot); + ZVAL_UNDEF(slot); goto exit; } } else if (EXPECTED(zobj->properties != NULL) && @@ -1413,13 +1409,11 @@ static int zend_std_has_property(zval *object, zval *member, int has_set_exists, cache_slot = NULL; } - property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), 1, cache_slot TSRMLS_CC); + property_info = zend_get_property_info_quick(zobj->ce, Z_STR_P(member), 1, 0, cache_slot TSRMLS_CC); if (EXPECTED(property_info != ZEND_WRONG_PROPERTY_INFO)) { - if (EXPECTED(property_info != NULL) && - EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0)) { - - value = &zobj->properties_table[property_info->offset]; + if (EXPECTED(property_info != NULL)) { + value = OBJ_PROP(zobj, property_info->offset); if (Z_TYPE_P(value) != IS_UNDEF) { goto found; } diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 1705965c6b..a6dac42b5a 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -74,6 +74,10 @@ # include <alloca.h> #endif +#if defined(ZEND_WIN32) +#include <intrin.h> +#endif + /* Only use this macro if you know for sure that all of the switches values are covered by its case statements */ #if ZEND_DEBUG @@ -196,8 +200,10 @@ char *alloca(); #if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004 && defined(__i386__) # define ZEND_FASTCALL __attribute__((fastcall)) -#elif defined(_MSC_VER) && defined(_M_IX86) +#elif defined(_MSC_VER) && defined(_M_IX86) && _MSC_VER <= 1700 # define ZEND_FASTCALL __fastcall +#elif defined(_MSC_VER) && _MSC_VER >= 1800 +# define ZEND_FASTCALL __vectorcall #else # define ZEND_FASTCALL #endif diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index fad38c6428..b6d2b82cde 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -1324,11 +1324,33 @@ ZEND_VM_HANDLER(82, ZEND_FETCH_OBJ_R, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV) zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (OP2_TYPE == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } FREE_OP2(); @@ -1352,7 +1374,7 @@ ZEND_VM_HANDLER(85, ZEND_FETCH_OBJ_W, VAR|UNUSED|CV, CONST|TMP|VAR|CV) zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); FREE_OP2(); if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -1376,7 +1398,7 @@ ZEND_VM_HANDLER(88, ZEND_FETCH_OBJ_RW, VAR|UNUSED|CV, CONST|TMP|VAR|CV) if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); FREE_OP2(); if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -1393,6 +1415,8 @@ ZEND_VM_HANDLER(91, ZEND_FETCH_OBJ_IS, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = GET_OP1_OBJ_ZVAL_PTR_DEREF(BP_VAR_IS); @@ -1405,11 +1429,33 @@ ZEND_VM_HANDLER(91, ZEND_FETCH_OBJ_IS, CONST|TMP|VAR|UNUSED|CV, CONST|TMP|VAR|CV zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (OP2_TYPE == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } FREE_OP2(); @@ -1438,7 +1484,7 @@ ZEND_VM_HANDLER(94, ZEND_FETCH_OBJ_FUNC_ARG, CONST|TMP|VAR|UNUSED|CV, CONST|TMP| if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); FREE_OP2(); if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -1464,7 +1510,7 @@ ZEND_VM_HANDLER(97, ZEND_FETCH_OBJ_UNSET, VAR|UNUSED|CV, CONST|TMP|VAR|CV) if (OP1_TYPE == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); FREE_OP2(); if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -2070,7 +2116,7 @@ ZEND_VM_HANDLER(109, ZEND_FETCH_CLASS, ANY, CONST|TMP|VAR|UNUSED|CV) if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) { Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name)); } else { - Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, 0 TSRMLS_CC); + Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC); CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var))); } } else if (Z_TYPE_P(class_name) == IS_OBJECT) { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 4f305c2258..8257789cd2 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1423,7 +1423,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLE if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) { Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name)); } else { - Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, 0 TSRMLS_CC); + Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC); CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var))); } } else if (Z_TYPE_P(class_name) == IS_OBJECT) { @@ -1758,7 +1758,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) { Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name)); } else { - Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, 0 TSRMLS_CC); + Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC); CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var))); } } else if (Z_TYPE_P(class_name) == IS_OBJECT) { @@ -1944,7 +1944,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) { Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name)); } else { - Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, 0 TSRMLS_CC); + Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC); CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var))); } } else if (Z_TYPE_P(class_name) == IS_OBJECT) { @@ -2130,7 +2130,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDL if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) { Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name)); } else { - Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, 0 TSRMLS_CC); + Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC); CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var))); } } else if (Z_TYPE_P(class_name) == IS_OBJECT) { @@ -2169,7 +2169,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CLASS_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_A if (CACHED_PTR(Z_CACHE_SLOT_P(class_name))) { Z_CE_P(EX_VAR(opline->result.var)) = CACHED_PTR(Z_CACHE_SLOT_P(class_name)); } else { - Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, 0 TSRMLS_CC); + Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class_by_name(Z_STR_P(class_name), opline->op2.zv + 1, opline->extended_value TSRMLS_CC); CACHE_PTR(Z_CACHE_SLOT_P(class_name), Z_CE_P(EX_VAR(opline->result.var))); } } else if (Z_TYPE_P(class_name) == IS_OBJECT) { @@ -3984,11 +3984,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_ zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -4003,6 +4025,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = opline->op1.zv; @@ -4015,11 +4039,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -4047,7 +4093,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_CONST_HANDLER(ZEND_ if (IS_CONST == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -5332,11 +5378,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_HA zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -5352,6 +5420,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_H zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = opline->op1.zv; @@ -5364,11 +5434,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_TMP_HANDLER(ZEND_OPCODE_H zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -5397,7 +5489,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_TMP_HANDLER(ZEND_OP if (IS_CONST == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -6525,11 +6617,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_HA zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -6545,6 +6659,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_H zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = opline->op1.zv; @@ -6557,11 +6673,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_VAR_HANDLER(ZEND_OPCODE_H zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -6590,7 +6728,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_VAR_HANDLER(ZEND_OP if (IS_CONST == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -8443,11 +8581,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HAN zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -8462,6 +8622,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HA zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = opline->op1.zv; @@ -8474,11 +8636,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HA zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -8506,7 +8690,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CONST_CV_HANDLER(ZEND_OPC if (IS_CONST == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CONST, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_CONST == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -10770,11 +10954,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_HA zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -10789,6 +10995,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_H zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -10801,11 +11009,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CONST_HANDLER(ZEND_OPCODE_H zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -10833,7 +11063,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_TMP_CONST_HANDLER(ZEND_OP if (IS_TMP_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -11994,11 +12224,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -12014,6 +12266,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAN zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -12026,11 +12280,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_TMP_HANDLER(ZEND_OPCODE_HAN zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -12059,7 +12335,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_TMP_TMP_HANDLER(ZEND_OPCO if (IS_TMP_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -13160,11 +13436,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -13180,6 +13478,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAN zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -13192,11 +13492,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_VAR_HANDLER(ZEND_OPCODE_HAN zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -13225,7 +13547,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_TMP_VAR_HANDLER(ZEND_OPCO if (IS_TMP_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -14943,11 +15265,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HANDL zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -14962,6 +15306,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HAND zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -14974,11 +15320,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_TMP_CV_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -15006,7 +15374,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_TMP_CV_HANDLER(ZEND_OPCOD if (IS_TMP_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_TMP_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_TMP_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -18392,11 +18760,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -18419,7 +18809,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HA zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -18443,7 +18833,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -18460,6 +18850,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -18472,11 +18864,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_H zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -18504,7 +18918,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_CONST_HANDLER(ZEND_OP if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -18530,7 +18944,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_CONST_HANDLER(ZEND_OPCOD if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -20684,11 +21098,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -20712,7 +21148,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAND zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -20736,7 +21172,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -20753,6 +21189,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -20765,11 +21203,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_HAN zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -20798,7 +21258,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_TMP_HANDLER(ZEND_OPCO if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -20824,7 +21284,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_TMP_HANDLER(ZEND_OPCODE_ if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -22814,11 +23274,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -22842,7 +23324,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAND zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -22866,7 +23348,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -22883,6 +23365,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -22895,11 +23379,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HAN zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -22928,7 +23434,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_VAR_HANDLER(ZEND_OPCO if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -22954,7 +23460,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_ if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -26204,11 +26710,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -26231,7 +26759,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDL zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -26255,7 +26783,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -26272,6 +26800,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC); @@ -26284,11 +26814,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op1.var); @@ -26316,7 +26868,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_VAR_CV_HANDLER(ZEND_OPCOD if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -26342,7 +26894,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_H if (IS_VAR == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_VAR, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); if (IS_VAR == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -27908,11 +28460,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -27935,7 +28509,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -27959,7 +28533,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCOD if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -27976,6 +28550,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCOD zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); @@ -27988,11 +28564,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCOD zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -28020,7 +28618,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_CONST_HANDLER(ZEND if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -28046,7 +28644,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_CONST_HANDLER(ZEND_OP if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -29270,11 +29868,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_H zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -29298,7 +29918,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_H zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -29322,7 +29942,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_ if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -29339,6 +29959,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_ zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); @@ -29351,11 +29973,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCODE_ zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -29384,7 +30028,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_TMP_HANDLER(ZEND_O if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -29410,7 +30054,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_TMP_HANDLER(ZEND_OPCO if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -30545,11 +31189,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_H zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -30573,7 +31239,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_H zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -30597,7 +31263,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_ if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -30614,6 +31280,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_ zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); @@ -30626,11 +31294,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCODE_ zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -30659,7 +31349,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_VAR_HANDLER(ZEND_O if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -30685,7 +31375,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_VAR_HANDLER(ZEND_OPCO if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -32307,11 +32997,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HA zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -32334,7 +33046,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_HA zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -32358,7 +33070,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_H if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -32375,6 +33087,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_H zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_obj_zval_ptr_unused(execute_data TSRMLS_CC); @@ -32387,11 +33101,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_UNUSED_CV_HANDLER(ZEND_OPCODE_H zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -32419,7 +33155,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_UNUSED_CV_HANDLER(ZEND_OP if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -32445,7 +33181,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_UNUSED_CV_HANDLER(ZEND_OPCOD if (IS_UNUSED == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_UNUSED, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); if (IS_UNUSED == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -35510,11 +36246,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAN zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -35537,7 +36295,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HAN zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -35561,7 +36319,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -35578,6 +36336,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); @@ -35590,11 +36350,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CONST_HANDLER(ZEND_OPCODE_HA zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CONST == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -35622,7 +36404,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_CONST_HANDLER(ZEND_OPC if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -35648,7 +36430,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_CONST_HANDLER(ZEND_OPCODE if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CONST, ((IS_CONST == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -37632,11 +38414,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -37660,7 +38464,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HANDL zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -37684,7 +38488,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -37701,6 +38505,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); @@ -37713,11 +38519,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_TMP_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -37746,7 +38574,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_TMP_HANDLER(ZEND_OPCOD if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -37772,7 +38600,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_TMP_HANDLER(ZEND_OPCODE_H if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_TMP_VAR, ((IS_TMP_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -39634,11 +40462,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -39662,7 +40512,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDL zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -39686,7 +40536,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -39703,6 +40553,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND zval *container; zend_free_op free_op2; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); @@ -39715,11 +40567,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HAND zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_VAR == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } zval_ptr_dtor_nogc(free_op2.var); @@ -39748,7 +40622,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_VAR_HANDLER(ZEND_OPCOD if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -39774,7 +40648,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_H if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_VAR, ((IS_VAR == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); zval_ptr_dtor_nogc(free_op2.var); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -42749,11 +43623,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLE zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_R, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -42776,7 +43672,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_W_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLE zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -42800,7 +43696,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_RW_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -42817,6 +43713,8 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL zval *container; zval *offset; + zval *retval; + zend_property_info *prop_info; SAVE_OPLINE(); container = _get_zval_ptr_cv_deref_BP_VAR_IS(execute_data, opline->op1.var TSRMLS_CC); @@ -42829,11 +43727,33 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_IS_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDL zval *retval; /* here we are sure we are dealing with an object */ - retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + do { + if (IS_CV == IS_CONST && + EXPECTED(Z_OBJCE_P(container) == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) { + zend_property_info *prop_info = CACHED_PTR(Z_CACHE_SLOT_P(offset) + 1); + zend_object *zobj = Z_OBJ_P(container); + + if (EXPECTED(prop_info)) { + retval = OBJ_PROP(zobj, prop_info->offset); + if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } else if (EXPECTED(zobj->properties != NULL)) { + retval = zend_hash_find(zobj->properties, Z_STR_P(offset)); + if (EXPECTED(retval)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + break; + } + } + } - if (retval != EX_VAR(opline->result.var)) { - ZVAL_COPY(EX_VAR(opline->result.var), retval); - } + retval = Z_OBJ_HT_P(container)->read_property(container, offset, BP_VAR_IS, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var) TSRMLS_CC); + + if (retval != EX_VAR(opline->result.var)) { + ZVAL_COPY(EX_VAR(opline->result.var), retval); + } + } while (0); } @@ -42861,7 +43781,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_FUNC_ARG_SPEC_CV_CV_HANDLER(ZEND_OPCODE if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); @@ -42887,7 +43807,7 @@ static int ZEND_FASTCALL ZEND_FETCH_OBJ_UNSET_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HA if (IS_CV == IS_VAR && UNEXPECTED(container == NULL)) { zend_error_noreturn(E_ERROR, "Cannot use string offset as an object"); } - zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); + zend_fetch_property_address(EX_VAR(opline->result.var), container, IS_CV, property, IS_CV, ((IS_CV == IS_CONST) ? (EX(run_time_cache) + Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET TSRMLS_CC); if (IS_CV == IS_VAR && READY_TO_DESTROY(free_op1.var)) { EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var)); diff --git a/ext/curl/tests/bug68089.phpt b/ext/curl/tests/bug68089.phpt index 3bd5889709..d65441b2cc 100644 --- a/ext/curl/tests/bug68089.phpt +++ b/ext/curl/tests/bug68089.phpt @@ -13,6 +13,6 @@ var_dump(curl_setopt($ch, CURLOPT_URL, $url)); ?> Done --EXPECTF-- -Warning: curl_setopt(): Curl option contains invalid characters (\0) in %s/bug68089.php on line 4 +Warning: curl_setopt(): Curl option contains invalid characters (\0) in %s%ebug68089.php on line 4 bool(false) Done diff --git a/ext/gd/config.w32 b/ext/gd/config.w32 index 2127fc5dce..da6d0d2ff5 100644 --- a/ext/gd/config.w32 +++ b/ext/gd/config.w32 @@ -83,6 +83,9 @@ if (PHP_GD != "no") { /D USE_GD_IOCTX \ /D MSWIN32 \ "); + if (ICC_TOOLSET) { + ADD_FLAG("LDFLAGS_GD", "/nodefaultlib:libcmt"); + } PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd" ); } else { diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index b5d446a54b..d79e42740d 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -875,12 +875,12 @@ static inline int do_validate_timestamps(zend_persistent_script *persistent_scri int validate_timestamp_and_record(zend_persistent_script *persistent_script, zend_file_handle *file_handle TSRMLS_DC) { if (ZCG(accel_directives).revalidate_freq && - (persistent_script->dynamic_members.revalidate >= ZCSG(revalidate_at))) { + persistent_script->dynamic_members.revalidate >= ZCG(request_time)) { return SUCCESS; } else if (do_validate_timestamps(persistent_script, file_handle TSRMLS_CC) == FAILURE) { return FAILURE; } else { - persistent_script->dynamic_members.revalidate = ZCSG(revalidate_at); + persistent_script->dynamic_members.revalidate = ZCG(request_time) + ZCG(accel_directives).revalidate_freq; return SUCCESS; } } @@ -1421,7 +1421,7 @@ static zend_persistent_script *compile_and_cache_file(zend_file_handle *file_han * otherwise we have a race-condition. */ new_persistent_script->timestamp = timestamp; - new_persistent_script->dynamic_members.revalidate = ZCSG(revalidate_at); + new_persistent_script->dynamic_members.revalidate = ZCG(request_time) + ZCG(accel_directives).revalidate_freq; } if (file_handle->opened_path) { @@ -1891,13 +1891,6 @@ static void accel_activate(void) zend_accel_error(ACCEL_LOG_WARNING, "Internal functions count changed - was %d, now %d", ZCG(internal_functions_count), zend_hash_num_elements(&ZCG(function_table))); } - if (ZCG(accel_directives).validate_timestamps) { - time_t now = ZCG(request_time); - if (now > ZCSG(revalidate_at) + (time_t)ZCG(accel_directives).revalidate_freq) { - ZCSG(revalidate_at) = now; - } - } - ZCG(cwd) = NULL; SHM_PROTECT(); @@ -2347,10 +2340,6 @@ static int accel_startup(zend_extension *extension) accelerator_orig_zend_resolve_path = zend_resolve_path; zend_resolve_path = persistent_zend_resolve_path; - if (ZCG(accel_directives).validate_timestamps) { - ZCSG(revalidate_at) = zend_accel_get_time() + ZCG(accel_directives).revalidate_freq; - } - /* Override chdir() function */ if ((func = zend_hash_str_find_ptr(CG(function_table), "chdir", sizeof("chdir")-1)) != NULL && func->type == ZEND_INTERNAL_FUNCTION) { diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index 28c3d21102..619ade025d 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -270,7 +270,6 @@ typedef struct _zend_accel_shared_globals { LONGLONG restart_in; #endif zend_bool restart_in_progress; - time_t revalidate_at; /* Interned Strings Support */ char *interned_strings_start; char *interned_strings_top; diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 918214edb1..6f9f2aebbf 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -668,7 +668,7 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec } else { offsets = (int *)safe_emalloc(size_offsets, sizeof(int), 0); } - + memset(offsets, 0, size_offsets*sizeof(int)); /* Allocate match sets array and initialize the values. */ if (global && subpats && subpats_order == PREG_PATTERN_ORDER) { match_sets = (zval *)safe_emalloc(num_subpats, sizeof(zval), 0); diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c index 9e8fc746fa..49fbc63745 100644 --- a/ext/pdo_pgsql/pgsql_statement.c +++ b/ext/pdo_pgsql/pgsql_statement.c @@ -376,15 +376,10 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data * /* We need to manually convert to a pg native boolean value */ if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_BOOL && ((param->param_type & PDO_PARAM_INPUT_OUTPUT) != PDO_PARAM_INPUT_OUTPUT)) { - zval *parameter; - if (Z_ISREF(param->parameter)) { - parameter = Z_REFVAL(param->parameter); - } else { - parameter = ¶m->parameter; - } SEPARATE_ZVAL(¶m->parameter); param->param_type = PDO_PARAM_STR; - ZVAL_STRINGL(parameter, Z_TYPE_P(parameter) == IS_TRUE ? "t" : "f", 1); + convert_to_boolean(¶m->parameter); + ZVAL_STRINGL(¶m->parameter, Z_TYPE_P(¶m->parameter) == IS_TRUE ? "t" : "f", 1); } } return 1; diff --git a/ext/pdo_pgsql/tests/bug62593.phpt b/ext/pdo_pgsql/tests/bug62593.phpt index e3ebf46ed5..4ab4566f00 100644 --- a/ext/pdo_pgsql/tests/bug62593.phpt +++ b/ext/pdo_pgsql/tests/bug62593.phpt @@ -34,6 +34,19 @@ $query->execute(); $errors[] = $query->errorInfo(); var_dump($value); +// Try with strings - Bug #68351 +$value = '0'; +$query->bindParam(':foo', $value, PDO::PARAM_BOOL); +$query->execute(); +$errors[] = $query->errorInfo(); +var_dump($query->fetchColumn()); + +$value = "abc"; +$query->bindParam(':foo', $value, PDO::PARAM_BOOL); +$query->execute(); +$errors[] = $query->errorInfo(); +var_dump($query->fetchColumn()); + $expect = 'No errors found'; foreach ($errors as $error) @@ -48,4 +61,6 @@ echo $expect; --EXPECTF-- bool(true) bool(false) +bool(true) +bool(false) No errors found diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 3d44c35b62..b972c2899c 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -3363,7 +3363,7 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value if (statics && (prop_info->flags & ZEND_ACC_STATIC) != 0) { prop = &ce->default_static_members_table[prop_info->offset]; } else if (!statics && (prop_info->flags & ZEND_ACC_STATIC) == 0) { - prop = &ce->default_properties_table[prop_info->offset]; + prop = &ce->default_properties_table[OBJ_PROP_TO_NUM(prop_info->offset)]; } } if (!prop) { diff --git a/ext/session/session.c b/ext/session/session.c index dae965b048..8d112c3a18 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -506,17 +506,8 @@ static void php_session_initialize(TSRMLS_D) /* {{{ */ PS(session_status) = php_session_active; } if (val) { - PHP_MD5_CTX context; - - /* Store read data's MD5 hash */ - PHP_MD5Init(&context); - PHP_MD5Update(&context, val->val, val->len); - PHP_MD5Final(PS(session_data_hash), &context); - php_session_decode(val->val, val->len TSRMLS_CC); zend_string_release(val); - } else { - memset(PS(session_data_hash),'\0', 16); } if (!PS(use_cookies) && PS(send_cookie)) { @@ -538,19 +529,7 @@ static void php_session_save_current_state(TSRMLS_D) /* {{{ */ val = php_session_encode(TSRMLS_C); if (val) { - PHP_MD5_CTX context; - unsigned char digest[16]; - - /* Generate data's MD5 hash */ - PHP_MD5Init(&context); - PHP_MD5Update(&context, val->val, val->len); - PHP_MD5Final(digest, &context); - /* Write only when save is required */ - if (memcmp(digest, PS(session_data_hash), 16)) { - ret = PS(mod)->s_write(&PS(mod_data), PS(id), val TSRMLS_CC); - } else { - ret = SUCCESS; - } + ret = PS(mod)->s_write(&PS(mod_data), PS(id), val TSRMLS_CC); zend_string_release(val); } else { ret = PS(mod)->s_write(&PS(mod_data), PS(id), STR_EMPTY_ALLOC() TSRMLS_CC); @@ -1971,7 +1950,6 @@ static PHP_FUNCTION(session_regenerate_id) RETURN_FALSE; } zend_string_release(PS(id)); - memset(PS(session_data_hash),'\0', 16); } PS(id) = PS(mod)->s_create_sid(&PS(mod_data) TSRMLS_CC); diff --git a/ext/session/tests/session_set_save_handler_iface_003.phpt b/ext/session/tests/session_set_save_handler_iface_003.phpt index bd757dce63..4d7ed3b7ee 100644 --- a/ext/session/tests/session_set_save_handler_iface_003.phpt +++ b/ext/session/tests/session_set_save_handler_iface_003.phpt @@ -38,7 +38,8 @@ class MySession2 implements SessionHandlerInterface, SessionIdInterface { } public function write($id, $data) { - return file_put_contents($this->path . $id, $data); + // Empty $data = 0 = false + return (bool)file_put_contents($this->path . $id, $data); } public function destroy($id) { diff --git a/ext/session/tests/session_set_save_handler_sid_001.phpt b/ext/session/tests/session_set_save_handler_sid_001.phpt index 0dc4fc11cf..24ba5d7489 100644 --- a/ext/session/tests/session_set_save_handler_sid_001.phpt +++ b/ext/session/tests/session_set_save_handler_sid_001.phpt @@ -32,7 +32,8 @@ class MySession2 { } public function write($id, $data) { - return file_put_contents($this->path . $id, $data); + // Empty $data = 0 = false + return (bool)file_put_contents($this->path . $id, $data); } public function destroy($id) { diff --git a/ext/session/tests/session_set_save_handler_write_short_circuit.phpt b/ext/session/tests/session_set_save_handler_write_short_circuit.phpt index 02ca182ec6..08da29a8fd 100644 --- a/ext/session/tests/session_set_save_handler_write_short_circuit.phpt +++ b/ext/session/tests/session_set_save_handler_write_short_circuit.phpt @@ -5,6 +5,7 @@ session.save_path= session.name=PHPSESSID --SKIPIF-- <?php include('skipif.inc'); ?> +skip - Waiting RFC patch merge --FILE-- <?php diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index ee0e025c5d..5adc9a9a11 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -34,6 +34,10 @@ #include "url_scanner_ex.h" +#if defined(_WIN32) && defined(__clang__) +#include <intrin.h> +#endif + extern zend_module_entry basic_functions_module; #define basic_functions_module_ptr &basic_functions_module diff --git a/ext/standard/file.c b/ext/standard/file.c index ff7c5433eb..4804e49338 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -339,16 +339,16 @@ static int flock_values[] = { LOCK_SH, LOCK_EX, LOCK_UN }; Portable file locking */ PHP_FUNCTION(flock) { - zval *arg1, *arg3 = NULL; + zval *res, *wouldblock = NULL; int act; php_stream *stream; zend_long operation = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z/", &arg1, &operation, &arg3) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z/", &res, &operation, &wouldblock) == FAILURE) { return; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, res); act = operation & 3; if (act < 1 || act > 3) { @@ -356,16 +356,16 @@ PHP_FUNCTION(flock) RETURN_FALSE; } - if (arg3) { - zval_dtor(arg3); - ZVAL_LONG(arg3, 0); + if (wouldblock) { + zval_dtor(wouldblock); + ZVAL_LONG(wouldblock, 0); } /* flock_values contains all possible actions if (operation & 4) we won't block on the lock */ act = flock_values[act - 1] | (operation & PHP_LOCK_NB ? LOCK_NB : 0); if (php_stream_lock(stream, act)) { - if (operation && errno == EWOULDBLOCK && arg3) { - ZVAL_LONG(arg3, 1); + if (operation && errno == EWOULDBLOCK && wouldblock) { + ZVAL_LONG(wouldblock, 1); } RETURN_FALSE; } @@ -887,20 +887,20 @@ PHP_NAMED_FUNCTION(php_if_fopen) Close an open file pointer */ PHPAPI PHP_FUNCTION(fclose) { - zval *arg1; + zval *res; php_stream *stream; #ifndef FAST_ZPP - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } #else ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_RESOURCE(arg1) + Z_PARAM_RESOURCE(res) ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE); #endif - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, res); if ((stream->flags & PHP_STREAM_FLAG_NO_FCLOSE) != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%pd is not a valid stream resource", stream->res->handle); @@ -965,14 +965,14 @@ PHP_FUNCTION(popen) Close a file pointer opened by popen() */ PHP_FUNCTION(pclose) { - zval *arg1; + zval *res; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, res); FG(pclose_wait) = 1; zend_list_close(stream->res); @@ -985,14 +985,14 @@ PHP_FUNCTION(pclose) Test for end-of-file on a file pointer */ PHPAPI PHP_FUNCTION(feof) { - zval *arg1; + zval *res; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, res); if (php_stream_eof(stream)) { RETURN_TRUE; @@ -1006,18 +1006,18 @@ PHPAPI PHP_FUNCTION(feof) Get a line from file pointer */ PHPAPI PHP_FUNCTION(fgets) { - zval *arg1; + zval *res; zend_long len = 1024; char *buf = NULL; int argc = ZEND_NUM_ARGS(); size_t line_len = 0; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &arg1, &len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &res, &len) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, res); if (argc == 1) { /* ask streams to give us a buffer of an appropriate size */ @@ -1062,16 +1062,16 @@ exit_failed: Get a character from file pointer */ PHPAPI PHP_FUNCTION(fgetc) { - zval *arg1; + zval *res; char buf[2]; int result; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, res); result = php_stream_getc(stream); @@ -1193,39 +1193,33 @@ PHP_FUNCTION(fscanf) Binary-safe file write */ PHPAPI PHP_FUNCTION(fwrite) { - zval *arg1; - char *arg2; - size_t arg2len; + zval *res; + char *input; + size_t inputlen; size_t ret; size_t num_bytes; - zend_long arg3 = 0; - char *buffer = NULL; + zend_long maxlen = 0; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &arg1, &arg2, &arg2len, &arg3) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &res, &input, &inputlen, &maxlen) == FAILURE) { RETURN_FALSE; } if (ZEND_NUM_ARGS() == 2) { - num_bytes = arg2len; + num_bytes = inputlen; + } else if (maxlen <= 0) { + num_bytes = 0; } else { - if (arg3 > 0) { - num_bytes = MIN((size_t)arg3, arg2len); - } else { - num_bytes = 0; - } + num_bytes = MIN((size_t) maxlen, inputlen); } if (!num_bytes) { RETURN_LONG(0); } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, res); - ret = php_stream_write(stream, buffer ? buffer : arg2, num_bytes); - if (buffer) { - efree(buffer); - } + ret = php_stream_write(stream, input, num_bytes); RETURN_LONG(ret); } @@ -1235,15 +1229,15 @@ PHPAPI PHP_FUNCTION(fwrite) Flushes output */ PHPAPI PHP_FUNCTION(fflush) { - zval *arg1; + zval *res; int ret; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, res); ret = php_stream_flush(stream); if (ret) { @@ -1257,14 +1251,14 @@ PHPAPI PHP_FUNCTION(fflush) Rewind the position of a file pointer */ PHPAPI PHP_FUNCTION(rewind) { - zval *arg1; + zval *res; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, res); if (-1 == php_stream_rewind(stream)) { RETURN_FALSE; @@ -1277,15 +1271,15 @@ PHPAPI PHP_FUNCTION(rewind) Get file pointer's read/write position */ PHPAPI PHP_FUNCTION(ftell) { - zval *arg1; + zval *res; zend_long ret; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, res); ret = php_stream_tell(stream); if (ret == -1) { @@ -1299,17 +1293,17 @@ PHPAPI PHP_FUNCTION(ftell) Seek on a file pointer */ PHPAPI PHP_FUNCTION(fseek) { - zval *arg1; - zend_long arg2, whence = SEEK_SET; + zval *res; + zend_long offset, whence = SEEK_SET; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &arg1, &arg2, &whence) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &res, &offset, &whence) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, res); - RETURN_LONG(php_stream_seek(stream, arg2, (int)whence)); + RETURN_LONG(php_stream_seek(stream, offset, (int) whence)); } /* }}} */ @@ -1411,7 +1405,7 @@ PHP_FUNCTION(readfile) Return or change the umask */ PHP_FUNCTION(umask) { - zend_long arg1 = 0; + zend_long mask = 0; int oldumask; oldumask = umask(077); @@ -1420,14 +1414,14 @@ PHP_FUNCTION(umask) BG(umask) = oldumask; } - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &mask) == FAILURE) { RETURN_FALSE; } if (ZEND_NUM_ARGS() == 0) { umask(oldumask); } else { - umask((int)arg1); + umask((int) mask); } RETURN_LONG(oldumask); @@ -1438,15 +1432,15 @@ PHP_FUNCTION(umask) Output all remaining data from a file pointer */ PHPAPI PHP_FUNCTION(fpassthru) { - zval *arg1; + zval *res; size_t size; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &res) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, res); size = php_stream_passthru(stream); RETURN_LONG(size); @@ -1780,15 +1774,15 @@ safe_to_copy: Binary-safe file read */ PHPAPI PHP_FUNCTION(fread) { - zval *arg1; + zval *res; zend_long len; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &res, &len) == FAILURE) { RETURN_FALSE; } - PHP_STREAM_TO_ZVAL(stream, arg1); + PHP_STREAM_TO_ZVAL(stream, res); if (len <= 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than 0"); diff --git a/main/win95nt.h b/main/win95nt.h index 76bec05ea5..febffecadf 100644 --- a/main/win95nt.h +++ b/main/win95nt.h @@ -55,7 +55,7 @@ typedef char * caddr_t; typedef unsigned int uint; typedef unsigned long ulong; #if !NSAPI -typedef long pid_t; +typedef int pid_t; #endif /* missing in vc5 math.h */ diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index 13439460ae..a9f27fcea1 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -478,8 +478,8 @@ static int init_request_info( TSRMLS_D ) SG(request_info).content_length = LSAPI_GetReqBodyLen(); SG(request_info).path_translated = estrdup( LSAPI_GetScriptFileName()); - /* It is not reset by zend engine, set it to 0. */ - SG(sapi_headers).http_response_code = 0; + /* It is not reset by zend engine, set it to 200. */ + SG(sapi_headers).http_response_code = 200; pAuth = LSAPI_GetHeader( H_AUTHORIZATION ); php_handle_auth_data(pAuth TSRMLS_CC); diff --git a/win32/build/Makefile b/win32/build/Makefile index b2918b7117..90f02d2494 100644 --- a/win32/build/Makefile +++ b/win32/build/Makefile @@ -89,7 +89,8 @@ $(PHPDLL_RES): win32\build\template.rc win32\build\template.rc $(BUILD_DIR)\$(PHPDLL): generated_files $(PHPDEF) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(PHPDLL_RES) $(MCFILE) - @$(CC) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /link /out:$(BUILD_DIR)\$(PHPDLL) $(PHP7_PGD_OPTION) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS) +# @$(CC) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /link /out:$(BUILD_DIR)\$(PHPDLL) $(PHP7_PGD_OPTION) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS) + @"$(LINK)" $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(STATIC_EXT_LIBS) $(LIBS) $(PHPDLL_RES) /out:$(BUILD_DIR)\$(PHPDLL) $(PHP7_PGD_OPTION) $(PHP_LDFLAGS) $(LDFLAGS) $(STATIC_EXT_LDFLAGS) -@$(_VC_MANIFEST_EMBED_DLL) $(BUILD_DIR)\$(PHPLIB): $(BUILD_DIR)\$(PHPDLL) diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 358ff4e0ce..7187eacca1 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -3,33 +3,15 @@ // "Master" config file; think of it as a configure.in // equivalent. -ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin'); -PHP_CL = PATH_PROG('cl', null, 'PHP_CL'); -if (!PHP_CL) { - ERROR("MS C++ compiler is required"); -} +ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, icc", "vs"); +toolset_option_handle(); -/* For the record here: */ -// 1200 is VC6 -// 1300 is vs.net 2002 -// 1310 is vs.net 2003 -// 1400 is vs.net 2005 -// 1500 is vs.net 2008 -// 1600 is vs.net 2010 -// Which version of the compiler do we have? -VCVERS = probe_binary(PHP_CL).substr(0, 5).replace('.', ''); -STDOUT.WriteLine(" Detected compiler " + VC_VERSIONS[VCVERS]); - -if (VCVERS < 1500) { - ERROR("Unsupported MS C++ Compiler, VC9 (2008) minimum is required"); -} +ARG_WITH('cygwin', 'Path to cygwin utilities on your system', '\\cygwin'); -AC_DEFINE('COMPILER', VC_VERSIONS[VCVERS], "Detected compiler version"); -DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]); -AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID"); +toolset_setup_compiler(); // do we use x64 or 80x86 version of compiler? -X64 = probe_binary(PHP_CL, 64, null, 'PHP_CL'); +X64 = toolset_is_64(); if (X64) { STDOUT.WriteLine(" Detected 64-bit compiler"); } else { @@ -38,52 +20,8 @@ if (X64) { AC_DEFINE('ARCHITECTURE', X64 ? 'x64' : 'x86', "Detected compiler architecture"); DEFINE("PHP_ARCHITECTURE", X64 ? 'x64' : 'x86'); -// cygwin now ships with link.exe. Avoid searching the cygwin path -// for this, as we want the MS linker, not the fileutil -PATH_PROG('link', WshShell.Environment("Process").Item("PATH")); -PATH_PROG('nmake'); - -// we don't want to define LIB, as that will override the default library path -// that is set in that env var -PATH_PROG('lib', null, 'MAKE_LIB'); -if (!PATH_PROG('bison')) { - ERROR('bison is required') -} - -// There's a minimum requirement for re2c.. -MINRE2C = "0.13.4"; - -RE2C = PATH_PROG('re2c'); -if (RE2C) { - var intvers, intmin; - var pattern = /\./g; - - RE2CVERS = probe_binary(RE2C, "version"); - STDOUT.WriteLine(' Detected re2c version ' + RE2CVERS); - - intvers = RE2CVERS.replace(pattern, '') - 0; - intmin = MINRE2C.replace(pattern, '') - 0; - - if (intvers < intmin) { - STDOUT.WriteLine('WARNING: The minimum RE2C version requirement is ' + MINRE2C); - STDOUT.WriteLine('Parsers will not be generated. Upgrade your copy at http://sf.net/projects/re2c'); - DEFINE('RE2C', ''); - } else { - DEFINE('RE2C_FLAGS', ''); - } -} else { - STDOUT.WriteLine('Parsers will not be regenerated'); -} -PATH_PROG('zip'); -PATH_PROG('lemon'); - -// avoid picking up midnight commander from cygwin -PATH_PROG('mc', WshShell.Environment("Process").Item("PATH")); - -// Try locating manifest tool -if (VCVERS > 1200) { - PATH_PROG('mt', WshShell.Environment("Process").Item("PATH")); -} +toolset_setup_linker(); +toolset_setup_project_tools(); // stick objects somewhere outside of the source tree ARG_ENABLE('object-out-dir', 'Alternate location for binary objects during build', ''); @@ -130,45 +68,11 @@ DEFINE('PHP_PREFIX', PHP_PREFIX); DEFINE("BASE_INCLUDES", "/I . /I main /I Zend /I TSRM /I ext "); -// CFLAGS for building the PHP dll -DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \ -/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=0x500"); - -DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)'); - -// General CFLAGS for building objects -DEFINE("CFLAGS", "/nologo /FD $(BASE_INCLUDES) /D _WINDOWS \ -/D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 "); - -if (VCVERS < 1400) { - // Enable automatic precompiled headers - ADD_FLAG('CFLAGS', ' /YX '); - - if (PHP_DEBUG == "yes") { - // Set some debug/release specific options - ADD_FLAG('CFLAGS', ' /GZ '); - } -} - -if (VCVERS >= 1400) { - // fun stuff: MS deprecated ANSI stdio and similar functions - // disable annoying warnings. In addition, time_t defaults - // to 64-bit. Ask for 32-bit. - if (X64) { - ADD_FLAG('CFLAGS', ' /wd4996 '); - } else { - ADD_FLAG('CFLAGS', ' /wd4996 /D_USE_32BIT_TIME_T=1 '); - } - - if (PHP_DEBUG == "yes") { - // Set some debug/release specific options - ADD_FLAG('CFLAGS', ' /RTC1 '); - } -} +toolset_setup_common_cflags(); ARG_WITH('mp', 'Tell Visual Studio use up to [n,auto,disable] processes for compilation', 'auto'); var PHP_MP_DISABLED = true; -if (VCVERS >= 1500 && PHP_MP != 'disable') { +if (VS_TOOLSET && VCVERS >= 1500 && PHP_MP != 'disable') { // no from disable-all if(PHP_MP == 'auto' || PHP_MP == 'no') { ADD_FLAG('CFLAGS', ' /MP '); @@ -184,19 +88,7 @@ if (VCVERS >= 1500 && PHP_MP != 'disable') { } // General link flags - -if (VCVERS >= 1700) { - DEFINE("LDFLAGS", "/nologo "); -} else { - DEFINE("LDFLAGS", "/nologo /version:" + - PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION); -} - -// General DLL link flags -DEFINE("DLL_LDFLAGS", "/dll "); - -// PHP DLL link flags -DEFINE("PHP_LDFLAGS", "$(DLL_LDFLAGS)"); +toolset_setup_common_ldlags(); // General libs // urlmon.lib ole32.lib oleaut32.lib uuid.lib gdi32.lib winspool.lib comdlg32.lib @@ -334,7 +226,7 @@ function add_extra_dirs() for (i = 0; i < path.length; i++) { f = FSO.GetAbsolutePathName(path[i]); if (FSO.FolderExists(f)) { - if (VCVERS <= 1200 && f.indexOf(" ") >= 0) { + if (VS_TOOLSET && VCVERS <= 1200 && f.indexOf(" ") >= 0) { ADD_FLAG("LDFLAGS", '/libpath:"\\"' + f + '\\"" '); } else { ADD_FLAG("LDFLAGS", '/libpath:"' + f + '" '); @@ -368,7 +260,8 @@ ADD_SOURCES("Zend", "zend_language_parser.c zend_language_scanner.c \ zend_float.c zend_string.c zend_generators.c zend_virtual_cwd.c zend_ast.c \ zend_inheritance.c"); -if (VCVERS == 1200) { +/* XXX inspect this for other toolsets */ +if (VS_TOOLSET && VCVERS == 1200) { AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1); } @@ -379,10 +272,10 @@ ADD_SOURCES("main", "main.c snprintf.c spprintf.c getopt.c fopen_wrappers.c \ ADD_SOURCES("win32", "inet.c fnmatch.c sockets.c"); // Newer versions have it -if (VCVERS <= 1300) { +if (VS_TOOLSET && VCVERS <= 1300) { ADD_SOURCES("win32", "strtoi64.c"); } -if (VCVERS >= 1400) { +if (VS_TOOLSET && VCVERS >= 1400 || ICC_TOOLSET) { AC_DEFINE('HAVE_STRNLEN', 1); } diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index 9b28352c8f..5a7f31d5d4 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -3,32 +3,15 @@ // "Master" config file; think of it as a configure.in
// equivalent.
+ARG_WITH("toolset", "Toolset to use for the compilation, supported: vs, clang, icc", "vs");
+toolset_option_handle()
+
var PHP_CYGWIN="notset";
-PHP_CL = PATH_PROG('cl', null, 'PHP_CL');
-if (!PHP_CL) {
- ERROR("MS C++ compiler is required");
-}
-/* For the record here: */
-// 1200 is VC6
-// 1300 is vs.net 2002
-// 1310 is vs.net 2003
-// 1400 is vs.net 2005
-// 1500 is vs.net 2008
-// 1600 is vs.net 2010
-// Which version of the compiler do we have?
-VCVERS = probe_binary(PHP_CL).substr(0, 5).replace('.', '');
-STDOUT.WriteLine(" Detected compiler " + VC_VERSIONS[VCVERS]);
-
-if (VCVERS < 1500) {
- ERROR("Unsupported MS C++ Compiler, VC9 (2008) minimum is required");
-}
-AC_DEFINE('COMPILER', VC_VERSIONS[VCVERS], "Detected compiler version");
-DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]);
-AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID");
+toolset_setup_compiler();
// do we use x64 or 80x86 version of compiler?
-X64 = probe_binary(PHP_CL, 64, null, 'PHP_CL');
+X64 = toolset_is_64();
if (X64) {
STDOUT.WriteLine(" Detected 64-bit compiler");
} else {
@@ -37,52 +20,8 @@ if (X64) { AC_DEFINE('ARCHITECTURE', X64 ? 'x64' : 'x86', "Detected compiler architecture");
DEFINE("PHP_ARCHITECTURE", X64 ? 'x64' : 'x86');
-// cygwin now ships with link.exe. Avoid searching the cygwin path
-// for this, as we want the MS linker, not the fileutil
-PATH_PROG('link', WshShell.Environment("Process").Item("PATH"));
-PATH_PROG('nmake');
-
-// we don't want to define LIB, as that will override the default library path
-// that is set in that env var
-PATH_PROG('lib', null, 'MAKE_LIB');
-if (!PATH_PROG('bison')) {
- ERROR('bison is required')
-}
-
-// There's a minimum requirement for re2c..
-MINRE2C = "0.13.4";
-
-RE2C = PATH_PROG('re2c');
-if (RE2C) {
- var intvers, intmin;
- var pattern = /\./g;
-
- RE2CVERS = probe_binary(RE2C, "version");
- STDOUT.WriteLine(' Detected re2c version ' + RE2CVERS);
-
- intvers = RE2CVERS.replace(pattern, '') - 0;
- intmin = MINRE2C.replace(pattern, '') - 0;
-
- if (intvers < intmin) {
- STDOUT.WriteLine('WARNING: The minimum RE2C version requirement is ' + MINRE2C);
- STDOUT.WriteLine('Parsers will not be generated. Upgrade your copy at http://sf.net/projects/re2c');
- DEFINE('RE2C', '');
- } else {
- DEFINE('RE2C_FLAGS', '');
- }
-} else {
- STDOUT.WriteLine('Parsers will not be regenerated');
-}
-PATH_PROG('zip');
-PATH_PROG('lemon');
-
-// avoid picking up midnight commander from cygwin
-PATH_PROG('mc', WshShell.Environment("Process").Item("PATH"));
-
-// Try locating manifest tool
-if (VCVERS > 1200) {
- PATH_PROG('mt', WshShell.Environment("Process").Item("PATH"));
-}
+toolset_setup_linker();
+toolset_setup_project_tools();
// stick objects somewhere outside of the source tree
ARG_ENABLE('object-out-dir', 'Alternate location for binary objects during build', '');
@@ -114,46 +53,12 @@ DEFINE('PHP_PREFIX', PHP_PREFIX); DEFINE("BASE_INCLUDES", "/I " + PHP_DIR + "/include /I " + PHP_DIR + "/include/main /I " + PHP_DIR + "/include/Zend /I " + PHP_DIR + "/include/TSRM /I " + PHP_DIR + "/include/ext ");
-// CFLAGS for building the PHP dll
-DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \
-/D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=0x500");
-
-DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)');
-
-// General CFLAGS for building objects
-DEFINE("CFLAGS", "/nologo /FD $(BASE_INCLUDES) /D _WINDOWS \
-/D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 ");
-
-if (VCVERS < 1400) {
- // Enable automatic precompiled headers
- ADD_FLAG('CFLAGS', ' /YX ');
-
- if (PHP_DEBUG == "yes") {
- // Set some debug/release specific options
- ADD_FLAG('CFLAGS', ' /GZ ');
- }
-}
-
-if (VCVERS >= 1400) {
- // fun stuff: MS deprecated ANSI stdio and similar functions
- // disable annoying warnings. In addition, time_t defaults
- // to 64-bit. Ask for 32-bit.
- if (X64) {
- ADD_FLAG('CFLAGS', ' /wd4996 ');
- } else {
- ADD_FLAG('CFLAGS', ' /wd4996 /D_USE_32BIT_TIME_T=1 ');
- }
-
- if (PHP_DEBUG == "yes") {
- // Set some debug/release specific options
- ADD_FLAG('CFLAGS', ' /RTC1 ');
- }
-}
+toolset_setup_common_cflags();
ARG_WITH('prefix', 'PHP installation prefix', '');
ARG_WITH('mp', 'Tell Visual Studio use up to [n,auto,disable] processes for compilation', 'auto');
var PHP_MP_DISABLED = true;
-if (VCVERS >= 1500 && PHP_MP != 'disable') {
+if (VS_TOOLSET && VCVERS >= 1500 && PHP_MP != 'disable') {
// no from disable-all
if(PHP_MP == 'auto' || PHP_MP == 'no') {
ADD_FLAG('CFLAGS', ' /MP ');
@@ -172,11 +77,8 @@ if (VCVERS >= 1500 && PHP_MP != 'disable') { * files that make up the snapshot template? */
ARG_WITH("snapshot-template", "Path to snapshot builder template dir", "no");
-// General DLL link flags
-DEFINE("DLL_LDFLAGS", "/dll ");
-
-// PHP DLL link flags
-DEFINE("PHP_LDFLAGS", "$(DLL_LDFLAGS)");
+// General link flags
+toolset_setup_common_ldlags();
// General libs
// urlmon.lib ole32.lib oleaut32.lib uuid.lib gdi32.lib winspool.lib comdlg32.lib
@@ -334,11 +236,12 @@ STDOUT.WriteLine("Build dir: " + get_define('BUILD_DIR')); STDOUT.WriteLine("PHP Core: " + get_define('PHPDLL') + " and " + get_define('PHPLIB'));
-if (VCVERS == 1200) {
+/* XXX inspect this for other toolsets */
+if (VS_TOOLSET && VCVERS == 1200) {
AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1);
}
-if (VCVERS >= 1400) {
+if (ICC_TOOLSET || VS_TOOLSET && VCVERS >= 1400) {
AC_DEFINE('HAVE_STRNLEN', 1);
}
diff --git a/win32/build/confutils.js b/win32/build/confutils.js index a394c52ad9..0f07e18120 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -1,2278 +1,2587 @@ -// Utils for configure script
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Wez Furlong <wez@thebrainroom.com> |
- +----------------------------------------------------------------------+
-*/
-
-// $Id: confutils.js,v 1.60.2.1.2.8.2.33 2009-05-29 07:43:07 kalle Exp $
-
-var STDOUT = WScript.StdOut;
-var STDERR = WScript.StdErr;
-var WshShell = WScript.CreateObject("WScript.Shell");
-var FSO = WScript.CreateObject("Scripting.FileSystemObject");
-var MFO = null;
-var SYSTEM_DRIVE = WshShell.Environment("Process").Item("SystemDrive");
-var PROGRAM_FILES = WshShell.Environment("Process").Item("ProgramFiles");
-var PROGRAM_FILESx86 = WshShell.Environment("Process").Item("ProgramFiles(x86)");
-var VCINSTALLDIR = WshShell.Environment("Process").Item("VCINSTALLDIR");
-var PHP_SRC_DIR=FSO.GetParentFolderName(WScript.ScriptFullName);
-
-/* Store the enabled extensions (summary + QA check) */
-var extensions_enabled = new Array();
-
-/* Store the SAPI enabled (summary + QA check) */
-var sapi_enabled = new Array();
-
-/* Store the headers to install */
-var headers_install = new Array();
-
-/* Mapping CL version > human readable name */
-var VC_VERSIONS = new Array();
-VC_VERSIONS[1200] = 'MSVC6 (Visual C++ 6.0)';
-VC_VERSIONS[1300] = 'MSVC7 (Visual C++ 2002)';
-VC_VERSIONS[1310] = 'MSVC7.1 (Visual C++ 2003)';
-VC_VERSIONS[1400] = 'MSVC8 (Visual C++ 2005)';
-VC_VERSIONS[1500] = 'MSVC9 (Visual C++ 2008)';
-VC_VERSIONS[1600] = 'MSVC10 (Visual C++ 2010)';
-VC_VERSIONS[1700] = 'MSVC11 (Visual C++ 2012)';
-VC_VERSIONS[1800] = 'MSVC12 (Visual C++ 2013)';
-
-var VC_VERSIONS_SHORT = new Array();
-VC_VERSIONS_SHORT[1200] = 'VC6';
-VC_VERSIONS_SHORT[1300] = 'VC7';
-VC_VERSIONS_SHORT[1310] = 'VC7.1';
-VC_VERSIONS_SHORT[1400] = 'VC8';
-VC_VERSIONS_SHORT[1500] = 'VC9';
-VC_VERSIONS_SHORT[1600] = 'VC10';
-VC_VERSIONS_SHORT[1700] = 'VC11';
-VC_VERSIONS_SHORT[1800] = 'VC12';
-
-if (PROGRAM_FILES == null) {
- PROGRAM_FILES = "C:\\Program Files";
-}
-
-if (MODE_PHPIZE) {
- if (!FSO.FileExists("config.w32")) {
- STDERR.WriteLine("Must be run from the root of the extension source");
- WScript.Quit(10);
- }
-} else {
- if (!FSO.FileExists("README.GIT-RULES")) {
- STDERR.WriteLine("Must be run from the root of the php source");
- WScript.Quit(10);
- }
-}
-
-var CWD = WshShell.CurrentDirectory;
-
-if (typeof(CWD) == "undefined") {
- CWD = FSO.GetParentFolderName(FSO.GetAbsolutePathName("README.GIT-RULES"));
-}
-
-/* defaults; we pick up the precise versions from configure.in */
-var PHP_VERSION = 5;
-var PHP_MINOR_VERSION = 0;
-var PHP_RELEASE_VERSION = 0;
-var PHP_EXTRA_VERSION = "";
-var PHP_VERSION_STRING = "5.0.0";
-
-function get_version_numbers()
-{
- var cin = file_get_contents("configure.in");
-
- if (cin.match(new RegExp("PHP_MAJOR_VERSION=(\\d+)"))) {
- PHP_VERSION = RegExp.$1;
- }
- if (cin.match(new RegExp("PHP_MINOR_VERSION=(\\d+)"))) {
- PHP_MINOR_VERSION = RegExp.$1;
- }
- if (cin.match(new RegExp("PHP_RELEASE_VERSION=(\\d+)"))) {
- PHP_RELEASE_VERSION = RegExp.$1;
- }
- PHP_VERSION_STRING = PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION;
-
- if (cin.match(new RegExp("PHP_EXTRA_VERSION=\"([^\"]+)\""))) {
- PHP_EXTRA_VERSION = RegExp.$1;
- if (PHP_EXTRA_VERSION.length) {
- PHP_VERSION_STRING += PHP_EXTRA_VERSION;
- }
- }
- DEFINE('PHP_VERSION_STRING', PHP_VERSION_STRING);
-}
-
-configure_args = new Array();
-configure_subst = WScript.CreateObject("Scripting.Dictionary");
-
-configure_hdr = WScript.CreateObject("Scripting.Dictionary");
-build_dirs = new Array();
-
-extension_include_code = "";
-extension_module_ptrs = "";
-
-if (!MODE_PHPIZE) {
- get_version_numbers();
-}
-
-/* execute a command and return the output as a string */
-function execute(command_line)
-{
- var e = WshShell.Exec(command_line);
- var ret = "";
-
- ret = e.StdOut.ReadAll();
-
-//STDOUT.WriteLine("command " + command_line);
-//STDOUT.WriteLine(ret);
-
- return ret;
-}
-
-function probe_binary(EXE, what)
-{
- // tricky escapes to get stderr redirection to work
- var command = 'cmd /c ""' + EXE;
- if (what == "version") {
- command = command + '" -v"';
- }
- var version = execute(command + '" 2>&1"');
-
- if (what == "64") {
- if (version.match(/x64/)) {
- return 1;
- }
- } else {
- if (version.match(/(\d+\.\d+(\.\d+)?(\.\d+)?)/)) {
- return RegExp.$1;
- }
- }
- return 0;
-}
-
-function condense_path(path)
-{
- path = FSO.GetAbsolutePathName(path);
-
- if (path.substr(0, CWD.length).toLowerCase()
- == CWD.toLowerCase() &&
- (path.charCodeAt(CWD.length) == 92 || path.charCodeAt(CWD.length) == 47)) {
- return path.substr(CWD.length + 1);
- }
-
- var a = CWD.split("\\");
- var b = path.split("\\");
- var i, j;
-
- for (i = 0; i < b.length; i++) {
- if (a[i].toLowerCase() == b[i].toLowerCase())
- continue;
- if (i > 0) {
- /* first difference found */
- path = "";
- for (j = 0; j < a.length - i; j++) {
- path += "..\\";
- }
- for (j = i; j < b.length; j++) {
- path += b[j];
- if (j < b.length - 1)
- path += "\\";
- }
- return path;
- }
- /* on a different drive */
- break;
- }
-
- return path;
-}
-
-function ConfigureArg(type, optname, helptext, defval)
-{
- var opptype = type == "enable" ? "disable" : "without";
-
- if (defval == "yes" || defval == "yes,shared") {
- this.arg = "--" + opptype + "-" + optname;
- this.imparg = "--" + type + "-" + optname;
- } else {
- this.arg = "--" + type + "-" + optname;
- this.imparg = "--" + opptype + "-" + optname;
- }
-
- this.optname = optname;
- this.helptext = helptext;
- this.defval = defval;
- this.symval = optname.toUpperCase().replace(new RegExp("-", "g"), "_");
- this.seen = false;
- this.argval = defval;
-}
-
-function ARG_WITH(optname, helptext, defval)
-{
- configure_args[configure_args.length] = new ConfigureArg("with", optname, helptext, defval);
-}
-
-function ARG_ENABLE(optname, helptext, defval)
-{
- configure_args[configure_args.length] = new ConfigureArg("enable", optname, helptext, defval);
-}
-
-function analyze_arg(argval)
-{
- var ret = new Array();
- var shared = false;
-
- if (argval == "shared") {
- shared = true;
- argval = "yes";
- } else if (argval == null) {
- /* nothing */
- } else if (arg_match = argval.match(new RegExp("^shared,(.*)"))) {
- shared = true;
- argval = arg_match[1];
- } else if (arg_match = argval.match(new RegExp("^(.*),shared$"))) {
- shared = true;
- argval = arg_match[1];
- }
-
- ret[0] = shared;
- ret[1] = argval;
- return ret;
-}
-
-function word_wrap_and_indent(indent, text, line_suffix, indent_char)
-{
- if (text == null) {
- return "";
- }
-
- var words = text.split(new RegExp("\\s+", "g"));
- var i = 0;
- var ret_text = "";
- var this_line = "";
- var t;
- var space = "";
- var lines = 0;
-
- if (line_suffix == null) {
- line_suffix = "";
- }
-
- if (indent_char == null) {
- indent_char = " ";
- }
-
- for (i = 0; i < indent; i++) {
- space += indent_char;
- }
-
- for (i = 0; i < words.length; i++) {
- if (this_line.length) {
- t = this_line + " " + words[i];
- } else {
- t = words[i];
- }
-
- if (t.length + indent > 78) {
- if (lines++) {
- ret_text += space;
- }
- ret_text += this_line + line_suffix + "\r\n";
- this_line = "";
- }
-
- if (this_line.length) {
- this_line += " " + words[i];
- } else {
- this_line = words[i];
- }
- }
-
- if (this_line.length) {
- if (lines)
- ret_text += space;
- ret_text += this_line;
- }
-
- return ret_text;
-}
-
-function conf_process_args()
-{
- var i, j;
- var configure_help_mode = false;
- var analyzed = false;
- var nice = "cscript /nologo configure.js ";
- var disable_all = false;
-
- args = WScript.Arguments;
- for (i = 0; i < args.length; i++) {
- arg = args(i);
- nice += ' "' + arg + '"';
- if (arg == "--help") {
- configure_help_mode = true;
- break;
- }
- if (arg == "--disable-all") {
- disable_all = true;
- continue;
- }
-
- // If it is --foo=bar, split on the equals sign
- arg = arg.split("=", 2);
- argname = arg[0];
- if (arg.length > 1) {
- argval = arg[1];
- } else {
- argval = null;
- }
-
- // Find the arg
- found = false;
- for (j = 0; j < configure_args.length; j++) {
- if (argname == configure_args[j].imparg || argname == configure_args[j].arg) {
- found = true;
-
- arg = configure_args[j];
- arg.seen = true;
-
- analyzed = analyze_arg(argval);
-
- /* Force shared when called after phpize */
- if (MODE_PHPIZE) {
- shared = "shared";
- } else {
- shared = analyzed[0];
- }
- argval = analyzed[1];
-
- if (argname == arg.imparg) {
- /* we matched the implicit, or default arg */
- if (argval == null) {
- argval = arg.defval;
- }
- } else {
- /* we matched the non-default arg */
- if (argval == null) {
- argval = arg.defval == "no" ? "yes" : "no";
- }
- }
-
- arg.argval = argval;
- eval("PHP_" + arg.symval + " = argval;");
- eval("PHP_" + arg.symval + "_SHARED = shared;");
- break;
- }
- }
- if (!found) {
- STDERR.WriteLine("Unknown option " + argname + "; please try configure.js --help for a list of valid options");
- WScript.Quit(2);
- }
- }
-
- if (configure_help_mode) {
- STDOUT.WriteLine(word_wrap_and_indent(0,
-"Options that enable extensions and SAPI will accept \
-'yes' or 'no' as a parameter. They also accept 'shared' \
-as a synonym for 'yes' and request a shared build of that \
-module. Not all modules can be built as shared modules; \
-configure will display [shared] after the module name if \
-can be built that way. \
-"
- ));
- STDOUT.WriteBlankLines(1);
-
- // Measure width to pretty-print the output
- max_width = 0;
- for (i = 0; i < configure_args.length; i++) {
- arg = configure_args[i];
- if (arg.arg.length > max_width)
- max_width = arg.arg.length;
- }
-
- for (i = 0; i < configure_args.length; i++) {
- arg = configure_args[i];
-
- n = max_width - arg.arg.length;
- pad = " ";
- for (j = 0; j < n; j++) {
- pad += " ";
- }
- STDOUT.WriteLine(" " + arg.arg + pad + word_wrap_and_indent(max_width + 5, arg.helptext));
- }
- WScript.Quit(1);
- }
-
- var snapshot_build_exclusions = new Array(
- 'debug', 'crt-debug', 'lzf-better-compression',
- 'php-build', 'snapshot-template', 'ereg',
- 'pcre-regex', 'fastcgi', 'force-cgi-redirect',
- 'path-info-check', 'zts', 'ipv6', 'memory-limit',
- 'zend-multibyte', 'fd-setsize', 'memory-manager',
- 't1lib', 'pgi', 'pgo'
- );
- var force;
-
- // Now set any defaults we might have missed out earlier
- for (i = 0; i < configure_args.length; i++) {
- arg = configure_args[i];
- if (arg.seen)
- continue;
- analyzed = analyze_arg(arg.defval);
- shared = analyzed[0];
- argval = analyzed[1];
-
- // Don't trust a default "yes" answer for a non-core module
- // in a snapshot build
- if (PHP_SNAPSHOT_BUILD != "no" && argval == "yes" && !shared) {
-
- force = true;
- for (j = 0; j < snapshot_build_exclusions.length; j++) {
- if (snapshot_build_exclusions[j] == arg.optname) {
- force = false;
- break;
- }
- }
-
- if (force) {
- /* now check if it is a core module */
- force = false;
- for (j = 0; j < core_module_list.length; j++) {
- if (core_module_list[j] == arg.optname) {
- force = true;
- break;
- }
- }
-
- if (!force) {
- STDOUT.WriteLine("snapshot: forcing " + arg.arg + " shared");
- shared = true;
- }
- }
- }
-
- if (PHP_SNAPSHOT_BUILD != "no" && argval == "no") {
- force = true;
- for (j = 0; j < snapshot_build_exclusions.length; j++) {
- if (snapshot_build_exclusions[j] == arg.optname) {
- force = false;
- break;
- }
- }
- if (force) {
- STDOUT.WriteLine("snapshot: forcing " + arg.optname + " on");
- argval = "yes";
- shared = true;
- }
- }
-
- if (disable_all) {
- force = true;
- for (j = 0; j < snapshot_build_exclusions.length; j++) {
- if (snapshot_build_exclusions[j] == arg.optname) {
- force = false;
- break;
- }
- }
- if (force) {
- if (arg.defval == '') {
- argval = '';
- } else {
- argval = "no";
- }
- shared = false;
- }
- }
-
- eval("PHP_" + arg.symval + " = argval;");
- eval("PHP_" + arg.symval + "_SHARED = shared;");
- }
-
- MFO = FSO.CreateTextFile("Makefile.objects", true);
-
- STDOUT.WriteLine("Saving configure options to config.nice.bat");
- var nicefile = FSO.CreateTextFile("config.nice.bat", true);
- nicefile.WriteLine(nice + " %*");
- nicefile.Close();
-
- AC_DEFINE('CONFIGURE_COMMAND', nice, "Configure line");
-}
-
-function DEFINE(name, value)
-{
- if (configure_subst.Exists(name)) {
- configure_subst.Remove(name);
- }
- configure_subst.Add(name, value);
-}
-
-// Searches a set of paths for a file;
-// returns the dir in which the file was found,
-// true if it was found in the default env path,
-// or false if it was not found at all.
-// env_name is the optional name of an env var
-// specifying the default path to search
-function search_paths(thing_to_find, explicit_path, env_name)
-{
- var i, found = false, place = false, file, env;
-
- STDOUT.Write("Checking for " + thing_to_find + " ... ");
-
- thing_to_find = thing_to_find.replace(new RegExp("/", "g"), "\\");
-
- if (explicit_path != null) {
- if (typeof(explicit_path) == "string") {
- explicit_path = explicit_path.split(";");
- }
-
- for (i = 0; i < explicit_path.length; i++) {
- file = glob(explicit_path[i] + "\\" + thing_to_find);
- if (file) {
- found = true;
- place = file[0];
- place = place.substr(0, place.length - thing_to_find.length - 1);
- break;
- }
- }
- }
-
- if (!found && env_name != null) {
- env = WshShell.Environment("Process").Item(env_name);
- env = env.split(";");
- for (i = 0; i < env.length; i++) {
- file = glob(env[i] + "\\" + thing_to_find);
- if (file) {
- found = true;
- place = true;
- break;
- }
- }
- }
-
- if (found && place == true) {
- STDOUT.WriteLine(" <in default path>");
- } else if (found) {
- STDOUT.WriteLine(" " + place);
- } else {
- STDOUT.WriteLine(" <not found>");
- }
- return place;
-}
-
-function PATH_PROG(progname, additional_paths, symbol)
-{
- var exe;
- var place;
- var cyg_path = PHP_CYGWIN + "\\bin;" + PHP_CYGWIN + "\\usr\\local\\bin";
- var php_build_bin_path = PHP_PHP_BUILD + "\\bin"
-
- exe = progname + ".exe";
-
- if (additional_paths == null) {
- additional_paths = cyg_path;
- } else {
- additional_paths += ";" + cyg_path;
- }
-
- additional_paths = additional_paths + ";" + php_build_bin_path;
-
- place = search_paths(exe, additional_paths, "PATH");
-
- if (place == true) {
- place = exe;
- } else if (place != false) {
- place = place + "\\" + exe;
- }
-
- if (place) {
- if (symbol == null) {
- symbol = progname.toUpperCase();
- }
- DEFINE(symbol, place);
- }
- return place;
-}
-
-function find_pattern_in_path(pattern, path)
-{
- if (path == null) {
- return false;
- }
-
- var dirs = path.split(';');
- var i;
- var items;
-
- for (i = 0; i < dirs.length; i++) {
- items = glob(dirs[i] + "\\" + pattern);
- if (items) {
- return condense_path(items[0]);
- }
- }
- return false;
-}
-
-function CHECK_LIB(libnames, target, path_to_check, common_name)
-{
- STDOUT.Write("Checking for library " + libnames + " ... ");
-
- if (common_name == null && target != null) {
- common_name = target;
- }
-
- if (path_to_check == null) {
- path_to_check = "";
- }
-
- // if they specified a common name for the package that contains
- // the library, tag some useful defaults on to the end of the
- // path to be searched
- if (common_name != null) {
- path_to_check += ";" + PHP_PHP_BUILD + "\\" + common_name + "*";
- path_to_check += ";" + PHP_PHP_BUILD + "\\lib\\" + common_name + "*";
- path_to_check += ";..\\" + common_name + "*";
- }
-
- // Determine target for build flags
- if (target == null) {
- target = "";
- } else {
- target = "_" + target.toUpperCase();
- }
-
- // Expand path to include general dirs
- path_to_check += ";" + php_usual_lib_suspects;
-
- // It is common practice to put libs under one of these dir names
- var subdirs = new Array(PHP_DEBUG == "yes" ? "Debug" : (PHP_DEBUG_PACK == "yes"?"Release_Dbg":"Release"), "lib", "libs", "libexec");
-
- // libnames can be ; separated list of accepted library names
- libnames = libnames.split(';');
-
- // for debug builds, lib may have _debug appended, we want that first
- if (PHP_DEBUG == "yes") {
- var length = libnames.length;
- for (var i = 0; i < length; i++) {
- var name = new String(libnames[i]);
- rExp = /.lib$/i;
- name = name.replace(rExp,"_debug.lib");
- libnames.unshift(name);
- }
- }
-
- var i, j, k, libname;
- var location = false;
- var path = path_to_check.split(';');
-
- for (i = 0; i < libnames.length; i++) {
- libname = libnames[i];
-
- for (k = 0; k < path.length; k++) {
- location = glob(path[k] + "\\" + libname);
- if (location) {
- location = location[0];
- break;
- }
- for (j = 0; j < subdirs.length; j++) {
- location = glob(path[k] + "\\" + subdirs[j] + "\\" + libname);
- if (location) {
- location = location[0];
- break;
- }
- }
- if (location)
- break;
- }
-
- if (location) {
- location = condense_path(location);
- var libdir = FSO.GetParentFolderName(location);
- libname = FSO.GetFileName(location);
- ADD_FLAG("LDFLAGS" + target, '/libpath:"' + libdir + '" ');
- ADD_FLAG("LIBS" + target, libname);
-
- STDOUT.WriteLine(location);
-
- return location;
- }
-
- // Check in their standard lib path
- location = find_pattern_in_path(libname, WshShell.Environment("Process").Item("LIB"));
-
- if (location) {
- location = condense_path(location);
- libname = FSO.GetFileName(location);
- ADD_FLAG("LIBS" + target, libname);
-
- STDOUT.WriteLine("<in LIB path> " + libname);
- return location;
- }
-
- // Check in their general extra libs path
- location = find_pattern_in_path(libname, PHP_EXTRA_LIBS);
- if (location) {
- location = condense_path(location);
- libname = FSO.GetFileName(location);
- ADD_FLAG("LIBS" + target, libname);
- STDOUT.WriteLine("<in extra libs path>");
- return location;
- }
- }
-
- STDOUT.WriteLine("<not found>");
-
- return false;
-}
-
-function OLD_CHECK_LIB(libnames, target, path_to_check)
-{
- if (target == null) {
- target = "";
- } else {
- target = "_" + target.toUpperCase();
- }
-
- if (path_to_check == null) {
- path_to_check = php_usual_lib_suspects;
- } else {
- path_to_check += ";" + php_usual_lib_suspects;
- }
- var have = 0;
- var p;
- var i;
- var libname;
-
- var subdir = PHP_DEBUG == "yes" ? "Debug" : (PHP_DEBUG_PACK == "yes"?"Release_Dbg":"Release");
-
- libnames = libnames.split(';');
- for (i = 0; i < libnames.length; i++) {
- libname = libnames[i];
- p = search_paths(libname, path_to_check, "LIB");
-
- if (!p) {
- p = search_paths(subdir + "\\" + libname, path_to_check, "LIB");
- if (p) {
- p += "\\" + subdir;
- }
- }
-
- if (typeof(p) == "string") {
- ADD_FLAG("LDFLAGS" + target, '/libpath:"' + p + '" ');
- ADD_FLAG("LIBS" + target, libname);
- have = 1;
- } else if (p == true) {
- ADD_FLAG("LIBS" + target, libname);
- have = 1;
- } else {
- /* not found in the defaults or the explicit paths,
- * so check the general extra libs; if we find
- * it here, no need to add another /libpath: for it as we
- * already have it covered, but we need to add the lib
- * to LIBS_XXX */
- if (false != search_paths(libname, PHP_EXTRA_LIBS, null)) {
- ADD_FLAG("LIBS" + target, libname);
- have = 1;
- }
- }
-
- if (have) {
- break;
- }
- }
-
-// AC_DEFINE("HAVE_" + header_name.toUpperCase().replace(new RegExp("/\\\\-\.", "g"), "_"), have);
-
- return have;
-
-}
-
-function CHECK_FUNC_IN_HEADER(header_name, func_name, path_to_check, add_to_flag)
-{
- var c = false;
- var sym;
-
- STDOUT.Write("Checking for " + func_name + " in " + header_name + " ... ");
-
- c = GREP_HEADER(header_name, func_name, path_to_check);
-
- sym = func_name.toUpperCase();
- sym = sym.replace(new RegExp("[\\\\/\.-]", "g"), "_");
-
- if (typeof(add_to_flag) == "undefined") {
- AC_DEFINE("HAVE_" + sym, c ? 1 : 0);
- } else {
- ADD_FLAG(add_to_flag, "/DHAVE_" + sym + "=" + (c ? "1" : "0"));
- }
-
- if (c) {
- STDOUT.WriteLine("OK");
- return c;
- }
- STDOUT.WriteLine("No");
- return false;
-}
-
-function GREP_HEADER(header_name, regex, path_to_check)
-{
- var c = false;
-
- if (FSO.FileExists(path_to_check + "\\" + header_name)) {
- c = file_get_contents(path_to_check + "\\" + header_name);
- }
-
- if (!c) {
- /* look in the include path */
-
- var p = search_paths(header_name, path_to_check, "INCLUDE");
- if (typeof(p) == "string") {
- c = file_get_contents(p);
- } else if (p == false) {
- p = search_paths(header_name, PHP_EXTRA_INCLUDES, null);
- if (typeof(p) == "string") {
- c = file_get_contents(p);
- }
- }
- if (!c) {
- return false;
- }
- }
-
- if (typeof(regex) == "string") {
- regex = new RegExp(regex);
- }
-
- if (c.match(regex)) {
- /* caller can now use RegExp.$1 etc. to get at patterns */
- return true;
- }
- return false;
-}
-
-function CHECK_HEADER_ADD_INCLUDE(header_name, flag_name, path_to_check, use_env, add_dir_part, add_to_flag_only)
-{
- var dir_part_to_add = "";
-
- if (use_env == null) {
- use_env = true;
- }
-
- // if true, add the dir part of the header_name to the include path
- if (add_dir_part == null) {
- add_dir_part = false;
- } else if (add_dir_part) {
- var basename = FSO.GetFileName(header_name);
- dir_part_to_add = "\\" + header_name.substr(0, header_name.length - basename.length - 1);
- }
-
- if (path_to_check == null) {
- path_to_check = php_usual_include_suspects;
- } else {
- path_to_check += ";" + php_usual_include_suspects;
- }
-
- var p = search_paths(header_name, path_to_check, use_env ? "INCLUDE" : null);
- var have = 0;
- var sym;
-
- if (typeof(p) == "string") {
- ADD_FLAG(flag_name, '/I "' + p + dir_part_to_add + '" ');
- } else if (p == false) {
- /* not found in the defaults or the explicit paths,
- * so check the general extra includes; if we find
- * it here, no need to add another /I for it as we
- * already have it covered, unless we are adding
- * the dir part.... */
- p = search_paths(header_name, PHP_EXTRA_INCLUDES, null);
- if (typeof(p) == "string" && add_dir_part) {
- ADD_FLAG(flag_name, '/I "' + p + dir_part_to_add + '" ');
- }
- }
- have = p ? 1 : 0
-
- sym = header_name.toUpperCase();
- sym = sym.replace(new RegExp("[\\\\/\.-]", "g"), "_");
-
- if (typeof(add_to_flag_only) == "undefined" &&
- flag_name.match(new RegExp("^CFLAGS_(.*)$"))) {
- add_to_flag_only = true;
- }
-
- if (typeof(add_to_flag_only) != "undefined") {
- ADD_FLAG(flag_name, "/DHAVE_" + sym + "=" + have);
- } else {
- AC_DEFINE("HAVE_" + sym, have, "have the " + header_name + " header file");
- }
-
- return p;
-}
-
-/* emits rule to generate version info for a SAPI
- * or extension. Returns the name of the .res file
- * that will be generated */
-function generate_version_info_resource(makefiletarget, basename, creditspath, sapi)
-{
- var resname = makefiletarget + ".res";
- var res_desc = makefiletarget;
- var res_prod_name = "PHP " + makefiletarget;
- var credits;
- var thanks = "";
- var logo = "";
- var debug = "";
- var project_url = "http://www.php.net";
- var project_header = creditspath + "/php_" + basename + ".h";
- var versioning = "";
-
- if (sapi) {
- var internal_name = basename.toUpperCase() + " SAPI";
- } else {
- var internal_name = basename.toUpperCase() + " extension";
- }
-
- if (FSO.FileExists(creditspath + '/CREDITS')) {
- credits = FSO.OpenTextFile(creditspath + '/CREDITS', 1);
- res_desc = credits.ReadLine();
- try {
- thanks = credits.ReadLine();
- } catch (e) {
- thanks = null;
- }
- if (thanks == null) {
- thanks = "";
- } else {
- thanks = "Thanks to " + thanks;
- }
- credits.Close();
- }
-
- if (creditspath.match(new RegExp("pecl"))) {
- /* PECL project url - this will eventually work correctly for all */
- project_url = "http://pecl.php.net/" + basename;
-
- /* keep independent versioning PECL-specific for now */
- if (FSO.FileExists(project_header)) {
- if (header = FSO.OpenTextFile(project_header, 1)) {
- contents = header.ReadAll();
- /* allowed: x.x.x[a|b|-alpha|-beta][RCx][-dev] */
- if (contents.match(new RegExp('PHP_' + basename.toUpperCase() + '_VERSION(\\s+)"((\\d+\.\\d+(\.\\d+)?)((a|b)(\\d)?|\-[a-z]{3,5})?(RC\\d+)?(\-dev)?)'))) {
- project_version = RegExp.$2;
- file_version = RegExp.$3.split('.');
- if (!file_version[2]) {
- file_version[2] = 0;
- }
- versioning = '\\"" /d EXT_FILE_VERSION=' + file_version[0] + ',' + file_version[1] + ',' + file_version[2] + ' /d EXT_VERSION="\\"' + project_version;
- }
- header.Close();
- }
- }
- }
-
- if (makefiletarget.match(new RegExp("\\.exe$"))) {
- logo = " /d WANT_LOGO ";
- }
-
- if (PHP_DEBUG != "no") {
- debug = " /d _DEBUG";
- }
-
- /**
- * Use user supplied template.rc if it exists
- */
- if (FSO.FileExists(creditspath + '\\template.rc')) {
- MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": " + creditspath + "\\template.rc");
- MFO.WriteLine("\t$(RC) /fo $(BUILD_DIR)\\" + resname + logo + debug +
- ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' +
- makefiletarget + '\\"" /d PRODUCT_NAME="\\"' + res_prod_name +
- versioning + '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" ' +
- creditspath + '\\template.rc');
- return resname;
- }
- if (MODE_PHPIZE) {
- MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": $(PHP_DIR)\\build\\template.rc");
- MFO.WriteLine("\t$(RC) /I $(PHP_DIR)/include /n /fo $(BUILD_DIR)\\" + resname + logo + debug +
- ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"'
- + makefiletarget + '\\"" /d URL="\\"' + project_url +
- '\\"" /d INTERNAL_NAME="\\"' + internal_name + versioning +
- '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" $(PHP_DIR)\\build\\template.rc');
- } else {
- MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": win32\\build\\template.rc");
- MFO.WriteLine("\t$(RC) /n /fo $(BUILD_DIR)\\" + resname + logo + debug +
- ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"'
- + makefiletarget + '\\"" /d URL="\\"' + project_url +
- '\\"" /d INTERNAL_NAME="\\"' + internal_name + versioning +
- '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" win32\\build\\template.rc');
- }
- MFO.WriteBlankLines(1);
- return resname;
-}
-
-/* Check if PGO is enabled for given module. To disable PGO for a particular module,
-define a global variable by the following name scheme before SAPI() or EXTENSION() call
- var PHP_MYMODULE_PGO = false; */
-function is_pgo_desired(mod)
-{
- var varname = "PHP_" + mod.toUpperCase() + "_PGO";
-
- /* XXX enable PGO in phpize mode */
- if (MODE_PHPIZE) {
- return false;
- }
-
- /* don't disable if there's no mention of the varname */
- if (eval("typeof " + varname + " == 'undefined'")) {
- return true;
- }
-
- return eval("!!" + varname);
-}
-
-function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir)
-{
- var SAPI = sapiname.toUpperCase();
- var ldflags;
- var resname;
- var ld;
- var manifest;
-
- if (typeof(obj_dir) == "undefined") {
- sapiname_for_printing = configure_module_dirname;
- } else {
- sapiname_for_printing = configure_module_dirname + " (via " + obj_dir + ")";
- }
-
- STDOUT.WriteLine("Enabling SAPI " + sapiname_for_printing);
-
- MFO.WriteBlankLines(1);
- MFO.WriteLine("# objects for SAPI " + sapiname);
- MFO.WriteBlankLines(1);
-
- if (cflags) {
- ADD_FLAG('CFLAGS_' + SAPI, cflags);
- }
-
- ADD_SOURCES(configure_module_dirname, file_list, sapiname, obj_dir);
- MFO.WriteBlankLines(1);
- MFO.WriteLine("# SAPI " + sapiname);
- MFO.WriteBlankLines(1);
-
- /* generate a .res file containing version information */
- resname = generate_version_info_resource(makefiletarget, sapiname, configure_module_dirname, true);
-
- MFO.WriteLine(makefiletarget + ": $(BUILD_DIR)\\" + makefiletarget);
- MFO.WriteLine("\t@echo SAPI " + sapiname_for_printing + " build complete");
- if (MODE_PHPIZE) {
- MFO.WriteLine("$(BUILD_DIR)\\" + makefiletarget + ": $(DEPS_" + SAPI + ") $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(BUILD_DIR)\\" + resname);
- } else {
- MFO.WriteLine("$(BUILD_DIR)\\" + makefiletarget + ": $(DEPS_" + SAPI + ") $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname);
- }
-
- if (makefiletarget.match(new RegExp("\\.dll$"))) {
- ldflags = "/dll $(LDFLAGS)";
- manifest = "-@$(_VC_MANIFEST_EMBED_DLL)";
- } else if (makefiletarget.match(new RegExp("\\.lib$"))) {
- ldflags = "$(LDFLAGS)";
- ld = "$(MAKE_LIB)";
- } else {
- ldflags = "$(LDFLAGS)";
- manifest = "-@$(_VC_MANIFEST_EMBED_EXE)";
- }
-
- if(is_pgo_desired(sapiname) && (PHP_PGI == "yes" || PHP_PGO != "no")) {
- // Add compiler and link flags if PGO options are selected
- if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
- ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2");
- ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG:PGINSTRUMENT");
- }
- else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
- ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2");
- ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG:PGUPDATE");
- }
-
- ldflags += " /PGD:$(PGOPGD_DIR)\\" + makefiletarget.substring(0, makefiletarget.indexOf(".")) + ".pgd";
- }
-
- if (MODE_PHPIZE) {
- if (ld) {
- MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname);
- } else {
- ld = "@$(CC)";
- MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")");
- }
- } else {
- if (ld) {
- MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname);
- } else {
- ld = "@$(CC)";
- MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")");
- }
- }
-
- if (manifest) {
- MFO.WriteLine("\t" + manifest);
- }
-
- DEFINE('CFLAGS_' + SAPI + '_OBJ', '$(CFLAGS_' + SAPI + ')');
-
- if (configure_module_dirname.match("pecl")) {
- ADD_FLAG("PECL_TARGETS", makefiletarget);
- } else {
- ADD_FLAG("SAPI_TARGETS", makefiletarget);
- }
-
- MFO.WriteBlankLines(1);
- sapi_enabled[sapi_enabled.length] = [sapiname];
-}
-
-function ADD_DIST_FILE(filename)
-{
- if (configure_module_dirname.match("pecl")) {
- ADD_FLAG("PECL_EXTRA_DIST_FILES", filename);
- } else {
- ADD_FLAG("PHP_EXTRA_DIST_FILES", filename);
- }
-}
-
-function file_get_contents(filename)
-{
- var f, c;
- try {
- f = FSO.OpenTextFile(filename, 1);
- c = f.ReadAll();
- f.Close();
- return c;
- } catch (e) {
- STDOUT.WriteLine("Problem reading " + filename);
- return false;
- }
-}
-
-// Add a dependency on another extension, so that
-// the dependencies are built before extname
-function ADD_EXTENSION_DEP(extname, dependson, optional)
-{
- var EXT = extname.toUpperCase();
- var DEP = dependson.toUpperCase();
- var dep_present = false;
- var dep_shared = false;
-
- try {
- dep_present = eval("PHP_" + DEP);
-
- if (dep_present != "no") {
- try {
- dep_shared = eval("PHP_" + DEP + "_SHARED");
- } catch (e) {
- dep_shared = false;
- }
- }
-
- } catch (e) {
- dep_present = "no";
- }
-
- if (optional) {
- if (dep_present == "no") {
- MESSAGE("\t" + dependson + " not found: " + dependson + " support in " + extname + " disabled");
- return false;
- }
- }
-
- var ext_shared = eval("PHP_" + EXT + "_SHARED");
-
- if (dep_shared) {
- if (!ext_shared) {
- if (optional) {
- MESSAGE("\tstatic " + extname + " cannot depend on shared " + dependson + ": " + dependson + "support disabled");
- return false;
- }
- ERROR("static " + extname + " cannot depend on shared " + dependson);
- }
-
- ADD_FLAG("LIBS_" + EXT, "php_" + dependson + ".lib");
- if (MODE_PHPIZE) {
- ADD_FLAG("LDFLAGS_" + EXT, "/libpath:$(BUILD_DIR_DEV)\\lib");
- ADD_FLAG("DEPS_" + EXT, "$(BUILD_DIR_DEV)\\lib\\php_" + dependson + ".lib");
- } else {
- ADD_FLAG("LDFLAGS_" + EXT, "/libpath:$(BUILD_DIR)");
- ADD_FLAG("DEPS_" + EXT, "$(BUILD_DIR)\\php_" + dependson + ".lib");
- }
-
- } else {
-
- if (dep_present == "no") {
- if (ext_shared) {
- WARNING(extname + " cannot be built: missing dependency, " + dependson + " not found");
-
- var dllname = ' php_' + extname + '.dll';
-
- if (!REMOVE_TARGET(dllname, 'EXT_TARGETS')) {
- REMOVE_TARGET(dllname, 'PECL_TARGETS');
- }
-
- return false;
-
- }
-
- ERROR("Cannot build " + extname + "; " + dependson + " not enabled");
- return false;
- }
- } // dependency is statically built-in to PHP
- return true;
-}
-
-var static_pgo_enabled = false;
-
-function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir)
-{
- var objs = null;
- var EXT = extname.toUpperCase();
- var extname_for_printing;
- var ldflags;
-
- if (shared == null) {
- eval("shared = PHP_" + EXT + "_SHARED;");
- } else {
- eval("PHP_" + EXT + "_SHARED = shared;");
- }
-
- if (cflags == null) {
- cflags = "";
- }
-
- if (typeof(obj_dir) == "undefined") {
- extname_for_printing = configure_module_dirname;
- } else {
- extname_for_printing = configure_module_dirname + " (via " + obj_dir + ")";
- }
-
- if (shared) {
- STDOUT.WriteLine("Enabling extension " + extname_for_printing + " [shared]");
- cflags = "/D COMPILE_DL_" + EXT + " /D " + EXT + "_EXPORTS=1 " + cflags;
- ADD_FLAG("CFLAGS_PHP", "/D COMPILE_DL_" + EXT);
- } else {
- STDOUT.WriteLine("Enabling extension " + extname_for_printing);
- }
-
- MFO.WriteBlankLines(1);
- MFO.WriteLine("# objects for EXT " + extname);
- MFO.WriteBlankLines(1);
-
- ADD_SOURCES(configure_module_dirname, file_list, extname, obj_dir);
-
- MFO.WriteBlankLines(1);
-
- if (shared) {
- if (dllname == null) {
- dllname = "php_" + extname + ".dll";
- }
- var libname = dllname.substring(0, dllname.length-4) + ".lib";
-
- var resname = generate_version_info_resource(dllname, extname, configure_module_dirname, false);
- var ld = "@$(CC)";
-
- ldflags = "";
- if (is_pgo_desired(extname) && (PHP_PGI == "yes" || PHP_PGO != "no")) {
- // Add compiler and link flags if PGO options are selected
- if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
- ADD_FLAG('LDFLAGS_' + EXT, "/LTCG:PGINSTRUMENT");
- }
- else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
- ADD_FLAG('LDFLAGS_' + EXT, "/LTCG:PGUPDATE");
- }
-
- ADD_FLAG('CFLAGS_' + EXT, "/GL /O2");
-
- ldflags = " /PGD:$(PGOPGD_DIR)\\" + dllname.substring(0, dllname.indexOf(".")) + ".pgd";
- }
-
- MFO.WriteLine("$(BUILD_DIR)\\" + libname + ": $(BUILD_DIR)\\" + dllname);
- MFO.WriteBlankLines(1);
- if (MODE_PHPIZE) {
- MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(DEPS_" + EXT + ") $(" + EXT + "_GLOBAL_OBJS) $(PHPLIB) $(BUILD_DIR)\\" + resname);
- MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + dllname + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")");
- } else {
- MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(DEPS_" + EXT + ") $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname);
- MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /link /out:$(BUILD_DIR)\\" + dllname + ldflags + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")");
- }
- MFO.WriteLine("\t-@$(_VC_MANIFEST_EMBED_DLL)");
- MFO.WriteBlankLines(1);
-
- if (configure_module_dirname.match("pecl")) {
- ADD_FLAG("PECL_TARGETS", dllname);
- } else {
- ADD_FLAG("EXT_TARGETS", dllname);
- }
- MFO.WriteLine(dllname + ": $(BUILD_DIR)\\" + dllname);
- MFO.WriteLine("\t@echo EXT " + extname + " build complete");
- MFO.WriteBlankLines(1);
-
- DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_' + EXT + ')');
- } else {
- ADD_FLAG("STATIC_EXT_OBJS", "$(" + EXT + "_GLOBAL_OBJS)");
- ADD_FLAG("STATIC_EXT_LIBS", "$(LIBS_" + EXT + ")");
- ADD_FLAG("STATIC_EXT_LDFLAGS", "$(LDFLAGS_" + EXT + ")");
- ADD_FLAG("STATIC_EXT_CFLAGS", "$(CFLAGS_" + EXT + ")");
- if (is_pgo_desired(extname) && (PHP_PGI == "yes" || PHP_PGO != "no")) {
- if (!static_pgo_enabled) {
- if (PHP_DEBUG != "yes" && PHP_PGI == "yes") {
- ADD_FLAG('STATIC_EXT_LDFLAGS', "/LTCG:PGINSTRUMENT");
- }
- else if (PHP_DEBUG != "yes" && PHP_PGO != "no") {
- ADD_FLAG('STATIC_EXT_LDFLAGS', "/LTCG:PGUPDATE");
- }
-
- ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2");
- static_pgo_enabled = true;
- }
- }
-
- /* find the header that declares the module pointer,
- * so we can include it in internal_functions.c */
- var ext_dir = FSO.GetFolder(configure_module_dirname);
- var fc = new Enumerator(ext_dir.Files);
- var re = /\.h$/;
- var s, c;
- for (; !fc.atEnd(); fc.moveNext()) {
- s = fc.item() + "";
- if (s.match(re)) {
- c = file_get_contents(s);
- if (c.match("phpext_")) {
- extension_include_code += '#include "' + configure_module_dirname + '/' + FSO.GetFileName(s) + '"\r\n';
- }
- }
- }
-
- extension_module_ptrs += '\tphpext_' + extname + '_ptr,\r\n';
-
- DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_PHP) $(CFLAGS_' + EXT + ')');
- }
- if (MODE_PHPIZE && FSO.FileExists(PHP_DIR + "/include/main/config.pickle.h")) {
- cflags = "/FI main/config.pickle.h " + cflags;
- }
- ADD_FLAG("CFLAGS_" + EXT, cflags);
-
- extensions_enabled[extensions_enabled.length] = [extname, shared ? 'shared' : 'static'];
-}
-
-function ADD_SOURCES(dir, file_list, target, obj_dir)
-{
- var i;
- var tv;
- var src, obj, sym, flags;
-
- if (target == null) {
- target = "php";
- }
-
- sym = target.toUpperCase() + "_GLOBAL_OBJS";
- flags = "CFLAGS_" + target.toUpperCase() + '_OBJ';
-
- if (configure_subst.Exists(sym)) {
- tv = configure_subst.Item(sym);
- } else {
- tv = "";
- }
-
- file_list = file_list.split(new RegExp("\\s+"));
- file_list.sort();
-
- var re = new RegExp("\.[a-z0-9A-Z]+$");
-
- dir = dir.replace(new RegExp("/", "g"), "\\");
- var objs_line = "";
- var srcs_line = "";
-
- var sub_build = "$(BUILD_DIR)\\";
-
- /* if module dir is not a child of the main source dir,
- * we need to tweak it; we should have detected such a
- * case in condense_path and rewritten the path to
- * be relative.
- * This probably breaks for non-sibling dirs, but that
- * is not a problem as buildconf only checks for pecl
- * as either a child or a sibling */
- if (obj_dir == null) {
- var build_dir = dir.replace(new RegExp("^..\\\\"), "");
- var mangle_dir = build_dir.replace(new RegExp("[\\\\/.-]", "g"), "_");
- var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase();
- }
- else {
- var build_dir = obj_dir.replace(new RegExp("^..\\\\"), "");
- var mangle_dir = build_dir.replace(new RegExp("[\\\\/.-]", "g"), "_");
- var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase();
- }
-
- var dirs = build_dir.split("\\");
- var i, d = "";
- for (i = 0; i < dirs.length; i++) {
- d += dirs[i];
- build_dirs[build_dirs.length] = d;
- d += "\\";
- }
- sub_build += d;
-
-
- DEFINE(bd_flags_name, " /Fd" + sub_build + " /Fp" + sub_build + " /FR" + sub_build + " ");
-
- for (i in file_list) {
- src = file_list[i];
- obj = src.replace(re, ".obj");
- tv += " " + sub_build + obj;
-
- if (!PHP_MP_DISABLED) {
- if (i > 0) {
- objs_line += " " + sub_build + obj;
- srcs_line += " " + dir + "\\" + src;
- } else {
- objs_line = sub_build + obj;
- srcs_line = dir + "\\" + src;
- }
- } else {
- MFO.WriteLine(sub_build + obj + ": " + dir + "\\" + src);
-
- if (PHP_ANALYZER == "pvs") {
- MFO.WriteLine("\t@\"$(PVS_STUDIO)\" --cl-params $(" + flags + ") $(CFLAGS) $(" + bd_flags_name + ") /c " + dir + "\\" + src + " --source-file " + dir + "\\" + src
- + " --cfg PVS-Studio.conf --errors-off \"V122 V117 V111\" ");
- }
- MFO.WriteLine("\t@$(CC) $(" + flags + ") $(CFLAGS) $(" + bd_flags_name + ") /c " + dir + "\\" + src + " /Fo" + sub_build + obj);
- }
- }
-
- if (!PHP_MP_DISABLED) {
- MFO.WriteLine(objs_line + ": " + srcs_line);
- MFO.WriteLine("\t$(CC) $(" + flags + ") $(CFLAGS) /Fo" + sub_build + " $(" + bd_flags_name + ") /c " + srcs_line);
- }
-
- DEFINE(sym, tv);
-}
-
-function REMOVE_TARGET(dllname, flag)
-{
- var dllname = dllname.replace(/\s/g, "");
- var EXT = dllname.replace(/php_(\S+)\.dll/, "$1").toUpperCase();
- var php_flags = configure_subst.Item("CFLAGS_PHP");
-
- if (configure_subst.Exists(flag)) {
- var targets = configure_subst.Item(flag);
-
- if (targets.match(dllname)) {
- configure_subst.Remove(flag);
- targets = targets.replace(dllname, "");
- targets = targets.replace(/\s+/, " ");
- targets = targets.replace(/\s$/, "");
- configure_subst.Add(flag, targets);
- configure_hdr.Add("HAVE_" + EXT, new Array(0, ""));
- configure_subst.Item("CFLAGS_PHP") = php_flags.replace(" /D COMPILE_DL_" + EXT, "");
- extensions_enabled.pop();
- return true;
- }
- }
- return false;
-}
-
-function generate_internal_functions()
-{
- var infile, outfile;
- var indata;
-
- STDOUT.WriteLine("Generating main/internal_functions.c");
-
- infile = FSO.OpenTextFile("main/internal_functions.c.in", 1);
- indata = infile.ReadAll();
- infile.Close();
-
- indata = indata.replace("@EXT_INCLUDE_CODE@", extension_include_code);
- indata = indata.replace("@EXT_MODULE_PTRS@", extension_module_ptrs);
-
- if (FSO.FileExists("main/internal_functions.c")) {
- var origdata = file_get_contents("main/internal_functions.c");
-
- if (origdata == indata) {
- STDOUT.WriteLine("\t[content unchanged; skipping]");
- return;
- }
- }
-
- outfile = FSO.CreateTextFile("main/internal_functions.c", true);
- outfile.Write(indata);
- outfile.Close();
-}
-
-function output_as_table(header, ar_out)
-{
- var l = header.length;
- var cols = 80;
- var fixedlength = "";
- var t = 0;
- var i,j,k,m;
- var out = "| ";
- var min = new Array(l);
- var max = new Array(l);
-
- if (!!ar_out[0] && l != ar_out[0].length) {
- STDOUT.WriteLine("Invalid header argument, can't output the table " + l + " " + ar_out[0].length );
- return;
- }
-
- for (j=0; j < l; j++) {
- var tmax, tmin;
-
- /*Figure out the max length per column */
- tmin = 0;
- tmax = 0;
- for (k = 0; k < ar_out.length; k++) {
- var t = ar_out[k][j].length;
- if (t > tmax) tmax = t;
- else if (t < tmin) tmin = t;
- }
- if (tmax > header[j].length) {
- max[j] = tmax;
- } else {
- max[j] = header[j].length;
- }
- if (tmin < header[j].length) {
- min[j] = header[j].length;
- }
- }
-
- sep = "";
- k = 0;
- for (i = 0; i < l; i++) {
- k += max[i] + 3;
- }
- k++;
-
- for (j=0; j < k; j++) {
- sep += "-";
- }
-
- STDOUT.WriteLine(sep);
- out = "|";
- for (j=0; j < l; j++) {
- out += " " + header[j];
- for (var i = 0; i < (max[j] - header[j].length); i++){
- out += " ";
- }
- out += " |";
- }
- STDOUT.WriteLine(out);
-
- STDOUT.WriteLine(sep);
-
- out = "|";
- for (i=0; i < ar_out.length; i++) {
- line = ar_out[i];
- for (j=0; j < l; j++) {
- out += " " + line[j];
- for (var k = 0; k < (max[j] - line[j].length); k++){
- out += " ";
- }
- out += " |";
- }
- STDOUT.WriteLine(out);
- out = "|";
- }
-
- STDOUT.WriteLine(sep);
-}
-
-function write_summary()
-{
- var ar = new Array();
-
- STDOUT.WriteBlankLines(2);
-
- STDOUT.WriteLine("Enabled extensions:");
- output_as_table(["Extension", "Mode"], extensions_enabled.sort());
- STDOUT.WriteBlankLines(2);
- if (!MODE_PHPIZE) {
- STDOUT.WriteLine("Enabled SAPI:");
- output_as_table(["Sapi Name"], sapi_enabled);
- STDOUT.WriteBlankLines(2);
- }
- ar[0] = ['Build type', PHP_DEBUG == "yes" ? "Debug" : "Release"];
- ar[1] = ['Thread Safety', PHP_ZTS == "yes" ? "Yes" : "No"];
- ar[2] = ['Compiler', VC_VERSIONS[VCVERS]];
- ar[3] = ['Architecture', X64 ? 'x64' : 'x86'];
- if (PHP_PGO == "yes") {
- ar[4] = ['Optimization', "PGO"];
- } else if (PHP_PGI == "yes") {
- ar[4] = ['Optimization', "PGI"];
- } else {
- ar[4] = ['Optimization', PHP_DEBUG == "yes" ? "disabled" : "PGO disabled"];
- }
- if (PHP_ANALYZER == "vs") {
- ar[5] = ['Static analyzer', 'Visual Studio'];
- } else if (PHP_ANALYZER == "pvs") {
- ar[5] = ['Static analyzer', 'PVS-Studio'];
- } else {
- ar[5] = ['Static analyzer', 'disabled'];
- }
-
- output_as_table(["",""], ar);
- STDOUT.WriteBlankLines(2);
-}
-
-function generate_files()
-{
- var i, dir, bd, last;
-
- STDOUT.WriteBlankLines(1);
- STDOUT.WriteLine("Creating build dirs...");
- dir = get_define("BUILD_DIR");
- build_dirs.sort();
- last = null;
-
- if (!FSO.FolderExists(dir)) {
- FSO.CreateFolder(dir);
- }
-
- for (i = 0; i < build_dirs.length; i++) {
- bd = FSO.BuildPath(dir, build_dirs[i]);
- if (bd == last) {
- continue;
- }
- last = bd;
-
- build_dir = get_define('BUILD_DIR');
- build_dir = build_dir.replace(new RegExp("\\\\", "g"), "\\\\");
- if (build_dir.substr(build_dir.Length - 2, 2) != '\\\\') {
- build_dir += '\\\\';
- }
- ADD_FLAG("BUILD_DIRS_SUB", bd.replace(new RegExp(build_dir), ''));
-
- if (!FSO.FolderExists(bd)) {
- FSO.CreateFolder(bd);
- }
- }
-
- STDOUT.WriteLine("Generating files...");
- generate_makefile();
- if (!MODE_PHPIZE) {
- generate_internal_functions();
- generate_config_h();
- generate_phpize();
- } else {
- generate_config_pickle_h();
- generate_ext_pickle();
- }
- STDOUT.WriteLine("Done.");
- STDOUT.WriteBlankLines(1);
- write_summary();
-
- if (PHP_SNAPSHOT_BUILD != "no") {
- STDOUT.WriteLine("Type 'nmake snap' to build a PHP snapshot");
- } else {
- STDOUT.WriteLine("Type 'nmake' to build PHP");
- }
-}
-
-function generate_ext_pickle()
-{
- var content;
- var DEPS = null;
- var dest;
- var deps_lines = new Array();
-
- var build_var_name = function(name) {
- return "PHP_" + name.toUpperCase();
- }
-
- STDOUT.WriteLine("Generating pickle deps");
- dest = PHP_DIR + "/script/";
-
- if (!FSO.FolderExists(dest)) {
- FSO.CreateFolder(dest);
- }
-
- if (FSO.FileExists(dest + "/ext_pickle.js")) {
- DEPS = FSO.OpenTextFile(dest + "/ext_pickle.js", 1);
-
- while (!DEPS.AtEndOfStream) {
- var ln = DEPS.ReadLine();
- var found = false;
-
- for (var i in extensions_enabled) {
- var reg0 = new RegExp(build_var_name(extensions_enabled[i][0]) + "\s*=.+", "g");
- var reg1 = new RegExp(build_var_name(extensions_enabled[i][0]) + "_SHARED" + "\s*=.+", "g");
-
- if (ln.match(reg1) || ln.match(reg0)) {
- found = true;
- break;
- }
- }
-
- if (!found) {
- deps_lines.push(ln);
- }
- }
- }
-
- for (var i in extensions_enabled) {
- deps_lines.push(build_var_name(extensions_enabled[i][0]) + "=true;");
- deps_lines.push(build_var_name(extensions_enabled[i][0]) + "_SHARED=" + (extensions_enabled[i][1] == 'shared' ? 'true' : 'false') + ";");
- }
-
- if (!!DEPS) {
- DEPS.Close();
- DEPS = null;
- }
-
- /* Replace the ext_pickle.js with the new content */
- DEPS = FSO.CreateTextFile(dest + "/ext_pickle.js", true);
-
- for (var j in deps_lines) {
- DEPS.WriteLine(deps_lines[j]);
- }
-
- DEPS.Close();
-}
-
-function generate_config_pickle_h()
-{
- var outfile = null;
- var lines = new Array();
- var keys = (new VBArray(configure_hdr.Keys())).toArray();
- dest = PHP_DIR + "/include/main";
-
- var ignore_key = function(key) {
- var ignores = [ "CONFIGURE_COMMAND", "PHP_COMPILER_ID", "COMPILER", "ARCHITECTURE", "HAVE_STRNLEN", "PHP_DIR" ];
-
- for (var k in ignores) {
- if (ignores[k] == key) {
- return true;
- }
- }
-
- return false;
- }
-
-
- STDOUT.WriteLine("Generating main/config.pickle.h");
-
- if (FSO.FileExists(dest + "/config.pickle.h")) {
- outfile = FSO.OpenTextFile(dest + "/config.pickle.h", 1);
-
- while (!outfile.AtEndOfStream) {
- var found = false;
- var ln = outfile.ReadLine();
-
- for (var i in keys) {
- var reg = new RegExp("#define[\s ]+" + keys[i] + "[\s ]*.*", "g");
-
- if (ln.match(reg)) {
- found = true;
- break;
- }
- }
-
- if (!found) {
- lines.push(ln);
- }
- }
- }
-
- for (var i in keys) {
- var item = configure_hdr.Item(keys[i]);
-
- if (ignore_key(keys[i])) {
- continue;
- }
-
- /* XXX fix comment handling */
- /*if (!lines[j].match(/^#define.+/g)) {
- continue;
- }*/
-
- lines.push("#define " + keys[i] + " " + item[0]);
- }
-
- if (outfile) {
- outfile.Close();
- outfile = null;
- }
-
- outfile = FSO.CreateTextFile(dest + "/config.pickle.h", true);
-
- for (var k in lines) {
- outfile.WriteLine(lines[k]);
- }
-
- outfile.Close();
-}
-
-function generate_config_h()
-{
- var infile, outfile;
- var indata;
- var prefix;
-
- prefix = PHP_PREFIX.replace(new RegExp("\\\\", "g"), "\\\\");
-
- STDOUT.WriteLine("Generating main/config.w32.h");
-
- infile = FSO.OpenTextFile("win32/build/config.w32.h.in", 1);
- indata = infile.ReadAll();
- infile.Close();
-
- outfile = FSO.CreateTextFile("main/config.w32.h", true);
-
- indata = indata.replace(new RegExp("@PREFIX@", "g"), prefix);
- outfile.Write(indata);
-
- var keys = (new VBArray(configure_hdr.Keys())).toArray();
- var i, j;
- var item;
- var pieces, stuff_to_crack, chunk;
-
- outfile.WriteBlankLines(1);
- outfile.WriteLine("/* values determined by configure.js */");
-
- for (i in keys) {
- item = configure_hdr.Item(keys[i]);
- outfile.WriteBlankLines(1);
- pieces = item[0];
-
- if (item[1] != undefined) {
- outfile.WriteLine("/* " + item[1] + " */");
- }
-
- if (typeof(pieces) == "string" && pieces.charCodeAt(0) == 34) {
- /* quoted string have a maximal length of 2k under vc.
- * solution is to crack them and let the compiler concat
- * them implicitly */
- stuff_to_crack = pieces;
- pieces = "";
-
- while (stuff_to_crack.length) {
- j = 65;
- while (stuff_to_crack.charCodeAt(j) != 32 && j < stuff_to_crack.length)
- j++;
-
- chunk = stuff_to_crack.substr(0, j);
- pieces += chunk;
- stuff_to_crack = stuff_to_crack.substr(chunk.length);
- if (stuff_to_crack.length)
- pieces += '" "';
- }
- }
-
- outfile.WriteLine("#define " + keys[i] + " " + pieces);
- }
-
- if (VCVERS >= 1800) {
- outfile.WriteLine("");
- outfile.WriteLine("#define HAVE_ACOSH 1");
- outfile.WriteLine("#define HAVE_ASINH 1");
- outfile.WriteLine("#define HAVE_ATANH 1");
- }
-
-
- outfile.Close();
-}
-
-function generate_phpize()
-{
- STDOUT.WriteLine("Generating phpize");
- dest = get_define("BUILD_DIR") + '/devel';
-
- if (!FSO.FolderExists(dest)) {
- FSO.CreateFolder(dest);
- }
-
- var MF = FSO.CreateTextFile(dest + "/phpize.js", true);
- var DEPS = FSO.CreateTextFile(dest + "/ext_deps.js", true);
-
- prefix = get_define("PHP_PREFIX");
- prefix = prefix.replace(new RegExp("/", "g"), "\\");
- prefix = prefix.replace(new RegExp("\\\\", "g"), "\\\\");
- MF.WriteLine("var PHP_PREFIX=" + '"' + prefix + '"');
- MF.WriteLine("var PHP_ZTS=" + '"' + (PHP_ZTS.toLowerCase() == "yes" ? "Yes" : "No") + '"');
- MF.WriteLine("var VC_VERSION=" + VCVERS);
- MF.WriteLine("var PHP_VERSION=" + PHP_VERSION);
- MF.WriteLine("var PHP_MINOR_VERSION=" + PHP_MINOR_VERSION);
- MF.WriteLine("var PHP_RELEASE_VERSION=" + PHP_RELEASE_VERSION);
- MF.WriteBlankLines(1);
- MF.WriteLine("/* Genereted extensions list with mode (static/shared) */");
-
- var count = extensions_enabled.length;
- for (i in extensions_enabled) {
- out = "PHP_" + extensions_enabled[i][0].toUpperCase() + "_SHARED=" + (extensions_enabled[i][1] == 'shared' ? 'true' : 'false') + ";";
- DEPS.WriteLine("PHP_" + extensions_enabled[i][0].toUpperCase() + "=true;");
- DEPS.WriteLine(out);
- MF.WriteLine(out);
- }
-
- MF.WriteBlankLines(2);
- MF.WriteLine("/* Genereted win32/build/phpize.js.in */");
- MF.WriteBlankLines(1);
- MF.Write(file_get_contents("win32/build/phpize.js.in"));
- MF.Close();
- DEPS.Close();
-
- /* Generate flags file */
- /* spit out variable definitions */
- CJ = FSO.CreateTextFile(dest + "/config.phpize.js");
-
- CJ.WriteLine("var PHP_ZTS =" + '"' + PHP_ZTS + '"');
- CJ.WriteLine("var PHP_DLL_LIB =" + '"' + get_define('PHPLIB') + '"');
- CJ.WriteLine("var PHP_DLL =" + '"' + get_define('PHPDLL') + '"');
- CJ.WriteBlankLines(1);
- CJ.Close();
-}
-
-function generate_makefile()
-{
- STDOUT.WriteLine("Generating Makefile");
- var MF = FSO.CreateTextFile("Makefile", true);
-
- MF.WriteLine("# Generated by configure.js");
- /* spit out variable definitions */
- var keys = (new VBArray(configure_subst.Keys())).toArray();
- var i;
- MF.WriteLine("PHP_SRC_DIR =" + PHP_SRC_DIR);
- for (i in keys) {
- // The trailing space is needed to prevent the trailing backslash
- // that is part of the build dir flags (CFLAGS_BD_XXX) from being
- // seen as a line continuation character
- MF.WriteLine(keys[i] + "=" +
- //word_wrap_and_indent(1, configure_subst.Item(keys[i]), ' \\', '\t') + " "
- configure_subst.Item(keys[i]) + " "
- );
- MF.WriteBlankLines(1);
- }
-
- MF.WriteBlankLines(1);
- if (MODE_PHPIZE) {
- var TF = FSO.OpenTextFile(PHP_DIR + "/script/Makefile.phpize", 1);
- } else {
- var TF = FSO.OpenTextFile("win32/build/Makefile", 1);
- }
-
- MF.Write(TF.ReadAll());
-
- MF.WriteLine("build-headers:");
- MF.WriteLine(" @if not exist $(BUILD_DIR_DEV)\\include mkdir $(BUILD_DIR_DEV)\\include >nul");
- MF.WriteLine(" @for %D in ($(INSTALL_HEADERS_DIR)) do @if not exist $(BUILD_DIR_DEV)\\include\\%D mkdir $(BUILD_DIR_DEV)\\include\\%D >nul");
- for (i in headers_install) {
- if (headers_install[i][2] != "") {
- MF.WriteLine(" @if not exist $(BUILD_DIR_DEV)\\include\\" + headers_install[i][2] + " mkdir $(BUILD_DIR_DEV)\\include\\" +
- headers_install[i][2] + ">nul");
- MF.WriteLine(" @copy " + headers_install[i][0] + " " + "$(BUILD_DIR_DEV)\\include\\" + headers_install[i][2] + " /y >nul");
- }
- }
- MF.WriteLine(" @for %D in ($(INSTALL_HEADERS_DIR)) do @copy %D*.h $(BUILD_DIR_DEV)\\include\\%D /y >nul");
- if (MODE_PHPIZE) {
- MF.WriteBlankLines(1);
- MF.WriteLine("build-bins:");
- for (var i in extensions_enabled) {
- var lib = "php_" + extensions_enabled[i][0] + ".lib";
- var dll = "php_" + extensions_enabled[i][0] + ".dll";
- MF.WriteLine(" @copy $(BUILD_DIR)\\" + lib + " $(BUILD_DIR_DEV)\\lib");
- MF.WriteLine(" @copy $(BUILD_DIR)\\" + dll + " $(PHP_PREFIX)");
- }
- } else {
- MF.WriteBlankLines(1);
- MF.WriteLine("build-ext-libs:");
- MF.WriteLine(" @if not exist $(BUILD_DIR_DEV)\\lib mkdir $(BUILD_DIR_DEV)\\lib >nul");
- for (var i in extensions_enabled) {
- var lib;
-
- lib = "php_" + extensions_enabled[i][0] + "*.lib";
-
- if ('shared' == extensions_enabled[i][1]) {
- MF.WriteLine(" @if exist $(BUILD_DIR)\\" + lib + " copy $(BUILD_DIR)\\" + lib + " $(BUILD_DIR_DEV)\\lib");
- }
- }
- }
- TF.Close();
-
- MF.WriteBlankLines(2);
-
- MFO.Close();
- TF = FSO.OpenTextFile("Makefile.objects", 1);
- if (!TF.AtEndOfStream) {
- MF.Write(TF.ReadAll());
- }
- TF.Close();
-
- MF.Close();
-}
-
-function ADD_FLAG(name, flags, target)
-{
- if (target != null) {
- name = target.toUpperCase() + "_" + name;
- }
- if (configure_subst.Exists(name)) {
- var curr_flags = configure_subst.Item(name);
-
- if (curr_flags.indexOf(flags) >= 0) {
- return;
- }
-
- flags = curr_flags + " " + flags;
- configure_subst.Remove(name);
- }
- configure_subst.Add(name, flags);
-}
-
-function get_define(name)
-{
- if (configure_subst.Exists(name)) {
- return configure_subst.Item(name);
- }
- return "";
-}
-
-// Add a .def to the core to export symbols
-function ADD_DEF_FILE(name)
-{
- if (!configure_subst.Exists("PHPDEF")) {
- DEFINE("PHPDEF", "$(BUILD_DIR)\\$(PHPDLL).def");
- ADD_FLAG("PHP_LDFLAGS", "/def:$(PHPDEF)");
- }
- ADD_FLAG("PHP_DLL_DEF_SOURCES", name);
-}
-
-function AC_DEFINE(name, value, comment, quote)
-{
- if (quote == null) {
- quote = true;
- }
- if (quote && typeof(value) == "string") {
- value = '"' + value.replace(new RegExp('(["\\\\])', "g"), '\\$1') + '"';
- } else if (value.length == 0) {
- value = '""';
- }
- var item = new Array(value, comment);
- if (configure_hdr.Exists(name)) {
- var orig_item = configure_hdr.Item(name);
- STDOUT.WriteLine("AC_DEFINE[" + name + "]=" + value + ": is already defined to " + orig_item[0]);
- } else {
- configure_hdr.Add(name, item);
- }
-}
-
-function MESSAGE(msg)
-{
- STDOUT.WriteLine("" + msg);
-}
-
-function ERROR(msg)
-{
- STDERR.WriteLine("ERROR: " + msg);
- WScript.Quit(3);
-}
-
-function WARNING(msg)
-{
- STDERR.WriteLine("WARNING: " + msg);
- STDERR.WriteBlankLines(1);
-}
-
-function copy_and_subst(srcname, destname, subst_array)
-{
- if (!FSO.FileExists(srcname)) {
- srcname = configure_module_dirname + "\\" + srcname;
- destname = configure_module_dirname + "\\" + destname;
- }
-
- var content = file_get_contents(srcname);
- var i;
-
- for (i = 0; i < subst_array.length; i+=2) {
- var re = subst_array[i];
- var rep = subst_array[i+1];
-
- content = content.replace(re, rep);
- }
-
- var f = FSO.CreateTextFile(destname, true);
- f.Write(content);
- f.Close();
-}
-
-// glob using simple filename wildcards
-// returns an array of matches that are found
-// in the filesystem
-function glob(path_pattern)
-{
- var path_parts = path_pattern.replace(new RegExp("/", "g"), "\\").split("\\");
- var p;
- var base = "";
- var is_pat_re = /\*/;
-
-//STDOUT.WriteLine("glob: " + path_pattern);
-
- if (FSO.FileExists(path_pattern)) {
- return new Array(path_pattern);
- }
-
- // first, build as much as possible that doesn't have a pattern
- for (p = 0; p < path_parts.length; p++) {
- if (path_parts[p].match(is_pat_re))
- break;
- if (p)
- base += "\\";
- base += path_parts[p];
- }
-
- return _inner_glob(base, p, path_parts);
-}
-
-function _inner_glob(base, p, parts)
-{
- var pat = parts[p];
- var full_name = base + "\\" + pat;
- var re = null;
- var items = null;
-
- if (p == parts.length) {
- return false;
- }
-
-//STDOUT.WriteLine("inner: base=" + base + " p=" + p + " pat=" + pat);
-
- if (FSO.FileExists(full_name)) {
- if (p < parts.length - 1) {
- // we didn't reach the full extent of the pattern
- return false;
- }
- return new Array(full_name);
- }
-
- if (FSO.FolderExists(full_name) && p == parts.length - 1) {
- // we have reached the end of the pattern; no need to recurse
- return new Array(full_name);
- }
-
- // Convert the pattern into a regexp
- re = new RegExp("^" + pat.replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\?/g, '.') + "$", "i");
-
- items = new Array();
-
- if (!FSO.FolderExists(base)) {
- return false;
- }
-
- var folder = FSO.GetFolder(base);
- var fc = null;
- var subitems = null;
- var item_name = null;
- var j;
-
- fc = new Enumerator(folder.SubFolders);
- for (; !fc.atEnd(); fc.moveNext()) {
- item_name = FSO.GetFileName(fc.item());
-
- if (item_name.match(re)) {
- // got a match; if we are at the end of the pattern, just add these
- // things to the items array
- if (p == parts.length - 1) {
- items[items.length] = fc.item();
- } else {
- // we should recurse and do more matches
- subitems = _inner_glob(base + "\\" + item_name, p + 1, parts);
- if (subitems) {
- for (j = 0; j < subitems.length; j++) {
- items[items.length] = subitems[j];
- }
- }
- }
- }
- }
-
- // if we are at the end of the pattern, we should match
- // files too
- if (p == parts.length - 1) {
- fc = new Enumerator(folder.Files);
- for (; !fc.atEnd(); fc.moveNext()) {
- item_name = FSO.GetFileName(fc.item());
- if (item_name.match(re)) {
- items[items.length] = fc.item();
- }
- }
- }
-
- if (items.length == 0)
- return false;
-
- return items;
-}
-
-function PHP_INSTALL_HEADERS(dir, headers_list)
-{
- headers_list = headers_list.split(new RegExp("\\s+"));
- headers_list.sort();
- if (dir.length > 0 && dir.substr(dir.length - 1) != '/' && dir.substr(dir.length - 1) != '\\') {
- dir += '/';
- }
- dir = dir.replace(new RegExp("/", "g"), "\\");
-
- for (i in headers_list) {
- found = false;
- src = headers_list[i];
- src = src.replace(new RegExp("/", "g"), "\\");
- isdir = FSO.FolderExists(dir + src);
- isfile = FSO.FileExists(dir + src);
- if (isdir) {
- if (src.length > 0 && src.substr(src.length - 1) != '/' && src.substr(src.length - 1) != '\\') {
- src += '\\';
- }
- headers_install[headers_install.length] = [dir + src, 'dir',''];
- ADD_FLAG("INSTALL_HEADERS_DIR", dir + src);
- found = true;
- } else if (isfile) {
- dirname = FSO.GetParentFolderName(dir + src);
- headers_install[headers_install.length] = [dir + src, 'file', dirname];
- ADD_FLAG("INSTALL_HEADERS", dir + src);
- found = true;
- } else {
- path = configure_module_dirname + "\\"+ src;
- isdir = FSO.FolderExists(path);
- isfile = FSO.FileExists(path);
- if (isdir) {
- if (src.length > 0 && src.substr(src.length - 1) != '/' && src.substr(src.length - 1) != '\\') {
- src += '\\';
- }
- headers_install[headers_install.length] = [path, 'dir',''];
- ADD_FLAG("INSTALL_HEADERS_DIR", path);
- } else if (isfile) {
- dirname = FSO.GetParentFolderName(path);
- headers_install[headers_install.length] = [path, 'file', dir];
- ADD_FLAG("INSTALL_HEADERS", dir + src);
- found = true;
- }
- }
-
- if (found == false) {
- STDOUT.WriteLine(headers_list);
- ERROR("Cannot find header " + dir + src);
- }
- }
-}
-
-// for snapshot builders, this option will attempt to enable everything
-// and you can then build everything, ignoring fatal errors within a module
-// by running "nmake snap"
-PHP_SNAPSHOT_BUILD = "no";
-if (!MODE_PHPIZE) {
- ARG_ENABLE('snapshot-build', 'Build a snapshot; turns on everything it can and ignores build errors', 'no');
-
- // one-shot build optimizes build by asking compiler to build
- // several objects at once, reducing overhead of starting new
- // compiler processes.
- ARG_ENABLE('one-shot', 'Optimize for fast build - best for release and snapshot builders, not so hot for edit-and-rebuild hacking', 'no');
-}
-
+// Utils for configure script +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2008 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Wez Furlong <wez@thebrainroom.com> | + +----------------------------------------------------------------------+ +*/ + +// $Id: confutils.js,v 1.60.2.1.2.8.2.33 2009-05-29 07:43:07 kalle Exp $ + +var STDOUT = WScript.StdOut; +var STDERR = WScript.StdErr; +var WshShell = WScript.CreateObject("WScript.Shell"); +var FSO = WScript.CreateObject("Scripting.FileSystemObject"); +var MFO = null; +var SYSTEM_DRIVE = WshShell.Environment("Process").Item("SystemDrive"); +var PROGRAM_FILES = WshShell.Environment("Process").Item("ProgramFiles"); +var PROGRAM_FILESx86 = WshShell.Environment("Process").Item("ProgramFiles(x86)"); +var VCINSTALLDIR = WshShell.Environment("Process").Item("VCINSTALLDIR"); +var PHP_SRC_DIR=FSO.GetParentFolderName(WScript.ScriptFullName); + +var VS_TOOLSET = true; +var CLANG_TOOLSET = false; +var ICC_TOOLSET = false; +var VCVERS = -1; +var CLANGVERS = -1; +var INTELVERS = -1; +var COMPILER_NUMERIC_VERSION = -1; +var COMPILER_NAME = "unknown"; + +var WINVER = "0x0600"; /* Vista */ + +// There's a minimum requirement for re2c.. +var MINRE2C = "0.13.4"; + +/* Store the enabled extensions (summary + QA check) */ +var extensions_enabled = new Array(); + +/* Store the SAPI enabled (summary + QA check) */ +var sapi_enabled = new Array(); + +/* Store the headers to install */ +var headers_install = new Array(); + +/* Mapping CL version > human readable name */ +var VC_VERSIONS = new Array(); +VC_VERSIONS[1200] = 'MSVC6 (Visual C++ 6.0)'; +VC_VERSIONS[1300] = 'MSVC7 (Visual C++ 2002)'; +VC_VERSIONS[1310] = 'MSVC7.1 (Visual C++ 2003)'; +VC_VERSIONS[1400] = 'MSVC8 (Visual C++ 2005)'; +VC_VERSIONS[1500] = 'MSVC9 (Visual C++ 2008)'; +VC_VERSIONS[1600] = 'MSVC10 (Visual C++ 2010)'; +VC_VERSIONS[1700] = 'MSVC11 (Visual C++ 2012)'; +VC_VERSIONS[1800] = 'MSVC12 (Visual C++ 2013)'; +/* XXX update after the final rename */ +VC_VERSIONS[1900] = 'MSVC14 (Visual C++ CTP14)'; + +var VC_VERSIONS_SHORT = new Array(); +VC_VERSIONS_SHORT[1200] = 'VC6'; +VC_VERSIONS_SHORT[1300] = 'VC7'; +VC_VERSIONS_SHORT[1310] = 'VC7.1'; +VC_VERSIONS_SHORT[1400] = 'VC8'; +VC_VERSIONS_SHORT[1500] = 'VC9'; +VC_VERSIONS_SHORT[1600] = 'VC10'; +VC_VERSIONS_SHORT[1700] = 'VC11'; +VC_VERSIONS_SHORT[1800] = 'VC12'; +VC_VERSIONS_SHORT[1900] = 'VC14'; + +if (PROGRAM_FILES == null) { + PROGRAM_FILES = "C:\\Program Files"; +} + +if (MODE_PHPIZE) { + if (!FSO.FileExists("config.w32")) { + STDERR.WriteLine("Must be run from the root of the extension source"); + WScript.Quit(10); + } +} else { + if (!FSO.FileExists("README.GIT-RULES")) { + STDERR.WriteLine("Must be run from the root of the php source"); + WScript.Quit(10); + } +} + +var CWD = WshShell.CurrentDirectory; + +if (typeof(CWD) == "undefined") { + CWD = FSO.GetParentFolderName(FSO.GetAbsolutePathName("README.GIT-RULES")); +} + +/* defaults; we pick up the precise versions from configure.in */ +var PHP_VERSION = 5; +var PHP_MINOR_VERSION = 0; +var PHP_RELEASE_VERSION = 0; +var PHP_EXTRA_VERSION = ""; +var PHP_VERSION_STRING = "5.0.0"; + +function get_version_numbers() +{ + var cin = file_get_contents("configure.in"); + + if (cin.match(new RegExp("PHP_MAJOR_VERSION=(\\d+)"))) { + PHP_VERSION = RegExp.$1; + } + if (cin.match(new RegExp("PHP_MINOR_VERSION=(\\d+)"))) { + PHP_MINOR_VERSION = RegExp.$1; + } + if (cin.match(new RegExp("PHP_RELEASE_VERSION=(\\d+)"))) { + PHP_RELEASE_VERSION = RegExp.$1; + } + PHP_VERSION_STRING = PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION; + + if (cin.match(new RegExp("PHP_EXTRA_VERSION=\"([^\"]+)\""))) { + PHP_EXTRA_VERSION = RegExp.$1; + if (PHP_EXTRA_VERSION.length) { + PHP_VERSION_STRING += PHP_EXTRA_VERSION; + } + } + DEFINE('PHP_VERSION_STRING', PHP_VERSION_STRING); +} + +configure_args = new Array(); +configure_subst = WScript.CreateObject("Scripting.Dictionary"); + +configure_hdr = WScript.CreateObject("Scripting.Dictionary"); +build_dirs = new Array(); + +extension_include_code = ""; +extension_module_ptrs = ""; + +if (!MODE_PHPIZE) { + get_version_numbers(); +} + +/* execute a command and return the output as a string */ +function execute(command_line) +{ + var e = WshShell.Exec(command_line); + var ret = ""; + + ret = e.StdOut.ReadAll(); + +//STDOUT.WriteLine("command " + command_line); +//STDOUT.WriteLine(ret); + + return ret; +} + +function probe_binary(EXE, what) +{ + // tricky escapes to get stderr redirection to work + var command = 'cmd /c ""' + EXE; + if (what == "version") { + command = command + '" -v"'; + } + var version = execute(command + '" 2>&1"'); + + if (what == "64") { + if (version.match(/x64/)) { + return 1; + } + } else { + if (version.match(/(\d+\.\d+(\.\d+)?(\.\d+)?)/)) { + return RegExp.$1; + } + } + return 0; +} + +function condense_path(path) +{ + path = FSO.GetAbsolutePathName(path); + + if (path.substr(0, CWD.length).toLowerCase() + == CWD.toLowerCase() && + (path.charCodeAt(CWD.length) == 92 || path.charCodeAt(CWD.length) == 47)) { + return path.substr(CWD.length + 1); + } + + var a = CWD.split("\\"); + var b = path.split("\\"); + var i, j; + + for (i = 0; i < b.length; i++) { + if (a[i].toLowerCase() == b[i].toLowerCase()) + continue; + if (i > 0) { + /* first difference found */ + path = ""; + for (j = 0; j < a.length - i; j++) { + path += "..\\"; + } + for (j = i; j < b.length; j++) { + path += b[j]; + if (j < b.length - 1) + path += "\\"; + } + return path; + } + /* on a different drive */ + break; + } + + return path; +} + +function ConfigureArg(type, optname, helptext, defval) +{ + var opptype = type == "enable" ? "disable" : "without"; + + if (defval == "yes" || defval == "yes,shared") { + this.arg = "--" + opptype + "-" + optname; + this.imparg = "--" + type + "-" + optname; + } else { + this.arg = "--" + type + "-" + optname; + this.imparg = "--" + opptype + "-" + optname; + } + + this.optname = optname; + this.helptext = helptext; + this.defval = defval; + this.symval = optname.toUpperCase().replace(new RegExp("-", "g"), "_"); + this.seen = false; + this.argval = defval; +} + +function ARG_WITH(optname, helptext, defval) +{ + configure_args[configure_args.length] = new ConfigureArg("with", optname, helptext, defval); +} + +function ARG_ENABLE(optname, helptext, defval) +{ + configure_args[configure_args.length] = new ConfigureArg("enable", optname, helptext, defval); +} + +function analyze_arg(argval) +{ + var ret = new Array(); + var shared = false; + + if (argval == "shared") { + shared = true; + argval = "yes"; + } else if (argval == null) { + /* nothing */ + } else if (arg_match = argval.match(new RegExp("^shared,(.*)"))) { + shared = true; + argval = arg_match[1]; + } else if (arg_match = argval.match(new RegExp("^(.*),shared$"))) { + shared = true; + argval = arg_match[1]; + } + + ret[0] = shared; + ret[1] = argval; + return ret; +} + +function word_wrap_and_indent(indent, text, line_suffix, indent_char) +{ + if (text == null) { + return ""; + } + + var words = text.split(new RegExp("\\s+", "g")); + var i = 0; + var ret_text = ""; + var this_line = ""; + var t; + var space = ""; + var lines = 0; + + if (line_suffix == null) { + line_suffix = ""; + } + + if (indent_char == null) { + indent_char = " "; + } + + for (i = 0; i < indent; i++) { + space += indent_char; + } + + for (i = 0; i < words.length; i++) { + if (this_line.length) { + t = this_line + " " + words[i]; + } else { + t = words[i]; + } + + if (t.length + indent > 78) { + if (lines++) { + ret_text += space; + } + ret_text += this_line + line_suffix + "\r\n"; + this_line = ""; + } + + if (this_line.length) { + this_line += " " + words[i]; + } else { + this_line = words[i]; + } + } + + if (this_line.length) { + if (lines) + ret_text += space; + ret_text += this_line; + } + + return ret_text; +} + +function conf_process_args() +{ + var i, j; + var configure_help_mode = false; + var analyzed = false; + var nice = "cscript /nologo configure.js "; + var disable_all = false; + + args = WScript.Arguments; + for (i = 0; i < args.length; i++) { + arg = args(i); + nice += ' "' + arg + '"'; + if (arg == "--help") { + configure_help_mode = true; + break; + } + if (arg == "--disable-all") { + disable_all = true; + continue; + } + + // If it is --foo=bar, split on the equals sign + arg = arg.split("=", 2); + argname = arg[0]; + if (arg.length > 1) { + argval = arg[1]; + } else { + argval = null; + } + + // Find the arg + found = false; + for (j = 0; j < configure_args.length; j++) { + if (argname == configure_args[j].imparg || argname == configure_args[j].arg) { + found = true; + + arg = configure_args[j]; + arg.seen = true; + + analyzed = analyze_arg(argval); + + /* Force shared when called after phpize */ + if (MODE_PHPIZE) { + shared = "shared"; + } else { + shared = analyzed[0]; + } + argval = analyzed[1]; + + if (argname == arg.imparg) { + /* we matched the implicit, or default arg */ + if (argval == null) { + argval = arg.defval; + } + } else { + /* we matched the non-default arg */ + if (argval == null) { + argval = arg.defval == "no" ? "yes" : "no"; + } + } + + arg.argval = argval; + eval("PHP_" + arg.symval + " = argval;"); + eval("PHP_" + arg.symval + "_SHARED = shared;"); + break; + } + } + if (!found) { + STDERR.WriteLine("Unknown option " + argname + "; please try configure.js --help for a list of valid options"); + WScript.Quit(2); + } + } + + if (configure_help_mode) { + STDOUT.WriteLine(word_wrap_and_indent(0, +"Options that enable extensions and SAPI will accept \ +'yes' or 'no' as a parameter. They also accept 'shared' \ +as a synonym for 'yes' and request a shared build of that \ +module. Not all modules can be built as shared modules; \ +configure will display [shared] after the module name if \ +can be built that way. \ +" + )); + STDOUT.WriteBlankLines(1); + + // Measure width to pretty-print the output + max_width = 0; + for (i = 0; i < configure_args.length; i++) { + arg = configure_args[i]; + if (arg.arg.length > max_width) + max_width = arg.arg.length; + } + + for (i = 0; i < configure_args.length; i++) { + arg = configure_args[i]; + + n = max_width - arg.arg.length; + pad = " "; + for (j = 0; j < n; j++) { + pad += " "; + } + STDOUT.WriteLine(" " + arg.arg + pad + word_wrap_and_indent(max_width + 5, arg.helptext)); + } + WScript.Quit(1); + } + + var snapshot_build_exclusions = new Array( + 'debug', 'crt-debug', 'lzf-better-compression', + 'php-build', 'snapshot-template', 'ereg', + 'pcre-regex', 'fastcgi', 'force-cgi-redirect', + 'path-info-check', 'zts', 'ipv6', 'memory-limit', + 'zend-multibyte', 'fd-setsize', 'memory-manager', + 't1lib', 'pgi', 'pgo' + ); + var force; + + // Now set any defaults we might have missed out earlier + for (i = 0; i < configure_args.length; i++) { + arg = configure_args[i]; + if (arg.seen) + continue; + analyzed = analyze_arg(arg.defval); + shared = analyzed[0]; + argval = analyzed[1]; + + // Don't trust a default "yes" answer for a non-core module + // in a snapshot build + if (PHP_SNAPSHOT_BUILD != "no" && argval == "yes" && !shared) { + + force = true; + for (j = 0; j < snapshot_build_exclusions.length; j++) { + if (snapshot_build_exclusions[j] == arg.optname) { + force = false; + break; + } + } + + if (force) { + /* now check if it is a core module */ + force = false; + for (j = 0; j < core_module_list.length; j++) { + if (core_module_list[j] == arg.optname) { + force = true; + break; + } + } + + if (!force) { + STDOUT.WriteLine("snapshot: forcing " + arg.arg + " shared"); + shared = true; + } + } + } + + if (PHP_SNAPSHOT_BUILD != "no" && argval == "no") { + force = true; + for (j = 0; j < snapshot_build_exclusions.length; j++) { + if (snapshot_build_exclusions[j] == arg.optname) { + force = false; + break; + } + } + if (force) { + STDOUT.WriteLine("snapshot: forcing " + arg.optname + " on"); + argval = "yes"; + shared = true; + } + } + + if (disable_all) { + force = true; + for (j = 0; j < snapshot_build_exclusions.length; j++) { + if (snapshot_build_exclusions[j] == arg.optname) { + force = false; + break; + } + } + if (force) { + if (arg.defval == '') { + argval = ''; + } else { + argval = "no"; + } + shared = false; + } + } + + eval("PHP_" + arg.symval + " = argval;"); + eval("PHP_" + arg.symval + "_SHARED = shared;"); + } + + MFO = FSO.CreateTextFile("Makefile.objects", true); + + STDOUT.WriteLine("Saving configure options to config.nice.bat"); + var nicefile = FSO.CreateTextFile("config.nice.bat", true); + nicefile.WriteLine(nice + " %*"); + nicefile.Close(); + + AC_DEFINE('CONFIGURE_COMMAND', nice, "Configure line"); +} + +function DEFINE(name, value) +{ + if (configure_subst.Exists(name)) { + configure_subst.Remove(name); + } + configure_subst.Add(name, value); +} + +// Searches a set of paths for a file; +// returns the dir in which the file was found, +// true if it was found in the default env path, +// or false if it was not found at all. +// env_name is the optional name of an env var +// specifying the default path to search +function search_paths(thing_to_find, explicit_path, env_name) +{ + var i, found = false, place = false, file, env; + + STDOUT.Write("Checking for " + thing_to_find + " ... "); + + thing_to_find = thing_to_find.replace(new RegExp("/", "g"), "\\"); + + if (explicit_path != null) { + if (typeof(explicit_path) == "string") { + explicit_path = explicit_path.split(";"); + } + + for (i = 0; i < explicit_path.length; i++) { + file = glob(explicit_path[i] + "\\" + thing_to_find); + if (file) { + found = true; + place = file[0]; + place = place.substr(0, place.length - thing_to_find.length - 1); + break; + } + } + } + + if (!found && env_name != null) { + env = WshShell.Environment("Process").Item(env_name); + env = env.split(";"); + for (i = 0; i < env.length; i++) { + file = glob(env[i] + "\\" + thing_to_find); + if (file) { + found = true; + place = true; + break; + } + } + } + + if (found && place == true) { + STDOUT.WriteLine(" <in default path>"); + } else if (found) { + STDOUT.WriteLine(" " + place); + } else { + STDOUT.WriteLine(" <not found>"); + } + return place; +} + +function PATH_PROG(progname, additional_paths, symbol) +{ + var exe; + var place; + var cyg_path = PHP_CYGWIN + "\\bin;" + PHP_CYGWIN + "\\usr\\local\\bin"; + var php_build_bin_path = PHP_PHP_BUILD + "\\bin" + + exe = progname + ".exe"; + + if (additional_paths == null) { + additional_paths = cyg_path; + } else { + additional_paths += ";" + cyg_path; + } + + additional_paths = additional_paths + ";" + php_build_bin_path; + + place = search_paths(exe, additional_paths, "PATH"); + + if (place == true) { + place = exe; + } else if (place != false) { + place = place + "\\" + exe; + } + + if (place) { + if (symbol == null) { + symbol = progname.toUpperCase(); + } + DEFINE(symbol, place); + } + return place; +} + +function find_pattern_in_path(pattern, path) +{ + if (path == null) { + return false; + } + + var dirs = path.split(';'); + var i; + var items; + + for (i = 0; i < dirs.length; i++) { + items = glob(dirs[i] + "\\" + pattern); + if (items) { + return condense_path(items[0]); + } + } + return false; +} + +function CHECK_LIB(libnames, target, path_to_check, common_name) +{ + STDOUT.Write("Checking for library " + libnames + " ... "); + + if (common_name == null && target != null) { + common_name = target; + } + + if (path_to_check == null) { + path_to_check = ""; + } + + // if they specified a common name for the package that contains + // the library, tag some useful defaults on to the end of the + // path to be searched + if (common_name != null) { + path_to_check += ";" + PHP_PHP_BUILD + "\\" + common_name + "*"; + path_to_check += ";" + PHP_PHP_BUILD + "\\lib\\" + common_name + "*"; + path_to_check += ";..\\" + common_name + "*"; + } + + // Determine target for build flags + if (target == null) { + target = ""; + } else { + target = "_" + target.toUpperCase(); + } + + // Expand path to include general dirs + path_to_check += ";" + php_usual_lib_suspects; + + // It is common practice to put libs under one of these dir names + var subdirs = new Array(PHP_DEBUG == "yes" ? "Debug" : (PHP_DEBUG_PACK == "yes"?"Release_Dbg":"Release"), "lib", "libs", "libexec"); + + // libnames can be ; separated list of accepted library names + libnames = libnames.split(';'); + + // for debug builds, lib may have _debug appended, we want that first + if (PHP_DEBUG == "yes") { + var length = libnames.length; + for (var i = 0; i < length; i++) { + var name = new String(libnames[i]); + rExp = /.lib$/i; + name = name.replace(rExp,"_debug.lib"); + libnames.unshift(name); + } + } + + var i, j, k, libname; + var location = false; + var path = path_to_check.split(';'); + + for (i = 0; i < libnames.length; i++) { + libname = libnames[i]; + + for (k = 0; k < path.length; k++) { + location = glob(path[k] + "\\" + libname); + if (location) { + location = location[0]; + break; + } + for (j = 0; j < subdirs.length; j++) { + location = glob(path[k] + "\\" + subdirs[j] + "\\" + libname); + if (location) { + location = location[0]; + break; + } + } + if (location) + break; + } + + if (location) { + location = condense_path(location); + var libdir = FSO.GetParentFolderName(location); + libname = FSO.GetFileName(location); + ADD_FLAG("LDFLAGS" + target, '/libpath:"' + libdir + '" '); + ADD_FLAG("LIBS" + target, libname); + + STDOUT.WriteLine(location); + + return location; + } + + // Check in their standard lib path + location = find_pattern_in_path(libname, WshShell.Environment("Process").Item("LIB")); + + if (location) { + location = condense_path(location); + libname = FSO.GetFileName(location); + ADD_FLAG("LIBS" + target, libname); + + STDOUT.WriteLine("<in LIB path> " + libname); + return location; + } + + // Check in their general extra libs path + location = find_pattern_in_path(libname, PHP_EXTRA_LIBS); + if (location) { + location = condense_path(location); + libname = FSO.GetFileName(location); + ADD_FLAG("LIBS" + target, libname); + STDOUT.WriteLine("<in extra libs path>"); + return location; + } + } + + STDOUT.WriteLine("<not found>"); + + return false; +} + +function OLD_CHECK_LIB(libnames, target, path_to_check) +{ + if (target == null) { + target = ""; + } else { + target = "_" + target.toUpperCase(); + } + + if (path_to_check == null) { + path_to_check = php_usual_lib_suspects; + } else { + path_to_check += ";" + php_usual_lib_suspects; + } + var have = 0; + var p; + var i; + var libname; + + var subdir = PHP_DEBUG == "yes" ? "Debug" : (PHP_DEBUG_PACK == "yes"?"Release_Dbg":"Release"); + + libnames = libnames.split(';'); + for (i = 0; i < libnames.length; i++) { + libname = libnames[i]; + p = search_paths(libname, path_to_check, "LIB"); + + if (!p) { + p = search_paths(subdir + "\\" + libname, path_to_check, "LIB"); + if (p) { + p += "\\" + subdir; + } + } + + if (typeof(p) == "string") { + ADD_FLAG("LDFLAGS" + target, '/libpath:"' + p + '" '); + ADD_FLAG("LIBS" + target, libname); + have = 1; + } else if (p == true) { + ADD_FLAG("LIBS" + target, libname); + have = 1; + } else { + /* not found in the defaults or the explicit paths, + * so check the general extra libs; if we find + * it here, no need to add another /libpath: for it as we + * already have it covered, but we need to add the lib + * to LIBS_XXX */ + if (false != search_paths(libname, PHP_EXTRA_LIBS, null)) { + ADD_FLAG("LIBS" + target, libname); + have = 1; + } + } + + if (have) { + break; + } + } + +// AC_DEFINE("HAVE_" + header_name.toUpperCase().replace(new RegExp("/\\\\-\.", "g"), "_"), have); + + return have; + +} + +function CHECK_FUNC_IN_HEADER(header_name, func_name, path_to_check, add_to_flag) +{ + var c = false; + var sym; + + STDOUT.Write("Checking for " + func_name + " in " + header_name + " ... "); + + c = GREP_HEADER(header_name, func_name, path_to_check); + + sym = func_name.toUpperCase(); + sym = sym.replace(new RegExp("[\\\\/\.-]", "g"), "_"); + + if (typeof(add_to_flag) == "undefined") { + AC_DEFINE("HAVE_" + sym, c ? 1 : 0); + } else { + ADD_FLAG(add_to_flag, "/DHAVE_" + sym + "=" + (c ? "1" : "0")); + } + + if (c) { + STDOUT.WriteLine("OK"); + return c; + } + STDOUT.WriteLine("No"); + return false; +} + +function GREP_HEADER(header_name, regex, path_to_check) +{ + var c = false; + + if (FSO.FileExists(path_to_check + "\\" + header_name)) { + c = file_get_contents(path_to_check + "\\" + header_name); + } + + if (!c) { + /* look in the include path */ + + var p = search_paths(header_name, path_to_check, "INCLUDE"); + if (typeof(p) == "string") { + c = file_get_contents(p); + } else if (p == false) { + p = search_paths(header_name, PHP_EXTRA_INCLUDES, null); + if (typeof(p) == "string") { + c = file_get_contents(p); + } + } + if (!c) { + return false; + } + } + + if (typeof(regex) == "string") { + regex = new RegExp(regex); + } + + if (c.match(regex)) { + /* caller can now use RegExp.$1 etc. to get at patterns */ + return true; + } + return false; +} + +function CHECK_HEADER_ADD_INCLUDE(header_name, flag_name, path_to_check, use_env, add_dir_part, add_to_flag_only) +{ + var dir_part_to_add = ""; + + if (use_env == null) { + use_env = true; + } + + // if true, add the dir part of the header_name to the include path + if (add_dir_part == null) { + add_dir_part = false; + } else if (add_dir_part) { + var basename = FSO.GetFileName(header_name); + dir_part_to_add = "\\" + header_name.substr(0, header_name.length - basename.length - 1); + } + + if (path_to_check == null) { + path_to_check = php_usual_include_suspects; + } else { + path_to_check += ";" + php_usual_include_suspects; + } + + var p = search_paths(header_name, path_to_check, use_env ? "INCLUDE" : null); + var have = 0; + var sym; + + if (typeof(p) == "string") { + ADD_FLAG(flag_name, '/I "' + p + dir_part_to_add + '" '); + } else if (p == false) { + /* not found in the defaults or the explicit paths, + * so check the general extra includes; if we find + * it here, no need to add another /I for it as we + * already have it covered, unless we are adding + * the dir part.... */ + p = search_paths(header_name, PHP_EXTRA_INCLUDES, null); + if (typeof(p) == "string" && add_dir_part) { + ADD_FLAG(flag_name, '/I "' + p + dir_part_to_add + '" '); + } + } + have = p ? 1 : 0 + + sym = header_name.toUpperCase(); + sym = sym.replace(new RegExp("[\\\\/\.-]", "g"), "_"); + + if (typeof(add_to_flag_only) == "undefined" && + flag_name.match(new RegExp("^CFLAGS_(.*)$"))) { + add_to_flag_only = true; + } + + if (typeof(add_to_flag_only) != "undefined") { + ADD_FLAG(flag_name, "/DHAVE_" + sym + "=" + have); + } else { + AC_DEFINE("HAVE_" + sym, have, "have the " + header_name + " header file"); + } + + return p; +} + +/* emits rule to generate version info for a SAPI + * or extension. Returns the name of the .res file + * that will be generated */ +function generate_version_info_resource(makefiletarget, basename, creditspath, sapi) +{ + var resname = makefiletarget + ".res"; + var res_desc = makefiletarget; + var res_prod_name = "PHP " + makefiletarget; + var credits; + var thanks = ""; + var logo = ""; + var debug = ""; + var project_url = "http://www.php.net"; + var project_header = creditspath + "/php_" + basename + ".h"; + var versioning = ""; + + if (sapi) { + var internal_name = basename.toUpperCase() + " SAPI"; + } else { + var internal_name = basename.toUpperCase() + " extension"; + } + + if (FSO.FileExists(creditspath + '/CREDITS')) { + credits = FSO.OpenTextFile(creditspath + '/CREDITS', 1); + res_desc = credits.ReadLine(); + try { + thanks = credits.ReadLine(); + } catch (e) { + thanks = null; + } + if (thanks == null) { + thanks = ""; + } else { + thanks = "Thanks to " + thanks; + } + credits.Close(); + } + + if (creditspath.match(new RegExp("pecl"))) { + /* PECL project url - this will eventually work correctly for all */ + project_url = "http://pecl.php.net/" + basename; + + /* keep independent versioning PECL-specific for now */ + if (FSO.FileExists(project_header)) { + if (header = FSO.OpenTextFile(project_header, 1)) { + contents = header.ReadAll(); + /* allowed: x.x.x[a|b|-alpha|-beta][RCx][-dev] */ + if (contents.match(new RegExp('PHP_' + basename.toUpperCase() + '_VERSION(\\s+)"((\\d+\.\\d+(\.\\d+)?)((a|b)(\\d)?|\-[a-z]{3,5})?(RC\\d+)?(\-dev)?)'))) { + project_version = RegExp.$2; + file_version = RegExp.$3.split('.'); + if (!file_version[2]) { + file_version[2] = 0; + } + versioning = '\\"" /d EXT_FILE_VERSION=' + file_version[0] + ',' + file_version[1] + ',' + file_version[2] + ' /d EXT_VERSION="\\"' + project_version; + } + header.Close(); + } + } + } + + if (makefiletarget.match(new RegExp("\\.exe$"))) { + logo = " /d WANT_LOGO "; + } + + if (PHP_DEBUG != "no") { + debug = " /d _DEBUG"; + } + + /** + * Use user supplied template.rc if it exists + */ + if (FSO.FileExists(creditspath + '\\template.rc')) { + MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": " + creditspath + "\\template.rc"); + MFO.WriteLine("\t$(RC) /fo $(BUILD_DIR)\\" + resname + logo + debug + + ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' + + makefiletarget + '\\"" /d PRODUCT_NAME="\\"' + res_prod_name + + versioning + '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" ' + + creditspath + '\\template.rc'); + return resname; + } + if (MODE_PHPIZE) { + MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": $(PHP_DIR)\\build\\template.rc"); + MFO.WriteLine("\t$(RC) /I $(PHP_DIR)/include /n /fo $(BUILD_DIR)\\" + resname + logo + debug + + ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' + + makefiletarget + '\\"" /d URL="\\"' + project_url + + '\\"" /d INTERNAL_NAME="\\"' + internal_name + versioning + + '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" $(PHP_DIR)\\build\\template.rc'); + } else { + MFO.WriteLine("$(BUILD_DIR)\\" + resname + ": win32\\build\\template.rc"); + MFO.WriteLine("\t$(RC) /n /fo $(BUILD_DIR)\\" + resname + logo + debug + + ' /d FILE_DESCRIPTION="\\"' + res_desc + '\\"" /d FILE_NAME="\\"' + + makefiletarget + '\\"" /d URL="\\"' + project_url + + '\\"" /d INTERNAL_NAME="\\"' + internal_name + versioning + + '\\"" /d THANKS_GUYS="\\"' + thanks + '\\"" win32\\build\\template.rc'); + } + MFO.WriteBlankLines(1); + return resname; +} + +/* Check if PGO is enabled for given module. To disable PGO for a particular module, +define a global variable by the following name scheme before SAPI() or EXTENSION() call + var PHP_MYMODULE_PGO = false; */ +function is_pgo_desired(mod) +{ + var varname = "PHP_" + mod.toUpperCase() + "_PGO"; + + /* XXX enable PGO in phpize mode */ + if (MODE_PHPIZE) { + return false; + } + + /* don't disable if there's no mention of the varname */ + if (eval("typeof " + varname + " == 'undefined'")) { + return true; + } + + return eval("!!" + varname); +} + +function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir) +{ + var SAPI = sapiname.toUpperCase(); + var ldflags; + var resname; + var ld; + var manifest; + + if (typeof(obj_dir) == "undefined") { + sapiname_for_printing = configure_module_dirname; + } else { + sapiname_for_printing = configure_module_dirname + " (via " + obj_dir + ")"; + } + + STDOUT.WriteLine("Enabling SAPI " + sapiname_for_printing); + + MFO.WriteBlankLines(1); + MFO.WriteLine("# objects for SAPI " + sapiname); + MFO.WriteBlankLines(1); + + if (cflags) { + ADD_FLAG('CFLAGS_' + SAPI, cflags); + } + + ADD_SOURCES(configure_module_dirname, file_list, sapiname, obj_dir); + MFO.WriteBlankLines(1); + MFO.WriteLine("# SAPI " + sapiname); + MFO.WriteBlankLines(1); + + /* generate a .res file containing version information */ + resname = generate_version_info_resource(makefiletarget, sapiname, configure_module_dirname, true); + + MFO.WriteLine(makefiletarget + ": $(BUILD_DIR)\\" + makefiletarget); + MFO.WriteLine("\t@echo SAPI " + sapiname_for_printing + " build complete"); + if (MODE_PHPIZE) { + MFO.WriteLine("$(BUILD_DIR)\\" + makefiletarget + ": $(DEPS_" + SAPI + ") $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(BUILD_DIR)\\" + resname); + } else { + MFO.WriteLine("$(BUILD_DIR)\\" + makefiletarget + ": $(DEPS_" + SAPI + ") $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname); + } + + if (makefiletarget.match(new RegExp("\\.dll$"))) { + ldflags = "/dll $(LDFLAGS)"; + manifest = "-@$(_VC_MANIFEST_EMBED_DLL)"; + } else if (makefiletarget.match(new RegExp("\\.lib$"))) { + ldflags = "$(LDFLAGS)"; + ld = "$(MAKE_LIB)"; + } else { + ldflags = "$(LDFLAGS)"; + manifest = "-@$(_VC_MANIFEST_EMBED_EXE)"; + } + + if(is_pgo_desired(sapiname) && (PHP_PGI == "yes" || PHP_PGO != "no")) { + // Add compiler and link flags if PGO options are selected + if (PHP_DEBUG != "yes" && PHP_PGI == "yes") { + ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2"); + ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG:PGINSTRUMENT"); + } + else if (PHP_DEBUG != "yes" && PHP_PGO != "no") { + ADD_FLAG('CFLAGS_' + SAPI, "/GL /O2"); + ADD_FLAG('LDFLAGS_' + SAPI, "/LTCG:PGUPDATE"); + } + + ldflags += " /PGD:$(PGOPGD_DIR)\\" + makefiletarget.substring(0, makefiletarget.indexOf(".")) + ".pgd"; + } + + if (MODE_PHPIZE) { + if (ld) { + MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); + } else { + ld = '@"$(LINK)"'; + MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); + } + } else { + if (ld) { + MFO.WriteLine("\t" + ld + " /nologo /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LDFLAGS_" + SAPI + ") $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname); + } else { + ld = '@"$(LINK)"'; + MFO.WriteLine("\t" + ld + " /nologo " + " $(" + SAPI + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + SAPI + ") $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + makefiletarget + " " + ldflags + " $(LDFLAGS_" + SAPI + ")"); + } + } + + if (manifest) { + MFO.WriteLine("\t" + manifest); + } + + DEFINE('CFLAGS_' + SAPI + '_OBJ', '$(CFLAGS_' + SAPI + ')'); + + if (configure_module_dirname.match("pecl")) { + ADD_FLAG("PECL_TARGETS", makefiletarget); + } else { + ADD_FLAG("SAPI_TARGETS", makefiletarget); + } + + MFO.WriteBlankLines(1); + sapi_enabled[sapi_enabled.length] = [sapiname]; +} + +function ADD_DIST_FILE(filename) +{ + if (configure_module_dirname.match("pecl")) { + ADD_FLAG("PECL_EXTRA_DIST_FILES", filename); + } else { + ADD_FLAG("PHP_EXTRA_DIST_FILES", filename); + } +} + +function file_get_contents(filename) +{ + var f, c; + try { + f = FSO.OpenTextFile(filename, 1); + c = f.ReadAll(); + f.Close(); + return c; + } catch (e) { + STDOUT.WriteLine("Problem reading " + filename); + return false; + } +} + +// Add a dependency on another extension, so that +// the dependencies are built before extname +function ADD_EXTENSION_DEP(extname, dependson, optional) +{ + var EXT = extname.toUpperCase(); + var DEP = dependson.toUpperCase(); + var dep_present = false; + var dep_shared = false; + + try { + dep_present = eval("PHP_" + DEP); + + if (dep_present != "no") { + try { + dep_shared = eval("PHP_" + DEP + "_SHARED"); + } catch (e) { + dep_shared = false; + } + } + + } catch (e) { + dep_present = "no"; + } + + if (optional) { + if (dep_present == "no") { + MESSAGE("\t" + dependson + " not found: " + dependson + " support in " + extname + " disabled"); + return false; + } + } + + var ext_shared = eval("PHP_" + EXT + "_SHARED"); + + if (dep_shared) { + if (!ext_shared) { + if (optional) { + MESSAGE("\tstatic " + extname + " cannot depend on shared " + dependson + ": " + dependson + "support disabled"); + return false; + } + ERROR("static " + extname + " cannot depend on shared " + dependson); + } + + ADD_FLAG("LIBS_" + EXT, "php_" + dependson + ".lib"); + if (MODE_PHPIZE) { + ADD_FLAG("LDFLAGS_" + EXT, "/libpath:$(BUILD_DIR_DEV)\\lib"); + ADD_FLAG("DEPS_" + EXT, "$(BUILD_DIR_DEV)\\lib\\php_" + dependson + ".lib"); + } else { + ADD_FLAG("LDFLAGS_" + EXT, "/libpath:$(BUILD_DIR)"); + ADD_FLAG("DEPS_" + EXT, "$(BUILD_DIR)\\php_" + dependson + ".lib"); + } + + } else { + + if (dep_present == "no") { + if (ext_shared) { + WARNING(extname + " cannot be built: missing dependency, " + dependson + " not found"); + + var dllname = ' php_' + extname + '.dll'; + + if (!REMOVE_TARGET(dllname, 'EXT_TARGETS')) { + REMOVE_TARGET(dllname, 'PECL_TARGETS'); + } + + return false; + + } + + ERROR("Cannot build " + extname + "; " + dependson + " not enabled"); + return false; + } + } // dependency is statically built-in to PHP + return true; +} + +var static_pgo_enabled = false; + +function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) +{ + var objs = null; + var EXT = extname.toUpperCase(); + var extname_for_printing; + var ldflags; + + if (shared == null) { + eval("shared = PHP_" + EXT + "_SHARED;"); + } else { + eval("PHP_" + EXT + "_SHARED = shared;"); + } + + if (cflags == null) { + cflags = ""; + } + + if (typeof(obj_dir) == "undefined") { + extname_for_printing = configure_module_dirname; + } else { + extname_for_printing = configure_module_dirname + " (via " + obj_dir + ")"; + } + + if (shared) { + STDOUT.WriteLine("Enabling extension " + extname_for_printing + " [shared]"); + cflags = "/D COMPILE_DL_" + EXT + " /D " + EXT + "_EXPORTS=1 " + cflags; + ADD_FLAG("CFLAGS_PHP", "/D COMPILE_DL_" + EXT); + } else { + STDOUT.WriteLine("Enabling extension " + extname_for_printing); + } + + MFO.WriteBlankLines(1); + MFO.WriteLine("# objects for EXT " + extname); + MFO.WriteBlankLines(1); + + ADD_SOURCES(configure_module_dirname, file_list, extname, obj_dir); + + MFO.WriteBlankLines(1); + + if (shared) { + if (dllname == null) { + dllname = "php_" + extname + ".dll"; + } + var libname = dllname.substring(0, dllname.length-4) + ".lib"; + + var resname = generate_version_info_resource(dllname, extname, configure_module_dirname, false); + var ld = '@"$(LINK)"'; + + ldflags = ""; + if (is_pgo_desired(extname) && (PHP_PGI == "yes" || PHP_PGO != "no")) { + // Add compiler and link flags if PGO options are selected + if (PHP_DEBUG != "yes" && PHP_PGI == "yes") { + ADD_FLAG('LDFLAGS_' + EXT, "/LTCG:PGINSTRUMENT"); + } + else if (PHP_DEBUG != "yes" && PHP_PGO != "no") { + ADD_FLAG('LDFLAGS_' + EXT, "/LTCG:PGUPDATE"); + } + + ADD_FLAG('CFLAGS_' + EXT, "/GL /O2"); + + ldflags = " /PGD:$(PGOPGD_DIR)\\" + dllname.substring(0, dllname.indexOf(".")) + ".pgd"; + } + + MFO.WriteLine("$(BUILD_DIR)\\" + libname + ": $(BUILD_DIR)\\" + dllname); + MFO.WriteBlankLines(1); + if (MODE_PHPIZE) { + MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(DEPS_" + EXT + ") $(" + EXT + "_GLOBAL_OBJS) $(PHPLIB) $(BUILD_DIR)\\" + resname); + MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + dllname + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")"); + } else { + MFO.WriteLine("$(BUILD_DIR)\\" + dllname + ": $(DEPS_" + EXT + ") $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(BUILD_DIR)\\" + resname); + MFO.WriteLine("\t" + ld + " $(" + EXT + "_GLOBAL_OBJS) $(BUILD_DIR)\\$(PHPLIB) $(LIBS_" + EXT + ") $(LIBS) $(BUILD_DIR)\\" + resname + " /out:$(BUILD_DIR)\\" + dllname + ldflags + " $(DLL_LDFLAGS) $(LDFLAGS) $(LDFLAGS_" + EXT + ")"); + } + MFO.WriteLine("\t-@$(_VC_MANIFEST_EMBED_DLL)"); + MFO.WriteBlankLines(1); + + if (configure_module_dirname.match("pecl")) { + ADD_FLAG("PECL_TARGETS", dllname); + } else { + ADD_FLAG("EXT_TARGETS", dllname); + } + MFO.WriteLine(dllname + ": $(BUILD_DIR)\\" + dllname); + MFO.WriteLine("\t@echo EXT " + extname + " build complete"); + MFO.WriteBlankLines(1); + + DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_' + EXT + ')'); + } else { + ADD_FLAG("STATIC_EXT_OBJS", "$(" + EXT + "_GLOBAL_OBJS)"); + ADD_FLAG("STATIC_EXT_LIBS", "$(LIBS_" + EXT + ")"); + ADD_FLAG("STATIC_EXT_LDFLAGS", "$(LDFLAGS_" + EXT + ")"); + ADD_FLAG("STATIC_EXT_CFLAGS", "$(CFLAGS_" + EXT + ")"); + if (is_pgo_desired(extname) && (PHP_PGI == "yes" || PHP_PGO != "no")) { + if (!static_pgo_enabled) { + if (PHP_DEBUG != "yes" && PHP_PGI == "yes") { + ADD_FLAG('STATIC_EXT_LDFLAGS', "/LTCG:PGINSTRUMENT"); + } + else if (PHP_DEBUG != "yes" && PHP_PGO != "no") { + ADD_FLAG('STATIC_EXT_LDFLAGS', "/LTCG:PGUPDATE"); + } + + ADD_FLAG("STATIC_EXT_CFLAGS", "/GL /O2"); + static_pgo_enabled = true; + } + } + + /* find the header that declares the module pointer, + * so we can include it in internal_functions.c */ + var ext_dir = FSO.GetFolder(configure_module_dirname); + var fc = new Enumerator(ext_dir.Files); + var re = /\.h$/; + var s, c; + for (; !fc.atEnd(); fc.moveNext()) { + s = fc.item() + ""; + if (s.match(re)) { + c = file_get_contents(s); + if (c.match("phpext_")) { + extension_include_code += '#include "' + configure_module_dirname + '/' + FSO.GetFileName(s) + '"\r\n'; + } + } + } + + extension_module_ptrs += '\tphpext_' + extname + '_ptr,\r\n'; + + DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_PHP) $(CFLAGS_' + EXT + ')'); + } + if (MODE_PHPIZE && FSO.FileExists(PHP_DIR + "/include/main/config.pickle.h")) { + cflags = "/FI main/config.pickle.h " + cflags; + } + ADD_FLAG("CFLAGS_" + EXT, cflags); + + extensions_enabled[extensions_enabled.length] = [extname, shared ? 'shared' : 'static']; +} + +function ADD_SOURCES(dir, file_list, target, obj_dir) +{ + var i; + var tv; + var src, obj, sym, flags; + + if (target == null) { + target = "php"; + } + + sym = target.toUpperCase() + "_GLOBAL_OBJS"; + flags = "CFLAGS_" + target.toUpperCase() + '_OBJ'; + + if (configure_subst.Exists(sym)) { + tv = configure_subst.Item(sym); + } else { + tv = ""; + } + + file_list = file_list.split(new RegExp("\\s+")); + file_list.sort(); + + var re = new RegExp("\.[a-z0-9A-Z]+$"); + + dir = dir.replace(new RegExp("/", "g"), "\\"); + var objs_line = ""; + var srcs_line = ""; + + var sub_build = "$(BUILD_DIR)\\"; + + /* if module dir is not a child of the main source dir, + * we need to tweak it; we should have detected such a + * case in condense_path and rewritten the path to + * be relative. + * This probably breaks for non-sibling dirs, but that + * is not a problem as buildconf only checks for pecl + * as either a child or a sibling */ + if (obj_dir == null) { + var build_dir = dir.replace(new RegExp("^..\\\\"), ""); + var mangle_dir = build_dir.replace(new RegExp("[\\\\/.-]", "g"), "_"); + var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase(); + } + else { + var build_dir = obj_dir.replace(new RegExp("^..\\\\"), ""); + var mangle_dir = build_dir.replace(new RegExp("[\\\\/.-]", "g"), "_"); + var bd_flags_name = "CFLAGS_BD_" + mangle_dir.toUpperCase(); + } + + var dirs = build_dir.split("\\"); + var i, d = ""; + for (i = 0; i < dirs.length; i++) { + d += dirs[i]; + build_dirs[build_dirs.length] = d; + d += "\\"; + } + sub_build += d; + + + DEFINE(bd_flags_name, " /Fp" + sub_build + " /FR" + sub_build + " "); + + for (i in file_list) { + src = file_list[i]; + obj = src.replace(re, ".obj"); + tv += " " + sub_build + obj; + + if (!PHP_MP_DISABLED) { + if (i > 0) { + objs_line += " " + sub_build + obj; + srcs_line += " " + dir + "\\" + src; + } else { + objs_line = sub_build + obj; + srcs_line = dir + "\\" + src; + } + } else { + MFO.WriteLine(sub_build + obj + ": " + dir + "\\" + src); + + if (PHP_ANALYZER == "pvs") { + MFO.WriteLine("\t@\"$(PVS_STUDIO)\" --cl-params $(" + flags + ") $(CFLAGS) $(" + bd_flags_name + ") /c " + dir + "\\" + src + " --source-file " + dir + "\\" + src + + " --cfg PVS-Studio.conf --errors-off \"V122 V117 V111\" "); + } + MFO.WriteLine("\t@$(CC) $(" + flags + ") $(CFLAGS) $(" + bd_flags_name + ") /c " + dir + "\\" + src + " /Fo" + sub_build + obj); + } + } + + if (!PHP_MP_DISABLED) { + MFO.WriteLine(objs_line + ": " + srcs_line); + MFO.WriteLine("\t$(CC) $(" + flags + ") $(CFLAGS) /Fo" + sub_build + " $(" + bd_flags_name + ") /c " + srcs_line); + } + + DEFINE(sym, tv); +} + +function REMOVE_TARGET(dllname, flag) +{ + var dllname = dllname.replace(/\s/g, ""); + var EXT = dllname.replace(/php_(\S+)\.dll/, "$1").toUpperCase(); + var php_flags = configure_subst.Item("CFLAGS_PHP"); + + if (configure_subst.Exists(flag)) { + var targets = configure_subst.Item(flag); + + if (targets.match(dllname)) { + configure_subst.Remove(flag); + targets = targets.replace(dllname, ""); + targets = targets.replace(/\s+/, " "); + targets = targets.replace(/\s$/, ""); + configure_subst.Add(flag, targets); + configure_hdr.Add("HAVE_" + EXT, new Array(0, "")); + configure_subst.Item("CFLAGS_PHP") = php_flags.replace(" /D COMPILE_DL_" + EXT, ""); + extensions_enabled.pop(); + return true; + } + } + return false; +} + +function generate_internal_functions() +{ + var infile, outfile; + var indata; + + STDOUT.WriteLine("Generating main/internal_functions.c"); + + infile = FSO.OpenTextFile("main/internal_functions.c.in", 1); + indata = infile.ReadAll(); + infile.Close(); + + indata = indata.replace("@EXT_INCLUDE_CODE@", extension_include_code); + indata = indata.replace("@EXT_MODULE_PTRS@", extension_module_ptrs); + + if (FSO.FileExists("main/internal_functions.c")) { + var origdata = file_get_contents("main/internal_functions.c"); + + if (origdata == indata) { + STDOUT.WriteLine("\t[content unchanged; skipping]"); + return; + } + } + + outfile = FSO.CreateTextFile("main/internal_functions.c", true); + outfile.Write(indata); + outfile.Close(); +} + +function output_as_table(header, ar_out) +{ + var l = header.length; + var cols = 80; + var fixedlength = ""; + var t = 0; + var i,j,k,m; + var out = "| "; + var min = new Array(l); + var max = new Array(l); + + if (!!ar_out[0] && l != ar_out[0].length) { + STDOUT.WriteLine("Invalid header argument, can't output the table " + l + " " + ar_out[0].length ); + return; + } + + for (j=0; j < l; j++) { + var tmax, tmin; + + /*Figure out the max length per column */ + tmin = 0; + tmax = 0; + for (k = 0; k < ar_out.length; k++) { + if(typeof ar_out[k][j] != 'undefined') { + var t = ar_out[k][j].length; + if (t > tmax) tmax = t; + else if (t < tmin) tmin = t; + } + } + if (tmax > header[j].length) { + max[j] = tmax; + } else { + max[j] = header[j].length; + } + if (tmin < header[j].length) { + min[j] = header[j].length; + } + } + + sep = ""; + k = 0; + for (i = 0; i < l; i++) { + k += max[i] + 3; + } + k++; + + for (j=0; j < k; j++) { + sep += "-"; + } + + STDOUT.WriteLine(sep); + out = "|"; + for (j=0; j < l; j++) { + out += " " + header[j]; + for (var i = 0; i < (max[j] - header[j].length); i++){ + out += " "; + } + out += " |"; + } + STDOUT.WriteLine(out); + + STDOUT.WriteLine(sep); + + out = "|"; + for (i=0; i < ar_out.length; i++) { + line = ar_out[i]; + for (j=0; j < l; j++) { + out += " " + line[j]; + if(typeof line[j] != 'undefined') { + for (var k = 0; k < (max[j] - line[j].length); k++){ + out += " "; + } + } + out += " |"; + } + STDOUT.WriteLine(out); + out = "|"; + } + + STDOUT.WriteLine(sep); +} + +function write_summary() +{ + var ar = new Array(); + + STDOUT.WriteBlankLines(2); + + STDOUT.WriteLine("Enabled extensions:"); + output_as_table(["Extension", "Mode"], extensions_enabled.sort()); + STDOUT.WriteBlankLines(2); + if (!MODE_PHPIZE) { + STDOUT.WriteLine("Enabled SAPI:"); + output_as_table(["Sapi Name"], sapi_enabled); + STDOUT.WriteBlankLines(2); + } + ar[0] = ['Build type', PHP_DEBUG == "yes" ? "Debug" : "Release"]; + ar[1] = ['Thread Safety', PHP_ZTS == "yes" ? "Yes" : "No"]; + ar[2] = ['Compiler', COMPILER_NAME]; + ar[3] = ['Architecture', X64 ? 'x64' : 'x86']; + if (PHP_PGO == "yes") { + ar[4] = ['Optimization', "PGO"]; + } else if (PHP_PGI == "yes") { + ar[4] = ['Optimization', "PGI"]; + } else { + ar[4] = ['Optimization', PHP_DEBUG == "yes" ? "disabled" : "PGO disabled"]; + } + if (PHP_ANALYZER == "vs") { + ar[5] = ['Static analyzer', 'Visual Studio']; + } else if (PHP_ANALYZER == "pvs") { + ar[5] = ['Static analyzer', 'PVS-Studio']; + } else { + ar[5] = ['Static analyzer', 'disabled']; + } + + output_as_table(["",""], ar); + STDOUT.WriteBlankLines(2); +} + +function generate_files() +{ + var i, dir, bd, last; + + STDOUT.WriteBlankLines(1); + STDOUT.WriteLine("Creating build dirs..."); + dir = get_define("BUILD_DIR"); + build_dirs.sort(); + last = null; + + if (!FSO.FolderExists(dir)) { + FSO.CreateFolder(dir); + } + + for (i = 0; i < build_dirs.length; i++) { + bd = FSO.BuildPath(dir, build_dirs[i]); + if (bd == last) { + continue; + } + last = bd; + + build_dir = get_define('BUILD_DIR'); + build_dir = build_dir.replace(new RegExp("\\\\", "g"), "\\\\"); + if (build_dir.substr(build_dir.Length - 2, 2) != '\\\\') { + build_dir += '\\\\'; + } + ADD_FLAG("BUILD_DIRS_SUB", bd.replace(new RegExp(build_dir), '')); + + if (!FSO.FolderExists(bd)) { + FSO.CreateFolder(bd); + } + } + + STDOUT.WriteLine("Generating files..."); + generate_makefile(); + if (!MODE_PHPIZE) { + generate_internal_functions(); + generate_config_h(); + generate_phpize(); + } else { + generate_config_pickle_h(); + generate_ext_pickle(); + } + STDOUT.WriteLine("Done."); + STDOUT.WriteBlankLines(1); + write_summary(); + + if (PHP_SNAPSHOT_BUILD != "no") { + STDOUT.WriteLine("Type 'nmake snap' to build a PHP snapshot"); + } else { + STDOUT.WriteLine("Type 'nmake' to build PHP"); + } +} + +function generate_ext_pickle() +{ + var content; + var DEPS = null; + var dest; + var deps_lines = new Array(); + + var build_var_name = function(name) { + return "PHP_" + name.toUpperCase(); + } + + STDOUT.WriteLine("Generating pickle deps"); + dest = PHP_DIR + "/script/"; + + if (!FSO.FolderExists(dest)) { + FSO.CreateFolder(dest); + } + + if (FSO.FileExists(dest + "/ext_pickle.js")) { + DEPS = FSO.OpenTextFile(dest + "/ext_pickle.js", 1); + + while (!DEPS.AtEndOfStream) { + var ln = DEPS.ReadLine(); + var found = false; + + for (var i in extensions_enabled) { + var reg0 = new RegExp(build_var_name(extensions_enabled[i][0]) + "\s*=.+", "g"); + var reg1 = new RegExp(build_var_name(extensions_enabled[i][0]) + "_SHARED" + "\s*=.+", "g"); + + if (ln.match(reg1) || ln.match(reg0)) { + found = true; + break; + } + } + + if (!found) { + deps_lines.push(ln); + } + } + } + + for (var i in extensions_enabled) { + deps_lines.push(build_var_name(extensions_enabled[i][0]) + "=true;"); + deps_lines.push(build_var_name(extensions_enabled[i][0]) + "_SHARED=" + (extensions_enabled[i][1] == 'shared' ? 'true' : 'false') + ";"); + } + + if (!!DEPS) { + DEPS.Close(); + DEPS = null; + } + + /* Replace the ext_pickle.js with the new content */ + DEPS = FSO.CreateTextFile(dest + "/ext_pickle.js", true); + + for (var j in deps_lines) { + DEPS.WriteLine(deps_lines[j]); + } + + DEPS.Close(); +} + +function generate_config_pickle_h() +{ + var outfile = null; + var lines = new Array(); + var keys = (new VBArray(configure_hdr.Keys())).toArray(); + dest = PHP_DIR + "/include/main"; + + var ignore_key = function(key) { + var ignores = [ "CONFIGURE_COMMAND", "PHP_COMPILER_ID", "COMPILER", "ARCHITECTURE", "HAVE_STRNLEN", "PHP_DIR" ]; + + for (var k in ignores) { + if (ignores[k] == key) { + return true; + } + } + + return false; + } + + + STDOUT.WriteLine("Generating main/config.pickle.h"); + + if (FSO.FileExists(dest + "/config.pickle.h")) { + outfile = FSO.OpenTextFile(dest + "/config.pickle.h", 1); + + while (!outfile.AtEndOfStream) { + var found = false; + var ln = outfile.ReadLine(); + + for (var i in keys) { + var reg = new RegExp("#define[\s ]+" + keys[i] + "[\s ]*.*", "g"); + + if (ln.match(reg)) { + found = true; + break; + } + } + + if (!found) { + lines.push(ln); + } + } + } + + for (var i in keys) { + var item = configure_hdr.Item(keys[i]); + + if (ignore_key(keys[i])) { + continue; + } + + /* XXX fix comment handling */ + /*if (!lines[j].match(/^#define.+/g)) { + continue; + }*/ + + lines.push("#define " + keys[i] + " " + item[0]); + } + + if (outfile) { + outfile.Close(); + outfile = null; + } + + outfile = FSO.CreateTextFile(dest + "/config.pickle.h", true); + + for (var k in lines) { + outfile.WriteLine(lines[k]); + } + + outfile.Close(); +} + +function generate_config_h() +{ + var infile, outfile; + var indata; + var prefix; + + prefix = PHP_PREFIX.replace(new RegExp("\\\\", "g"), "\\\\"); + + STDOUT.WriteLine("Generating main/config.w32.h"); + + infile = FSO.OpenTextFile("win32/build/config.w32.h.in", 1); + indata = infile.ReadAll(); + infile.Close(); + + outfile = FSO.CreateTextFile("main/config.w32.h", true); + + indata = indata.replace(new RegExp("@PREFIX@", "g"), prefix); + outfile.Write(indata); + + var keys = (new VBArray(configure_hdr.Keys())).toArray(); + var i, j; + var item; + var pieces, stuff_to_crack, chunk; + + outfile.WriteBlankLines(1); + outfile.WriteLine("/* values determined by configure.js */"); + + for (i in keys) { + item = configure_hdr.Item(keys[i]); + outfile.WriteBlankLines(1); + pieces = item[0]; + + if (item[1] != undefined) { + outfile.WriteLine("/* " + item[1] + " */"); + } + + if (typeof(pieces) == "string" && pieces.charCodeAt(0) == 34) { + /* quoted string have a maximal length of 2k under vc. + * solution is to crack them and let the compiler concat + * them implicitly */ + stuff_to_crack = pieces; + pieces = ""; + + while (stuff_to_crack.length) { + j = 65; + while (stuff_to_crack.charCodeAt(j) != 32 && j < stuff_to_crack.length) + j++; + + chunk = stuff_to_crack.substr(0, j); + pieces += chunk; + stuff_to_crack = stuff_to_crack.substr(chunk.length); + if (stuff_to_crack.length) + pieces += '" "'; + } + } + + outfile.WriteLine("#define " + keys[i] + " " + pieces); + } + + if (VS_TOOLSET && VCVERS >= 1800) { + outfile.WriteLine(""); + outfile.WriteLine("#define HAVE_ACOSH 1"); + outfile.WriteLine("#define HAVE_ASINH 1"); + outfile.WriteLine("#define HAVE_ATANH 1"); + } + + + outfile.Close(); +} + +function generate_phpize() +{ + STDOUT.WriteLine("Generating phpize"); + dest = get_define("BUILD_DIR") + '/devel'; + + if (!FSO.FolderExists(dest)) { + FSO.CreateFolder(dest); + } + + var MF = FSO.CreateTextFile(dest + "/phpize.js", true); + var DEPS = FSO.CreateTextFile(dest + "/ext_deps.js", true); + + prefix = get_define("PHP_PREFIX"); + prefix = prefix.replace(new RegExp("/", "g"), "\\"); + prefix = prefix.replace(new RegExp("\\\\", "g"), "\\\\"); + MF.WriteLine("var PHP_PREFIX=" + '"' + prefix + '"'); + MF.WriteLine("var PHP_ZTS=" + '"' + (PHP_ZTS.toLowerCase() == "yes" ? "Yes" : "No") + '"'); + MF.WriteLine("var VC_VERSION=" + VCVERS); + MF.WriteLine("var PHP_VERSION=" + PHP_VERSION); + MF.WriteLine("var PHP_MINOR_VERSION=" + PHP_MINOR_VERSION); + MF.WriteLine("var PHP_RELEASE_VERSION=" + PHP_RELEASE_VERSION); + MF.WriteBlankLines(1); + MF.WriteLine("/* Genereted extensions list with mode (static/shared) */"); + + var count = extensions_enabled.length; + for (i in extensions_enabled) { + out = "PHP_" + extensions_enabled[i][0].toUpperCase() + "_SHARED=" + (extensions_enabled[i][1] == 'shared' ? 'true' : 'false') + ";"; + DEPS.WriteLine("PHP_" + extensions_enabled[i][0].toUpperCase() + "=true;"); + DEPS.WriteLine(out); + MF.WriteLine(out); + } + + MF.WriteBlankLines(2); + MF.WriteLine("/* Genereted win32/build/phpize.js.in */"); + MF.WriteBlankLines(1); + MF.Write(file_get_contents("win32/build/phpize.js.in")); + MF.Close(); + DEPS.Close(); + + /* Generate flags file */ + /* spit out variable definitions */ + CJ = FSO.CreateTextFile(dest + "/config.phpize.js"); + + CJ.WriteLine("var PHP_ZTS =" + '"' + PHP_ZTS + '"'); + CJ.WriteLine("var PHP_DLL_LIB =" + '"' + get_define('PHPLIB') + '"'); + CJ.WriteLine("var PHP_DLL =" + '"' + get_define('PHPDLL') + '"'); + CJ.WriteBlankLines(1); + CJ.Close(); +} + +function generate_makefile() +{ + STDOUT.WriteLine("Generating Makefile"); + var MF = FSO.CreateTextFile("Makefile", true); + + MF.WriteLine("# Generated by configure.js"); + /* spit out variable definitions */ + var keys = (new VBArray(configure_subst.Keys())).toArray(); + var i; + MF.WriteLine("PHP_SRC_DIR =" + PHP_SRC_DIR); + for (i in keys) { + // The trailing space is needed to prevent the trailing backslash + // that is part of the build dir flags (CFLAGS_BD_XXX) from being + // seen as a line continuation character + MF.WriteLine(keys[i] + "=" + + //word_wrap_and_indent(1, configure_subst.Item(keys[i]), ' \\', '\t') + " " + configure_subst.Item(keys[i]) + " " + ); + MF.WriteBlankLines(1); + } + + MF.WriteBlankLines(1); + if (MODE_PHPIZE) { + var TF = FSO.OpenTextFile(PHP_DIR + "/script/Makefile.phpize", 1); + } else { + var TF = FSO.OpenTextFile("win32/build/Makefile", 1); + } + + MF.Write(TF.ReadAll()); + + MF.WriteLine("build-headers:"); + MF.WriteLine(" @if not exist $(BUILD_DIR_DEV)\\include mkdir $(BUILD_DIR_DEV)\\include >nul"); + MF.WriteLine(" @for %D in ($(INSTALL_HEADERS_DIR)) do @if not exist $(BUILD_DIR_DEV)\\include\\%D mkdir $(BUILD_DIR_DEV)\\include\\%D >nul"); + for (i in headers_install) { + if (headers_install[i][2] != "") { + MF.WriteLine(" @if not exist $(BUILD_DIR_DEV)\\include\\" + headers_install[i][2] + " mkdir $(BUILD_DIR_DEV)\\include\\" + + headers_install[i][2] + ">nul"); + MF.WriteLine(" @copy " + headers_install[i][0] + " " + "$(BUILD_DIR_DEV)\\include\\" + headers_install[i][2] + " /y >nul"); + } + } + MF.WriteLine(" @for %D in ($(INSTALL_HEADERS_DIR)) do @copy %D*.h $(BUILD_DIR_DEV)\\include\\%D /y >nul"); + if (MODE_PHPIZE) { + MF.WriteBlankLines(1); + MF.WriteLine("build-bins:"); + for (var i in extensions_enabled) { + var lib = "php_" + extensions_enabled[i][0] + ".lib"; + var dll = "php_" + extensions_enabled[i][0] + ".dll"; + MF.WriteLine(" @copy $(BUILD_DIR)\\" + lib + " $(BUILD_DIR_DEV)\\lib"); + MF.WriteLine(" @copy $(BUILD_DIR)\\" + dll + " $(PHP_PREFIX)"); + } + } else { + MF.WriteBlankLines(1); + MF.WriteLine("build-ext-libs:"); + MF.WriteLine(" @if not exist $(BUILD_DIR_DEV)\\lib mkdir $(BUILD_DIR_DEV)\\lib >nul"); + for (var i in extensions_enabled) { + var lib; + + lib = "php_" + extensions_enabled[i][0] + "*.lib"; + + if ('shared' == extensions_enabled[i][1]) { + MF.WriteLine(" @if exist $(BUILD_DIR)\\" + lib + " copy $(BUILD_DIR)\\" + lib + " $(BUILD_DIR_DEV)\\lib"); + } + } + } + TF.Close(); + + MF.WriteBlankLines(2); + + MFO.Close(); + TF = FSO.OpenTextFile("Makefile.objects", 1); + if (!TF.AtEndOfStream) { + MF.Write(TF.ReadAll()); + } + TF.Close(); + + MF.Close(); +} + +function ADD_FLAG(name, flags, target) +{ + if (target != null) { + name = target.toUpperCase() + "_" + name; + } + if (configure_subst.Exists(name)) { + var curr_flags = configure_subst.Item(name); + + if (curr_flags.indexOf(flags) >= 0) { + return; + } + + flags = curr_flags + " " + flags; + configure_subst.Remove(name); + } + configure_subst.Add(name, flags); +} + +function get_define(name) +{ + if (configure_subst.Exists(name)) { + return configure_subst.Item(name); + } + return ""; +} + +// Add a .def to the core to export symbols +function ADD_DEF_FILE(name) +{ + if (!configure_subst.Exists("PHPDEF")) { + DEFINE("PHPDEF", "$(BUILD_DIR)\\$(PHPDLL).def"); + ADD_FLAG("PHP_LDFLAGS", "/def:$(PHPDEF)"); + } + ADD_FLAG("PHP_DLL_DEF_SOURCES", name); +} + +function AC_DEFINE(name, value, comment, quote) +{ + if (quote == null) { + quote = true; + } + if (quote && typeof(value) == "string") { + value = '"' + value.replace(new RegExp('(["\\\\])', "g"), '\\$1') + '"'; + } else if (typeof(value) != "undefined" && value.length == 0) { + value = '""'; + } + var item = new Array(value, comment); + if (configure_hdr.Exists(name)) { + var orig_item = configure_hdr.Item(name); + STDOUT.WriteLine("AC_DEFINE[" + name + "]=" + value + ": is already defined to " + orig_item[0]); + } else { + configure_hdr.Add(name, item); + } +} + +function MESSAGE(msg) +{ + STDOUT.WriteLine("" + msg); +} + +function ERROR(msg) +{ + STDERR.WriteLine("ERROR: " + msg); + WScript.Quit(3); +} + +function WARNING(msg) +{ + STDERR.WriteLine("WARNING: " + msg); + STDERR.WriteBlankLines(1); +} + +function copy_and_subst(srcname, destname, subst_array) +{ + if (!FSO.FileExists(srcname)) { + srcname = configure_module_dirname + "\\" + srcname; + destname = configure_module_dirname + "\\" + destname; + } + + var content = file_get_contents(srcname); + var i; + + for (i = 0; i < subst_array.length; i+=2) { + var re = subst_array[i]; + var rep = subst_array[i+1]; + + content = content.replace(re, rep); + } + + var f = FSO.CreateTextFile(destname, true); + f.Write(content); + f.Close(); +} + +// glob using simple filename wildcards +// returns an array of matches that are found +// in the filesystem +function glob(path_pattern) +{ + var path_parts = path_pattern.replace(new RegExp("/", "g"), "\\").split("\\"); + var p; + var base = ""; + var is_pat_re = /\*/; + +//STDOUT.WriteLine("glob: " + path_pattern); + + if (FSO.FileExists(path_pattern)) { + return new Array(path_pattern); + } + + // first, build as much as possible that doesn't have a pattern + for (p = 0; p < path_parts.length; p++) { + if (path_parts[p].match(is_pat_re)) + break; + if (p) + base += "\\"; + base += path_parts[p]; + } + + return _inner_glob(base, p, path_parts); +} + +function _inner_glob(base, p, parts) +{ + var pat = parts[p]; + var full_name = base + "\\" + pat; + var re = null; + var items = null; + + if (p == parts.length) { + return false; + } + +//STDOUT.WriteLine("inner: base=" + base + " p=" + p + " pat=" + pat); + + if (FSO.FileExists(full_name)) { + if (p < parts.length - 1) { + // we didn't reach the full extent of the pattern + return false; + } + return new Array(full_name); + } + + if (FSO.FolderExists(full_name) && p == parts.length - 1) { + // we have reached the end of the pattern; no need to recurse + return new Array(full_name); + } + + // Convert the pattern into a regexp + re = new RegExp("^" + pat.replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\?/g, '.') + "$", "i"); + + items = new Array(); + + if (!FSO.FolderExists(base)) { + return false; + } + + var folder = FSO.GetFolder(base); + var fc = null; + var subitems = null; + var item_name = null; + var j; + + fc = new Enumerator(folder.SubFolders); + for (; !fc.atEnd(); fc.moveNext()) { + item_name = FSO.GetFileName(fc.item()); + + if (item_name.match(re)) { + // got a match; if we are at the end of the pattern, just add these + // things to the items array + if (p == parts.length - 1) { + items[items.length] = fc.item(); + } else { + // we should recurse and do more matches + subitems = _inner_glob(base + "\\" + item_name, p + 1, parts); + if (subitems) { + for (j = 0; j < subitems.length; j++) { + items[items.length] = subitems[j]; + } + } + } + } + } + + // if we are at the end of the pattern, we should match + // files too + if (p == parts.length - 1) { + fc = new Enumerator(folder.Files); + for (; !fc.atEnd(); fc.moveNext()) { + item_name = FSO.GetFileName(fc.item()); + if (item_name.match(re)) { + items[items.length] = fc.item(); + } + } + } + + if (items.length == 0) + return false; + + return items; +} + +function PHP_INSTALL_HEADERS(dir, headers_list) +{ + headers_list = headers_list.split(new RegExp("\\s+")); + headers_list.sort(); + if (dir.length > 0 && dir.substr(dir.length - 1) != '/' && dir.substr(dir.length - 1) != '\\') { + dir += '/'; + } + dir = dir.replace(new RegExp("/", "g"), "\\"); + + for (i in headers_list) { + found = false; + src = headers_list[i]; + src = src.replace(new RegExp("/", "g"), "\\"); + isdir = FSO.FolderExists(dir + src); + isfile = FSO.FileExists(dir + src); + if (isdir) { + if (src.length > 0 && src.substr(src.length - 1) != '/' && src.substr(src.length - 1) != '\\') { + src += '\\'; + } + headers_install[headers_install.length] = [dir + src, 'dir','']; + ADD_FLAG("INSTALL_HEADERS_DIR", dir + src); + found = true; + } else if (isfile) { + dirname = FSO.GetParentFolderName(dir + src); + headers_install[headers_install.length] = [dir + src, 'file', dirname]; + ADD_FLAG("INSTALL_HEADERS", dir + src); + found = true; + } else { + path = configure_module_dirname + "\\"+ src; + isdir = FSO.FolderExists(path); + isfile = FSO.FileExists(path); + if (isdir) { + if (src.length > 0 && src.substr(src.length - 1) != '/' && src.substr(src.length - 1) != '\\') { + src += '\\'; + } + headers_install[headers_install.length] = [path, 'dir','']; + ADD_FLAG("INSTALL_HEADERS_DIR", path); + } else if (isfile) { + dirname = FSO.GetParentFolderName(path); + headers_install[headers_install.length] = [path, 'file', dir]; + ADD_FLAG("INSTALL_HEADERS", dir + src); + found = true; + } + } + + if (found == false) { + STDOUT.WriteLine(headers_list); + ERROR("Cannot find header " + dir + src); + } + } +} + +// for snapshot builders, this option will attempt to enable everything +// and you can then build everything, ignoring fatal errors within a module +// by running "nmake snap" +PHP_SNAPSHOT_BUILD = "no"; +if (!MODE_PHPIZE) { + ARG_ENABLE('snapshot-build', 'Build a snapshot; turns on everything it can and ignores build errors', 'no'); + + // one-shot build optimizes build by asking compiler to build + // several objects at once, reducing overhead of starting new + // compiler processes. + ARG_ENABLE('one-shot', 'Optimize for fast build - best for release and snapshot builders, not so hot for edit-and-rebuild hacking', 'no'); +} + + +function toolset_option_handle() +{ + if ("clang" == PHP_TOOLSET) { + VS_TOOLSET = false; + CLANG_TOOLSET = true; + ICC_TOOLSET = false; + } else if ("icc" == PHP_TOOLSET) { + VS_TOOLSET = false; + CLANG_TOOLSET = false; + ICC_TOOLSET = true; + } else { + /* Visual Studio is the default toolset. */ + PHP_TOOLSET = "no" == PHP_TOOLSET ? "vs" : PHP_TOOLSET; + if (!!PHP_TOOLSET && "vs" != PHP_TOOLSET) { + ERROR("Unsupported toolset '" + PHP_TOOLSET + "'"); + } + VS_TOOLSET = true; + CLANG_TOOLSET = false; + ICC_TOOLSET = false; + } +} + +function toolset_setup_compiler() +{ + PHP_CL = toolset_get_compiler(); + if (!PHP_CL) { + ERROR("Compiler not found"); + } + + COMPILER_NUMERIC_VERSION = toolset_get_compiler_version(); + COMPILER_NAME = toolset_get_compiler_name(); + + if (VS_TOOLSET) { + /* For the record here: */ + // 1200 is VC6 + // 1300 is vs.net 2002 + // 1310 is vs.net 2003 + // 1400 is vs.net 2005 + // 1500 is vs.net 2008 + // 1600 is vs.net 2010 + // Which version of the compiler do we have? + VCVERS = COMPILER_NUMERIC_VERSION; + + if (VCVERS < 1500) { + ERROR("Unsupported MS C++ Compiler, VC9 (2008) minimum is required"); + } + + AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version"); + DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]); + AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID"); + } else if (CLANG_TOOLSET) { + CLANGVERS = COMPILER_NUMERIC_VERSION; + + AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version"); + DEFINE("PHP_COMPILER_SHORT", "clang"); + AC_DEFINE('PHP_COMPILER_ID', "clang"); /* XXX something better were to write here */ + + } else if (ICC_TOOLSET) { + INTELVERS = COMPILER_NUMERIC_VERSION; + + AC_DEFINE('COMPILER', COMPILER_NAME, "Detected compiler version"); + DEFINE("PHP_COMPILER_SHORT", "icc"); + AC_DEFINE('PHP_COMPILER_ID', "icc"); /* XXX something better were to write here */ + } + STDOUT.WriteLine(" Detected compiler " + COMPILER_NAME); +} + +function toolset_setup_project_tools() +{ + PATH_PROG('nmake'); + + // we don't want to define LIB, as that will override the default library path + // that is set in that env var + PATH_PROG('lib', null, 'MAKE_LIB'); + if (!PATH_PROG('bison')) { + ERROR('bison is required') + } + + RE2C = PATH_PROG('re2c'); + if (RE2C) { + var intvers, intmin; + var pattern = /\./g; + + RE2CVERS = probe_binary(RE2C, "version"); + STDOUT.WriteLine(' Detected re2c version ' + RE2CVERS); + + intvers = RE2CVERS.replace(pattern, '') - 0; + intmin = MINRE2C.replace(pattern, '') - 0; + + if (intvers < intmin) { + STDOUT.WriteLine('WARNING: The minimum RE2C version requirement is ' + MINRE2C); + STDOUT.WriteLine('Parsers will not be generated. Upgrade your copy at http://sf.net/projects/re2c'); + DEFINE('RE2C', ''); + } else { + DEFINE('RE2C_FLAGS', ''); + } + } else { + STDOUT.WriteLine('Parsers will not be regenerated'); + } + PATH_PROG('zip'); + PATH_PROG('lemon'); + + // avoid picking up midnight commander from cygwin + PATH_PROG('mc', WshShell.Environment("Process").Item("PATH")); + + // Try locating manifest tool + if (VS_TOOLSET && VCVERS > 1200) { + PATH_PROG('mt', WshShell.Environment("Process").Item("PATH")); + } +} + +function toolset_get_compiler() +{ + if (VS_TOOLSET) { + return PATH_PROG('cl', null, 'PHP_CL') + } else if (CLANG_TOOLSET) { + return PATH_PROG('clang-cl', null, 'PHP_CL') + } else if (ICC_TOOLSET) { + return PATH_PROG('icl', null, 'PHP_CL') + } + + ERROR("Unsupported toolset"); +} + +function toolset_get_compiler_version() +{ + var version; + + if (VS_TOOLSET) { + version = probe_binary(PHP_CL).substr(0, 5).replace('.', ''); + + return version; + } else if (CLANG_TOOLSET) { + var command = 'cmd /c ""' + PHP_CL + '" -v"'; + var full = execute(command + '" 2>&1"'); + + if (full.match(/clang version ([\d\.]+) \((.*)\)/)) { + version = RegExp.$1; + version = version.replace(/\./g, ''); + version = version/100 < 1 ? version*10 : version; + + return version; + } + } else if (ICC_TOOLSET) { + var command = 'cmd /c ""' + PHP_CL + '" -v"'; + var full = execute(command + '" 2>&1"'); + + if (full.match(/Version (\d+\.\d+\.\d+)/)) { + version = RegExp.$1; + version = version.replace(/\./g, ''); + version = version/100 < 1 ? version*10 : version; + + return version; + } + } + + ERROR("Failed to parse compiler version or unsupported toolset"); +} + +function toolset_get_compiler_name() +{ + var version; + + if (VS_TOOLSET) { + version = probe_binary(PHP_CL).substr(0, 5).replace('.', ''); + return VC_VERSIONS[version]; + } else if (CLANG_TOOLSET || ICC_TOOLSET) { + var command = 'cmd /c ""' + PHP_CL + '" -v"'; + var full = execute(command + '" 2>&1"'); + + return full.split(/\n/)[0].replace(/\s/g, ' '); + } + + WARNING("Unsupported toolset"); +} + + +function toolset_is_64() +{ + if (VS_TOOLSET) { + return probe_binary(PHP_CL, 64); + } else if (CLANG_TOOLSET) { + /*var command = 'cmd /c ""' + PHP_CL + '" -v"'; + var full = execute(command + '" 2>&1"'); + + return null != full.match(/x86_64/);*/ + + /* Even executed within an environment setup with vcvars32.bat, + clang-cl doesn't recognize the arch toolset. But as it needs + the VS environment, checking the arch of cl.exe is correct. */ + return probe_binary(PATH_PROG('cl', null), 64); + } else if (ICC_TOOLSET) { + var command = 'cmd /c ""' + PHP_CL + '" -v"'; + var full = execute(command + '" 2>&1"'); + + return null != full.match(/Intel\(R\) 64/); + } + + ERROR("Unsupported toolset"); +} + + +function toolset_setup_linker() +{ + if (VS_TOOLSET) { + return PATH_PROG('link', WshShell.Environment("Process").Item("PATH")); + } else if (CLANG_TOOLSET) { + //return PATH_PROG('lld', WshShell.Environment("Process").Item("PATH"), "LINK"); + return PATH_PROG('link', WshShell.Environment("Process").Item("PATH")); + } else if (ICC_TOOLSET) { + return PATH_PROG('xilink', WshShell.Environment("Process").Item("PATH"), "LINK"); + } + + ERROR("Unsupported toolset"); +} + +function toolset_setup_common_cflags() +{ + // CFLAGS for building the PHP dll + DEFINE("CFLAGS_PHP", "/D _USRDLL /D PHP7DLLTS_EXPORTS /D PHP_EXPORTS \ + /D LIBZEND_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=" + WINVER); + + DEFINE('CFLAGS_PHP_OBJ', '$(CFLAGS_PHP) $(STATIC_EXT_CFLAGS)'); + + // General CFLAGS for building objects + DEFINE("CFLAGS", "/nologo $(BASE_INCLUDES) /D _WINDOWS \ + /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /W3 "); + + if (VS_TOOLSET) { + ADD_FLAG("CFLAGS", " /FD "); + + if (VCVERS < 1400) { + // Enable automatic precompiled headers + ADD_FLAG('CFLAGS', ' /YX '); + + if (PHP_DEBUG == "yes") { + // Set some debug/release specific options + ADD_FLAG('CFLAGS', ' /GZ '); + } + } + + if (VCVERS >= 1400) { + // fun stuff: MS deprecated ANSI stdio and similar functions + // disable annoying warnings. In addition, time_t defaults + // to 64-bit. Ask for 32-bit. + if (X64) { + ADD_FLAG('CFLAGS', ' /wd4996 '); + } else { + ADD_FLAG('CFLAGS', ' /wd4996 /D_USE_32BIT_TIME_T=1 '); + } + + if (PHP_DEBUG == "yes") { + // Set some debug/release specific options + ADD_FLAG('CFLAGS', ' /RTC1 '); + } + } + + } else if (CLANG_TOOLSET) { + if (X64) { + ADD_FLAG('CFLAGS', '-m64'); + } else { + ADD_FLAG('CFLAGS', '-m32'); + } + ADD_FLAG("CFLAGS", " /fallback "); + } +} + +function toolset_setup_common_ldlags() +{ + // General DLL link flags + DEFINE("DLL_LDFLAGS", "/dll "); + + // PHP DLL link flags + DEFINE("PHP_LDFLAGS", "$(DLL_LDFLAGS)"); + + if (VS_TOOLSET) { + if (VCVERS >= 1700) { + DEFINE("LDFLAGS", "/nologo "); + } else { + DEFINE("LDFLAGS", "/nologo /version:" + + PHP_VERSION + "." + PHP_MINOR_VERSION + "." + PHP_RELEASE_VERSION); + } + } else { + DEFINE("LDFLAGS", "/nologo "); + } +} + diff --git a/win32/php_stdint.h b/win32/php_stdint.h index 71aec2a358..e5e0efbb1d 100644 --- a/win32/php_stdint.h +++ b/win32/php_stdint.h @@ -33,6 +33,10 @@ #error "Use this header only with Microsoft Visual C++ compilers!" #endif // _MSC_VER ] +// Starting with vc14, many of the C11 features are now included, so we only +// need many of these typedefs and defines for older VS suites +#if _MSC_VER < 1900 + #ifndef _MSC_STDINT_H_ // [ #define _MSC_STDINT_H_ @@ -85,9 +89,6 @@ typedef __int64 int64_t; #ifndef uint8_t typedef unsigned __int8 uint8_t; #endif -#ifndef u_char -typedef unsigned __int8 u_char; -#endif typedef unsigned __int16 uint16_t; #ifndef uint32_t typedef unsigned __int32 uint32_t; @@ -254,3 +255,11 @@ static __inline int64_t llabs(int64_t i) #endif // _MSC_STDINT_H_ ] + +#else +#include <stdint.h> +#endif + +#ifndef u_char +typedef unsigned __int8 u_char; +#endif diff --git a/win32/time.h b/win32/time.h index d5d86eb1ed..8f39c0481c 100644 --- a/win32/time.h +++ b/win32/time.h @@ -28,7 +28,7 @@ struct itimerval { struct timeval it_value; /* current value */ }; -#ifndef timespec +#if !defined(timespec) && _MSC_VER < 1900 struct timespec { time_t tv_sec; /* seconds */ |