Roll back optimization changes.
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
#include <bits/stdint-intn.h>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <memory.h>
|
||||
#include <stdio.h>
|
||||
#include "runtime.h"
|
||||
|
||||
#define TOGGLE_MARK(n) ((uint64_t) n ^ ((uint64_t) 1 << 63))
|
||||
#define IS_MARKED(n) ((((uint64_t) n) ^ ((uint64_t) n << 1)) & ((uint64_t) 1 << 63))
|
||||
|
||||
struct node_base* alloc_node() {
|
||||
struct node_base* new_node = malloc(sizeof(struct node_app));
|
||||
new_node->gc_next = NULL;
|
||||
@@ -25,7 +21,10 @@ struct node_app* alloc_app(struct node_base* l, struct node_base* r) {
|
||||
}
|
||||
|
||||
struct node_num* alloc_num(int32_t n) {
|
||||
return (struct node_num*) TOGGLE_MARK(n);
|
||||
struct node_num* node = (struct node_num*) alloc_node();
|
||||
node->base.tag = NODE_NUM;
|
||||
node->value = n;
|
||||
return node;
|
||||
}
|
||||
|
||||
struct node_global* alloc_global(void (*f)(struct gmachine*), int32_t a) {
|
||||
@@ -50,7 +49,7 @@ void free_node_direct(struct node_base* n) {
|
||||
}
|
||||
|
||||
void gc_visit_node(struct node_base* n) {
|
||||
if(IS_MARKED(n) || n->gc_reachable) return;
|
||||
if(n->gc_reachable) return;
|
||||
n->gc_reachable = 1;
|
||||
|
||||
if(n->tag == NODE_APP) {
|
||||
@@ -170,7 +169,6 @@ void gmachine_split(struct gmachine* g, size_t n) {
|
||||
}
|
||||
|
||||
struct node_base* gmachine_track(struct gmachine* g, struct node_base* b) {
|
||||
if(IS_MARKED(b)) return b;
|
||||
g->gc_node_count++;
|
||||
b->gc_next = g->gc_nodes;
|
||||
g->gc_nodes = b;
|
||||
@@ -210,9 +208,7 @@ void unwind(struct gmachine* g) {
|
||||
|
||||
while(1) {
|
||||
struct node_base* peek = stack_peek(s, 0);
|
||||
if(IS_MARKED(peek)) {
|
||||
break;
|
||||
} else if(peek->tag == NODE_APP) {
|
||||
if(peek->tag == NODE_APP) {
|
||||
struct node_app* n = (struct node_app*) peek;
|
||||
stack_push(s, n->left);
|
||||
} else if(peek->tag == NODE_GLOBAL) {
|
||||
@@ -238,9 +234,7 @@ void unwind(struct gmachine* g) {
|
||||
extern void f_main(struct gmachine* s);
|
||||
|
||||
void print_node(struct node_base* n) {
|
||||
if(IS_MARKED(n)) {
|
||||
printf("%d", (int32_t) n);
|
||||
} else if(n->tag == NODE_APP) {
|
||||
if(n->tag == NODE_APP) {
|
||||
struct node_app* app = (struct node_app*) n;
|
||||
print_node(app->left);
|
||||
putchar(' ');
|
||||
@@ -252,6 +246,9 @@ void print_node(struct node_base* n) {
|
||||
printf("(Global: %p)", global->function);
|
||||
} else if(n->tag == NODE_IND) {
|
||||
print_node(((struct node_ind*) n)->next);
|
||||
} else if(n->tag == NODE_NUM) {
|
||||
struct node_num* num = (struct node_num*) n;
|
||||
printf("%d", num->value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user