Created
April 14, 2014 08:57
-
-
Save imasahiro/10629551 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
typedef uintptr_t VALUE; | |
struct RBasic { | |
VALUE flag; | |
const VALUE klass; | |
}; | |
struct a { | |
struct RBasic base; | |
VALUE *v; | |
int len; | |
}; | |
void __write_barrier() {} | |
int n = 0; | |
void *b = NULL; | |
void g(struct a *a) { | |
while(n < a->len) { | |
int v = n + 1; | |
__write_barrier(); | |
a->v[n++] = (VALUE) b; // 1 | |
n += 10; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- orignal.c 2014-04-14 17:55:05.000000000 +0900 | |
+++ generated.c 2014-04-14 17:56:13.000000000 +0900 | |
@@ -21,6 +21,7 @@ | |
void g(struct a *a) { | |
while(n < a->len) { | |
int v = n + 1; | |
+ __write_barrier(); | |
a->v[n++] = (VALUE) b; // 1 | |
n += 10; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
typedef uintptr_t VALUE; | |
struct RBasic { | |
VALUE flag; | |
const VALUE klass; | |
}; | |
struct a { | |
struct RBasic base; | |
VALUE *v; | |
int len; | |
}; | |
void __write_barrier() {} | |
int n = 0; | |
void *b = NULL; | |
void g(struct a *a) { | |
while(n < a->len) { | |
int v = n + 1; | |
a->v[n++] = (VALUE) b; // here | |
n += 10; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment