# HG changeset patch # User Shohei KOKUBO # Date 1429550937 -32400 # Node ID 1eb599acffe43afd29c93d3d457cc028cc2ffa27 # Parent 481760d44d87bc3e197892822a8e6ab9579d2afb modify allocate diff -r 481760d44d87 -r 1eb599acffe4 src/CMakeLists.txt --- a/src/CMakeLists.txt Tue Apr 14 03:47:15 2015 +0900 +++ b/src/CMakeLists.txt Tue Apr 21 02:28:57 2015 +0900 @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 2.8) +# output compile log +set(CMAKE_VERBOSE_MAKEFILE 1) + # set compiler set(CMAKE_C_COMPILER $ENV{CbC_Clang}/clang) diff -r 481760d44d87 -r 1eb599acffe4 src/allocate/allocate.c --- a/src/allocate/allocate.c Tue Apr 14 03:47:15 2015 +0900 +++ b/src/allocate/allocate.c Tue Apr 21 02:28:57 2015 +0900 @@ -12,6 +12,7 @@ #endif #define NUM 100 +#define ALLOCATE_SIZE 1024 extern __code initAllocateContext(struct Context* context); /* @@ -56,10 +57,9 @@ int main() { struct Context* context = (struct Context*)malloc(sizeof(struct Context)); - context->code = malloc(sizeof(__code*)*1024); - context->data = malloc(sizeof(union Data**)*1024); - for (int i=0;i<1024;i++) - context->data[i] = malloc(sizeof(union Data*)); + context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); + context->data = malloc(sizeof(union Data**)*ALLOCATE_SIZE); + context->heap = malloc(sizeof(union Data*)*ALLOCATE_SIZE); initAllocateContext(context); goto start_code(context, Code1); } diff -r 481760d44d87 -r 1eb599acffe4 src/allocate/allocateContext.c --- a/src/allocate/allocateContext.c Tue Apr 14 03:47:15 2015 +0900 +++ b/src/allocate/allocateContext.c Tue Apr 21 02:28:57 2015 +0900 @@ -7,12 +7,14 @@ extern __code exit_code(struct Context*); __code initAllocateContext(struct Context* context) { - context->codeSize = 3; context->code[Code1] = code1; context->code[Code2] = code2; context->code[Code3] = code3; context->code[Allocate] = allocate; context->code[Exit] = exit_code; + context->dataSize = 0; + context->data[context->dataSize] = context->heap; + context->dataSize++; } diff -r 481760d44d87 -r 1eb599acffe4 src/allocate/allocateContext.h --- a/src/allocate/allocateContext.h Tue Apr 14 03:47:15 2015 +0900 +++ b/src/allocate/allocateContext.h Tue Apr 21 02:28:57 2015 +0900 @@ -11,6 +11,7 @@ struct Context { int codeSize; __code (**code) (struct Context *); + void* heap; int dataSize; union Data **data; }; diff -r 481760d44d87 -r 1eb599acffe4 src/include/allocate.h --- a/src/include/allocate.h Tue Apr 14 03:47:15 2015 +0900 +++ b/src/include/allocate.h Tue Apr 21 02:28:57 2015 +0900 @@ -7,6 +7,8 @@ } __code meta_allocate(struct Context* context) { + context->data[context->dataSize] = context->heap; + context->heap += sizeof(union Data); context->dataSize++; goto (context->code[context->data[context->dataSize-1]->allocate.next])(context); }