Skip to content

Instantly share code, notes, and snippets.

View validate_ascii.ll
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%struct.__loadu_si128 = type { <2 x i64> }
define i32 @validate_ascii(i8*, i64, i8*, i64*) #4 {
%5 = icmp ule i64 16, %1
br i1 %5, label %6, label %30
%7 = sub i64 %1, 16
View gc_compress.diff
diff --git a/Zend/zend_gc.c b/Zend/zend_gc.c
index 79c3470..f8fc6cd 100644
--- a/Zend/zend_gc.c
+++ b/Zend/zend_gc.c
@@ -126,16 +126,12 @@
#define GC_DEFAULT_BUF_SIZE (16 * 1024)
#define GC_BUF_GROW_STEP (128 * 1024)
-#define GC_COMPRESS_FACTOR 4096 /* shold be 0 to disable compression */
-#define GC_MAX_UNCOMPRESSED ((1024 * 1024) - GC_COMPRESS_FACTOR)
View mt_rand.c
// Resulting code as the diff is hard to read
static uint32_t rand_range32(uint32_t umax) {
uint32_t result, limit;
result = php_mt_rand();
/* Special case where no modulus is required */
if (UNEXPECTED(umax == UINT32_MAX)) {
return result;
@nikic
nikic / demo.php
Created Dec 26, 2016
Demo for format preserving AST transformation
View demo.php
<?php
/* This demo replaces all unqualified function calls and namespaced lookups
* with fully qualified ones. Apart from this change all formatting should
* be preserved. */
use PhpParser\Lexer;
use PhpParser\Parser;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor;
View jit_output.asm
JIT$$interrupt_handler: ; (unknown)
mov $0x0, EG(vm_interrupt)
cmp $0x0, EG(timed_out)
jz .L1
xor %edi, %edi
call zend_timeout
.L1:
add $0x8, %rsp
jmp (%r15)
View timelib.diff
diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c
index 308437e..ebc4d1e 100644
--- a/ext/date/lib/parse_tz.c
+++ b/ext/date/lib/parse_tz.c
@@ -438,7 +438,7 @@ static struct location_info **create_location_table(void)
return NULL;
}
- li = timelib_calloc(LOCINFO_HASH_SIZE, sizeof *li);
+ li = calloc(LOCINFO_HASH_SIZE, sizeof *li);
View bench.php
<?php error_reporting(E_ALL);
function formatT($t) {
return sprintf('%.1f mus', $t * 1000000);
}
function formatResult($result) {
list($mean, $stddev) = $result;
return formatT($mean) . " +/- " . formatT($stddev);
}
@nikic
nikic / BinaryTree.php
Created Apr 23, 2015
Tree traversal performance: yield from vs. naive implementation
View BinaryTree.php
<?php error_reporting(E_ALL);
class BinaryTree {
private $content, $left, $right;
public function __construct($content, BinaryTree $left = null, BinaryTree $right = null) {
$this->content = $content;
$this->left = $left;
$this->right = $right;
}
View gist:04fce01e69ae5b7b44f8
<?php
require './vendor/autoload.php';
// The code samples to parse.
// => bool(false)
$code = '<?php class Foo {public $bar;}';
// => bool(true)
View coalesce.diff
diff --git a/Zend/zend_ast.h b/Zend/zend_ast.h
index 2a1582c..b571ee1 100644
--- a/Zend/zend_ast.h
+++ b/Zend/zend_ast.h
@@ -115,6 +115,7 @@ enum _zend_ast_kind {
ZEND_AST_NEW,
ZEND_AST_INSTANCEOF,
ZEND_AST_YIELD,
+ ZEND_AST_COALESCE,
You can’t perform that action at this time.