Skip to content

Instantly share code, notes, and snippets.

@imasahiro
Created April 14, 2014 08:57
Show Gist options
  • Save imasahiro/10629551 to your computer and use it in GitHub Desktop.
Save imasahiro/10629551 to your computer and use it in GitHub Desktop.
#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;
}
}
--- 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;
}
#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