diff options
author | Dmitry Stogov <dmitry@zend.com> | 2015-02-13 22:20:39 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2015-02-13 22:20:39 +0300 |
commit | e10e151e9b92313a7085272c85bebf6c82017fce (patch) | |
tree | 6cac4100536c5e25143c55d1ab6b2f3b3dc81cf9 /Zend/zend_gc.c | |
parent | bc630ad6da0c6d7cf2d224dba8972499d5691c6b (diff) | |
download | php-git-e10e151e9b92313a7085272c85bebf6c82017fce.tar.gz |
Merged zend_array and HashTable into the single data structure.
Now each HashTable is also zend_array, so it's refcounted and may be a subject for Copy on Write
zend_array_dup() was changed to allocate and return HashTable, instead of taking preallocated HashTable as argument.
Diffstat (limited to 'Zend/zend_gc.c')
-rw-r--r-- | Zend/zend_gc.c | 49 |
1 files changed, 16 insertions, 33 deletions
diff --git a/Zend/zend_gc.c b/Zend/zend_gc.c index 947ddc84eb..13d3ee7f01 100644 --- a/Zend/zend_gc.c +++ b/Zend/zend_gc.c @@ -231,9 +231,7 @@ tail_call: for (i = 0; i < n; i++) { if (Z_REFCOUNTED(table[i])) { ref = Z_COUNTED(table[i]); - if (GC_TYPE(ref) != IS_ARRAY || (zend_array*)ref != &EG(symbol_table)) { - GC_REFCOUNT(ref)++; - } + GC_REFCOUNT(ref)++; if (GC_GET_COLOR(GC_INFO(ref)) != GC_BLACK) { if (!props && i == n - 1) { goto tail_call; @@ -250,14 +248,12 @@ tail_call: } } else if (GC_TYPE(ref) == IS_ARRAY) { if ((zend_array*)ref != &EG(symbol_table)) { - ht = &((zend_array*)ref)->ht; + ht = (zend_array*)ref; } } else if (GC_TYPE(ref) == IS_REFERENCE) { if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { ref = Z_COUNTED(((zend_reference*)ref)->val); - if (GC_TYPE(ref) != IS_ARRAY || (zend_array*)ref != &EG(symbol_table)) { - GC_REFCOUNT(ref)++; - } + GC_REFCOUNT(ref)++; if (GC_GET_COLOR(GC_INFO(ref)) != GC_BLACK) { goto tail_call; } @@ -269,9 +265,7 @@ tail_call: p = ht->arData + idx; if (!Z_REFCOUNTED(p->val)) continue; ref = Z_COUNTED(p->val); - if (GC_TYPE(ref) != IS_ARRAY || (zend_array*)ref != &EG(symbol_table)) { - GC_REFCOUNT(ref)++; - } + GC_REFCOUNT(ref)++; if (GC_GET_COLOR(GC_INFO(ref)) != GC_BLACK) { if (idx == ht->nNumUsed-1) { goto tail_call; @@ -312,9 +306,7 @@ tail_call: for (i = 0; i < n; i++) { if (Z_REFCOUNTED(table[i])) { ref = Z_COUNTED(table[i]); - if (GC_TYPE(ref) != IS_ARRAY || ((zend_array*)ref) != &EG(symbol_table)) { - GC_REFCOUNT(ref)--; - } + GC_REFCOUNT(ref)--; if (!props && i == n - 1) { goto tail_call; } else { @@ -331,7 +323,7 @@ tail_call: if (((zend_array*)ref) == &EG(symbol_table)) { GC_SET_BLACK(GC_INFO(ref)); } else { - ht = &((zend_array*)ref)->ht; + ht = (zend_array*)ref; } } else if (GC_TYPE(ref) == IS_REFERENCE) { if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { @@ -341,9 +333,7 @@ tail_call: return; } ref = Z_COUNTED(((zend_reference*)ref)->val); - if (GC_TYPE(ref) != IS_ARRAY || (zend_array*)ref != &EG(symbol_table)) { - GC_REFCOUNT(ref)--; - } + GC_REFCOUNT(ref)--; goto tail_call; } return; @@ -358,9 +348,7 @@ tail_call: continue; } ref = Z_COUNTED(p->val); - if (GC_TYPE(ref) != IS_ARRAY || ((zend_array*)ref) != &EG(symbol_table)) { - GC_REFCOUNT(ref)--; - } + GC_REFCOUNT(ref)--; if (idx == ht->nNumUsed-1) { goto tail_call; } else { @@ -428,7 +416,7 @@ tail_call: if ((zend_array*)ref == &EG(symbol_table)) { GC_SET_BLACK(GC_INFO(ref)); } else { - ht = &((zend_array*)ref)->ht; + ht = (zend_array*)ref; } } else if (GC_TYPE(ref) == IS_REFERENCE) { if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { @@ -529,9 +517,7 @@ tail_call: for (i = 0; i < n; i++) { if (Z_REFCOUNTED(table[i])) { ref = Z_COUNTED(table[i]); - if (GC_TYPE(ref) != IS_ARRAY || (zend_array*)ref != &EG(symbol_table)) { - GC_REFCOUNT(ref)++; - } + GC_REFCOUNT(ref)++; if (!props && i == n - 1) { goto tail_call; } else { @@ -548,13 +534,11 @@ tail_call: ht = props; } } else if (GC_TYPE(ref) == IS_ARRAY) { - ht = &((zend_array*)ref)->ht; + ht = (zend_array*)ref; } else if (GC_TYPE(ref) == IS_REFERENCE) { if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { ref = Z_COUNTED(((zend_reference*)ref)->val); - if (GC_TYPE(ref) != IS_ARRAY || (zend_array*)ref != &EG(symbol_table)) { - GC_REFCOUNT(ref)++; - } + GC_REFCOUNT(ref)++; goto tail_call; } return count; @@ -571,9 +555,7 @@ tail_call: continue; } ref = Z_COUNTED(p->val); - if (GC_TYPE(ref) != IS_ARRAY || (zend_array*)ref != &EG(symbol_table)) { - GC_REFCOUNT(ref)++; - } + GC_REFCOUNT(ref)++; if (idx == ht->nNumUsed-1) { goto tail_call; } else { @@ -681,7 +663,7 @@ tail_call: ht = props; } } else if (GC_TYPE(ref) == IS_ARRAY) { - ht = &((zend_array*)ref)->ht; + ht = (zend_array*)ref; } else if (GC_TYPE(ref) == IS_REFERENCE) { if (Z_REFCOUNTED(((zend_reference*)ref)->val)) { ref = Z_COUNTED(((zend_reference*)ref)->val); @@ -802,8 +784,9 @@ ZEND_API int zend_gc_collect_cycles(void) } else if (GC_TYPE(p) == IS_ARRAY) { zend_array *arr = (zend_array*)p; + GC_REFCOUNT(arr) = 0; GC_TYPE(arr) = IS_NULL; - zend_hash_destroy(&arr->ht); + zend_hash_destroy(arr); } current = GC_G(next_to_free); } |