mirror of
https://github.com/corda/corda.git
synced 2025-01-19 11:16:54 +00:00
refactor build system to support cross-compiling
This commit is contained in:
parent
3e84d4438a
commit
ac4b28ffe6
170
makefile
170
makefile
@ -1,43 +1,37 @@
|
|||||||
MAKEFLAGS = -s
|
MAKEFLAGS = -s
|
||||||
|
|
||||||
arch = $(shell uname -m)
|
input = $(cls)/Memory.class
|
||||||
ifeq ($(arch),i586)
|
|
||||||
arch = i386
|
build-arch = $(shell uname -m)
|
||||||
|
ifeq ($(build-arch),i586)
|
||||||
|
build-arch = i386
|
||||||
endif
|
endif
|
||||||
ifeq ($(arch),i686)
|
ifeq ($(build-arch),i686)
|
||||||
arch = i386
|
build-arch = i386
|
||||||
endif
|
endif
|
||||||
|
|
||||||
platform = $(shell uname -s | tr [:upper:] [:lower:])
|
build-platform = $(shell uname -s | tr [:upper:] [:lower:])
|
||||||
|
|
||||||
ifeq ($(platform),darwin)
|
arch = $(build-arch)
|
||||||
rdynamic =
|
|
||||||
thread-cflags =
|
platform = $(build-platform)
|
||||||
shared = -dynamiclib
|
|
||||||
so-extension = jnilib
|
|
||||||
ld-library-path = DYLD_LIBRARY_PATH
|
|
||||||
else
|
|
||||||
rdynamic = -rdynamic
|
|
||||||
thread-cflags = -pthread
|
|
||||||
shared = -shared
|
|
||||||
so-extension = so
|
|
||||||
ld-library-path = LD_LIBRARY_PATH
|
|
||||||
endif
|
|
||||||
|
|
||||||
process = interpret
|
process = interpret
|
||||||
|
|
||||||
mode = debug
|
mode = debug
|
||||||
|
|
||||||
|
build-dir = build/$(build-platform)/$(build-arch)
|
||||||
bld = build/$(platform)/$(arch)/$(mode)
|
bld = build/$(platform)/$(arch)/$(mode)
|
||||||
cls = build/classes
|
cls = build/classes
|
||||||
src = src
|
src = src
|
||||||
classpath = classpath
|
classpath = classpath
|
||||||
test = test
|
test = test
|
||||||
|
|
||||||
input = $(cls)/Memory.class
|
build-cxx = g++
|
||||||
|
build-cc = gcc
|
||||||
|
|
||||||
cxx = g++
|
cxx = $(build-cxx)
|
||||||
cc = gcc
|
cc = $(build-cc)
|
||||||
vg = nice valgrind --suppressions=valgrind.supp --undef-value-errors=no \
|
vg = nice valgrind --suppressions=valgrind.supp --undef-value-errors=no \
|
||||||
--num-callers=32 --db-attach=yes --freelist-vol=100000000
|
--num-callers=32 --db-attach=yes --freelist-vol=100000000
|
||||||
db = gdb --args
|
db = gdb --args
|
||||||
@ -45,49 +39,80 @@ javac = javac
|
|||||||
strip = :
|
strip = :
|
||||||
show-size = :
|
show-size = :
|
||||||
|
|
||||||
|
rdynamic = -rdynamic
|
||||||
|
thread-cflags = -pthread
|
||||||
|
shared = -shared
|
||||||
|
so-extension = so
|
||||||
|
ld-library-path = LD_LIBRARY_PATH
|
||||||
|
|
||||||
warnings = -Wall -Wextra -Werror -Wunused-parameter \
|
warnings = -Wall -Wextra -Werror -Wunused-parameter \
|
||||||
-Winit-self -Wconversion
|
-Winit-self -Wconversion
|
||||||
|
|
||||||
thread-lflags = -lpthread
|
|
||||||
|
|
||||||
cflags = $(warnings) -fPIC -fno-rtti -fno-exceptions -fvisibility=hidden \
|
cflags = $(warnings) -fPIC -fno-rtti -fno-exceptions -fvisibility=hidden \
|
||||||
-I$(src) -I$(bld) $(thread-cflags) -D__STDC_LIMIT_MACROS
|
-I$(src) -I$(build-dir) $(thread-cflags) -D__STDC_LIMIT_MACROS
|
||||||
|
|
||||||
lflags = $(thread-lflags) -ldl -lm -lz
|
lflags = -lpthread -ldl -lm -lz
|
||||||
|
|
||||||
|
system = posix
|
||||||
|
|
||||||
|
ifeq ($(platform),darwin)
|
||||||
|
rdynamic =
|
||||||
|
thread-cflags =
|
||||||
|
shared = -dynamiclib
|
||||||
|
so-extension = jnilib
|
||||||
|
ld-library-path = DYLD_LIBRARY_PATH
|
||||||
|
endif
|
||||||
|
ifeq ($(platform),windows)
|
||||||
|
inc = ../6.0/shared/include/msw
|
||||||
|
lib = ../6.0/shared/lib/native/msw
|
||||||
|
|
||||||
|
system = windows
|
||||||
|
cxx = i586-mingw32msvc-g++
|
||||||
|
cc = i586-mingw32msvc-gcc
|
||||||
|
rdynamic =
|
||||||
|
so-extension = dll
|
||||||
|
thread-cflags =
|
||||||
|
lflags = -L$(lib) -lm -lz -Wl,--kill-at
|
||||||
|
cflags = $(warnings) -fno-rtti -fno-exceptions -I$(src) -I$(build-dir) \
|
||||||
|
$(thread-cflags) -D__STDC_LIMIT_MACROS -I$(inc)
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(mode),debug)
|
ifeq ($(mode),debug)
|
||||||
cflags += -O0 -g3
|
cflags += -O0 -g3
|
||||||
endif
|
endif
|
||||||
ifeq ($(mode),stress)
|
ifeq ($(mode),stress)
|
||||||
cflags += -O0 -g3 -DVM_STRESS
|
cflags += -O0 -g3 -DVM_STRESS
|
||||||
endif
|
endif
|
||||||
ifeq ($(mode),stress-major)
|
ifeq ($(mode),stress-major)
|
||||||
cflags += -O0 -g3 -DVM_STRESS -DVM_STRESS_MAJOR
|
cflags += -O0 -g3 -DVM_STRESS -DVM_STRESS_MAJOR
|
||||||
endif
|
endif
|
||||||
ifeq ($(mode),fast)
|
ifeq ($(mode),fast)
|
||||||
cflags += -O3 -DNDEBUG
|
cflags += -O3 -DNDEBUG
|
||||||
strip = strip
|
strip = strip
|
||||||
show-size = ls -l
|
show-size = ls -l
|
||||||
endif
|
endif
|
||||||
|
|
||||||
cpp-objects = $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(bld)/%.o,$(x)))
|
ifeq ($(arch),i386)
|
||||||
asm-objects = $(foreach x,$(1),$(patsubst $(2)/%.S,$(bld)/%-asm.o,$(x)))
|
pointer-size = 4
|
||||||
|
else
|
||||||
|
pointer-size = 8
|
||||||
|
endif
|
||||||
|
|
||||||
|
cpp-objects = $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(3)/%.o,$(x)))
|
||||||
|
asm-objects = $(foreach x,$(1),$(patsubst $(2)/%.S,$(3)/%-asm.o,$(x)))
|
||||||
java-classes = $(foreach x,$(1),$(patsubst $(2)/%.java,$(cls)/%.class,$(x)))
|
java-classes = $(foreach x,$(1),$(patsubst $(2)/%.java,$(cls)/%.class,$(x)))
|
||||||
|
|
||||||
stdcpp-sources = $(src)/stdc++.cpp
|
|
||||||
stdcpp-objects = $(call cpp-objects,$(stdcpp-sources),$(src))
|
|
||||||
|
|
||||||
jni-sources = $(shell find $(classpath) -name '*.cpp')
|
jni-sources = $(shell find $(classpath) -name '*.cpp')
|
||||||
jni-objects = $(call cpp-objects,$(jni-sources),$(classpath))
|
jni-objects = $(call cpp-objects,$(jni-sources),$(classpath),$(bld))
|
||||||
jni-cflags = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux $(cflags)
|
jni-cflags = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux $(cflags)
|
||||||
jni-library = $(bld)/libnatives.$(so-extension)
|
jni-library = $(bld)/libnatives.$(so-extension)
|
||||||
|
|
||||||
generated-code = \
|
generated-code = \
|
||||||
$(bld)/type-enums.cpp \
|
$(build-dir)/type-enums.cpp \
|
||||||
$(bld)/type-declarations.cpp \
|
$(build-dir)/type-declarations.cpp \
|
||||||
$(bld)/type-constructors.cpp \
|
$(build-dir)/type-constructors.cpp \
|
||||||
$(bld)/type-initializations.cpp \
|
$(build-dir)/type-initializations.cpp \
|
||||||
$(bld)/type-java-initializations.cpp
|
$(build-dir)/type-java-initializations.cpp
|
||||||
|
|
||||||
interpreter-depends = \
|
interpreter-depends = \
|
||||||
$(generated-code) \
|
$(generated-code) \
|
||||||
@ -103,7 +128,7 @@ interpreter-depends = \
|
|||||||
$(src)/machine.h
|
$(src)/machine.h
|
||||||
|
|
||||||
interpreter-sources = \
|
interpreter-sources = \
|
||||||
$(src)/system.cpp \
|
$(src)/$(system).cpp \
|
||||||
$(src)/finder.cpp \
|
$(src)/finder.cpp \
|
||||||
$(src)/machine.cpp \
|
$(src)/machine.cpp \
|
||||||
$(src)/heap.cpp \
|
$(src)/heap.cpp \
|
||||||
@ -112,12 +137,16 @@ interpreter-sources = \
|
|||||||
$(src)/jnienv.cpp \
|
$(src)/jnienv.cpp \
|
||||||
$(src)/main.cpp
|
$(src)/main.cpp
|
||||||
|
|
||||||
interpreter-asm-sources = $(src)/compile.S $(src)/system.S
|
interpreter-asm-sources = $(src)/$(system).S
|
||||||
|
|
||||||
|
ifeq ($(process),compile)
|
||||||
|
interpreter-asm-sources += $(src)/compile.S
|
||||||
|
endif
|
||||||
|
|
||||||
interpreter-cpp-objects = \
|
interpreter-cpp-objects = \
|
||||||
$(call cpp-objects,$(interpreter-sources),$(src))
|
$(call cpp-objects,$(interpreter-sources),$(src),$(bld))
|
||||||
interpreter-asm-objects = \
|
interpreter-asm-objects = \
|
||||||
$(call asm-objects,$(interpreter-asm-sources),$(src))
|
$(call asm-objects,$(interpreter-asm-sources),$(src),$(bld))
|
||||||
interpreter-objects = \
|
interpreter-objects = \
|
||||||
$(interpreter-cpp-objects) \
|
$(interpreter-cpp-objects) \
|
||||||
$(interpreter-asm-objects)
|
$(interpreter-asm-objects)
|
||||||
@ -127,8 +156,9 @@ generator-headers = \
|
|||||||
$(src)/output.h
|
$(src)/output.h
|
||||||
generator-sources = \
|
generator-sources = \
|
||||||
$(src)/type-generator.cpp
|
$(src)/type-generator.cpp
|
||||||
generator-objects = $(call cpp-objects,$(generator-sources),$(src))
|
generator-objects = $(call \
|
||||||
generator-executable = $(bld)/generator
|
cpp-objects,$(generator-sources),$(src),$(build-dir))
|
||||||
|
generator-executable = $(build-dir)/generator
|
||||||
|
|
||||||
executable = $(bld)/vm
|
executable = $(bld)/vm
|
||||||
|
|
||||||
@ -157,15 +187,15 @@ run: build
|
|||||||
|
|
||||||
.PHONY: debug
|
.PHONY: debug
|
||||||
debug: build
|
debug: build
|
||||||
LD_LIBRARY_PATH=$(bld) gdb --args $(executable) $(args)
|
$(ld-library-path)=$(bld) gdb --args $(executable) $(args)
|
||||||
|
|
||||||
.PHONY: vg
|
.PHONY: vg
|
||||||
vg: build
|
vg: build
|
||||||
LD_LIBRARY_PATH=$(bld) $(vg) $(executable) $(args)
|
$(ld-library-path)=$(bld) $(vg) $(executable) $(args)
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: build
|
test: build
|
||||||
LD_LIBRARY_PATH=$(bld) /bin/bash $(test)/test.sh 2>/dev/null \
|
$(ld-library-path)=$(bld) /bin/bash $(test)/test.sh 2>/dev/null \
|
||||||
$(executable) $(mode) "$(flags)" $(call class-names,$(test-classes))
|
$(executable) $(mode) "$(flags)" $(call class-names,$(test-classes))
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
@ -175,15 +205,15 @@ clean:
|
|||||||
|
|
||||||
.PHONY: clean-native
|
.PHONY: clean-native
|
||||||
clean-native:
|
clean-native:
|
||||||
@echo "removing $(bld)"
|
@echo "removing $(bld) and $(build-dir)"
|
||||||
rm -rf $(bld)
|
rm -rf $(bld) $(build-dir)
|
||||||
|
|
||||||
gen-arg = $(shell echo $(1) | sed -e 's:$(bld)/type-\(.*\)\.cpp:\1:')
|
gen-arg = $(shell echo $(1) | sed -e 's:$(build-dir)/type-\(.*\)\.cpp:\1:')
|
||||||
$(generated-code): %.cpp: $(src)/types.def $(generator-executable)
|
$(generated-code): %.cpp: $(src)/types.def $(generator-executable)
|
||||||
@echo "generating $(@)"
|
@echo "generating $(@)"
|
||||||
$(generator-executable) $(call gen-arg,$(@)) < $(<) > $(@)
|
$(generator-executable) $(call gen-arg,$(@)) < $(<) > $(@)
|
||||||
|
|
||||||
$(bld)/type-generator.o: \
|
$(build-dir)/type-generator.o: \
|
||||||
$(generator-headers)
|
$(generator-headers)
|
||||||
|
|
||||||
define compile-class
|
define compile-class
|
||||||
@ -206,17 +236,16 @@ define compile-object
|
|||||||
$(cxx) $(cflags) -c $(<) -o $(@)
|
$(cxx) $(cflags) -c $(<) -o $(@)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(stdcpp-objects): $(bld)/%.o: $(src)/%.cpp
|
|
||||||
$(compile-object)
|
|
||||||
|
|
||||||
$(interpreter-cpp-objects): $(bld)/%.o: $(src)/%.cpp $(interpreter-depends)
|
$(interpreter-cpp-objects): $(bld)/%.o: $(src)/%.cpp $(interpreter-depends)
|
||||||
$(compile-object)
|
$(compile-object)
|
||||||
|
|
||||||
$(interpreter-asm-objects): $(bld)/%-asm.o: $(src)/%.S
|
$(interpreter-asm-objects): $(bld)/%-asm.o: $(src)/%.S
|
||||||
$(compile-object)
|
$(compile-object)
|
||||||
|
|
||||||
$(generator-objects): $(bld)/%.o: $(src)/%.cpp
|
$(generator-objects): $(build-dir)/%.o: $(src)/%.cpp
|
||||||
$(compile-object)
|
@echo "compiling $(@)"
|
||||||
|
@mkdir -p $(dir $(@))
|
||||||
|
$(build-cxx) $(cflags) -c $(<) -o $(@)
|
||||||
|
|
||||||
$(jni-objects): $(bld)/%.o: $(classpath)/%.cpp
|
$(jni-objects): $(bld)/%.o: $(classpath)/%.cpp
|
||||||
@echo "compiling $(@)"
|
@echo "compiling $(@)"
|
||||||
@ -225,25 +254,14 @@ $(jni-objects): $(bld)/%.o: $(classpath)/%.cpp
|
|||||||
|
|
||||||
$(jni-library): $(jni-objects)
|
$(jni-library): $(jni-objects)
|
||||||
@echo "linking $(@)"
|
@echo "linking $(@)"
|
||||||
$(cc) $(lflags) $(shared) $(^) -o $(@)
|
$(cc) $(^) $(lflags) $(shared) -o $(@)
|
||||||
|
|
||||||
$(executable): $(interpreter-objects) $(stdcpp-objects)
|
$(executable): $(interpreter-objects) $(stdcpp-objects)
|
||||||
@echo "linking $(@)"
|
@echo "linking $(@)"
|
||||||
$(cc) $(lflags) $(rdynamic) $(^) -o $(@)
|
$(cc) $(^) $(lflags) $(rdynamic) -o $(@)
|
||||||
@$(strip) --strip-all $(@)
|
@$(strip) --strip-all $(@)
|
||||||
@$(show-size) $(@)
|
@$(show-size) $(@)
|
||||||
|
|
||||||
.PHONY: generator
|
$(generator-executable): $(generator-objects)
|
||||||
generator: $(generator-executable)
|
|
||||||
|
|
||||||
.PHONY: run-generator
|
|
||||||
run-generator: $(generator-executable)
|
|
||||||
$(<) < $(src)/types.def
|
|
||||||
|
|
||||||
.PHONY: vg-generator
|
|
||||||
vg-generator: $(generator-executable)
|
|
||||||
$(vg) $(<) < $(src)/types.def
|
|
||||||
|
|
||||||
$(generator-executable): $(generator-objects) $(stdcpp-objects)
|
|
||||||
@echo "linking $(@)"
|
@echo "linking $(@)"
|
||||||
$(cc) $(lflags) $(^) -o $(@)
|
$(build-cc) -DPOINTER_SIZE=$(pointer-size) $(^) -o $(@)
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
|
|
||||||
inline void* operator new(size_t, void* p) throw() { return p; }
|
inline void* operator new(size_t, void* p) throw() { return p; }
|
||||||
|
|
||||||
|
inline void operator delete(void*) { abort(); }
|
||||||
|
|
||||||
namespace vm {
|
namespace vm {
|
||||||
|
|
||||||
const unsigned BytesPerWord = sizeof(uintptr_t);
|
const unsigned BytesPerWord = sizeof(uintptr_t);
|
||||||
|
@ -1550,16 +1550,18 @@ exit(Thread* t)
|
|||||||
object f = *p;
|
object f = *p;
|
||||||
*p = finalizerNext(t, *p);
|
*p = finalizerNext(t, *p);
|
||||||
|
|
||||||
reinterpret_cast<void (*)(Thread*, object)>(finalizerFinalize(t, f))
|
void (*function)(Thread*, object);
|
||||||
(t, finalizerTarget(t, f));
|
memcpy(&function, &finalizerFinalize(t, f), BytesPerWord);
|
||||||
|
function(t, finalizerTarget(t, f));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (object* p = &(t->m->tenuredFinalizers); *p;) {
|
for (object* p = &(t->m->tenuredFinalizers); *p;) {
|
||||||
object f = *p;
|
object f = *p;
|
||||||
*p = finalizerNext(t, *p);
|
*p = finalizerNext(t, *p);
|
||||||
|
|
||||||
reinterpret_cast<void (*)(Thread*, object)>(finalizerFinalize(t, f))
|
void (*function)(Thread*, object);
|
||||||
(t, finalizerTarget(t, f));
|
memcpy(&function, &finalizerFinalize(t, f), BytesPerWord);
|
||||||
|
function(t, finalizerTarget(t, f));
|
||||||
}
|
}
|
||||||
|
|
||||||
disposeAll(t, t->m->rootThread);
|
disposeAll(t, t->m->rootThread);
|
||||||
@ -2390,7 +2392,10 @@ addFinalizer(Thread* t, object target, void (*finalize)(Thread*, object))
|
|||||||
|
|
||||||
ACQUIRE(t, t->m->referenceLock);
|
ACQUIRE(t, t->m->referenceLock);
|
||||||
|
|
||||||
object f = makeFinalizer(t, 0, reinterpret_cast<void*>(finalize), 0);
|
void* function;
|
||||||
|
memcpy(&function, &finalize, BytesPerWord);
|
||||||
|
|
||||||
|
object f = makeFinalizer(t, 0, function, 0);
|
||||||
finalizerTarget(t, f) = target;
|
finalizerTarget(t, f) = target;
|
||||||
finalizerNext(t, f) = t->m->finalizers;
|
finalizerNext(t, f) = t->m->finalizers;
|
||||||
t->m->finalizers = f;
|
t->m->finalizers = f;
|
||||||
@ -2602,8 +2607,9 @@ collect(Thread* t, Heap::CollectionType type)
|
|||||||
postCollect(m->rootThread);
|
postCollect(m->rootThread);
|
||||||
|
|
||||||
for (object f = m->finalizeQueue; f; f = finalizerNext(t, f)) {
|
for (object f = m->finalizeQueue; f; f = finalizerNext(t, f)) {
|
||||||
reinterpret_cast<void (*)(Thread*, object)>(finalizerFinalize(t, f))
|
void (*function)(Thread*, object);
|
||||||
(t, finalizerTarget(t, f));
|
memcpy(&function, &finalizerFinalize(t, f), BytesPerWord);
|
||||||
|
function(t, finalizerTarget(t, f));
|
||||||
}
|
}
|
||||||
m->finalizeQueue = 0;
|
m->finalizeQueue = 0;
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
using namespace vm;
|
using namespace vm;
|
||||||
|
|
||||||
|
extern "C" void __cxa_pure_virtual(void) { abort(); }
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
#include "stdlib.h"
|
|
||||||
|
|
||||||
extern "C" void
|
|
||||||
__cxa_pure_virtual(void)
|
|
||||||
{
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
operator delete(void*)
|
|
||||||
{
|
|
||||||
abort();
|
|
||||||
}
|
|
@ -8,21 +8,31 @@
|
|||||||
|
|
||||||
#define UNREACHABLE abort()
|
#define UNREACHABLE abort()
|
||||||
|
|
||||||
|
inline void operator delete(void*) { abort(); }
|
||||||
|
|
||||||
|
extern "C" void __cxa_pure_virtual(void) { abort(); }
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
#ifndef POINTER_SIZE
|
||||||
|
# define POINTER_SIZE sizeof(void*)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const unsigned BytesPerWord = POINTER_SIZE;
|
||||||
|
|
||||||
inline unsigned
|
inline unsigned
|
||||||
pad(unsigned size, unsigned alignment)
|
pad(unsigned size, unsigned alignment)
|
||||||
{
|
{
|
||||||
unsigned n = alignment;
|
unsigned n = alignment;
|
||||||
while (size and n % size and n % sizeof(void*)) ++ n;
|
while (size and n % size and n % BytesPerWord) ++ n;
|
||||||
return n - alignment;
|
return n - alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned
|
inline unsigned
|
||||||
pad(unsigned n)
|
pad(unsigned n)
|
||||||
{
|
{
|
||||||
unsigned extra = n % sizeof(void*);
|
unsigned extra = n % BytesPerWord;
|
||||||
return (extra ? n + sizeof(void*) - extra : n);
|
return (extra ? n + BytesPerWord - extra : n);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@ -393,7 +403,7 @@ addMember(Object* o, Object* member)
|
|||||||
case Object::Type: case Object::Pod:
|
case Object::Type: case Object::Pod:
|
||||||
if (member->type == Object::Array) {
|
if (member->type == Object::Array) {
|
||||||
static_cast<Type*>(o)->members.append
|
static_cast<Type*>(o)->members.append
|
||||||
(Scalar::make(o, 0, "uintptr_t", "length", sizeof(uintptr_t)));
|
(Scalar::make(o, 0, "uintptr_t", "length", BytesPerWord));
|
||||||
}
|
}
|
||||||
static_cast<Type*>(o)->members.append(member);
|
static_cast<Type*>(o)->members.append(member);
|
||||||
break;
|
break;
|
||||||
@ -664,7 +674,7 @@ class MemberIterator {
|
|||||||
members(0),
|
members(0),
|
||||||
member(0),
|
member(0),
|
||||||
index_(-1),
|
index_(-1),
|
||||||
offset_(type->type == Object::Pod ? 0 : sizeof(void*)),
|
offset_(type->type == Object::Pod ? 0 : BytesPerWord),
|
||||||
size_(0),
|
size_(0),
|
||||||
padding_(0),
|
padding_(0),
|
||||||
alignment_(0)
|
alignment_(0)
|
||||||
@ -705,7 +715,7 @@ class MemberIterator {
|
|||||||
case Object::Scalar: {
|
case Object::Scalar: {
|
||||||
size_ = memberSize(member);
|
size_ = memberSize(member);
|
||||||
padding_ = pad(size_, alignment_);
|
padding_ = pad(size_, alignment_);
|
||||||
alignment_ = (alignment_ + size_ + padding_) % sizeof(void*);
|
alignment_ = (alignment_ + size_ + padding_) % BytesPerWord;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Object::Array: {
|
case Object::Array: {
|
||||||
@ -777,9 +787,9 @@ unsigned
|
|||||||
sizeOf(const char* type, Object* declarations)
|
sizeOf(const char* type, Object* declarations)
|
||||||
{
|
{
|
||||||
if (equal(type, "object")) {
|
if (equal(type, "object")) {
|
||||||
return sizeof(void*);
|
return BytesPerWord;
|
||||||
} else if (equal(type, "intptr_t")) {
|
} else if (equal(type, "intptr_t")) {
|
||||||
return sizeof(intptr_t);
|
return BytesPerWord;
|
||||||
} else if (equal(type, "unsigned") or equal(type, "int")) {
|
} else if (equal(type, "unsigned") or equal(type, "int")) {
|
||||||
return sizeof(int);
|
return sizeof(int);
|
||||||
} else if (equal(type, "bool")) {
|
} else if (equal(type, "bool")) {
|
||||||
@ -797,7 +807,7 @@ sizeOf(const char* type, Object* declarations)
|
|||||||
} else if (endsWith("[0]", type)) {
|
} else if (endsWith("[0]", type)) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (namesPointer(type)) {
|
} else if (namesPointer(type)) {
|
||||||
return sizeof(void*);
|
return BytesPerWord;
|
||||||
} else {
|
} else {
|
||||||
Object* dec = declaration(type, declarations);
|
Object* dec = declaration(type, declarations);
|
||||||
if (dec) return typeSize(dec);
|
if (dec) return typeSize(dec);
|
||||||
@ -1186,7 +1196,7 @@ typeBodyOffset(Object* type, Object* offset)
|
|||||||
default: UNREACHABLE;
|
default: UNREACHABLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsigned padding = pad(sizeof(void*), it.alignment());
|
unsigned padding = pad(BytesPerWord, it.alignment());
|
||||||
if (padding) offset = cons(Number::make(padding), offset);
|
if (padding) offset = cons(Number::make(padding), offset);
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
@ -1198,7 +1208,7 @@ typeOffset(Object* type, Object* super)
|
|||||||
return typeBodyOffset(super, typeOffset(super, typeSuper(super)));
|
return typeBodyOffset(super, typeOffset(super, typeSuper(super)));
|
||||||
} else {
|
} else {
|
||||||
return (type->type == Object::Type ?
|
return (type->type == Object::Type ?
|
||||||
cons(Number::make(sizeof(void*)), 0) : 0);
|
cons(Number::make(BytesPerWord), 0) : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1489,7 +1499,7 @@ set(uint32_t* mask, unsigned index)
|
|||||||
unsigned
|
unsigned
|
||||||
typeFixedSize(Object* type)
|
typeFixedSize(Object* type)
|
||||||
{
|
{
|
||||||
unsigned length = sizeof(void*);
|
unsigned length = BytesPerWord;
|
||||||
for (MemberIterator it(type); it.hasMore();) {
|
for (MemberIterator it(type); it.hasMore();) {
|
||||||
Object* m = it.next();
|
Object* m = it.next();
|
||||||
switch (m->type) {
|
switch (m->type) {
|
||||||
@ -1527,13 +1537,13 @@ uint32_t
|
|||||||
typeObjectMask(Object* type)
|
typeObjectMask(Object* type)
|
||||||
{
|
{
|
||||||
assert(typeFixedSize(type) + typeArrayElementSize(type)
|
assert(typeFixedSize(type) + typeArrayElementSize(type)
|
||||||
< 32 * sizeof(void*));
|
< 32 * BytesPerWord);
|
||||||
|
|
||||||
uint32_t mask = 1;
|
uint32_t mask = 1;
|
||||||
|
|
||||||
for (MemberIterator it(type); it.hasMore();) {
|
for (MemberIterator it(type); it.hasMore();) {
|
||||||
Object* m = it.next();
|
Object* m = it.next();
|
||||||
unsigned offset = it.offset() / sizeof(void*);
|
unsigned offset = it.offset() / BytesPerWord;
|
||||||
|
|
||||||
switch (m->type) {
|
switch (m->type) {
|
||||||
case Object::Scalar: {
|
case Object::Scalar: {
|
||||||
@ -1551,7 +1561,7 @@ typeObjectMask(Object* type)
|
|||||||
for (MemberIterator it(memberTypeObject(m)); it.hasMore();) {
|
for (MemberIterator it(memberTypeObject(m)); it.hasMore();) {
|
||||||
Object* m = it.next();
|
Object* m = it.next();
|
||||||
if (memberGC(m)) {
|
if (memberGC(m)) {
|
||||||
set(&mask, offset + (it.offset() / sizeof(void*)));
|
set(&mask, offset + (it.offset() / BytesPerWord));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1657,14 +1667,14 @@ writeInitializations(Output* out, Object* declarations)
|
|||||||
|
|
||||||
out->write("t->m->types = allocate(t, pad((");
|
out->write("t->m->types = allocate(t, pad((");
|
||||||
out->write(count);
|
out->write(count);
|
||||||
out->write(" * sizeof(void*)) + sizeof(uintptr_t) + sizeof(void*)));\n");
|
out->write(" * BytesPerWord) + (BytesPerWord * 2)));\n");
|
||||||
out->write("cast<object>(t->m->types, 0) = 0;\n");
|
out->write("cast<object>(t->m->types, 0) = 0;\n");
|
||||||
out->write("arrayLength(t, t->m->types) = ");
|
out->write("arrayLength(t, t->m->types) = ");
|
||||||
out->write(count);
|
out->write(count);
|
||||||
out->write(";\n");
|
out->write(";\n");
|
||||||
out->write("memset(&arrayBody(t, t->m->types, 0), 0, ");
|
out->write("memset(&arrayBody(t, t->m->types, 0), 0, ");
|
||||||
out->write(count);
|
out->write(count);
|
||||||
out->write(" * sizeof(void*));\n\n");
|
out->write(" * BytesPerWord);\n\n");
|
||||||
|
|
||||||
declarations = reorder(declarations);
|
declarations = reorder(declarations);
|
||||||
|
|
||||||
|
1
src/windows.S
Normal file
1
src/windows.S
Normal file
@ -0,0 +1 @@
|
|||||||
|
// todo
|
1
src/windows.cpp
Normal file
1
src/windows.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
// todo
|
Loading…
Reference in New Issue
Block a user