Commit b7837499 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Some refactoring for some GC changes

parent 3d9bca6b
...@@ -187,7 +187,7 @@ endif ...@@ -187,7 +187,7 @@ endif
EXTRA_CXXFLAGS ?= EXTRA_CXXFLAGS ?=
CXXFLAGS_DBG := $(LLVM_CXXFLAGS) $(COMMON_CXXFLAGS) -O0 -DBINARY_SUFFIX= -DBINARY_STRIPPED_SUFFIX=_stripped $(EXTRA_CXXFLAGS) CXXFLAGS_DBG := $(LLVM_CXXFLAGS) $(COMMON_CXXFLAGS) -O0 -DBINARY_SUFFIX= -DBINARY_STRIPPED_SUFFIX=_stripped $(EXTRA_CXXFLAGS)
CXXFLAGS_PROFILE = $(LLVM_PROFILE_CXXFLAGS) $(COMMON_CXXFLAGS) -pg -O3 -DNDEBUG -DNVALGRIND -DBINARY_SUFFIX=_release -DBINARY_STRIPPED_SUFFIX= -fno-function-sections $(EXTRA_CXXFLAGS) CXXFLAGS_PROFILE = $(LLVM_PROFILE_CXXFLAGS) $(COMMON_CXXFLAGS) -pg -O3 -DNDEBUG -DNVALGRIND -DBINARY_SUFFIX=_release -DBINARY_STRIPPED_SUFFIX= -fno-function-sections $(EXTRA_CXXFLAGS)
CXXFLAGS_RELEASE := $(LLVM_RELEASE_CXXFLAGS) $(COMMON_CXXFLAGS) -O3 -fstrict-aliasing -enable-tbaa -DNDEBUG -DNVALGRIND -DBINARY_SUFFIX=_release -DBINARY_STRIPPED_SUFFIX= $(EXTRA_CXXFLAGS) CXXFLAGS_RELEASE := $(LLVM_RELEASE_CXXFLAGS) $(COMMON_CXXFLAGS) -O3 -fstrict-aliasing -DNDEBUG -DNVALGRIND -DBINARY_SUFFIX=_release -DBINARY_STRIPPED_SUFFIX= $(EXTRA_CXXFLAGS)
LDFLAGS := $(LLVM_LDFLAGS) $(COMMON_LDFLAGS) LDFLAGS := $(LLVM_LDFLAGS) $(COMMON_LDFLAGS)
LDFLAGS_DEBUG := $(LLVM_DEBUG_LDFLAGS) $(COMMON_LDFLAGS) LDFLAGS_DEBUG := $(LLVM_DEBUG_LDFLAGS) $(COMMON_LDFLAGS)
...@@ -203,7 +203,7 @@ CLANG_DEPS := $(CLANGPP_EXE) $(abspath $(dir $(CLANGPP_EXE))/../../built_release ...@@ -203,7 +203,7 @@ CLANG_DEPS := $(CLANGPP_EXE) $(abspath $(dir $(CLANGPP_EXE))/../../built_release
# settings to make clang and ccache play nicely: # settings to make clang and ccache play nicely:
CLANG_CCACHE_FLAGS := -Qunused-arguments CLANG_CCACHE_FLAGS := -Qunused-arguments
CLANG_EXTRA_FLAGS := -Wno-mismatched-tags -ferror-limit=$(ERROR_LIMIT) $(CLANG_CCACHE_FLAGS) CLANG_EXTRA_FLAGS := -Wno-mismatched-tags -enable-tbaa -ferror-limit=$(ERROR_LIMIT) $(CLANG_CCACHE_FLAGS)
ifeq ($(COLOR),1) ifeq ($(COLOR),1)
CLANG_EXTRA_FLAGS += -fcolor-diagnostics CLANG_EXTRA_FLAGS += -fcolor-diagnostics
else else
......
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
#define __has_builtin(x) 0 #define __has_builtin(x) 0
#endif #endif
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#define _STRINGIFY(N) #N #define _STRINGIFY(N) #N
#define STRINGIFY(N) _STRINGIFY(N) #define STRINGIFY(N) _STRINGIFY(N)
#define _CAT(A, B) A##B #define _CAT(A, B) A##B
......
...@@ -36,6 +36,36 @@ ...@@ -36,6 +36,36 @@
namespace pyston { namespace pyston {
namespace gc { namespace gc {
class TraceStack {
private:
std::vector<void*> v;
public:
TraceStack() {}
TraceStack(const TraceStack& rhs) {
for (void* p : rhs.v) {
push(p);
}
}
void push(void* p) {
v.push_back(p);
}
int size() { return v.size(); }
void reserve(int num) { v.reserve(num + v.size()); }
void* pop() {
if (v.size()) {
void* r = v.back();
v.pop_back();
return r;
}
return NULL;
}
};
static TraceStack roots; static TraceStack roots;
void registerPermanentRoot(void* obj) { void registerPermanentRoot(void* obj) {
assert(global_heap.getAllocationFromInteriorPointer(obj)); assert(global_heap.getAllocationFromInteriorPointer(obj));
......
...@@ -22,29 +22,6 @@ ...@@ -22,29 +22,6 @@
namespace pyston { namespace pyston {
namespace gc { namespace gc {
class TraceStack {
private:
std::vector<void*> v;
public:
template <typename T> void pushall(T start, T end) { v.insert(v.end(), start, end); }
void push(void* p) { v.push_back(p); }
int size() { return v.size(); }
void reserve(int num) { v.reserve(num + v.size()); }
void* pop() {
if (v.size()) {
void* r = v.back();
v.pop_back();
return r;
}
return NULL;
}
};
// Mark this gc-allocated object as being a root, even if there are no visible references to it. // Mark this gc-allocated object as being a root, even if there are no visible references to it.
// (Note: this marks the gc allocation itself, not the pointer that points to one. For that, use // (Note: this marks the gc allocation itself, not the pointer that points to one. For that, use
// a GCRootHandle) // a GCRootHandle)
......
...@@ -2,46 +2,9 @@ ...@@ -2,46 +2,9 @@
#include <cstdio> #include <cstdio>
#include "stdint.h" #include "stdint.h"
class C { extern void foo();
public:
C(int i) {
printf("ctor\n");
}
void* operator new(size_t bytes) {
printf("operator new\n");
return NULL;
}
};
int f() { void bar(int* x) {
printf("f()"); if (*x & 0x08)
return 1; foo();
}
extern "C" C* c() {
return new C(f());
}
void moo(double);
float chrs[10];
void foo(int i) {
moo(chrs[i]);
}
void moo2(long long);
int chrs2[10];
void foo2(int i) {
moo2(chrs2[i]);
}
void moo3(long long);
short chrs3[10];
void foo3(int i) {
moo3(chrs3[i]);
}
void moo4(bool);
bool chrs4[10];
void foo4(int i) {
moo4(chrs4[i]);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment