remove the libstdc++ dependency once and for all

The trick is to make all destructors non-virtual.  This is safe because
we never use the delete operator, which is the only case where virtual
destructors are relevant.  This is a better solution than implementing
our own delete operator, because we want libraries loaded at runtime to
use the libstdc++ version, not ours.
This commit is contained in:
Joel Dice 2008-10-28 15:40:50 -06:00
parent 88a1faa2a2
commit 6f1d02dae7
14 changed files with 9 additions and 58 deletions

View File

@ -50,7 +50,11 @@ strip-all = --strip-all
rdynamic = -rdynamic
warnings = -Wall -Wextra -Werror -Wunused-parameter -Winit-self
# note that we supress the non-virtual-dtor warning because we never
# use the delete operator, which means we don't need virtual
# destructors:
warnings = -Wall -Wextra -Werror -Wunused-parameter -Winit-self \
-Wno-non-virtual-dtor
common-cflags = $(warnings) -fno-rtti -fno-exceptions \
"-I$(JAVA_HOME)/include" -idirafter $(src) -I$(native-build) \
@ -62,15 +66,8 @@ build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
cflags = $(build-cflags)
use-libstdcpp = true
common-lflags = -lm -lz
ifeq ($(use-libstdcpp),true)
common-lflags += -lstdc++
common-cflags += -DUSE_LIBSTDCPP
endif
build-lflags =
lflags = $(common-lflags) -lpthread -ldl

View File

@ -17,7 +17,6 @@ namespace vm {
class Allocator {
public:
virtual ~Allocator() { }
virtual void* tryAllocate(unsigned size) = 0;
virtual void* allocate(unsigned size) = 0;
virtual void free(const void* p, unsigned size) = 0;

View File

@ -78,8 +78,6 @@ const int AnyRegister = -2;
class Promise {
public:
virtual ~Promise() { }
virtual int64_t value() = 0;
virtual bool resolved() = 0;
};
@ -101,8 +99,6 @@ class ResolvedPromise: public Promise {
class TraceHandler {
public:
virtual ~TraceHandler() { }
virtual void handleTrace(Promise* address) = 0;
};
@ -146,8 +142,6 @@ class Assembler {
class Client {
public:
virtual ~Client() { }
virtual int acquireTemporary
(uint32_t mask = ~static_cast<uint32_t>(0)) = 0;
virtual void releaseTemporary(int r) = 0;
@ -156,8 +150,6 @@ class Assembler {
virtual void restore(int r) = 0;
};
virtual ~Assembler() { }
virtual void setClient(Client* client) = 0;
virtual unsigned registerCount() = 0;

View File

@ -11,12 +11,9 @@
#include "stdint.h"
#include "stdlib.h"
#ifndef USE_LIBSTDCPP
// since we aren't linking against libstdc++, we must implement some
// dummy functions:
// since we aren't linking against libstdc++, we must implement this
// ourselves:
extern "C" void __cxa_pure_virtual(void) { abort(); }
void operator delete(void*) { abort(); }
#endif
#ifdef __MINGW32__
# define EXPORT __declspec(dllexport)

View File

@ -48,8 +48,6 @@ class Site {
public:
Site(): next(0) { }
virtual ~Site() { }
virtual Site* readTarget(Context*, Read*) { return this; }
virtual unsigned copyCost(Context*, Site*) = 0;
@ -364,8 +362,6 @@ class Event {
sequence(sequence), stackReset(false)
{ }
virtual ~Event() { }
virtual void compile(Context* c) = 0;
virtual bool skipMove(unsigned) { return false; }

View File

@ -21,8 +21,6 @@ class Compiler {
public:
class Client {
public:
virtual ~Client() { }
virtual intptr_t getThunk(UnaryOperation op, unsigned size) = 0;
virtual intptr_t getThunk(BinaryOperation op, unsigned size) = 0;
};
@ -32,8 +30,6 @@ class Compiler {
class Operand { };
virtual ~Compiler() { }
virtual void pushState() = 0;
virtual void popState() = 0;
virtual void saveStack() = 0;

View File

@ -60,7 +60,7 @@ equal(const void* a, unsigned al, const void* b, unsigned bl)
class Element {
public:
Element(): next(0) { }
virtual ~Element() { }
virtual System::Region* find(const char* name) = 0;
virtual bool exists(const char* name) = 0;
virtual void dispose() = 0;

View File

@ -19,7 +19,6 @@ namespace vm {
class Finder {
public:
virtual ~Finder() { }
virtual System::Region* find(const char* name) = 0;
virtual bool exists(const char* name) = 0;
virtual const char* path() = 0;

View File

@ -32,19 +32,16 @@ class Heap: public Allocator {
class Visitor {
public:
virtual ~Visitor() { }
virtual void visit(void*) = 0;
};
class Walker {
public:
virtual ~Walker() { }
virtual bool visit(unsigned) = 0;
};
class Client {
public:
virtual ~Client() { }
virtual void collect(void* context, CollectionType type) = 0;
virtual void visitRoots(Visitor*) = 0;
virtual bool isFixed(void*) = 0;
@ -54,7 +51,6 @@ class Heap: public Allocator {
virtual void walk(void*, Walker*) = 0;
};
virtual ~Heap() { }
virtual void setClient(Client* client) = 0;
virtual void collect(CollectionType type, unsigned footprint) = 0;
virtual void* allocateFixed(Allocator* allocator, unsigned sizeInWords,

View File

@ -1212,7 +1212,7 @@ class Thread {
t->protector = this;
}
virtual ~Protector() {
~Protector() {
t->protector = next;
}

View File

@ -23,15 +23,11 @@ class Processor {
class StackVisitor {
public:
virtual ~StackVisitor() { }
virtual bool visit(StackWalker* walker) = 0;
};
class StackWalker {
public:
virtual ~StackWalker() { }
virtual void walk(StackVisitor* v) = 0;
virtual object method() = 0;
@ -41,8 +37,6 @@ class Processor {
virtual unsigned count() = 0;
};
virtual ~Processor() { }
virtual Thread*
makeThread(Machine* m, object javaThread, Thread* parent) = 0;

View File

@ -19,7 +19,6 @@ class Stream {
public:
class Client {
public:
virtual ~Client() { }
virtual void NO_RETURN handleError() = 0;
};

View File

@ -28,7 +28,6 @@ class System {
class Thread {
public:
virtual ~Thread() { }
virtual void interrupt() = 0;
virtual void join() = 0;
virtual void dispose() = 0;
@ -36,13 +35,11 @@ class System {
class ThreadVisitor {
public:
virtual ~ThreadVisitor() { }
virtual void visit(void* ip, void* base, void* stack) = 0;
};
class Runnable {
public:
virtual ~Runnable() { }
virtual void attach(Thread*) = 0;
virtual void run() = 0;
virtual bool interrupted() = 0;
@ -51,7 +48,6 @@ class System {
class Mutex {
public:
virtual ~Mutex() { }
virtual void acquire() = 0;
virtual void release() = 0;
virtual void dispose() = 0;
@ -59,7 +55,6 @@ class System {
class Monitor {
public:
virtual ~Monitor() { }
virtual bool tryAcquire(Thread* context) = 0;
virtual void acquire(Thread* context) = 0;
virtual void release(Thread* context) = 0;
@ -72,7 +67,6 @@ class System {
class Local {
public:
virtual ~Local() { }
virtual void* get() = 0;
virtual void set(void* p) = 0;
virtual void dispose() = 0;
@ -80,7 +74,6 @@ class System {
class Region {
public:
virtual ~Region() { }
virtual const uint8_t* start() = 0;
virtual size_t length() = 0;
virtual void dispose() = 0;
@ -88,7 +81,6 @@ class System {
class Library {
public:
virtual ~Library() { }
virtual void* resolve(const char* function) = 0;
virtual const char* name() = 0;
virtual bool mapName() = 0;
@ -99,8 +91,6 @@ class System {
class SignalHandler {
public:
virtual ~SignalHandler() { }
virtual bool handleSignal(void** ip, void** base, void** stack,
void** thread) = 0;
};
@ -120,8 +110,6 @@ class System {
System::Monitor* m;
};
virtual ~System() { }
virtual bool success(Status) = 0;
virtual void* tryAllocate(unsigned sizeInBytes) = 0;
virtual void free(const void* p) = 0;

View File

@ -130,8 +130,6 @@ class Task {
public:
Task(Task* next): next(next) { }
virtual ~Task() { }
virtual void run(Context* c) = 0;
Task* next;