[llvm-commits] [vmkit] r48952 - in /vmkit/trunk: ./ lib/Mvm/ lib/Mvm/Allocator/ lib/Mvm/CommonThread/ lib/Mvm/GCMmap2/
Owen Anderson
resistor at mac.com
Sun Mar 30 09:41:18 PDT 2008
Author: resistor
Date: Sun Mar 30 11:41:18 2008
New Revision: 48952
URL: http://llvm.org/viewvc/llvm-project?rev=48952&view=rev
Log:
Rename a bunch of files from .cc to .cpp for consistency.
Added:
vmkit/trunk/lib/Mvm/Allocator/gcalloc.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/Allocator/gcalloc.cc
vmkit/trunk/lib/Mvm/Allocator/gcchunk.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/Allocator/gcchunk.cc
vmkit/trunk/lib/Mvm/Allocator/gcerror.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/Allocator/gcerror.cc
vmkit/trunk/lib/Mvm/Allocator/gcmapper.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/Allocator/gcmapper.cc
vmkit/trunk/lib/Mvm/Allocator/main.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/Allocator/main.cc
vmkit/trunk/lib/Mvm/CommonThread/cterror.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/CommonThread/cterror.cc
vmkit/trunk/lib/Mvm/CommonThread/ctlock.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/CommonThread/ctlock.cc
vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/CommonThread/ctthread.cc
vmkit/trunk/lib/Mvm/CommonThread/main.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/CommonThread/main.cc
vmkit/trunk/lib/Mvm/Disassembler.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/Disassembler.cc
vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/GCMmap2/gc.cc
vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cc
vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cc
vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cc
vmkit/trunk/lib/Mvm/GCMmap2/main.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/GCMmap2/main.cc
vmkit/trunk/lib/Mvm/JIT.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/JIT.cc
vmkit/trunk/lib/Mvm/Main.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/Main.cc
vmkit/trunk/lib/Mvm/Object.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/Object.cc
vmkit/trunk/lib/Mvm/Sigsegv.cpp
- copied unchanged from r48951, vmkit/trunk/lib/Mvm/Sigsegv.cc
Removed:
vmkit/trunk/lib/Mvm/Allocator/gcalloc.cc
vmkit/trunk/lib/Mvm/Allocator/gcchunk.cc
vmkit/trunk/lib/Mvm/Allocator/gcerror.cc
vmkit/trunk/lib/Mvm/Allocator/gcmapper.cc
vmkit/trunk/lib/Mvm/Allocator/main.cc
vmkit/trunk/lib/Mvm/CommonThread/cterror.cc
vmkit/trunk/lib/Mvm/CommonThread/ctlock.cc
vmkit/trunk/lib/Mvm/CommonThread/ctthread.cc
vmkit/trunk/lib/Mvm/CommonThread/main.cc
vmkit/trunk/lib/Mvm/Disassembler.cc
vmkit/trunk/lib/Mvm/GCMmap2/gc.cc
vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cc
vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cc
vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cc
vmkit/trunk/lib/Mvm/GCMmap2/main.cc
vmkit/trunk/lib/Mvm/JIT.cc
vmkit/trunk/lib/Mvm/Main.cc
vmkit/trunk/lib/Mvm/Object.cc
vmkit/trunk/lib/Mvm/Sigsegv.cc
Modified:
vmkit/trunk/configure.ac
vmkit/trunk/lib/Mvm/Allocator/Makefile.am
vmkit/trunk/lib/Mvm/CommonThread/Makefile.am
vmkit/trunk/lib/Mvm/GCMmap2/Makefile.am
vmkit/trunk/lib/Mvm/Makefile.am
Modified: vmkit/trunk/configure.ac
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/configure.ac?rev=48952&r1=48951&r2=48952&view=diff
==============================================================================
--- vmkit/trunk/configure.ac (original)
+++ vmkit/trunk/configure.ac Sun Mar 30 11:41:18 2008
@@ -2,7 +2,7 @@
AC_INIT([micro-vm],[0.0.1])
AC_PREREQ([2.59])
-AC_CONFIG_SRCDIR([lib/Mvm/Main.cc])
+AC_CONFIG_SRCDIR([lib/Mvm/Main.cpp])
dnl **************************************************************************
Modified: vmkit/trunk/lib/Mvm/Allocator/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Allocator/Makefile.am?rev=48952&r1=48951&r2=48952&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Allocator/Makefile.am (original)
+++ vmkit/trunk/lib/Mvm/Allocator/Makefile.am Sun Mar 30 11:41:18 2008
@@ -1,10 +1,10 @@
noinst_LIBRARIES = libuvm_alloc.a
noinst_PROGRAMS = mainuvm_alloc
-libuvm_alloc_a_SOURCES = gcalloc.cc gcalloc.h gcchunk.cc gcchunk.h gcerror.cc gcerror.h gcmapper.cc gcmapper.h osdep.h
+libuvm_alloc_a_SOURCES = gcalloc.cpp gcalloc.h gcchunk.cpp gcchunk.h gcerror.cpp gcerror.h gcmapper.cpp gcmapper.h osdep.h
libuvm_alloc_a_CXXFLAGS = -O2 -W -Wall -Werror -ansi -pedantic -Wno-variadic-macros
-mainuvm_alloc_SOURCES = main.cc
+mainuvm_alloc_SOURCES = main.cpp
mainuvm_alloc_CXXFLAGS =
mainuvm_alloc_LDADD = libuvm_alloc.a
Removed: vmkit/trunk/lib/Mvm/Allocator/gcalloc.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Allocator/gcalloc.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/Allocator/gcalloc.cc (original)
+++ vmkit/trunk/lib/Mvm/Allocator/gcalloc.cc (removed)
@@ -1,136 +0,0 @@
-//===--------------- gcalloc.cc - Mvm allocator ---------------------------===//
-//
-// Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gcalloc.h"
-#include "types.h"
-
-GCChunkNode *GCAllocator::alloc_headers(uintptr_t headers_nbb, void *base,
- uintptr_t depl, uintptr_t filled) {
- GCChunkNode *headers;
- uintptr_t rounded = GCMappedArea::round(headers_nbb);
-
- if(headers_nbb == rounded)
- headers = (GCChunkNode *)(new GCMappedArea(&headers_area, rounded))->area();
- else {
- headers = used_headers;
- used_headers = (GCChunkNode *)((uintptr_t)used_headers + headers_nbb);
- if(used_headers >= max_headers) {
- headers = (GCChunkNode *)(new GCMappedArea(&headers_area, used_headers_nbb))->area();
- used_headers = (GCChunkNode *)((uintptr_t)headers + headers_nbb);
- max_headers = (GCChunkNode *)((uintptr_t)headers + used_headers_nbb);
- }
- }
-
- register GCChunkNode *cur = headers;
- register GCChunkNode *lim = (GCChunkNode *)((uintptr_t)headers + headers_nbb);
- register GCChunkNode *max = lim - (1 + filled);
- for(;cur<max; cur++) {
- cur->initialise(cur+1, base);
- base = (void *)((uintptr_t)base + depl);
- }
- for(;cur<lim; cur++) {
- cur->initialise(0, base);
- base = (void *)((uintptr_t)base + depl);
- }
- return headers;
-}
-
-GCChunkNode *GCAllocator::alloc_list(GCFreeList *fl, uintptr_t n) {
- GCChunkNode *headers;
- uintptr_t area_nbb;
- void *area_ptr;
- GCPage *page;
-
- if(GCFreeListFinder::isMmaped(n)) {
- area_nbb = GCMappedArea::round(n);
-
- /* on alloue un Descripteur */
- page = new GCDescriptorMappedChunk(&normal_area, area_nbb, area_nbb);
- area_ptr = page->area();
-
- headers = page->headers();
- } else {
- uintptr_t chunk_nbb = fl->chunk_nbb();
-
- /* on alloue un Descripteur */
- page = new GCPage(&normal_area, area_nbb = fl->area_nbb(), chunk_nbb);
-
- area_ptr = page->area();
-
- /* on alloue des headers */
- headers = alloc_headers(fl->headers_nbb(), area_ptr, chunk_nbb, fl->filled());
-
- page->headers(headers);
- }
-
- /* on hash notre nouveau chunk */
- GCHash::hash_unprotected(page, area_ptr, area_nbb, area_nbb);
-
- fl->list(headers);
- return headers;
-}
-
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#define max(a, b) ((a) < (b) ? (b) : (a))
-
-GCFreeListFinder::GCFreeListFinder() {
- unsigned int i, j, m;
- GCFreeList *cur;
-
- for(i=0; i<=min_exp; i++)
- exp_lists[i] = _exp_lists;
- _exp_lists[0].initialise(min_exp, 128*min_exp);
-
- for(i=min_exp_log, cur=_exp_lists+1; i<max_exp_log; i++, cur++) {
- m = 1 << (i + 1);
- cur->initialise(m, 512*m);
- for(j=1<<i; j<m; j++)
- exp_lists[j+1] = cur;
- }
-
- for(i=0;i<nb_lin; i++) {
- m = ((i+1)<<lin_step_log) + max_exp;
- lin_lists[i].initialise(m, min(128*m, 65536));
- }
-
- // for(i=0; i<max_lin+2; i++)
- // printf("%d => %d\n", i, find(i)->chunk_nbb());
-}
-
-
-GCAllocator::GCAllocator() {
- used_headers = 0;
- max_headers = 0;
- GCHash::initialise();
-}
-
-GCAllocator::~GCAllocator() {
- GCMappedArea *cur;
-
- for(cur=normal_area.next(); cur!=&normal_area; cur=cur->next())
- delete cur->munmap();
-
- for(cur=headers_area.next(); cur!=&headers_area; cur=cur->next())
- delete cur->munmap();
-
- for(cur=mapped_area.next(); cur!=&mapped_area; cur=cur->next())
- delete cur->munmap();
- GCHash::unlink();
-}
-
-void *GCAllocator::operator new(uintptr_t req) {
- uintptr_t nbb = GCMappedArea::round(req);
- GCAllocator *res = (GCAllocator *)GCMappedArea::do_mmap(nbb);
- res->my_size = nbb;
- return res;
-}
-
-void GCAllocator::operator delete(void *ptr) {
- GCMappedArea::do_munmap(ptr, ((GCAllocator *)ptr)->my_size);
-}
Removed: vmkit/trunk/lib/Mvm/Allocator/gcchunk.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Allocator/gcchunk.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/Allocator/gcchunk.cc (original)
+++ vmkit/trunk/lib/Mvm/Allocator/gcchunk.cc (removed)
@@ -1,114 +0,0 @@
-//===---------------- gcchunk.cc - Mvm allocator --------------------------===//
-//
-// Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gcchunk.h"
-
-
-GCHashSet *GCHash::sets[GCHashConst::nb_set_per_hash];
-unsigned int GCHash::used[GCHashConst::nb_set_per_hash];
-GCHashSet GCHash::empty;
-bool GCHash::inited = 0;
-size_t GCHash::nb_link = 0;
-
-GCChunkNode GCPage::empty;
-
-GCPage GCHashSet::empty;
-
-void GCHashSet::hash(GCPage *d, void *base, size_t nbb, size_t nbb_map, unsigned int *c) {
- register unsigned int entry = GCHashConst::desc_entry(base);
- register unsigned int pbase = entry << PAGE_SHIFT;
- register unsigned int top_del = (pbase + nbb) >> PAGE_SHIFT;
- register unsigned int top_add = (pbase + nbb_map) >> PAGE_SHIFT;
-
- // printf(" %p Hash from %d to %d and to %d\n", this, entry, top_add, top_del);
- for(; entry<top_add; entry++) {
- pages[entry] = d;
- (*c)++;
- }
- for(; entry<top_del; entry++) {
- pages[entry] = ∅
- (*c)--;
- }
-}
-
-void GCHash::hash_unprotected(GCPage *desc, void *base, unsigned int nbb, unsigned int nbb_map) {
- uintptr_t entry = GCHashConst::set_entry(base);
- uintptr_t cur_sz = GCHashConst::set_entry_2_ptr(entry + 1) - (uintptr_t)base; /* taille restante */
- cur_sz = ((cur_sz < nbb) ? cur_sz : nbb); /* on prends le min avec nbb */
-
- // printf("Hash %p (%p %p %d) in entry %d with %d/%d\n", desc, desc->area(), base, desc->nbb(), entry, cur_sz, nbb_map);
- while(cur_sz) {
- if(sets[entry] == &empty)
- sets[entry] = new GCHashSet();
-
- sets[entry]->hash(desc, base, cur_sz, (nbb_map > cur_sz) ? cur_sz : nbb_map, used + entry);
-
- if(!used[entry]) {
- delete sets[entry];
- sets[entry] = ∅
- }
- entry++;
- base = (void *)((uintptr_t)base + cur_sz);
- nbb -= cur_sz;
- nbb_map = (nbb_map < cur_sz) ? 0 : nbb_map - cur_sz;
- cur_sz = (nbb < GCHashConst::set_nbb) ? nbb : GCHashConst::set_nbb;
- }
-}
-
-void GCPage::initialise() {
- empty.initialise(0, 0);
-}
-
-GCHashSet::GCHashSet() {
- unsigned int i;
-
- for(i=0; i<GCHashConst::nb_desc_per_set; i++)
- pages[i] = ∅
-}
-
-void GCHash::initialise() {
- if(!inited) {
- inited = 1;
- GCMinAlloc::initialise();
-
- unsigned int i;
-
- for(i=0; i<GCHashConst::nb_set_per_hash; i++) {
- sets[i] = ∅
- used[i] = 0;
- }
- GCPage::initialise();
- }
- nb_link++;
-}
-
-void GCHash::destroy() {
- if(inited) {
- if(nb_link)
- gcwarning2("Can't destroy GC hash map: you have clients connected on it\n");
- else {
- inited = 0;
- unsigned int i;
-
- for(i=0; i<GCHashConst::nb_set_per_hash; i++)
- if(sets[i] != &empty)
- delete sets[i];
-
- GCMinAlloc::destroy();
- }
- }
-}
-
-void *GCHashSet::operator new(size_t sz) {
- return (void *)GCMappedArea::do_mmap(sz);
-}
-
-void GCHashSet::operator delete(void *ptr, size_t sz) {
- GCMappedArea::do_munmap(ptr, sz);
-}
Removed: vmkit/trunk/lib/Mvm/Allocator/gcerror.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Allocator/gcerror.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/Allocator/gcerror.cc (original)
+++ vmkit/trunk/lib/Mvm/Allocator/gcerror.cc (removed)
@@ -1,36 +0,0 @@
-//===--------------- gcerror.cc - Mvm allocator ---------------------------===//
-//
-// Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gcerror.h"
-#include <stdarg.h>
-#include "osdep.h"
-
-static void __gcfatal(const char *file, unsigned int l, const char *func, const char *msg, ...)
-{
- va_list va;
- va_start(va, msg);
- fprintf(stderr, "GC[error] in %s line %d (function %s)\n", file, l, func);
- vfprintf(stderr, msg, va);
- fprintf(stderr, "\n");
- va_end(va);
- exit(0);
-}
-
-static void _on_fatal() {}
-
-void (*_gcfatal)(const char *, unsigned int l, const char *, const char *, ...) = __gcfatal;
-void (*on_fatal)(void) = _on_fatal;
-
-static void _defaultOnMemoryError(unsigned int sz)
-{
- fprintf(stderr, "GC[error] out of memory for %d bytes\n", sz);
- exit(0);
-}
-
-void (*onMemoryError)(unsigned int) = _defaultOnMemoryError;
Removed: vmkit/trunk/lib/Mvm/Allocator/gcmapper.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Allocator/gcmapper.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/Allocator/gcmapper.cc (original)
+++ vmkit/trunk/lib/Mvm/Allocator/gcmapper.cc (removed)
@@ -1,137 +0,0 @@
-//===--------------- gcmapper.cc - Mvm allocator ---------------------------===//
-//
-// Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gcmapper.h"
-#include <string.h>
-#include <sys/mman.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-
-GCMinAllocStack GCMinAlloc::_stacks[GCMinAlloc::max_min_alloc >> log_step];
-GCMinAllocStack *GCMinAlloc::stacks[GCMinAlloc::max_min_alloc+1];
-GCMappedArea GCMinAlloc::base_area;
-
-
-
-#if defined(__MACH__)
-#define DO_MMAP(sz) mmap(0, sz, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0)
-#else
-#define DO_MMAP(sz) mmap(0, sz, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0)
-#endif
-
-#define DO_MUNMAP(ptr, sz) munmap(ptr, sz)
-
-#if defined(__MACH__)
-static inline void* manual_mremap(void * addr, int old_size, int new_size, int flags)
-{
- void * res = addr;
- if (new_size < old_size)
- DO_MUNMAP((void*)((int)addr + new_size), old_size - new_size);
- else if (new_size > old_size)
- // Use of MAP_FIXED is discouraged...
- // res = mmap(addr, new_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, MAP_FIXED);
- res=(void*)-1;
-
- return res;
-}
-#endif
-
-static inline void *do_mmap(size_t sz) {
- void *res = DO_MMAP(sz);
- //printf("mmap %d bytes at %d\n", sz, res);
- if(res == MAP_FAILED)
- if (errno == ENOMEM)
- (*onMemoryError)(sz);
- else
- {
- gcfatal("unable to mmap %d bytes", sz);
- }
- return res;
-}
-
-static inline void do_munmap(void *ptr, size_t sz) {
- // printf("munmap %d bytes at %p\n", sz, ptr);
- DO_MUNMAP(ptr, sz);
-}
-
-void *GCMappedArea::do_mmap(size_t sz) { return ::do_mmap(sz); }
-void GCMappedArea::do_munmap(void *ptr, size_t sz) { ::do_munmap(ptr, sz); }
-
-GCMappedArea *GCMappedArea::munmap() {
- ::do_munmap(_mapped_area, _mapped_nbb);
- return this;
-}
-
-GCMappedArea *GCMappedArea::mmap(size_t n) {
- _mapped_area = ::do_mmap(_mapped_nbb = n);
- return this;
-}
-
-int GCMappedArea::mremap(size_t n) {
-#if defined(__MACH__)
- void *res = manual_mremap(_mapped_area, _mapped_nbb, n, 0);
-#else
- void *res = ::mremap(_mapped_area, _mapped_nbb, n, 0);
-#endif
-
- if((intptr_t)res == -1)
- return -1;
- _mapped_area = res;
- _mapped_nbb = n;
- return 0;
-}
-
-void *GCMinAlloc::alloc_area(GCMinAllocStack *s) {
- GCMinAllocStack *area_stack = stacks[sizeof(GCMappedArea)];
- GCMappedArea *area = (GCMappedArea *)area_stack->alloc();
-
- if(!area) {
- /* pbm : on n'a vraiment plus rien :) */
- area = (GCMappedArea *)::do_mmap(PAGE_SIZE);
- area->initialise(area, PAGE_SIZE);
- area_stack->fill((uintptr_t)(area + 1), PAGE_SIZE - sizeof(GCMappedArea));
- area->append(&base_area);
- area = (GCMappedArea *)area_stack->alloc();
- }
- area->mmap(PAGE_SIZE);
- area->append(&base_area);
- s->fill((uintptr_t)area->area(), area->nbb());
-
- return s->alloc();
-}
-
-void GCMinAlloc::initialise() {
- unsigned int i, j, m;
- size_t nb_stacks = max_min_alloc >> log_step;
-
- stacks[0] = _stacks;
- for(i=0; i<nb_stacks; i++) {
- m = i<<log_step;
- _stacks[i].initialise(m + (1<<log_step));
- for(j=0; j<(1<<log_step); j++)
- stacks[m+j+1] = _stacks + i;
- }
-}
-
-void GCMinAlloc::destroy() {
- unsigned int nb_area, i;
- GCMappedArea *cur;
-
- for(nb_area=0, cur=base_area.next(); cur!=&base_area; cur=cur->next(), nb_area++);
-
- GCMappedArea* areas = (GCMappedArea*)alloca(sizeof(GCMappedArea) * nb_area);
-
- for(i=0, cur=base_area.next(); cur!=&base_area; cur=cur->next(), i++)
- areas[i] = *cur;
-
- for(i=0; i<nb_area; i++)
- areas[i].munmap();
-}
Removed: vmkit/trunk/lib/Mvm/Allocator/main.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Allocator/main.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/Allocator/main.cc (original)
+++ vmkit/trunk/lib/Mvm/Allocator/main.cc (removed)
@@ -1,123 +0,0 @@
-//===------------------ main.cc - Mvm allocator ---------------------------===//
-//
-// Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gcalloc.h"
-#include <stdio.h>
-#include <time.h>
-#include <stdlib.h>
-#include <math.h>
-#include <sys/time.h>
-
-unsigned int rand(unsigned int min, unsigned int max) {
- return (unsigned int)nearbyint((((double)(max - min))*::rand())/(RAND_MAX + 1.0)) + min;
-}
-
-void tire(size_t n, size_t *vals, size_t *reallocs, size_t *frees) {
- for(size_t i=0; i<n; i++) {
- if(rand(0, 20))
- vals[i] = rand(1, 256);
- else
- vals[i] = rand(256, 65536);
- if(!rand(0, 10)) /* un chance sur 10 de réallouer */
- if(rand(0, 20))
- reallocs[i] = rand(1, 256);
- else
- reallocs[i] = rand(256, 65536);
- else
- reallocs[i] = 0;
- if(rand(0, 10)) /* un chance sur 10 de ne pas libérer */
- frees[i] = 1;
- else
- frees[i] = 0;
- }
-}
-
-void printMesure(size_t n, size_t *vals, size_t *reallocs, size_t *frees, struct timeval *start, struct timeval *end) {
- size_t totAllocated = 0;
- size_t curAllocated = 0;
- size_t na = 0;
- size_t nr = 0;
- size_t nf = 0;
- size_t no = 0;
-
- for(size_t i=0; i<n; i++) {
- size_t here = vals[i] + reallocs[i];
- if(reallocs[i]) {
- na++;
- nr++;
- }
- na++;
- totAllocated += here;
- if(!frees[i]) {
- curAllocated += here;
- no++;
- } else
- nf++;
- }
-
- printf("; %d allocations (%d reallocations, %d free, %d chunks)\n", na, nr, nf, no);
- printf("; Allocated: %d bytes, current %d bytes\n", totAllocated, curAllocated);
-
- struct timeval diff;
- timersub(end, start, &diff);
- double f = (double)diff.tv_sec + ((double)diff.tv_usec / 1000000.0);
- printf("; time consumed: %fs\n", f);
-}
-
-void mesureAllocateur() {
- size_t n = 512*1024;
- size_t vals[n];
- size_t reallocs[n];
- size_t frees[n];
-
- printf("Tire une sequence d'allocations alléatoire\n");
- tire(n, vals, reallocs, frees);
-
- printf("test\n");
- struct timeval start;
- struct timeval end;
- GCAllocator *a = new GCAllocator();
-
- gettimeofday(&start, 0);
- for(size_t i=0; i<n; i++) {
- void *p = a->alloc(vals[i]);
- if(reallocs[i])
- p = a->realloc(p, reallocs[i]);
- if(frees[i])
- a->free(p);
- }
- gettimeofday(&end, 0);
- delete a;
-
- printMesure(n, vals, reallocs, frees, &start, &end);
- printf("Press a key...\n");
- getchar();
-
- gettimeofday(&start, 0);
- for(size_t i=0; i<n; i++) {
- void *p = malloc(vals[i]);
- ((char *)p)[0] = 1;
- if(reallocs[i])
- p = realloc(p, reallocs[i]);
- if(frees[i])
- free(p);
- }
- gettimeofday(&end, 0);
- printMesure(n, vals, reallocs, frees, &start, &end);
- printf("Press a key...\n");
- getchar();
-
-}
-
-int main(int argc, char **argv) {
- mesureAllocateur();
-
- GCHash::destroy();
- return 0;
-}
Modified: vmkit/trunk/lib/Mvm/CommonThread/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/Makefile.am?rev=48952&r1=48951&r2=48952&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/Makefile.am (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/Makefile.am Sun Mar 30 11:41:18 2008
@@ -5,7 +5,7 @@
ALLOCDIR = ../Allocator
ALLOCLIBS = $(ALLOCDIR)/libuvm_alloc.a
-libuvm_common_thread_a_SOURCES = cterror.h ctthread.cc cterror.cc ctlock.cc
+libuvm_common_thread_a_SOURCES = cterror.h ctthread.cpp cterror.cpp ctlock.cpp
libuvm_common_thread_a_CXXFLAGS = -frepo -O2 -W -Wall -Werror -ansi -pedantic -Wno-unused-parameter
CLEANFILES = *~ *.bak .*.sw?
Removed: vmkit/trunk/lib/Mvm/CommonThread/cterror.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/cterror.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/cterror.cc (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/cterror.cc (removed)
@@ -1,35 +0,0 @@
-//===-------------- cterror.cc - Mvm common threads -----------------------===//
-//
-// Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "cterror.h"
-#include <stdio.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-
-void (*pgcdomsgf)(const char *, unsigned int l, const char *, const char *, ...) = _gcdomsgf;
-void (**gcdomsgf)(const char *, unsigned int l, const char *, const char *, ...) = &pgcdomsgf;
-
-const char *ctperror() {
- return strerror(errno);
-}
-
-void _gcdomsgf(const char *file, unsigned int l, const char *func, const char *msg, ...)
-{
- va_list va;
- va_start(va, msg);
- fprintf(stderr, "GC[error] in %s line %d (function %s)\n", file, l, func);
- vfprintf(stderr, msg, va);
- fprintf(stderr, "\n");
- va_end(va);
- exit(0);
-}
-
-
Removed: vmkit/trunk/lib/Mvm/CommonThread/ctlock.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctlock.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctlock.cc (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctlock.cc (removed)
@@ -1,239 +0,0 @@
-//===--- ctlock.cc - Common threads implementation of locks ---------------===//
-//
-// The Micro Virtual Machine
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "mvm/Threads/Cond.h"
-#include "mvm/Threads/Locks.h"
-#include "mvm/Threads/Thread.h"
-#include "cterror.h"
-#include <sys/time.h>
-
-
-using namespace mvm;
-
-inline int atomic_test_and_pass(unsigned int *ptr) {
-
-#if defined(__ppc__) || defined(__powerpc__)
- int result;
-# if defined(__MACH__)
- const int val=1;
-
- asm volatile("1:\n"
-#if 0
- " lwz %0,0(%1)\n" /* result <- ptr[0] */
- " cmpwi %0,0\n"
- " bne 1b\n"
-#endif
- " lwarx %0,0,%1\n" /* result <- ptr[0] */
- " cmpwi %0,0\n"
- " bne 1b\n"
- " stwcx. %2,0,%1\n" /* ptr[0] <- 1 (si pas d'autre accès) */
- " bne- 1b\n"
- " isync\n" /* empeche toute execution d'instruction après le lock!!! */
- :"=&r"(result): "r"(ptr), "r"(val): "cr0", "memory");
- /* le & empeche gcc d'utiliser le même register pour result et les entrées... */
-# else
- const int val=1;
-
- asm volatile("1:\n"
- " lwarx %0,0,%1\n" /* result <- ptr[0] */
- " cmpwi %0,0\n"
- " bne 1b\n"
- " stwcx. %2,0,%1\n" /* ptr[0] <- 1 (si pas d'autre accès) */
- " bne- 1b\n"
- " isync\n" /* empeche toute execution d'instruction après le lock!!! */
- :"=&r"(result): "r"(ptr), "r"(val): "cr0", "memory");
- /* le & empeche gcc d'utiliser le même register pour result et les entrées... */
-# endif
-
- return result;
-#elif defined(__i386__)
- // asm ("bts $1, %1; sbbl %0, %0":"=r" (result):"m" (*ptr):"memory");
- unsigned int old;
- int c=0;
- do {
- asm volatile("movl $1,%0;"
- "xchgl %0, %1" : "=&r"(old) : "m"(*ptr));
- if(!old)
- return 0;
- if(!(++c & 0xf))
- Thread::yield();
- } while(1);
-#else
-#error "I do not know how to do an atomic test and pass on your machine"
-#endif
-}
-
-Lock *Lock::allocRecursive() {
- return new LockRecursive();
-}
-
-Lock *Lock::allocNormal() {
- return new LockNormal();
-}
-
-void Lock::destroy(Lock *l) {
-}
-
-bool Lock::selfOwner(Lock *l) {
- return l->owner() == Thread::self();
-}
-
-int Lock::getOwner(Lock *l) {
- return l->owner();
-}
-
-void SpinLock::slock() {
- atomic_test_and_pass(&value);
-}
-
-void LockNormal::my_lock(Lock *l) {
- unsigned int c = 0;
-
- l->slock();
-
- while(l->owner()) {
- l->sunlock();
- Thread::yield(&c);
- l->slock();
- }
- l->owner(Thread::self());
- l->sunlock();
-}
-
-void LockNormal::my_unlock(Lock *l) {
- l->owner(0);
-}
-
-int LockNormal::my_trylock(Lock *) {
- ctfatal("not implemented");
- return -1;
-}
-
-void LockRecursive::my_lock(Lock *l) {
- unsigned int c = 0;
-
- int self = Thread::self();
-
- l->slock();
- while(l->owner() && (l->owner() != self)) {
- l->sunlock();
- Thread::yield(&c);
- l->slock();
- }
- l->owner(self);
- ((LockRecursive *)l)->n++;
- l->sunlock();
-}
-
- void LockRecursive::my_unlock(Lock *l) {
- if(!--((LockRecursive *)l)->n)
- l->owner(0);
- }
-
-int LockRecursive::my_trylock(Lock *) {
- ctfatal("not implemented");
- return -1;
-}
-
-int LockRecursive::recursion_count(Lock *l){
- return ((LockRecursive*)l)->n;
-}
-
-int LockRecursive::my_unlock_all(Lock *l){
- int count = ((LockRecursive*)l)->n;
- ((LockRecursive*)l)->n = 0;
- l->owner(0);
- return count;
-}
-
-void LockRecursive::my_lock_all(Lock *l, int count){
- LockRecursive::my_lock(l);
- ((LockRecursive*)l)->n = count;
-}
-
-
-
-
-void Cond::wait(Lock *l) {
- unsigned int n=0;
- unsigned int my_barrier = no_barrier;
-
- n_wait++; /* un attente de plus */
- while(1) {
- if(no_barrier == my_barrier) /* pas de broadcast */
- if(go) { /* un signal? */
- n_wait--; /* pus une attente en moins */
- go--; /* pour le pochain */
- return;
- } else { /* à l'ouest rien de nouveau */
- l->unlock(); /* je rend gentillement le lock */
- Thread::yield(&n); /* j'attends qu'on me libère... */
- l->lock(); /* je reprends mon lock */
- }
- else /* on a eu un broadcast */
- return;
- }
-}
-
-int Cond::timed_wait(Lock *l, struct timeval *ref) {
- unsigned int n=0;
- unsigned int my_barrier = no_barrier;
- struct timeval max, cur;
-
- gettimeofday(&max, 0);
- timeradd(&max, ref, &max);
-
- n_wait++;
- while(1) {
- if(no_barrier == my_barrier) /* pas de broadcast */
- if(go) { /* un signal? */
- n_wait--; /* puis une attente en moins */
- go--; /* pour le pochain */
- return 0;
- } else { /* à l'ouest rien de nouveau */
- gettimeofday(&cur, 0);
- if(timercmp(&cur, &max, >=)) {/* timesout écoulé */
- n_wait--; /* on n'attend plus */
- return 1; /* c'est nif */
- }
-
- l->unlock();
- timersub(&max, &cur, &cur); /* le reste */
- if(!cur.tv_sec && (cur.tv_usec <= 2))
- Thread::yield(); /* j'attends qu'on me libère... */
- else
- Thread::yield(&n); /* j'attends qu'on me libère... */
- l->lock(); /* je reprends mon lock */
- }
- else /* on a eu un broadcast */
- return 0;
- }
-}
-
-void Cond::broadcast() {
- no_barrier++;
- n_wait = 0;
-}
-
-void Cond::signal() {
- if(n_wait>go) go++;
-}
-
-
-extern "C" void lock_C(Lock* l) {
- return l->lock();
-}
-
-extern "C" void unlock_C(Lock* l) {
- return l->unlock();
-}
-
-Cond* Cond::allocCond() {
- return new Cond();
-}
Removed: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctthread.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cc (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cc (removed)
@@ -1,75 +0,0 @@
-//===-------------- ctthread.cc - Mvm common threads ----------------------===//
-//
-// Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "mvm/Threads/Key.h"
-#include "mvm/Threads/Thread.h"
-
-#include <pthread.h>
-#include <signal.h>
-#include <time.h>
-
-using namespace mvm;
-
-void Thread::yield() {
- sched_yield();
-}
-
-int Thread::self() {
- return (int)pthread_self();
-}
-
-void Thread::yield(unsigned int *c) {
- if(++(*c) & 3)
- sched_yield();
- else {
- struct timespec ts;
- ts.tv_sec = 0;
- ts.tv_nsec = 2000;
- nanosleep(&ts, 0);
- }
-}
-
-int Thread::kill(int tid, int signo) {
- return pthread_kill((pthread_t)tid, signo);
-}
-
-void Thread::exit(int value) {
- pthread_exit((void*)value);
-}
-
-void* ThreadKey::get() {
- pthread_key_t k = (pthread_key_t)val;
- return (void *)pthread_getspecific(k);
-}
-
-void ThreadKey::set(void *v) {
- pthread_key_t k = (pthread_key_t)val;
- pthread_setspecific(k, v);
-}
-
-ThreadKey::ThreadKey(void (*_destr)(void *)) {
- pthread_key_create((pthread_key_t*)&val, _destr);
-}
-
-ThreadKey::ThreadKey() {
- pthread_key_create((pthread_key_t*)&val, NULL);
-}
-
-void ThreadKey::initialise() {
- pthread_key_create((pthread_key_t*)&val, NULL);
-}
-
-void Thread::initialise() {
-}
-
-int Thread::start(int *tid, int (*fct)(void *), void *arg) {
- int res = pthread_create((pthread_t *)tid, 0, (void * (*)(void *))fct, arg);
- pthread_detach(*(pthread_t *)tid);
- return res;
-}
Removed: vmkit/trunk/lib/Mvm/CommonThread/main.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/main.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/main.cc (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/main.cc (removed)
@@ -1,94 +0,0 @@
-//===----------------- main.cc - Mvm common threads -----------------------===//
-//
-// Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "ctthread.h"
-#include <stdio.h>
-#include <sys/time.h>
-
-LockReccursive * l;
-Cond * c;
-int go=0;
-
-extern "C" int getchar(void);
-
-int f(void *arg) {
- struct timeval tv;
- tv.tv_sec = 2;
- tv.tv_usec = 0;
- l->lock();
- while(!go) {
- printf("Wait %d\n", Thread::self());
- c->timed_wait(l, &tv);
- }
- l->unlock();
- printf("Salut\n");
- return 0;
-}
-
-void pre(void *a) {
- printf("Pré %p\n", a);
-}
-
-void post(void *a) {
- printf("Post %p\n", a);
-}
-
-class Zop {
-public:
- static Key<Zop> * k;
- static void initialise_Key(void *pk) {
- printf("Init %p %p\n", pk, &k);
- ((Key<Zop>*)pk)->set(new Zop());
- printf("GOOD\n");
- }
-
- static void duplicate_for_thread(void *, void *z) {
- printf("Dup %p\n", z);
- k->set(new Zop());
- }
-
- static void destroy_Key(void *z) {
- printf("************ Del %p\n", z);
- delete (Zop *)z;
- }
-};
-
-Key<Zop>* Zop::k;
-
-int main(int argc, char **argv) {
- printf("START\n");
- ctthread_t tid;
-
- printf("Initialise thread...\n");
- Thread::initialise();
- printf("Create Key...\n");
-
- Zop::k = new Key<Zop>();
- l = new LockReccursive();
- c = new Cond();
- printf("OK\n");
-
- Thread::register_handler(pre, post, (void *)0x1000);
- Thread::remove_handler(Thread::register_handler(pre, post, (void *)0x1000));
-
- Thread::start(&tid, f, (void *)22);
- Thread::start(&tid, f, (void *)33);
-
- getchar();
- l->lock();
- go = 1;
- c->broadcast();
- l->unlock();
-
- printf("On est passé\n");
-
- getchar();
- Thread::exit(22);
-}
-
Removed: vmkit/trunk/lib/Mvm/Disassembler.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Disassembler.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/Disassembler.cc (original)
+++ vmkit/trunk/lib/Mvm/Disassembler.cc (removed)
@@ -1,91 +0,0 @@
-//===--------- Disassembler.cc - Intefarce to disassembler ----------------===//
-//
-// Micro Virtual Machine
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "mvm/JIT.h"
-
-#ifdef HAVE_DISASSEMBLER
-
-#if defined(__PPC__)
-extern "C"
-{
-# include <dis-asm.h>
-# include <bfd.h>
-}
-
-
-
-static struct disassemble_info info;
-static int initialised= 0;
-
-// this is the only function exported from this file
-
-int mvm::jit::disassemble(unsigned int *addr)
-{
-
- if (!initialised)
- {
- INIT_DISASSEMBLE_INFO(info, stdout, fprintf);
- info.flavour= bfd_target_elf_flavour;
- info.arch= bfd_arch_powerpc;
- info.mach= bfd_mach_ppc_750; // generic(ish) == PPC G3
- info.endian= BFD_ENDIAN_BIG;
- info.buffer_length= 65536;
- }
- info.buffer= (bfd_byte *)addr;
- info.buffer_vma= (bfd_vma)(long)addr;
- return print_insn_big_powerpc((bfd_vma)(long)addr, &info);
-
-}
-
-#elif defined(__i386__)
-extern "C"
-{
-# include <bfd.h> // bfd types
-# include <dis-asm.h> // disassemble_info
- int print_insn_i386_att(bfd_vma, disassemble_info *);
-};
-
-
-static struct disassemble_info info;
-static int initialised= 0;
-
-
-int mvm::jit::disassemble(unsigned int *addr)
-{
- if (!initialised)
- {
- INIT_DISASSEMBLE_INFO(info, stdout, fprintf);
- info.flavour= bfd_target_elf_flavour;
- info.arch= bfd_arch_i386;
- info.mach= bfd_mach_i386_i386;
- info.endian= BFD_ENDIAN_LITTLE;
- info.buffer_length= 65536;
- }
- info.buffer= (bfd_byte *)addr;
- info.buffer_vma= (bfd_vma)(long)addr;
- return print_insn_i386_att((bfd_vma)(long)addr, &info);
-}
-
-#else
-
-int mvm::jit::disassemble(unsigned int* addr) {
- return 0;
-}
-
-#endif
-
-#else
-
-int mvm::jit::disassemble(unsigned int* addr) {
- return 0;
-}
-
-#endif
-
-
Modified: vmkit/trunk/lib/Mvm/GCMmap2/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/Makefile.am?rev=48952&r1=48951&r2=48952&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/Makefile.am (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/Makefile.am Sun Mar 30 11:41:18 2008
@@ -8,13 +8,13 @@
LIBTHREAD=$(THREADDIR)/libuvm_ at vvmthreadtype@_thread.a
LIBALLOC=$(ALLOCDIR)/libuvm_alloc.a
-libuvm_gc_mmap2_a_SOURCES = gc.cc gccollector.cc gcinit.cc gccollector.h
+libuvm_gc_mmap2_a_SOURCES = gc.cpp gccollector.cpp gcinit.cpp gccollector.h
if HAVE_PTHREAD
-libuvm_gc_mmap2_a_SOURCES += gcthread.cc
+libuvm_gc_mmap2_a_SOURCES += gcthread.cpp
endif
libuvm_gc_mmap2_a_CXXFLAGS =$(INCLUDEDIRS) -O2 -W -Wall -ansi -pedantic -Wno-unused-parameter -Wno-variadic-macros
-mainuvm_gc_mmap2_SOURCES = main.cc
+mainuvm_gc_mmap2_SOURCES = main.cpp
mainuvm_gc_mmap2_CXXFLAGS = -O2
mainuvm_gc_mmap2_LDADD = libuvm_gc_mmap2.a $(LIBTHREAD) $(LIBALLOC)
mainuvm_gc_mmap2_LDFLAGS =
Removed: vmkit/trunk/lib/Mvm/GCMmap2/gc.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gc.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gc.cc (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gc.cc (removed)
@@ -1,175 +0,0 @@
-//===---------------- gc.cc - Mvm Garbage Collector -----------------------===//
-//
-// Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "mvm/GC/GC.h"
-#include "gccollector.h"
-#include "gcerror.h"
-
-using namespace mvm;
-
-static GCCollector TheCollector;
-
-typedef void (*memoryError_t)(unsigned int);
-
-memoryError_t GCCollector::internMemoryError;
-
-void gc::markAndTrace() const {
- TheCollector.markAndTrace((void*)this);
-}
-
-size_t gc::objectSize() const {
- return GCCollector::objectSize((gc*)this);
-}
-
-void *gc::operator new(size_t sz, VirtualTable *vt) {
- return TheCollector.gcmalloc(vt, sz);
-}
-
-void gc::operator delete(void *) {
- gcfatal(0, "never call directly a destructor.....");
-}
-
-void *gc::realloc(size_t n) {
- return TheCollector.gcrealloc(this, n);
-}
-
-unsigned int Collector::enable(unsigned int n) {
- return TheCollector.enable(n);
-}
-
-int Collector::isStable(gc_lock_recovery_fct_t fct, int a0, int a1, int a2,
- int a3, int a4, int a5, int a6, int a7) {
- return TheCollector.isStable(fct, a0, a1, a2, a3, a4, a5, a6, a7);
-}
-
-void Collector::die_if_sigsegv_occured_during_collection(void *addr) {
- TheCollector.die_if_sigsegv_occured_during_collection(addr);
-}
-
-void Collector::gcStats(size_t &no, size_t &nbb) {
- TheCollector.gcStats(&no, &nbb);
-}
-
-void Collector::initialise(markerFn marker, void *base_sp) {
-#ifdef HAVE_PTHREAD
- Thread::initialise();
-#endif
- TheCollector.initialise(marker);
-#ifdef HAVE_PTHREAD
- TheCollector.inject_my_thread(base_sp);
-#endif
-}
-
-void Collector::destroy() {
- TheCollector.destroy();
-}
-
-void Collector::inject_my_thread(void *base_sp) {
-#ifdef HAVE_PTHREAD
- TheCollector.inject_my_thread(base_sp);
-#endif
-}
-
-void Collector::maybeCollect() {
- TheCollector.maybeCollect();
-}
-
-void Collector::collect(void) {
- TheCollector.collect();
-}
-
-gc *Collector::begOf(const void *obj) {
- return GCCollector::begOf((void*)obj);
-}
-
-int Collector::byteOffset(void *obj) {
- int beg = (intptr_t)GCCollector::begOf(obj);
- intptr_t off = (intptr_t)obj;
- return (off-beg);
-}
-
-
-void Collector::applyFunc(void (*func)(gc *o, void *data), void *data) {
- return TheCollector.applyFunc(func, data);
-}
-
-int Collector::getMaxMemory(void){
- return 0;
-}
-
-int Collector::getFreeMemory(void){
- return 0;
-}
-
-int Collector::getTotalMemory(void){
- return 0;
-}
-
-void Collector::setMaxMemory(size_t sz){
-}
-
-void Collector::setMinMemory(size_t sz){
-}
-
-void Collector::registerMemoryError(void (*func)(unsigned int)){
- GCCollector::internMemoryError = func;
- //onMemoryError = &GCCollector::defaultMemoryError;
-}
-
-void Collector::remove_my_thread() {
-#ifdef HAVE_PTHREAD
- TheCollector.remove_thread(TheCollector.threads->myloc());
-#endif
-}
-
-#ifdef HAVE_PTHREAD
-void GCCollector::siggc_handler(int) {
- GCThreadCollector *loc = TheCollector.threads->myloc();
- register unsigned int cm = TheCollector.current_mark;
- // jmp_buf buf;
-
- // setjmp(buf);
-
- TheCollector.threads->stackLock();
-
- if(!loc) /* a key is being destroyed */
- TheCollector.threads->another_mark();
- else if(loc->current_mark() != cm) {
- register unsigned int **cur = (unsigned int **)&cur;
- register unsigned int **max = loc->base_sp();
-
- GCChunkNode *node;
-
- for(; cur<max; cur++) {
- if((node = o2node(*cur)) && (!TheCollector.isMarked(node))) {
- node->remove();
- node->append(TheCollector.used_nodes);
- TheCollector.mark(node);
- }
- }
-
- loc->current_mark(cm);
- TheCollector.threads->another_mark();
-
- TheCollector.threads->waitCollection();
- }
- TheCollector.threads->stackUnlock();
-}
-#endif
-
-void GCThread::waitCollection() {
- unsigned int cm = TheCollector.current_mark;
-
- if(Thread::self() != collector_tid) {
- collectorGo();
- while((TheCollector.current_mark == cm) &&
- (TheCollector.status == GCCollector::stat_collect))
- _collectionCond.wait(&_stackLock);
- }
-}
Removed: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cc (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cc (removed)
@@ -1,97 +0,0 @@
-//===----------- gccollector.cc - Mvm Garbage Collector -------------------===//
-//
-// Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gccollector.h"
-#include <setjmp.h>
-
-using namespace mvm;
-
-void GCCollector::do_collect() {
- //printf("----- do collect -----\n");
- jmp_buf buf;
- setjmp(buf);
- GCChunkNode *cur;
- _since_last_collection = _collect_freq_auto;
-
- current_mark++;
-
- unused_nodes->attrape(used_nodes);
-
-#ifdef HAVE_PTHREAD
- threads->synchronize();
-#endif
-
- for(cur=used_nodes->next(); cur!=used_nodes; cur=cur->next())
- trace(cur);
-
- if(_marker)
- _marker();
-
- status = stat_finalize;
-
- /* finalize */
- GCChunkNode finalizable;
- finalizable.attrape(unused_nodes);
-
- status = stat_alloc;
-#ifdef HAVE_PTHREAD
- threads->collectionFinished();
-#endif
-
- /* kill everyone */
- GCChunkNode *next;
-
- for(cur=finalizable.next(); cur!=&finalizable; cur=next) {
- register gc_header *c = cur->chunk();
- next = cur->next();
-
- c->_2gc()->destroyer(real_nbb(cur));
-
- //printf(" !!!! reject %p [%p]\n", cur->chunk()->_2gc(), cur);
- allocator->reject_chunk(cur);
- }
-
-}
-
-void GCCollector::collect_unprotect() {
- if(_enable_collection && (status == stat_alloc)) {
- status = stat_collect;
- do_collect();
- }
-}
-
-#ifdef HAVE_PTHREAD
-void GCCollector::die_if_sigsegv_occured_during_collection(void *addr) {
- if(!isStable(0, 0, 0, 0, 0, 0, 0, 0, 0)) {
- printf("; ****************************************************** ;\n");
- printf("; SIGSEGV occured during a collection ;\n");
- printf("; I'm trying to let the allocator in a coherent stat ;\n");
- printf("; but the collector is DEAD and will never collect again ;\n");
- printf("; ****************************************************** ;\n");
-
- status = stat_broken; /* Collection is finished and no other collection will happend */
- threads->cancel(); /* Emulates a full collection to unlock mutators */
- used_nodes->eat(unused_nodes); /* All nodes are uses. Finalized are lost */
- unlock_dont_recovery(); /* Unlocks the GC lock */
- //gcfatal("SIGSEGV occured during collection at %p", addr);
- }
-}
-#endif /* HAVE_PTHREAD */
-
-void GCCollector::gcStats(size_t *_no, size_t *_nbb) {
- register unsigned int n, tot;
- register GCChunkNode *cur;
- lock();
- for(n=0, tot=0, cur=used_nodes->next(); cur!=used_nodes; cur=cur->next(), n++)
- tot += cur->nbb();
- unlock();
- *_no = n;
- *_nbb = tot;
-}
-
Removed: vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cc (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gcinit.cc (removed)
@@ -1,114 +0,0 @@
-//===--------------- gcinit.cc - Mvm Garbage Collector -------------------===//
-//
-// Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <signal.h>
-#include "gccollector.h"
-
-using namespace mvm;
-
-static const size_t def_collect_freq_auto = 4*1024*1024;
-static const size_t def_collect_freq_maybe = 512*1024;
-
-#if defined(__MACH__)
-# define SIGGC SIGXCPU
-#else
-# define SIGGC SIGPWR
-#endif
-
-int GCCollector::siggc() {
- return SIGGC;
-}
-
-void GCCollector::initialise(Collector::markerFn marker) {
-
- used_nodes = new GCChunkNode();
- unused_nodes = new GCChunkNode();
-#ifdef HAVE_PTHREAD
- threads = new GCThread();
-#endif
-
- struct sigaction sa;
- sigset_t mask;
-
-#ifdef HAVE_PTHREAD
- //on_fatal = unlock_dont_recovery;
-#endif
-
- sigaction(SIGGC, 0, &sa);
- sigfillset(&mask);
- sa.sa_mask = mask;
- sa.sa_handler = siggc_handler;
- sa.sa_flags |= SA_RESTART;
- sigaction(SIGGC, &sa, 0);
-
- allocator = new GCAllocator();
-// GCCollector::GCCollector(void (*marker)(void *)) {
-
- _marker = marker;
-
- used_nodes->alone();
-
- current_mark = 0;
-
- _collect_freq_auto = def_collect_freq_auto;
- _collect_freq_maybe = def_collect_freq_maybe;
-
- _since_last_collection = _collect_freq_auto;
-
- _enable_auto = 1;
- _enable_collection = 1;
- _enable_maybe = 1;
-
- status = stat_alloc;
-}
-
-void GCCollector::destroy() {
- delete allocator;
- allocator = 0;
-}
-
-
-static void *get_curr_fp(void)
-{
- register void *fp;
- asm(
-# if defined(__ppc__) || defined(__PPC__)
-# if defined(__MACH__)
- " mr %0, r1 "
-# else
- " mr %0, 1 "
-# endif
-# elif defined(__i386__)
- " movl %%ebp, %0 "
-# elif defined(__amd64__)
- " movq %%rbp, %0 "
-# else
-# error:
-# error: I do not know how to read the frame pointer on this machine
-# error:
-# endif
- :"=r"(fp):);
- return fp;
-}
-
-static void *get_base_sp(void)
-{
- void *fp= 0;
- for (fp= get_curr_fp(); (*(void **)fp); fp= *(void **)fp);
- return fp;
-}
-
-#ifdef HAVE_PTHREAD
-void GCCollector::inject_my_thread(void *base_sp) {
- if(!base_sp)
- base_sp = get_base_sp();
- threads->inject(base_sp, current_mark);
-}
-#endif
-
Removed: vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cc (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gcthread.cc (removed)
@@ -1,47 +0,0 @@
-//===-------------- gcthread.cc - Mvm Garbage Collector -------------------===//
-//
-// Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gccollector.h"
-
-using namespace mvm;
-
-void GCThread::waitStacks() {
- _stackLock.lock();
- while(_nb_collected < _nb_threads)
- _stackCond.wait(&_stackLock);
- _stackLock.unlock();
-}
-
-void GCThread::synchronize() {
- GCThreadCollector *cur;
- int signo = GCCollector::siggc();
- int reached = 0;
- collector_tid = Thread::self();
-
- _nb_collected = 0;
- for(cur=(GCThreadCollector *)base.next(); cur!=&base; cur=(GCThreadCollector *)cur->next()) {
- int t = cur->tid();
- if(t != Thread::self())
- Thread::kill(cur->tid(), signo);
- else
- reached = 1;
- }
- if(reached) /* moi aussi je dois collecter... */
- GCCollector::siggc_handler(signo);
- waitStacks();
-}
-
-int GCLockRecovery::verify_recall(gc_lock_recovery_fct_t fct, int a0, int a1, int a2, int a3, int a4, int a5, int a6, int a7) {
- if(owner() == Thread::self()) {
- _fct = fct; _args[0] = a0; _args[1] = a1; _args[2] = a2; _args[3] = a3;
- _args[4] = a4; _args[5] = a5; _args[6] = a6; _args[7] = a7;
- return 0;
- } else
- return 1;
-}
Removed: vmkit/trunk/lib/Mvm/GCMmap2/main.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/main.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/main.cc (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/main.cc (removed)
@@ -1,36 +0,0 @@
-//===---------------- main.cc - Mvm Garbage Collector ---------------------===//
-//
-// Mvm
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "mvm/GC/GC.h"
-#include <stdio.h>
-
-void destr(gc *me, size_t sz) {
- printf("Destroy %p\n", me);
-}
-
-void trace(gc *me, size_t sz) {
- // printf("Trace %p\n", me);
-}
-
-void marker(void) {
- // printf("Marker...\n");
-}
-
-int main(int argc, char **argv) {
- Collector::initialise(marker, 0);
-
- Collector::destroy();
- return 0;
-}
-
-
-
-
-
-
Removed: vmkit/trunk/lib/Mvm/JIT.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/JIT.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/JIT.cc (original)
+++ vmkit/trunk/lib/Mvm/JIT.cc (removed)
@@ -1,792 +0,0 @@
-//===---------------- JIT.cc - Initialize the JIT -------------------------===//
-//
-// The Micro Virtual Machine
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <llvm/Type.h>
-#include <llvm/Support/CFG.h>
-#include <llvm/Module.h>
-#include <llvm/Constants.h>
-#include <llvm/Type.h>
-#include <llvm/DerivedTypes.h>
-#include <llvm/Function.h>
-#include <llvm/Instructions.h>
-#include <llvm/ModuleProvider.h>
-#include <llvm/ExecutionEngine/JIT.h>
-#include <llvm/ExecutionEngine/GenericValue.h>
-#include <llvm/PassManager.h>
-#include <llvm/Analysis/Verifier.h>
-#include <llvm/Transforms/Scalar.h>
-#include <llvm/Target/TargetData.h>
-#include <llvm/Assembly/PrintModulePass.h>
-#include <llvm/Target/TargetOptions.h>
-#include <llvm/CodeGen/MachineCodeEmitter.h>
-#include <llvm/CodeGen/MachineBasicBlock.h>
-#include "llvm/Constants.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Module.h"
-#include "llvm/ModuleProvider.h"
-#include "llvm/PassManager.h"
-#include "llvm/ValueSymbolTable.h"
-#include "llvm/Analysis/LoopPass.h"
-#include "llvm/Analysis/Verifier.h"
-#include "llvm/Assembly/Writer.h"
-#include "llvm/Assembly/PrintModulePass.h"
-#include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/CodeGen/RegAllocRegistry.h"
-#include "llvm/CodeGen/SchedulerRegistry.h"
-#include "llvm/CodeGen/ScheduleDAG.h"
-#include "llvm/Target/SubtargetFeature.h"
-#include "llvm/Target/TargetData.h"
-#include "llvm/Target/TargetLowering.h"
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetMachineRegistry.h"
-#include "llvm/Transforms/Scalar.h"
-#include "llvm/Transforms/IPO.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringMap.h"
-#include "llvm/Support/Streams.h"
-#include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/MutexGuard.h"
-
-#include <llvm/Transforms/IPO.h>
-
-#include <stdio.h>
-
-#include "mvm/JIT.h"
-#include "mvm/Method.h"
-#include "mvm/VMLet.h"
-
-#include "MvmMemoryManager.h"
-
-using namespace mvm;
-using namespace mvm::jit;
-using namespace llvm;
-
-
-extern "C" void printFloat(float f) {
- printf("%f\n", f);
-}
-
-extern "C" void printDouble(double d) {
- printf("%f\n", d);
-}
-
-extern "C" void printLong(sint64 l) {
- printf("%lld\n", l);
-}
-
-extern "C" void printInt(sint32 i) {
- printf("%d\n", i);
-}
-
-extern "C" void printObject(mvm::Object* obj) {
- printf("%s\n", obj->printString());
-}
-
-static void addPass(FunctionPassManager *PM, Pass *P) {
- // Add the pass to the pass manager...
- PM->add(P);
-}
-
-void jit::AddStandardCompilePasses(FunctionPassManager *PM) {
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
- // LLVM does not allow calling functions from other modules in verifier
- //PM->add(createVerifierPass()); // Verify that input is correct
-
- addPass(PM, createCFGSimplificationPass()); // Clean up disgusting code
- addPass(PM, createScalarReplAggregatesPass());// Kill useless allocas
- addPass(PM, createInstructionCombiningPass()); // Clean up after IPCP & DAE
- addPass(PM, createCFGSimplificationPass()); // Clean up after IPCP & DAE
- addPass(PM, createPromoteMemoryToRegisterPass());// Kill useless allocas
- addPass(PM, createInstructionCombiningPass()); // Clean up after IPCP & DAE
- addPass(PM, createCFGSimplificationPass()); // Clean up after IPCP & DAE
-
- addPass(PM, createTailDuplicationPass()); // Simplify cfg by copying code
- addPass(PM, createInstructionCombiningPass()); // Cleanup for scalarrepl.
- addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs
- addPass(PM, createScalarReplAggregatesPass()); // Break up aggregate allocas
- addPass(PM, createInstructionCombiningPass()); // Combine silly seq's
- addPass(PM, createCondPropagationPass()); // Propagate conditionals
-
-
- addPass(PM, createTailCallEliminationPass()); // Eliminate tail calls
- addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs
- addPass(PM, createReassociatePass()); // Reassociate expressions
- addPass(PM, createLoopRotatePass());
- addPass(PM, createLICMPass()); // Hoist loop invariants
- addPass(PM, createLoopUnswitchPass()); // Unswitch loops.
- addPass(PM, createInstructionCombiningPass()); // Clean up after LICM/reassoc
- addPass(PM, createIndVarSimplifyPass()); // Canonicalize indvars
- addPass(PM, createLoopUnrollPass()); // Unroll small loops
- addPass(PM, createInstructionCombiningPass()); // Clean up after the unroller
- addPass(PM, createGVNPass()); // GVN for load instructions
- addPass(PM, createGCSEPass()); // Remove common subexprs
- addPass(PM, createSCCPPass()); // Constant prop with SCCP
-
-
- // Run instcombine after redundancy elimination to exploit opportunities
- // opened up by them.
- addPass(PM, createInstructionCombiningPass());
- addPass(PM, createCondPropagationPass()); // Propagate conditionals
-
- addPass(PM, createDeadStoreEliminationPass()); // Delete dead stores
- addPass(PM, createAggressiveDCEPass()); // SSA based 'Aggressive DCE'
- addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs
-
-}
-
-
-
-
-static void initialiseTypes(llvm::Module* mod) {
- {
- // llvm::Type Definitions
- std::vector<const llvm::Type*>StructTy_struct_NativeString_fields;
- StructTy_struct_NativeString_fields.push_back(IntegerType::get(8));
- StructType* StructTy_struct_NativeString =
- StructType::get(StructTy_struct_NativeString_fields, /*isPacked=*/true);
- mod->addTypeName("struct.mvm::NativeString", StructTy_struct_NativeString);
-
- mod->addTypeName("struct.mvm::Object", StructTy_struct_NativeString);
- mod->addTypeName("struct.mvm::Thread", StructTy_struct_NativeString);
-
- std::vector<const llvm::Type*>StructTy_struct_PrintBuffer_fields;
- StructTy_struct_PrintBuffer_fields.push_back(IntegerType::get(32));
- StructTy_struct_PrintBuffer_fields.push_back(IntegerType::get(32));
- PointerType* PointerTy_0 = PointerType::getUnqual(StructTy_struct_NativeString);
-
- StructTy_struct_PrintBuffer_fields.push_back(PointerTy_0);
- StructType* StructTy_struct_PrintBuffer =
- StructType::get(StructTy_struct_PrintBuffer_fields, /*isPacked=*/false);
- mod->addTypeName("struct.mvm::PrintBuffer", StructTy_struct_PrintBuffer);
-
- std::vector<const llvm::Type*>StructTy_struct_VirtualTable_fields;
- std::vector<const llvm::Type*>StructTy_struct_gc_vt_fields;
- std::vector<const llvm::Type*>FuncTy_2_args;
- FuncTy_2_args.push_back(PointerTy_0);
- FuncTy_2_args.push_back(IntegerType::get(32));
- FunctionType* FuncTy_2 = FunctionType::get(
- /*Result=*/llvm::Type::VoidTy,
- /*Params=*/FuncTy_2_args,
- /*isVarArg=*/false);
-
- PointerType* PointerTy_1 = PointerType::getUnqual(FuncTy_2);
-
- StructTy_struct_gc_vt_fields.push_back(PointerTy_1);
- StructTy_struct_gc_vt_fields.push_back(PointerTy_1);
- StructType* StructTy_struct_gc_vt =
- StructType::get(StructTy_struct_gc_vt_fields, /*isPacked=*/false);
- mod->addTypeName("struct.mvm::gc_vt", StructTy_struct_gc_vt);
-
- StructTy_struct_VirtualTable_fields.push_back(PointerTy_1);
- StructTy_struct_VirtualTable_fields.push_back(PointerTy_1);
- std::vector<const llvm::Type*>FuncTy_4_args;
- FuncTy_4_args.push_back(PointerTy_0);
- PointerType* PointerTy_5 = PointerType::getUnqual(StructTy_struct_PrintBuffer);
-
- FuncTy_4_args.push_back(PointerTy_5);
- FunctionType* FuncTy_4 = FunctionType::get(
- /*Result=*/llvm::Type::VoidTy,
- /*Params=*/FuncTy_4_args,
- /*isVarArg=*/false);
-
- PointerType* PointerTy_3 = PointerType::getUnqual(FuncTy_4);
-
- StructTy_struct_VirtualTable_fields.push_back(PointerTy_3);
- std::vector<const llvm::Type*>FuncTy_7_args;
- FuncTy_7_args.push_back(PointerTy_0);
- FunctionType* FuncTy_7 = FunctionType::get(
- /*Result=*/IntegerType::get(32),
- /*Params=*/FuncTy_7_args,
- /*isVarArg=*/false);
-
- PointerType* PointerTy_6 = PointerType::getUnqual(FuncTy_7);
-
- StructTy_struct_VirtualTable_fields.push_back(PointerTy_6);
- StructTy_struct_VirtualTable_fields.push_back(IntegerType::get(32));
- OpaqueType* OpaqueTy_struct_llvm__Type = OpaqueType::get();
- mod->addTypeName("struct.llvm::Type", OpaqueTy_struct_llvm__Type);
-
- PointerType* PointerTy_8 = PointerType::getUnqual(OpaqueTy_struct_llvm__Type);
-
- StructTy_struct_VirtualTable_fields.push_back(PointerTy_8);
- StructType* StructTy_struct_VirtualTable =
- StructType::get(StructTy_struct_VirtualTable_fields, /*isPacked=*/false);
- mod->addTypeName("struct.mvm::VirtualTable", StructTy_struct_VirtualTable);
-
- mod->addTypeName("struct.mvm::gc_vt", StructTy_struct_gc_vt);
- mod->addTypeName("struct.llvm::Type", OpaqueTy_struct_llvm__Type);
- }
-
-
-
- {
- // Lock llvm::Type Definitions
- std::vector<const llvm::Type*>StructTy_struct_mvm__Lock_fields;
- std::vector<const llvm::Type*>StructTy_struct_mvm__SpinLock_fields;
- StructTy_struct_mvm__SpinLock_fields.push_back(IntegerType::get(32));
- StructType* StructTy_struct_mvm__SpinLock =
- StructType::get(StructTy_struct_mvm__SpinLock_fields, /*isPacked=*/false);
- mod->addTypeName("struct.mvm::SpinLock", StructTy_struct_mvm__SpinLock);
-
- StructTy_struct_mvm__Lock_fields.push_back(StructTy_struct_mvm__SpinLock);
- std::vector<const llvm::Type*>FuncTy_1_args;
- PATypeHolder StructTy_struct_mvm__Lock_fwd = OpaqueType::get();
- PointerType* PointerTy_2 = PointerType::getUnqual(StructTy_struct_mvm__Lock_fwd);
-
- FuncTy_1_args.push_back(PointerTy_2);
- FunctionType* FuncTy_1 = FunctionType::get(
- /*Result=*/llvm::Type::VoidTy,
- /*Params=*/FuncTy_1_args,
- /*isVarArg=*/false);
-
- PointerType* PointerTy_0 = PointerType::getUnqual(FuncTy_1);
-
- StructTy_struct_mvm__Lock_fields.push_back(PointerTy_0);
- StructTy_struct_mvm__Lock_fields.push_back(PointerTy_0);
- std::vector<const llvm::Type*>FuncTy_4_args;
- FuncTy_4_args.push_back(PointerTy_2);
- FunctionType* FuncTy_4 = FunctionType::get(
- /*Result=*/IntegerType::get(32),
- /*Params=*/FuncTy_4_args,
- /*isVarArg=*/false);
-
- PointerType* PointerTy_3 = PointerType::getUnqual(FuncTy_4);
-
- StructTy_struct_mvm__Lock_fields.push_back(PointerTy_3);
- StructTy_struct_mvm__Lock_fields.push_back(IntegerType::get(32));
- StructType* StructTy_struct_mvm__Lock =
- StructType::get(StructTy_struct_mvm__Lock_fields, /*isPacked=*/false);
- mod->addTypeName("struct.mvm::Lock", StructTy_struct_mvm__Lock);
- mod->addTypeName("struct.mvm::LockNormal", StructTy_struct_mvm__Lock);
- cast<OpaqueType>(StructTy_struct_mvm__Lock_fwd.get())->
- refineAbstractTypeTo(StructTy_struct_mvm__Lock);
- StructTy_struct_mvm__Lock =
- cast<StructType>(StructTy_struct_mvm__Lock_fwd.get());
-
-
- std::vector<const llvm::Type*>StructTy_struct_mvm__LockRecursive_fields;
- StructTy_struct_mvm__LockRecursive_fields.push_back(StructTy_struct_mvm__Lock);
- StructTy_struct_mvm__LockRecursive_fields.push_back(IntegerType::get(32));
- StructType* StructTy_struct_mvm__LockRecursive =
- StructType::get(StructTy_struct_mvm__LockRecursive_fields,
- /*isPacked=*/false);
- mod->addTypeName("struct.mvm::LockRecursive",
- StructTy_struct_mvm__LockRecursive);
-
- std::vector<const llvm::Type*>StructTy_struct_mvm__Object_fields;
- StructTy_struct_mvm__Object_fields.push_back(IntegerType::get(8));
- StructType* StructTy_struct_mvm__Object =
- StructType::get(StructTy_struct_mvm__Object_fields, /*isPacked=*/true);
- mod->addTypeName("struct.mvm::Object", StructTy_struct_mvm__Object);
-
- mod->addTypeName("struct.mvm::SpinLock", StructTy_struct_mvm__SpinLock);
-
-
- // llvm::Type definition of Cond and CollectableArea
- std::vector<const llvm::Type*>StructTy_struct_collectablearea_fields;
- StructTy_struct_collectablearea_fields.push_back(IntegerType::get(32));
- StructTy_struct_collectablearea_fields.push_back(IntegerType::get(32));
- StructTy_struct_collectablearea_fields.push_back(IntegerType::get(32));
- StructType* StructTy_struct_collectablearea =
- StructType::get(StructTy_struct_collectablearea_fields, /*isPacked=*/false);
- mod->addTypeName("struct.mvm::Cond", StructTy_struct_collectablearea);
- mod->addTypeName("struct.mvm::CollectableArea", StructTy_struct_collectablearea);
- }
-
- // llvm::Type Definitions of Key
- std::vector<const llvm::Type*>StructTy_struct_Key_fields;
- PointerType* PointerTy_0 = PointerType::getUnqual(IntegerType::get(8));
-
- StructTy_struct_Key_fields.push_back(PointerTy_0);
- StructType* StructTy_struct_Key =
- StructType::get(StructTy_struct_Key_fields, /*isPacked=*/false);
- mod->addTypeName("struct.mvm::ThreadKey", StructTy_struct_Key);
-
- // TODO
- mod->addTypeName("struct.mvm::Method", StructTy_struct_Key);
- mod->addTypeName("struct.mvm::Code", StructTy_struct_Key);
-
-}
-
-extern "C" void __register_frame(void*);
-
-void VMLet::initialise() {
- llvm::SizedMemoryCode = true;
- llvm::NoFramePointerElim = true;
- llvm::ExceptionHandling = true;
- llvm::Module *module = jit::globalModule = new llvm::Module ("microvm");
- jit::globalModuleProvider = new llvm::ExistingModuleProvider (jit::globalModule);
- jit::memoryManager = new MvmMemoryManager();
-
- initialiseTypes(globalModule);
-
- executionEngine = llvm::ExecutionEngine::createJIT(jit::globalModuleProvider, 0, jit::memoryManager);
- executionEngine->InstallExceptionTableRegister(__register_frame);
-
- ptrType = PointerType::getUnqual(Type::Int8Ty);
-
- {
- std::vector<const llvm::Type *> arg_types;
- arg_types.insert (arg_types.begin (), llvm::PointerType::getUnqual(ptrType));
-
- llvm::FunctionType *mtype = llvm::FunctionType::get (llvm::Type::VoidTy, arg_types, false);
- new llvm::Function(mtype, llvm::GlobalValue::ExternalLinkage, "llvm.va_start", module);
- }
-
- {
- std::vector<const llvm::Type *> arg_types;
- arg_types.insert (arg_types.begin (), llvm::Type::Int32Ty);
-
- llvm::FunctionType *mtype = llvm::FunctionType::get (ptrType, arg_types, false);
- new llvm::Function(mtype, llvm::GlobalValue::ExternalLinkage, "llvm.frameaddress", module);
- }
-
- {
- const llvm::Type *BPTy = ptrType;
- // Prototype malloc as "char* malloc(...)", because we don't know in
- // doInitialization whether size_t is int or long.
- FunctionType *FT = FunctionType::get(BPTy, std::vector<const llvm::Type*>(), true);
- new llvm::Function(FT, llvm::GlobalValue::ExternalLinkage, "_ZN2gcnwEjP5gc_vt", module);
- }
-
-
- // Create printFloatLLVM
- {
- std::vector<const Type*> args;
- args.push_back(Type::FloatTy);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- printFloatLLVM = new Function(type, GlobalValue::ExternalLinkage,
- "printFloat",
- module);
- }
-
- // Create printDoubleLLVM
- {
- std::vector<const Type*> args;
- args.push_back(Type::DoubleTy);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- printDoubleLLVM = new Function(type, GlobalValue::ExternalLinkage,
- "printDouble",
- module);
- }
-
- // Create printLongLLVM
- {
- std::vector<const Type*> args;
- args.push_back(Type::Int64Ty);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- printLongLLVM = new Function(type, GlobalValue::ExternalLinkage,
- "printLong",
- module);
- }
-
- // Create printIntLLVM
- {
- std::vector<const Type*> args;
- args.push_back(Type::Int32Ty);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- printIntLLVM = new Function(type, GlobalValue::ExternalLinkage,
- "printInt",
- module);
- }
-
- // Create printObjectLLVM
- {
- std::vector<const Type*> args;
- args.push_back(ptrType);
- const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-
- printObjectLLVM = new Function(type, GlobalValue::ExternalLinkage,
- "printObject",
- module);
- }
-
-
- {
- const PointerType* PointerTy_0 = ptrType;
-
- std::vector<const Type*>FuncTy_4_args;
- FuncTy_4_args.push_back(IntegerType::get(32));
-
-
- std::vector<const Type*>FuncTy_7_args;
- FuncTy_7_args.push_back(PointerTy_0);
- FuncTy_7_args.push_back(PointerTy_0);
- std::vector<const Type*>FuncTy_9_args;
- FuncTy_9_args.push_back(PointerTy_0);
- FunctionType* FuncTy_9 = FunctionType::get(
- /*Result=*/Type::VoidTy,
- /*Params=*/FuncTy_9_args,
- /*isVarArg=*/false);
- PointerType* PointerTy_8 = PointerType::getUnqual(FuncTy_9);
-
- FuncTy_7_args.push_back(PointerTy_8);
-
- std::vector<const Type*>FuncTy_11_args;
- FunctionType* FuncTy_11 = FunctionType::get(
- /*Result=*/PointerTy_0,
- /*Params=*/FuncTy_11_args,
- /*isVarArg=*/false);
-
- llvmGetException = new Function(
- /*Type=*/FuncTy_11,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"llvm.eh.exception", module); // (external, no body)
-
- std::vector<const Type*>FuncTy_13_args;
- FuncTy_13_args.push_back(PointerTy_0);
- FuncTy_13_args.push_back(PointerTy_0);
- FunctionType* FuncTy_13 = FunctionType::get(
- /*Result=*/IntegerType::get(32),
- /*Params=*/FuncTy_13_args,
- /*isVarArg=*/true);
-
- if (sizeof(void*) == 4) {
- exceptionSelector = new Function(
- /*Type=*/FuncTy_13,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"llvm.eh.selector.i32", module); // (external, no body)
- } else {
- exceptionSelector = new Function(
- /*Type=*/FuncTy_13,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"llvm.eh.selector.i64", module); // (external, no body)
- }
-
- std::vector<const Type*>FuncTy_19_args;
- FunctionType* FuncTy_19 = FunctionType::get(
- /*Result=*/Type::VoidTy,
- /*Params=*/FuncTy_19_args,
- /*isVarArg=*/false);
-
- personality = new Function(
- /*Type=*/FuncTy_19,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"__gxx_personality_v0", module); // (external, no body)
-
- unwindResume = new Function(
- /*Type=*/FuncTy_9,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"_Unwind_Resume_or_Rethrow", module); // (external, no body)
-
-
- std::vector<const Type*>FuncTy_17_args;
- FuncTy_17_args.push_back(PointerTy_0);
- FunctionType* FuncTy_17 = FunctionType::get(
- /*Result=*/PointerTy_0,
- /*Params=*/FuncTy_17_args,
- /*isVarArg=*/false);
-
- exceptionBeginCatch = new Function(
- /*Type=*/FuncTy_17,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"__cxa_begin_catch", module); // (external, no body)
-
- exceptionEndCatch = new Function(
- /*Type=*/FuncTy_19,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"__cxa_end_catch", module); // (external, no body)
- }
-
- // Math function
- {
- std::vector<const Type*>args1;
- args1.push_back(Type::DoubleTy);
- FunctionType* FuncTy = FunctionType::get(
- /*Result=*/Type::DoubleTy,
- /*Params=*/args1,
- /*isVarArg=*/false);
-
- func_llvm_sqrt_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "llvm.sqrt.f64", module);
- func_llvm_sin_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "llvm.sin.f64", module);
- func_llvm_cos_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "llvm.cos.f64", module);
- func_llvm_tan_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "tan", module);
- func_llvm_asin_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "asin", module);
- func_llvm_acos_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "acos", module);
- func_llvm_atan_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "atan", module);
- func_llvm_exp_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "exp", module);
- func_llvm_log_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "log", module);
- func_llvm_ceil_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "ceil", module);
- func_llvm_floor_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "floor", module);
- func_llvm_cbrt_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "cbrt", module);
- func_llvm_cosh_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "cosh", module);
- func_llvm_expm1_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "expm1", module);
- func_llvm_log10_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "log10", module);
- func_llvm_log1p_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "log1p", module);
- func_llvm_sinh_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "sinh", module);
- func_llvm_tanh_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "tanh", module);
- func_llvm_fabs_f64 = new Function(FuncTy, GlobalValue::ExternalLinkage, "fabs", module);
-
- std::vector<const Type*>args2;
- args2.push_back(Type::DoubleTy);
- args2.push_back(Type::DoubleTy);
- FunctionType* FuncTy2 = FunctionType::get(
- /*Result=*/Type::DoubleTy,
- /*Params=*/args2,
- /*isVarArg=*/false);
-
- func_llvm_hypot_f64 = new Function(FuncTy2, GlobalValue::ExternalLinkage, "hypot", module);
- //func_llvm_pow_f64 = new Function(FuncTy2, GlobalValue::ExternalLinkage, "llvm.pow.f64", module);
- func_llvm_pow_f64 = new Function(FuncTy2, GlobalValue::ExternalLinkage, "pow", module);
- func_llvm_atan2_f64 = new Function(FuncTy2, GlobalValue::ExternalLinkage, "atan2", module);
-
- std::vector<const Type*>args3;
- args3.push_back(Type::DoubleTy);
- FunctionType* FuncTy3 = FunctionType::get(
- /*Result=*/Type::DoubleTy,
- /*Params=*/args3,
- /*isVarArg=*/false);
-
- func_llvm_rint_f64 = new Function(FuncTy3, GlobalValue::ExternalLinkage, "rint", module);
-
- std::vector<const Type*>args4;
- args4.push_back(Type::FloatTy);
- FunctionType* FuncTyF = FunctionType::get(
- /*Result=*/Type::FloatTy,
- /*Params=*/args4,
- /*isVarArg=*/false);
-
- func_llvm_fabs_f32 = new Function(FuncTyF, GlobalValue::ExternalLinkage, "fabsf", module);
-
- }
-
- // Create setjmp
- {
- std::vector<const Type*> args;
- args.push_back(ptrType);
- const FunctionType* type = FunctionType::get(Type::Int32Ty, args,
- false);
-
- setjmpLLVM = new Function(type, GlobalValue::ExternalLinkage,
- "setjmp",
- module);
-
- }
-
- /* Create memcpy */
- {
- PointerType* PointerTy_2 = PointerType::getUnqual(IntegerType::get(8));
- std::vector<const Type*>FuncTy_4_args;
- FuncTy_4_args.push_back(PointerTy_2);
- FuncTy_4_args.push_back(PointerTy_2);
- FuncTy_4_args.push_back(IntegerType::get(32));
- FuncTy_4_args.push_back(IntegerType::get(32));
- FunctionType* FuncTy_4 = FunctionType::get(
- /*Result=*/Type::VoidTy,
- /*Params=*/FuncTy_4_args,
- /*isVarArg=*/false);
- llvm_memcpy_i32 = new Function(
- /*Type=*/FuncTy_4,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"llvm.memcpy.i32", module); // (external, no body)
- }
-
- /* Create memset */
- {
- PointerType* PointerTy_2 = PointerType::getUnqual(IntegerType::get(8));
- std::vector<const Type*>FuncTy_4_args;
- FuncTy_4_args.push_back(PointerTy_2);
- FuncTy_4_args.push_back(IntegerType::get(8));
- FuncTy_4_args.push_back(IntegerType::get(32));
- FuncTy_4_args.push_back(IntegerType::get(32));
- FunctionType* FuncTy_4 = FunctionType::get(
- /*Result=*/Type::VoidTy,
- /*Params=*/FuncTy_4_args,
- /*isVarArg=*/false);
- llvm_memset_i32 = new Function(
- /*Type=*/FuncTy_4,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"llvm.memset.i32", module); // (external, no body)
- }
-
-
- // Constant declaration
- constantLongMinusOne = ConstantInt::get(Type::Int64Ty, -1);
- constantLongZero = ConstantInt::get(Type::Int64Ty, 0);
- constantLongOne = ConstantInt::get(Type::Int64Ty, 1);
- constantZero = ConstantInt::get(Type::Int32Ty, 0);
- constantInt8Zero = ConstantInt::get(Type::Int8Ty, 0);
- constantOne = ConstantInt::get(Type::Int32Ty, 1);
- constantTwo = ConstantInt::get(Type::Int32Ty, 2);
- constantThree = ConstantInt::get(Type::Int32Ty, 3);
- constantFour = ConstantInt::get(Type::Int32Ty, 4);
- constantFive = ConstantInt::get(Type::Int32Ty, 5);
- constantSix = ConstantInt::get(Type::Int32Ty, 6);
- constantSeven = ConstantInt::get(Type::Int32Ty, 7);
- constantEight = ConstantInt::get(Type::Int32Ty, 8);
- constantMinusOne = ConstantInt::get(Type::Int32Ty, -1);
- constantMinInt = ConstantInt::get(Type::Int32Ty, MinInt);
- constantMaxInt = ConstantInt::get(Type::Int32Ty, MaxInt);
- constantMinLong = ConstantInt::get(Type::Int64Ty, MinLong);
- constantMaxLong = ConstantInt::get(Type::Int64Ty, MaxLong);
- constantFloatZero = ConstantFP::get(Type::FloatTy, APFloat(0.0f));
- constantFloatOne = ConstantFP::get(Type::FloatTy, APFloat(1.0f));
- constantFloatTwo = ConstantFP::get(Type::FloatTy, APFloat(2.0f));
- constantDoubleZero = ConstantFP::get(Type::DoubleTy, APFloat(0.0));
- constantDoubleOne = ConstantFP::get(Type::DoubleTy, APFloat(1.0));
- constantMaxIntFloat = ConstantFP::get(Type::FloatTy, APFloat(MaxIntFloat));
- constantMinIntFloat = ConstantFP::get(Type::FloatTy, APFloat(MinIntFloat));
- constantMinLongFloat = ConstantFP::get(Type::FloatTy, APFloat(MinLongFloat));
- constantMinLongDouble = ConstantFP::get(Type::DoubleTy, APFloat(MinLongDouble));
- constantMaxLongFloat = ConstantFP::get(Type::FloatTy, APFloat(MaxLongFloat));
- constantMaxIntDouble = ConstantFP::get(Type::DoubleTy, APFloat(MaxIntDouble));
- constantMinIntDouble = ConstantFP::get(Type::DoubleTy, APFloat(MinIntDouble));
- constantMaxLongDouble = ConstantFP::get(Type::DoubleTy, APFloat(MaxLongDouble));
- constantMaxLongDouble = ConstantFP::get(Type::DoubleTy, APFloat(MaxLongDouble));
- constantFloatInfinity = ConstantFP::get(Type::FloatTy, APFloat(MaxFloat));
- constantFloatMinusInfinity = ConstantFP::get(Type::FloatTy, APFloat(MinFloat));
- constantDoubleInfinity = ConstantFP::get(Type::DoubleTy, APFloat(MaxDouble));
- constantDoubleMinusInfinity = ConstantFP::get(Type::DoubleTy, APFloat(MinDouble));
- constantDoubleMinusZero = ConstantFP::get(Type::DoubleTy, APFloat(-0.0));
- constantFloatMinusZero = ConstantFP::get(Type::FloatTy, APFloat(-0.0f));
-
- constantPtrNull = Constant::getNullValue(ptrType);
- arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::Int8Ty, 0));
-
-
- //mvm::jit::protectTypes = mvm::Lock::allocNormal();
- //mvm::Object::pushRoot((mvm::Object*)mvm::jit::protectTypes);
-
- //mvm::jit::protectConstants = mvm::Lock::allocNormal();
- //mvm::Object::pushRoot((mvm::Object*)mvm::jit::protectConstants);
-
- mvm::jit::protectEngine = mvm::Lock::allocNormal();
- mvm::Object::pushRoot((mvm::Object*)mvm::jit::protectEngine);
-
-}
-
-llvm::Function* mvm::jit::llvm_memcpy_i32;
-llvm::Function* mvm::jit::llvm_memset_i32;
-
-llvm::Function* mvm::jit::exceptionEndCatch;
-llvm::Function* mvm::jit::exceptionBeginCatch;
-llvm::Function* mvm::jit::unwindResume;
-llvm::Function* mvm::jit::exceptionSelector;
-llvm::Function* mvm::jit::personality;
-llvm::Function* mvm::jit::llvmGetException;
-
-llvm::Function* mvm::jit::printFloatLLVM;
-llvm::Function* mvm::jit::printDoubleLLVM;
-llvm::Function* mvm::jit::printLongLLVM;
-llvm::Function* mvm::jit::printIntLLVM;
-llvm::Function* mvm::jit::printObjectLLVM;
-
-llvm::Function* mvm::jit::setjmpLLVM;
-
-llvm::Function* mvm::jit::func_llvm_fabs_f32;
-llvm::Function* mvm::jit::func_llvm_fabs_f64;
-llvm::Function* mvm::jit::func_llvm_sqrt_f64;
-llvm::Function* mvm::jit::func_llvm_sin_f64;
-llvm::Function* mvm::jit::func_llvm_cos_f64;
-llvm::Function* mvm::jit::func_llvm_tan_f64;
-llvm::Function* mvm::jit::func_llvm_asin_f64;
-llvm::Function* mvm::jit::func_llvm_acos_f64;
-llvm::Function* mvm::jit::func_llvm_atan_f64;
-llvm::Function* mvm::jit::func_llvm_atan2_f64;
-llvm::Function* mvm::jit::func_llvm_exp_f64;
-llvm::Function* mvm::jit::func_llvm_log_f64;
-llvm::Function* mvm::jit::func_llvm_pow_f64;
-llvm::Function* mvm::jit::func_llvm_ceil_f64;
-llvm::Function* mvm::jit::func_llvm_floor_f64;
-llvm::Function* mvm::jit::func_llvm_rint_f64;
-llvm::Function* mvm::jit::func_llvm_cbrt_f64;
-llvm::Function* mvm::jit::func_llvm_cosh_f64;
-llvm::Function* mvm::jit::func_llvm_expm1_f64;
-llvm::Function* mvm::jit::func_llvm_hypot_f64;
-llvm::Function* mvm::jit::func_llvm_log10_f64;
-llvm::Function* mvm::jit::func_llvm_log1p_f64;
-llvm::Function* mvm::jit::func_llvm_sinh_f64;
-llvm::Function* mvm::jit::func_llvm_tanh_f64;
-
-llvm::ExecutionEngine* mvm::jit::executionEngine;
-
-//mvm::Lock* mvm::jit::protectTypes;
-//mvm::Lock* mvm::jit::protectConstants;
-mvm::Lock* mvm::jit::protectEngine;
-llvm::ConstantInt* mvm::jit::constantInt8Zero;
-llvm::ConstantInt* mvm::jit::constantZero;
-llvm::ConstantInt* mvm::jit::constantOne;
-llvm::ConstantInt* mvm::jit::constantTwo;
-llvm::ConstantInt* mvm::jit::constantThree;
-llvm::ConstantInt* mvm::jit::constantFour;
-llvm::ConstantInt* mvm::jit::constantFive;
-llvm::ConstantInt* mvm::jit::constantSix;
-llvm::ConstantInt* mvm::jit::constantSeven;
-llvm::ConstantInt* mvm::jit::constantEight;
-llvm::ConstantInt* mvm::jit::constantMinusOne;
-llvm::ConstantInt* mvm::jit::constantLongMinusOne;
-llvm::ConstantInt* mvm::jit::constantLongZero;
-llvm::ConstantInt* mvm::jit::constantLongOne;
-llvm::ConstantInt* mvm::jit::constantMinInt;
-llvm::ConstantInt* mvm::jit::constantMaxInt;
-llvm::ConstantInt* mvm::jit::constantMinLong;
-llvm::ConstantInt* mvm::jit::constantMaxLong;
-llvm::ConstantFP* mvm::jit::constantFloatZero;
-llvm::ConstantFP* mvm::jit::constantFloatOne;
-llvm::ConstantFP* mvm::jit::constantFloatTwo;
-llvm::ConstantFP* mvm::jit::constantDoubleZero;
-llvm::ConstantFP* mvm::jit::constantDoubleOne;
-llvm::ConstantFP* mvm::jit::constantMaxIntFloat;
-llvm::ConstantFP* mvm::jit::constantMinIntFloat;
-llvm::ConstantFP* mvm::jit::constantMinLongFloat;
-llvm::ConstantFP* mvm::jit::constantMinLongDouble;
-llvm::ConstantFP* mvm::jit::constantMaxLongFloat;
-llvm::ConstantFP* mvm::jit::constantMaxIntDouble;
-llvm::ConstantFP* mvm::jit::constantMinIntDouble;
-llvm::ConstantFP* mvm::jit::constantMaxLongDouble;
-llvm::ConstantFP* mvm::jit::constantDoubleInfinity;
-llvm::ConstantFP* mvm::jit::constantDoubleMinusInfinity;
-llvm::ConstantFP* mvm::jit::constantFloatInfinity;
-llvm::ConstantFP* mvm::jit::constantFloatMinusInfinity;
-llvm::ConstantFP* mvm::jit::constantFloatMinusZero;
-llvm::ConstantFP* mvm::jit::constantDoubleMinusZero;
-llvm::Constant* mvm::jit::constantPtrNull;
-const llvm::PointerType* mvm::jit::ptrType;
-const llvm::Type* mvm::jit::arrayPtrType;
-
-llvm::Module *mvm::jit::globalModule;
-llvm::ExistingModuleProvider *mvm::jit::globalModuleProvider;
-llvm::JITMemoryManager *mvm::jit::memoryManager;
-
-
-uint64 mvm::jit::getTypeSize(const llvm::Type* type) {
- return executionEngine->getTargetData()->getABITypeSize(type);
-}
-
-extern "C" void __deregister_frame(void*);
-
-void ExceptionTable::destroyer(size_t sz) {
- __deregister_frame(this->frameRegister());
-}
-
-void mvm::jit::runPasses(llvm::Function* func, llvm::FunctionPassManager* pm) {
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
- pm->run(*func);
-}
-
-void mvm::jit::protectConstants() {
- mvm::jit::executionEngine->lock.acquire();
-}
-
-void mvm::jit::unprotectConstants() {
- mvm::jit::executionEngine->lock.release();
-}
-
-void mvm::jit::protectTypes() {
- mvm::jit::executionEngine->lock.acquire();
-}
-
-void mvm::jit::unprotectTypes() {
- mvm::jit::executionEngine->lock.release();
-}
Removed: vmkit/trunk/lib/Mvm/Main.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Main.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/Main.cc (original)
+++ vmkit/trunk/lib/Mvm/Main.cc (removed)
@@ -1,57 +0,0 @@
-//===--------------- Main.cc - Execution of the mvm -----------------------===//
-//
-// The Micro Virtual Machine
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "mvm/GC/GC.h"
-#include "mvm/PrintBuffer.h"
-#include "mvm/Threads/Thread.h"
-#include "mvm/Sigsegv.h"
-#include "mvm/VMLet.h"
-
-
-#include <dlfcn.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <stdio.h>
-
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/ManagedStatic.h"
-
-#include "CommandLine.h"
-
-using namespace mvm;
-
-
-typedef int (*boot)(int, char**, char**);
-
-static void clearSignals(void) {
- signal(SIGINT, SIG_DFL);
- signal(SIGILL, SIG_DFL);
-#if !defined(WIN32)
- signal(SIGIOT, SIG_DFL);
- signal(SIGBUS, SIG_DFL);
-#endif
- signal(SIGSEGV, SIG_DFL);
-}
-
-int main(int argc, char **argv, char **envp) {
- llvm::llvm_shutdown_obj X;
- int base;
- llvm::cl::ParseCommandLineOptions(argc, argv,
- " VMKit: a virtual machine launcher\n");
- Object::initialise(&base);
- VMLet::initialise();
-
- CommandLine cl;
- cl.start();
-
- clearSignals();
- Thread::exit(0);
-
- return 0;
-}
Modified: vmkit/trunk/lib/Mvm/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Makefile.am?rev=48952&r1=48951&r2=48952&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/Makefile.am (original)
+++ vmkit/trunk/lib/Mvm/Makefile.am Sun Mar 30 11:41:18 2008
@@ -14,7 +14,7 @@
LIBSUVM=$(LIBGC) $(LIBALLOC) $(LIBTHREAD)
PREFIX=@prefix@
-main_SOURCES = Main.cc Object.cc Sigsegv.cc JIT.cc CommandLine.cpp CommandLine.h MvmMemoryManager.h MvmMemoryManager.cpp EscapeAnalysis.cpp Disassembler.cc
+main_SOURCES = Main.cpp Object.cpp Sigsegv.cpp JIT.cpp CommandLine.cpp CommandLine.h MvmMemoryManager.h MvmMemoryManager.cpp EscapeAnalysis.cpp Disassembler.cpp
main_CXXFLAGS = $(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -pedantic -Wno-long-long -fno-omit-frame-pointer -O2 -g
main_LDFLAGS=@rdynamic@
main_LDADD = $(LIBSUVM) @LLVMDYLIB@
Removed: vmkit/trunk/lib/Mvm/Object.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Object.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/Object.cc (original)
+++ vmkit/trunk/lib/Mvm/Object.cc (removed)
@@ -1,174 +0,0 @@
-//===--------- Object.cc - Common objects for vmlets ----------------------===//
-//
-// The Micro Virtual Machine
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <stdlib.h>
-
-#include "mvm/Method.h"
-#include "mvm/Object.h"
-#include "mvm/PrintBuffer.h"
-#include "mvm/GC/GC.h"
-
-using namespace mvm;
-
-VirtualTable *Object::VT = 0;
-VirtualTable *Method::VT = 0;
-VirtualTable *Code::VT = 0;
-VirtualTable *ExceptionTable::VT = 0;
-VirtualTable *NativeString::VT = 0;
-VirtualTable *PrintBuffer::VT = 0;
-
-
-Object **Object::rootTable= 0;
-int Object::rootTableSize= 0;
-int Object::rootTableLimit= 0;
-
-void Object::growRootTable(void) {
- if (rootTableLimit != 0) {
- assert(rootTable != 0);
- rootTableLimit*= 2;
- rootTable= (Object **)
- ::realloc((void *)rootTable, rootTableLimit * sizeof(Object **));
- return;
- }
- rootTableLimit= 32;
- rootTable= (Object **)malloc(32 * sizeof(Object **));
-}
-
-
-void Object::markAndTraceRoots(void) {
- for (int i= 0; i < rootTableSize; ++i)
- rootTable[i]->markAndTrace();
-}
-
-void Object::initialise(void *b_sp) {
-# define INIT(X) { \
- X fake; \
- X::VT = ((void**)(void*)(&fake))[0]; }
-
- INIT(Object);
- INIT(Method);
- INIT(Code);
- INIT(NativeString);
- INIT(PrintBuffer);
- INIT(ExceptionTable);
-
-#undef INIT
-
- Collector::initialise(Object::markAndTraceRoots, b_sp);
-}
-
-void Code::tracer(size_t sz) {
- ((Code *)this)->method(sz)->markAndTrace();
-}
-
-void Method::tracer(size_t sz) {
- Method *const self= (Method *)this;
- self->definition()->markAndTrace();
- self->literals()->markAndTrace();
- self->name()->markAndTrace();
- self->code()->markAndTrace();
- self->exceptionTable()->markAndTrace();
-}
-
-void PrintBuffer::tracer(size_t sz) {
- ((PrintBuffer *)this)->contents()->markAndTrace();
-}
-
-PrintBuffer *PrintBuffer::alloc(void) {
- return allocPrintBuffer();
-}
-
-
-PrintBuffer *PrintBuffer::writeObj(const Object *obj) {
- Object *beg = (Object*)Collector::begOf(obj);
-
- if(beg) {
- if(beg == obj)
- obj->print((mvm::PrintBuffer*)this);
- else {
- write("<In Object [");
- beg->print(this);
- write("] -- offset ");
- writeS4((intptr_t)obj - (intptr_t)beg);
- write(">");
- }
- } else {
- write("<DirectValue: ");
- writeS4((intptr_t)obj);
- write(">");
- }
- return this;
-}
-
-extern "C" void write_ptr(PrintBuffer* buf, void* obj) {
- buf->writePtr(obj);
-}
-
-extern "C" void write_int(PrintBuffer* buf, int a) {
- buf->writeS4(a);
-}
-
-extern "C" void write_str(PrintBuffer* buf, char* a) {
- buf->write(a);
-}
-
-char *Object::printString(void) const {
- PrintBuffer *buf= PrintBuffer::alloc();
- buf->writeObj(this);
- return buf->contents()->cString();
-}
-
-void Object::print(PrintBuffer *buf) const {
- buf->write("<Object@");
- buf->writePtr((void*)this);
- buf->write(">");
-}
-
-void Code::print(PrintBuffer *buf) const {
- buf->write("Code<");
- buf->write(">");
-}
-
-void Method::print(PrintBuffer *buf) const {
- Method *const self= (Method *)this;
- buf->write("Method<");
- if (self->name()) {
- self->name()->print(buf);
- } else {
- buf->write("lambda");
- }
- buf->write(">");
-}
-
-void NativeString::print(PrintBuffer *buf) const {
- NativeString *const self= (NativeString *)this;
- buf->write("\"");
- for (size_t i= 0; i < strlen(self->cString()); ++i) {
- int c= self->cString()[i];
- switch (c) {
- case '\b': buf->write("\\b"); break;
- case '\f': buf->write("\\f"); break;
- case '\n': buf->write("\\n"); break;
- case '\r': buf->write("\\r"); break;
- case '\t': buf->write("\\t"); break;
- case '"': buf->write("\\\""); break;
- default: {
- char esc[32];
- if (c < 32)
- sprintf(esc, "\\x%02x", c);
- else
- sprintf(esc, "%c", c);
- buf->write(esc);
- }
- }
- }
- buf->write("\"");
-}
-
-NativeString *PrintBuffer::getContents() { return contents(); }
Removed: vmkit/trunk/lib/Mvm/Sigsegv.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Sigsegv.cc?rev=48951&view=auto
==============================================================================
--- vmkit/trunk/lib/Mvm/Sigsegv.cc (original)
+++ vmkit/trunk/lib/Mvm/Sigsegv.cc (removed)
@@ -1,72 +0,0 @@
-//===----------- Sigsegv.cc - Sigsegv default handling --------------------===//
-//
-// The Micro Virtual Machine
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-
-#include "mvm/GC/GC.h"
-#include "mvm/Sigsegv.h"
-#include "mvm/VMLet.h"
-
-#include <signal.h>
-#include <stdio.h>
-
-using namespace mvm;
-
-void (*client_sigsegv_handler)(int, void *) = 0;
-
-#if defined(__MACH__) && defined(__i386__)
-#include "ucontext.h"
-#endif
-
-void sigsegv_handler(int n, siginfo_t *_info, void *context) {
- void *addr = _info->si_addr;
-#if defined(__i386__)
- struct frame {
- struct frame *caller;
- void *ip;
- };
-
- struct frame *fp; /* my frame */
- asm ("mov %%ebp, %0" : "=&r"(fp)); /* get it */
- struct frame *caller = fp->caller; /* my caller */
- /* preserve my caller if I return from the handler */
- void *caller_ip = caller->ip;
-
-# if defined(__MACH__)
- //.gregs[REG_EIP]; /* just like it's on the stack.. */
- caller->ip = (void *)((ucontext_t*)context)->uc_mcontext->__ss.__eip;
-# else
- /* comme si c'était lui qui était sur la pile... */
- caller->ip = (void *)((ucontext_t*)context)->uc_mcontext.gregs[REG_EIP];
-# endif
-#endif
-
- /* Free the GC if it sisgegv'd. No other collection is possible */
- Collector::die_if_sigsegv_occured_during_collection(addr);
-
- // sys_exit(0);
- if(client_sigsegv_handler)
- client_sigsegv_handler(n, addr);
- else
- signal(SIGSEGV, SIG_DFL);
-
-#if defined(__i386__)
- caller->ip = caller_ip; /* restore the caller ip */
-#endif
-}
-
-void VMLet::register_sigsegv_handler(void (*fct)(int, void *)) {
- struct sigaction sa;
-
- sigaction(SIGSEGV, 0, &sa);
- sa.sa_sigaction = sigsegv_handler;
- sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER);
- sigaction(SIGSEGV, &sa, 0);
- client_sigsegv_handler = fct;
-}
-
More information about the llvm-commits
mailing list