From 77365dfcc14b6cdf2def0813c83e757aab68cb24 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Tue, 19 Feb 2013 20:23:11 -0700 Subject: [PATCH 1/6] move binary-to-object to new tree structure --- .../avian/tools/object-writer}/tools.h | 0 makefile | 29 ++++++++++--------- src/bootimage.cpp | 2 +- .../binary-to-object}/main.cpp | 2 +- .../object-writer}/elf.cpp | 2 +- .../object-writer}/endianness.h | 0 .../object-writer}/mach-o.cpp | 2 +- .../object-writer}/pe.cpp | 2 +- .../object-writer}/tools.cpp | 2 +- 9 files changed, 22 insertions(+), 19 deletions(-) rename {src/binaryToObject => include/avian/tools/object-writer}/tools.h (100%) rename src/{binaryToObject => tools/binary-to-object}/main.cpp (98%) rename src/{binaryToObject => tools/object-writer}/elf.cpp (99%) rename src/{binaryToObject => tools/object-writer}/endianness.h (100%) rename src/{binaryToObject => tools/object-writer}/mach-o.cpp (99%) rename src/{binaryToObject => tools/object-writer}/pe.cpp (99%) rename src/{binaryToObject => tools/object-writer}/tools.cpp (98%) diff --git a/src/binaryToObject/tools.h b/include/avian/tools/object-writer/tools.h similarity index 100% rename from src/binaryToObject/tools.h rename to include/avian/tools/object-writer/tools.h diff --git a/makefile b/makefile index 1e29f0ca91..38872186bf 100755 --- a/makefile +++ b/makefile @@ -214,7 +214,7 @@ warnings = -Wall -Wextra -Werror -Wunused-parameter -Winit-self \ target-cflags = -DTARGET_BYTES_PER_WORD=$(pointer-size) common-cflags = $(warnings) -fno-rtti -fno-exceptions -I$(classpath-src) \ - "-I$(JAVA_HOME)/include" -idirafter $(src) -I$(build) $(classpath-cflags) \ + "-I$(JAVA_HOME)/include" -idirafter $(src) -I$(build) -Iinclude $(classpath-cflags) \ -D__STDC_LIMIT_MACROS -D_JNI_IMPLEMENTATION_ -DAVIAN_VERSION=\"$(version)\" \ -DAVIAN_INFO="\"$(info)\"" \ -DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \ @@ -232,7 +232,7 @@ endif build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \ "-I$(JAVA_HOME)/include/linux" -I$(src) -pthread -converter-cflags = -D__STDC_CONSTANT_MACROS -Isrc/binaryToObject -Isrc/ \ +converter-cflags = -D__STDC_CONSTANT_MACROS -Iinclude/ -Isrc/ \ -fno-rtti -fno-exceptions \ -DAVIAN_TARGET_ARCH=AVIAN_ARCH_UNKNOWN \ -DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_UNKNOWN \ @@ -1126,18 +1126,20 @@ generator-lzma-objects = \ $(call generator-c-objects,$(lzma-decode-sources),$(lzma)/C,$(build)) generator = $(build)/generator -converter-depends = \ - $(src)/binaryToObject/tools.h \ - $(src)/binaryToObject/endianness.h +all-depends = $(shell find include -name '*.h') -converter-sources = \ - $(src)/binaryToObject/tools.cpp \ - $(src)/binaryToObject/elf.cpp \ - $(src)/binaryToObject/mach-o.cpp \ - $(src)/binaryToObject/pe.cpp +object-writer-depends = $(shell find $(src)/tools/object-writer -name '*.h') +object-writer-sources = $(shell find $(src)/tools/object-writer -name '*.cpp') +object-writer-objects = $(call cpp-objects,$(object-writer-sources),$(src),$(build)) -converter-tool-sources = \ - $(src)/binaryToObject/main.cpp +binary-to-object-depends = $(shell find $(src)/tools/binary-to-object/ -name '*.h') +binary-to-object-sources = $(shell find $(src)/tools/binary-to-object/ -name '*.cpp') +binary-to-object-objects = $(call cpp-objects,$(binary-to-object-sources),$(src),$(build)) + +converter-sources = $(object-writer-sources) + +converter-tool-depends = $(binary-to-object-depends) $(all-depends) +converter-tool-sources = $(binary-to-object-sources) converter-objects = $(call cpp-objects,$(converter-sources),$(src),$(build)) converter-tool-objects = $(call cpp-objects,$(converter-tool-sources),$(src),$(build)) @@ -1497,11 +1499,12 @@ $(boot-object): $(boot-source) $(boot-javahome-object): $(src)/boot-javahome.cpp $(compile-object) -$(converter-objects) $(converter-tool-objects): $(build)/binaryToObject/%.o: $(src)/binaryToObject/%.cpp $(converter-depends) +$(object-writer-objects) $(binary-to-object-objects): $(build)/%.o: $(src)/%.cpp $(binary-to-object-depends) $(object-writer-depends) $(all-depends) @mkdir -p $(dir $(@)) $(build-cxx) $(converter-cflags) -c $(<) -o $(@) $(converter): $(converter-objects) $(converter-tool-objects) + @mkdir -p $(dir $(@)) $(build-cc) $(^) -g -o $(@) $(lzma-encoder-objects): $(build)/lzma/%.o: $(src)/lzma/%.cpp diff --git a/src/bootimage.cpp b/src/bootimage.cpp index 0dba4af877..05fef8158d 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -17,7 +17,7 @@ #include "codegen/assembler.h" #include "codegen/promise.h" #include "target.h" -#include "binaryToObject/tools.h" +#include #include "lzma.h" // since we aren't linking against libstdc++, we must implement this diff --git a/src/binaryToObject/main.cpp b/src/tools/binary-to-object/main.cpp similarity index 98% rename from src/binaryToObject/main.cpp rename to src/tools/binary-to-object/main.cpp index fe389f3d29..86d780bbec 100644 --- a/src/binaryToObject/main.cpp +++ b/src/tools/binary-to-object/main.cpp @@ -22,7 +22,7 @@ #endif #include -#include "tools.h" +#include extern "C" void __cxa_pure_virtual() { diff --git a/src/binaryToObject/elf.cpp b/src/tools/object-writer/elf.cpp similarity index 99% rename from src/binaryToObject/elf.cpp rename to src/tools/object-writer/elf.cpp index a2277c3488..bf220e1e04 100644 --- a/src/binaryToObject/elf.cpp +++ b/src/tools/object-writer/elf.cpp @@ -15,7 +15,7 @@ #include "endianness.h" -#include "tools.h" +#include #define EI_NIDENT 16 diff --git a/src/binaryToObject/endianness.h b/src/tools/object-writer/endianness.h similarity index 100% rename from src/binaryToObject/endianness.h rename to src/tools/object-writer/endianness.h diff --git a/src/binaryToObject/mach-o.cpp b/src/tools/object-writer/mach-o.cpp similarity index 99% rename from src/binaryToObject/mach-o.cpp rename to src/tools/object-writer/mach-o.cpp index 96dd63aafd..fac134f272 100644 --- a/src/binaryToObject/mach-o.cpp +++ b/src/tools/object-writer/mach-o.cpp @@ -14,7 +14,7 @@ #include "endianness.h" -#include "tools.h" +#include #define MH_MAGIC_64 0xfeedfacf #define MH_MAGIC 0xfeedface diff --git a/src/binaryToObject/pe.cpp b/src/tools/object-writer/pe.cpp similarity index 99% rename from src/binaryToObject/pe.cpp rename to src/tools/object-writer/pe.cpp index 186e491447..0fdc4a16e0 100644 --- a/src/binaryToObject/pe.cpp +++ b/src/tools/object-writer/pe.cpp @@ -13,7 +13,7 @@ #include #include -#include "tools.h" +#include namespace { diff --git a/src/binaryToObject/tools.cpp b/src/tools/object-writer/tools.cpp similarity index 98% rename from src/binaryToObject/tools.cpp rename to src/tools/object-writer/tools.cpp index 9cc9059b93..49726245c7 100644 --- a/src/binaryToObject/tools.cpp +++ b/src/tools/object-writer/tools.cpp @@ -13,7 +13,7 @@ #include #include -#include "tools.h" +#include namespace avian { From 987af120d81d7763d9fdd929a5fe5046b2f51c68 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Tue, 19 Feb 2013 22:12:28 -0700 Subject: [PATCH 2/6] move codegen headers to include/ --- {src => include/avian/vm}/codegen/assembler.h | 4 ++-- {src => include/avian/vm}/codegen/compiler.h | 0 {src => include/avian/vm}/codegen/lir-ops.inc.cpp | 0 {src => include/avian/vm}/codegen/lir.h | 0 {src => include/avian/vm}/codegen/promise.h | 0 {src => include/avian/vm}/codegen/registers.h | 0 {src => include/avian/vm}/codegen/targets.h | 2 +- src/codegen/arm/assembler.cpp | 4 ++-- src/codegen/compiler.cpp | 6 +++--- src/codegen/compiler/context.h | 4 ++-- src/codegen/compiler/regalloc.h | 4 ++-- src/codegen/compiler/value.h | 5 ++--- src/codegen/powerpc/assembler.cpp | 4 ++-- src/codegen/registers.cpp | 2 +- src/codegen/targets.cpp | 3 ++- src/codegen/x86/assembler.cpp | 4 ++-- src/compile.cpp | 7 ++++--- unittest/codegen/assembler-test.cpp | 6 +++--- 18 files changed, 28 insertions(+), 27 deletions(-) rename {src => include/avian/vm}/codegen/assembler.h (98%) rename {src => include/avian/vm}/codegen/compiler.h (100%) rename {src => include/avian/vm}/codegen/lir-ops.inc.cpp (100%) rename {src => include/avian/vm}/codegen/lir.h (100%) rename {src => include/avian/vm}/codegen/promise.h (100%) rename {src => include/avian/vm}/codegen/registers.h (100%) rename {src => include/avian/vm}/codegen/targets.h (95%) diff --git a/src/codegen/assembler.h b/include/avian/vm/codegen/assembler.h similarity index 98% rename from src/codegen/assembler.h rename to include/avian/vm/codegen/assembler.h index 21301fd71f..593e0e6fe7 100644 --- a/src/codegen/assembler.h +++ b/include/avian/vm/codegen/assembler.h @@ -14,8 +14,8 @@ #include "system.h" #include "zone.h" -#include "codegen/lir.h" -#include "codegen/promise.h" +#include +#include namespace avian { namespace codegen { diff --git a/src/codegen/compiler.h b/include/avian/vm/codegen/compiler.h similarity index 100% rename from src/codegen/compiler.h rename to include/avian/vm/codegen/compiler.h diff --git a/src/codegen/lir-ops.inc.cpp b/include/avian/vm/codegen/lir-ops.inc.cpp similarity index 100% rename from src/codegen/lir-ops.inc.cpp rename to include/avian/vm/codegen/lir-ops.inc.cpp diff --git a/src/codegen/lir.h b/include/avian/vm/codegen/lir.h similarity index 100% rename from src/codegen/lir.h rename to include/avian/vm/codegen/lir.h diff --git a/src/codegen/promise.h b/include/avian/vm/codegen/promise.h similarity index 100% rename from src/codegen/promise.h rename to include/avian/vm/codegen/promise.h diff --git a/src/codegen/registers.h b/include/avian/vm/codegen/registers.h similarity index 100% rename from src/codegen/registers.h rename to include/avian/vm/codegen/registers.h diff --git a/src/codegen/targets.h b/include/avian/vm/codegen/targets.h similarity index 95% rename from src/codegen/targets.h rename to include/avian/vm/codegen/targets.h index 1d146e4b4d..e3ffbd981a 100644 --- a/src/codegen/targets.h +++ b/include/avian/vm/codegen/targets.h @@ -11,7 +11,7 @@ #ifndef AVIAN_CODEGEN_TARGETS_H #define AVIAN_CODEGEN_TARGETS_H -#include "codegen/assembler.h" +#include namespace avian { namespace codegen { diff --git a/src/codegen/arm/assembler.cpp b/src/codegen/arm/assembler.cpp index c15007835f..2298fb50d6 100644 --- a/src/codegen/arm/assembler.cpp +++ b/src/codegen/arm/assembler.cpp @@ -8,8 +8,8 @@ There is NO WARRANTY for this software. See license.txt for details. */ -#include "codegen/assembler.h" -#include "codegen/registers.h" +#include +#include #include "alloc-vector.h" #include "util/abort.h" diff --git a/src/codegen/compiler.cpp b/src/codegen/compiler.cpp index 23c62a8b5e..d67b979406 100644 --- a/src/codegen/compiler.cpp +++ b/src/codegen/compiler.cpp @@ -12,9 +12,9 @@ #include "util/runtime-array.h" -#include "codegen/compiler.h" -#include "codegen/assembler.h" -#include "codegen/promise.h" +#include +#include +#include #include "codegen/compiler/regalloc.h" #include "codegen/compiler/context.h" diff --git a/src/codegen/compiler/context.h b/src/codegen/compiler/context.h index 974de8e17a..58118b57dc 100644 --- a/src/codegen/compiler/context.h +++ b/src/codegen/compiler/context.h @@ -11,8 +11,8 @@ #ifndef AVIAN_CODEGEN_COMPILER_CONTEXT_H #define AVIAN_CODEGEN_COMPILER_CONTEXT_H -#include "codegen/assembler.h" -#include "codegen/compiler.h" +#include +#include #include "codegen/compiler/regalloc.h" diff --git a/src/codegen/compiler/regalloc.h b/src/codegen/compiler/regalloc.h index cfbf154f1f..c121614799 100644 --- a/src/codegen/compiler/regalloc.h +++ b/src/codegen/compiler/regalloc.h @@ -13,8 +13,8 @@ #include "common.h" -#include "codegen/lir.h" -#include "codegen/registers.h" +#include +#include class Aborter; diff --git a/src/codegen/compiler/value.h b/src/codegen/compiler/value.h index 9cdac0bba3..60fe0461a3 100644 --- a/src/codegen/compiler/value.h +++ b/src/codegen/compiler/value.h @@ -11,9 +11,8 @@ #ifndef AVIAN_CODEGEN_COMPILER_VALUE_H #define AVIAN_CODEGEN_COMPILER_VALUE_H -#include "codegen/lir.h" - -#include "codegen/compiler.h" +#include +#include namespace avian { namespace codegen { diff --git a/src/codegen/powerpc/assembler.cpp b/src/codegen/powerpc/assembler.cpp index 426891d475..f45819d869 100644 --- a/src/codegen/powerpc/assembler.cpp +++ b/src/codegen/powerpc/assembler.cpp @@ -8,8 +8,8 @@ There is NO WARRANTY for this software. See license.txt for details. */ -#include "codegen/assembler.h" -#include "codegen/registers.h" +#include +#include #include "alloc-vector.h" #include "util/abort.h" diff --git a/src/codegen/registers.cpp b/src/codegen/registers.cpp index 6e8dea822a..c3bf451176 100644 --- a/src/codegen/registers.cpp +++ b/src/codegen/registers.cpp @@ -8,7 +8,7 @@ There is NO WARRANTY for this software. See license.txt for details. */ -#include "codegen/registers.h" +#include namespace avian { namespace codegen { diff --git a/src/codegen/targets.cpp b/src/codegen/targets.cpp index 2df6636120..4b9d44fc7e 100644 --- a/src/codegen/targets.cpp +++ b/src/codegen/targets.cpp @@ -8,7 +8,8 @@ There is NO WARRANTY for this software. See license.txt for details. */ -#include "codegen/targets.h" +#include + #include "environment.h" namespace avian { diff --git a/src/codegen/x86/assembler.cpp b/src/codegen/x86/assembler.cpp index 5e3fa6aa3c..9c19bc2544 100644 --- a/src/codegen/x86/assembler.cpp +++ b/src/codegen/x86/assembler.cpp @@ -12,8 +12,8 @@ #include "target.h" #include "alloc-vector.h" -#include "codegen/assembler.h" -#include "codegen/registers.h" +#include +#include #include "util/runtime-array.h" #include "util/abort.h" diff --git a/src/compile.cpp b/src/compile.cpp index 5b9245df15..63ff48ec94 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -13,11 +13,12 @@ #include "alloc-vector.h" #include "process.h" #include "target.h" -#include "codegen/assembler.h" -#include "codegen/compiler.h" -#include "codegen/targets.h" #include "arch.h" +#include +#include +#include + #include "util/runtime-array.h" using namespace vm; diff --git a/unittest/codegen/assembler-test.cpp b/unittest/codegen/assembler-test.cpp index 3fe8a07427..760e770bd8 100644 --- a/unittest/codegen/assembler-test.cpp +++ b/unittest/codegen/assembler-test.cpp @@ -15,9 +15,9 @@ #include "system.h" #include "target.h" -#include "codegen/assembler.h" -#include "codegen/targets.h" -#include "codegen/lir.h" +#include +#include +#include #include "test-harness.h" From 263c0dee4f427e6bf97dbaf140deb3b12bbb6908 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Tue, 19 Feb 2013 22:42:07 -0700 Subject: [PATCH 3/6] move abort.h to include, add namespacing --- {src => include/avian}/util/abort.h | 8 +++++++- src/codegen/arm/assembler.cpp | 3 ++- src/codegen/compiler/context.h | 4 +++- src/codegen/compiler/regalloc.h | 9 +++++++-- src/codegen/powerpc/assembler.cpp | 3 ++- src/codegen/x86/assembler.cpp | 3 ++- src/heap/heap.cpp | 1 + src/machine.h | 2 ++ src/system.h | 6 +++--- 9 files changed, 29 insertions(+), 10 deletions(-) rename {src => include/avian}/util/abort.h (87%) diff --git a/src/util/abort.h b/include/avian/util/abort.h similarity index 87% rename from src/util/abort.h rename to include/avian/util/abort.h index 7624ea5b8f..d209479b97 100644 --- a/src/util/abort.h +++ b/include/avian/util/abort.h @@ -11,6 +11,9 @@ #ifndef AVIAN_UTIL_ABORT_H #define AVIAN_UTIL_ABORT_H +namespace avian { +namespace util { + class Aborter { public: virtual void NO_RETURN abort() = 0; @@ -37,5 +40,8 @@ inline void assert(T t, bool v) { expect(t, v); } #endif + +} // namespace util +} // namespace avian -#endif // AVIAN_UTIL_ABORT_H \ No newline at end of file +#endif // AVIAN_UTIL_ABORT_H diff --git a/src/codegen/arm/assembler.cpp b/src/codegen/arm/assembler.cpp index 2298fb50d6..119cc2b31f 100644 --- a/src/codegen/arm/assembler.cpp +++ b/src/codegen/arm/assembler.cpp @@ -12,7 +12,7 @@ #include #include "alloc-vector.h" -#include "util/abort.h" +#include #include "util/runtime-array.h" @@ -23,6 +23,7 @@ using namespace vm; using namespace avian::codegen; +using namespace avian::util; namespace local { diff --git a/src/codegen/compiler/context.h b/src/codegen/compiler/context.h index 58118b57dc..d9894eda8c 100644 --- a/src/codegen/compiler/context.h +++ b/src/codegen/compiler/context.h @@ -14,7 +14,9 @@ #include #include -#include "codegen/compiler/regalloc.h" +#include "regalloc.h" + +using namespace avian::util; namespace avian { namespace codegen { diff --git a/src/codegen/compiler/regalloc.h b/src/codegen/compiler/regalloc.h index c121614799..7bc7b6e8e0 100644 --- a/src/codegen/compiler/regalloc.h +++ b/src/codegen/compiler/regalloc.h @@ -16,12 +16,17 @@ #include #include -class Aborter; - namespace avian { + +namespace util { +class Aborter; +} // namespace util + namespace codegen { namespace compiler { +using namespace avian::util; + class Context; class Value; class SiteMask; diff --git a/src/codegen/powerpc/assembler.cpp b/src/codegen/powerpc/assembler.cpp index f45819d869..1ef611be1a 100644 --- a/src/codegen/powerpc/assembler.cpp +++ b/src/codegen/powerpc/assembler.cpp @@ -12,7 +12,7 @@ #include #include "alloc-vector.h" -#include "util/abort.h" +#include #define CAST1(x) reinterpret_cast(x) #define CAST2(x) reinterpret_cast(x) @@ -21,6 +21,7 @@ using namespace vm; using namespace avian::codegen; +using namespace avian::util; namespace { diff --git a/src/codegen/x86/assembler.cpp b/src/codegen/x86/assembler.cpp index 9c19bc2544..c7fcab491b 100644 --- a/src/codegen/x86/assembler.cpp +++ b/src/codegen/x86/assembler.cpp @@ -16,7 +16,7 @@ #include #include "util/runtime-array.h" -#include "util/abort.h" +#include #define CAST1(x) reinterpret_cast(x) #define CAST2(x) reinterpret_cast(x) @@ -24,6 +24,7 @@ using namespace vm; using namespace avian::codegen; +using namespace avian::util; namespace { diff --git a/src/heap/heap.cpp b/src/heap/heap.cpp index 119a250572..3d060e256d 100644 --- a/src/heap/heap.cpp +++ b/src/heap/heap.cpp @@ -14,6 +14,7 @@ #include "arch.h" using namespace vm; +using namespace avian::util; namespace { diff --git a/src/machine.h b/src/machine.h index 1d29cbc88a..bba9c8dfbf 100644 --- a/src/machine.h +++ b/src/machine.h @@ -19,6 +19,8 @@ #include "constants.h" #include "arch.h" +using namespace avian::util; + #ifdef PLATFORM_WINDOWS # define JNICALL __stdcall #else diff --git a/src/system.h b/src/system.h index 1a95980da3..ba6193a1ac 100644 --- a/src/system.h +++ b/src/system.h @@ -13,11 +13,11 @@ #include "common.h" #include "allocator.h" -#include "util/abort.h" +#include namespace vm { -class System : public Aborter { +class System : public avian::util::Aborter { public: typedef intptr_t Status; @@ -165,7 +165,7 @@ allocate(System* s, unsigned size) #define ACQUIRE_MONITOR(t, m) \ System::MonitorResource MAKE_NAME(monitorResource_) (t, m) -inline Aborter* getAborter(System* s) { +inline avian::util::Aborter* getAborter(System* s) { return s; } From b9e281612b99584b7739c1442e39e1da336f4859 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Tue, 19 Feb 2013 22:56:05 -0700 Subject: [PATCH 4/6] move runtime-array to include --- classpath/jni-util.h | 2 +- {src => include/avian}/util/runtime-array.h | 0 src/arm.h | 2 +- src/builtin.cpp | 2 +- src/classpath-avian.cpp | 2 +- src/classpath-common.h | 2 +- src/codegen/arm/assembler.cpp | 2 +- src/codegen/compiler.cpp | 2 +- src/codegen/compiler/event.cpp | 2 +- src/codegen/x86/assembler.cpp | 2 +- src/compile.cpp | 2 +- src/finder.cpp | 2 +- src/interpret.cpp | 2 +- src/jnienv.cpp | 2 +- src/machine.cpp | 2 +- src/main.cpp | 2 +- src/process.cpp | 2 +- src/windows.cpp | 2 +- 18 files changed, 17 insertions(+), 17 deletions(-) rename {src => include/avian}/util/runtime-array.h (100%) diff --git a/classpath/jni-util.h b/classpath/jni-util.h index a73905fadf..bed4658953 100644 --- a/classpath/jni-util.h +++ b/classpath/jni-util.h @@ -15,7 +15,7 @@ #include "stdlib.h" #include "string.h" -#include "util/runtime-array.h" +#include #undef JNIEXPORT diff --git a/src/util/runtime-array.h b/include/avian/util/runtime-array.h similarity index 100% rename from src/util/runtime-array.h rename to include/avian/util/runtime-array.h diff --git a/src/arm.h b/src/arm.h index 5d2835de14..5b8cdab3db 100644 --- a/src/arm.h +++ b/src/arm.h @@ -13,7 +13,7 @@ #include "types.h" #include "common.h" -#include "util/runtime-array.h" +#include #ifdef __APPLE__ # include "libkern/OSAtomic.h" diff --git a/src/builtin.cpp b/src/builtin.cpp index eaa66ed101..865cb5708c 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -13,7 +13,7 @@ #include "processor.h" #include "util.h" -#include "util/runtime-array.h" +#include using namespace vm; diff --git a/src/classpath-avian.cpp b/src/classpath-avian.cpp index f313bffa01..de85398707 100644 --- a/src/classpath-avian.cpp +++ b/src/classpath-avian.cpp @@ -12,7 +12,7 @@ #include "classpath-common.h" #include "process.h" -#include "util/runtime-array.h" +#include using namespace vm; diff --git a/src/classpath-common.h b/src/classpath-common.h index 11c22b913f..6298d47695 100644 --- a/src/classpath-common.h +++ b/src/classpath-common.h @@ -13,7 +13,7 @@ #include "tokenizer.h" -#include "util/runtime-array.h" +#include namespace vm { diff --git a/src/codegen/arm/assembler.cpp b/src/codegen/arm/assembler.cpp index 119cc2b31f..56bd71938d 100644 --- a/src/codegen/arm/assembler.cpp +++ b/src/codegen/arm/assembler.cpp @@ -14,7 +14,7 @@ #include "alloc-vector.h" #include -#include "util/runtime-array.h" +#include #define CAST1(x) reinterpret_cast(x) #define CAST2(x) reinterpret_cast(x) diff --git a/src/codegen/compiler.cpp b/src/codegen/compiler.cpp index d67b979406..fa453974e5 100644 --- a/src/codegen/compiler.cpp +++ b/src/codegen/compiler.cpp @@ -10,7 +10,7 @@ #include "target.h" -#include "util/runtime-array.h" +#include #include #include diff --git a/src/codegen/compiler/event.cpp b/src/codegen/compiler/event.cpp index ba8c0c222a..c9bb0dcf79 100644 --- a/src/codegen/compiler/event.cpp +++ b/src/codegen/compiler/event.cpp @@ -9,7 +9,7 @@ details. */ #include "target.h" -#include "util/runtime-array.h" +#include #include "codegen/compiler/context.h" #include "codegen/compiler/event.h" diff --git a/src/codegen/x86/assembler.cpp b/src/codegen/x86/assembler.cpp index c7fcab491b..90eea322fc 100644 --- a/src/codegen/x86/assembler.cpp +++ b/src/codegen/x86/assembler.cpp @@ -15,7 +15,7 @@ #include #include -#include "util/runtime-array.h" +#include #include #define CAST1(x) reinterpret_cast(x) diff --git a/src/compile.cpp b/src/compile.cpp index 63ff48ec94..02a87cd4c8 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -19,7 +19,7 @@ #include #include -#include "util/runtime-array.h" +#include using namespace vm; diff --git a/src/finder.cpp b/src/finder.cpp index 479761c19f..93e95250fd 100644 --- a/src/finder.cpp +++ b/src/finder.cpp @@ -14,7 +14,7 @@ #include "finder.h" #include "lzma.h" -#include "util/runtime-array.h" +#include using namespace vm; diff --git a/src/interpret.cpp b/src/interpret.cpp index 8b9f4e12d9..c025957d48 100644 --- a/src/interpret.cpp +++ b/src/interpret.cpp @@ -16,7 +16,7 @@ #include "process.h" #include "arch.h" -#include "util/runtime-array.h" +#include using namespace vm; diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 37d3a65f13..2f9492bd58 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -14,7 +14,7 @@ #include "processor.h" #include "constants.h" -#include "util/runtime-array.h" +#include using namespace vm; diff --git a/src/machine.cpp b/src/machine.cpp index 8555878c41..f18ff06552 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -17,7 +17,7 @@ #include "arch.h" #include "lzma.h" -#include "util/runtime-array.h" +#include #if defined(PLATFORM_WINDOWS) # define WIN32_LEAN_AND_MEAN diff --git a/src/main.cpp b/src/main.cpp index e70555e73e..ccd8255940 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,7 +16,7 @@ #include "system.h" #include "finder.h" -#include "util/runtime-array.h" +#include #if (defined __MINGW32__) || (defined _MSC_VER) # define PATH_SEPARATOR ';' diff --git a/src/process.cpp b/src/process.cpp index b13aa7ca4f..6f1c5dbbd8 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -10,7 +10,7 @@ #include "process.h" -#include "util/runtime-array.h" +#include using namespace vm; diff --git a/src/windows.cpp b/src/windows.cpp index 5c85eb906e..640117ed2c 100644 --- a/src/windows.cpp +++ b/src/windows.cpp @@ -25,7 +25,7 @@ #include "arch.h" #include "system.h" -#include "util/runtime-array.h" +#include #if defined(WINAPI_FAMILY) From 52b2fd74ef98fc26124635e9f3f10e1d287a55c1 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Wed, 20 Feb 2013 07:51:57 -0700 Subject: [PATCH 5/6] move math functions out of common.h, and into include/avian/util/math.h --- include/avian/util/math.h | 53 ++++++++++++++++++++++++++++++++++ src/alloc-vector.h | 6 ++-- src/bootimage-template.cpp | 4 +-- src/bootimage.h | 2 ++ src/codegen/compiler/event.cpp | 21 ++++++++------ src/common.h | 47 ------------------------------ src/heap/heap.cpp | 2 ++ src/machine.cpp | 2 ++ src/posix.cpp | 3 ++ src/zone.h | 6 ++-- 10 files changed, 84 insertions(+), 62 deletions(-) create mode 100644 include/avian/util/math.h diff --git a/include/avian/util/math.h b/include/avian/util/math.h new file mode 100644 index 0000000000..ecd4f18fc5 --- /dev/null +++ b/include/avian/util/math.h @@ -0,0 +1,53 @@ +/* Copyright (c) 2008-2012, Avian Contributors + + Permission to use, copy, modify, and/or distribute this software + for any purpose with or without fee is hereby granted, provided + that the above copyright notice and this permission notice appear + in all copies. + + There is NO WARRANTY for this software. See license.txt for + details. */ + +#ifndef AVIAN_UTIL_MATH_H +#define AVIAN_UTIL_MATH_H + +namespace avian { +namespace util { + +inline unsigned max(unsigned a, unsigned b) { + return (a > b ? a : b); +} + +inline unsigned min(unsigned a, unsigned b) { + return (a < b ? a : b); +} + +inline unsigned avg(unsigned a, unsigned b) { + return (a + b) / 2; +} + +inline unsigned ceilingDivide(unsigned n, unsigned d) { + return (n + d - 1) / d; +} + +inline bool powerOfTwo(unsigned n) { + for (; n > 2; n >>= 1) if (n & 1) return false; + return true; +} + +inline unsigned nextPowerOfTwo(unsigned n) { + unsigned r = 1; + while (r < n) r <<= 1; + return r; +} + +inline unsigned log(unsigned n) { + unsigned r = 0; + for (unsigned i = 1; i < n; ++r) i <<= 1; + return r; +} + +} // namespace util +} // namespace avian + +#endif // AVIAN_UTIL_MATH_H diff --git a/src/alloc-vector.h b/src/alloc-vector.h index 6714573b0d..4032987655 100644 --- a/src/alloc-vector.h +++ b/src/alloc-vector.h @@ -14,6 +14,8 @@ #include "system.h" #include "target.h" +#include + namespace vm { class Vector { @@ -51,8 +53,8 @@ class Vector { if (position + space > capacity) { assert(s, minimumCapacity >= 0); - unsigned newCapacity = max - (position + space, max(minimumCapacity, capacity * 2)); + unsigned newCapacity = avian::util::max + (position + space, avian::util::max(minimumCapacity, capacity * 2)); uint8_t* newData = static_cast (allocator->allocate(newCapacity)); if (data) { diff --git a/src/bootimage-template.cpp b/src/bootimage-template.cpp index 72374f3392..86df096777 100644 --- a/src/bootimage-template.cpp +++ b/src/bootimage-template.cpp @@ -9,13 +9,13 @@ const unsigned NAME(BootHeapOffset) = 1 << (NAME(BootShift) + 1); inline unsigned LABEL(codeMapSize)(unsigned codeSize) { - return ceilingDivide(codeSize, TargetBitsPerWord) * TargetBytesPerWord; + return avian::util::ceilingDivide(codeSize, TargetBitsPerWord) * TargetBytesPerWord; } inline unsigned LABEL(heapMapSize)(unsigned heapSize) { - return ceilingDivide(heapSize, TargetBitsPerWord * TargetBytesPerWord) + return avian::util::ceilingDivide(heapSize, TargetBitsPerWord * TargetBytesPerWord) * TargetBytesPerWord; } diff --git a/src/bootimage.h b/src/bootimage.h index 16f11ab379..bf96cdaf17 100644 --- a/src/bootimage.h +++ b/src/bootimage.h @@ -15,6 +15,8 @@ #include "target.h" #include "machine.h" +#include + namespace vm { class BootImage { diff --git a/src/codegen/compiler/event.cpp b/src/codegen/compiler/event.cpp index c9bb0dcf79..f07706e499 100644 --- a/src/codegen/compiler/event.cpp +++ b/src/codegen/compiler/event.cpp @@ -10,6 +10,7 @@ #include "target.h" #include +#include #include "codegen/compiler/context.h" #include "codegen/compiler/event.h" @@ -20,6 +21,8 @@ #include "codegen/compiler/frame.h" #include "codegen/compiler/ir.h" +using namespace avian::util; + namespace avian { namespace codegen { namespace compiler { @@ -921,11 +924,11 @@ appendCombine(Context* c, lir::TernaryOperation type, intptr_t handler = c->client->getThunk (type, firstSize, resultSize, &threadParameter); - unsigned stackSize = vm::ceilingDivide(secondSize, vm::TargetBytesPerWord) - + vm::ceilingDivide(firstSize, vm::TargetBytesPerWord); + unsigned stackSize = ceilingDivide(secondSize, vm::TargetBytesPerWord) + + ceilingDivide(firstSize, vm::TargetBytesPerWord); - compiler::push(c, vm::ceilingDivide(secondSize, vm::TargetBytesPerWord), second); - compiler::push(c, vm::ceilingDivide(firstSize, vm::TargetBytesPerWord), first); + compiler::push(c, ceilingDivide(secondSize, vm::TargetBytesPerWord), second); + compiler::push(c, ceilingDivide(firstSize, vm::TargetBytesPerWord), first); if (threadParameter) { ++ stackSize; @@ -1047,7 +1050,7 @@ appendTranslate(Context* c, lir::BinaryOperation type, unsigned firstSize, if (thunk) { Stack* oldStack = c->stack; - compiler::push(c, vm::ceilingDivide(firstSize, vm::TargetBytesPerWord), first); + compiler::push(c, ceilingDivide(firstSize, vm::TargetBytesPerWord), first); Stack* argumentStack = c->stack; c->stack = oldStack; @@ -1057,7 +1060,7 @@ appendTranslate(Context* c, lir::BinaryOperation type, unsigned firstSize, (c, lir::ValueGeneral, constantSite (c, c->client->getThunk(type, firstSize, resultSize))), 0, 0, result, resultSize, argumentStack, - vm::ceilingDivide(firstSize, vm::TargetBytesPerWord), 0); + ceilingDivide(firstSize, vm::TargetBytesPerWord), 0); } else { append(c, new(c->zone) TranslateEvent @@ -1404,8 +1407,8 @@ appendBranch(Context* c, lir::TernaryOperation type, unsigned size, Value* first assert(c, not threadParameter); - compiler::push(c, vm::ceilingDivide(size, vm::TargetBytesPerWord), second); - compiler::push(c, vm::ceilingDivide(size, vm::TargetBytesPerWord), first); + compiler::push(c, ceilingDivide(size, vm::TargetBytesPerWord), second); + compiler::push(c, ceilingDivide(size, vm::TargetBytesPerWord), first); Stack* argumentStack = c->stack; c->stack = oldStack; @@ -1414,7 +1417,7 @@ appendBranch(Context* c, lir::TernaryOperation type, unsigned size, Value* first appendCall (c, value (c, lir::ValueGeneral, constantSite(c, handler)), 0, 0, result, 4, - argumentStack, vm::ceilingDivide(size, vm::TargetBytesPerWord) * 2, 0); + argumentStack, ceilingDivide(size, vm::TargetBytesPerWord) * 2, 0); appendBranch(c, thunkBranch(c, type), 4, value (c, lir::ValueGeneral, constantSite(c, static_cast(0))), diff --git a/src/common.h b/src/common.h index 7cf763c4bd..b7408e289a 100644 --- a/src/common.h +++ b/src/common.h @@ -296,24 +296,6 @@ const uintptr_t PointerMask const unsigned LikelyPageSizeInBytes = 4 * 1024; -inline unsigned -max(unsigned a, unsigned b) -{ - return (a > b ? a : b); -} - -inline unsigned -min(unsigned a, unsigned b) -{ - return (a < b ? a : b); -} - -inline unsigned -avg(unsigned a, unsigned b) -{ - return (a + b) / 2; -} - inline unsigned pad(unsigned n, unsigned alignment) { @@ -338,35 +320,6 @@ padWord(uintptr_t n) return padWord(n, BytesPerWord); } -inline unsigned -ceilingDivide(unsigned n, unsigned d) -{ - return (n + d - 1) / d; -} - -inline bool -powerOfTwo(unsigned n) -{ - for (; n > 2; n >>= 1) if (n & 1) return false; - return true; -} - -inline unsigned -nextPowerOfTwo(unsigned n) -{ - unsigned r = 1; - while (r < n) r <<= 1; - return r; -} - -inline unsigned -log(unsigned n) -{ - unsigned r = 0; - for (unsigned i = 1; i < n; ++r) i <<= 1; - return r; -} - template inline unsigned wordOf(unsigned i) diff --git a/src/heap/heap.cpp b/src/heap/heap.cpp index 3d060e256d..1fc3cae022 100644 --- a/src/heap/heap.cpp +++ b/src/heap/heap.cpp @@ -13,6 +13,8 @@ #include "common.h" #include "arch.h" +#include + using namespace vm; using namespace avian::util; diff --git a/src/machine.cpp b/src/machine.cpp index f18ff06552..06a86a562c 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -18,6 +18,7 @@ #include "lzma.h" #include +#include #if defined(PLATFORM_WINDOWS) # define WIN32_LEAN_AND_MEAN @@ -25,6 +26,7 @@ #endif using namespace vm; +using namespace avian::util; namespace { diff --git a/src/posix.cpp b/src/posix.cpp index 4c320e0167..1f643d93d6 100644 --- a/src/posix.cpp +++ b/src/posix.cpp @@ -51,10 +51,13 @@ #include "arch.h" #include "system.h" +#include + #define ACQUIRE(x) MutexResource MAKE_NAME(mutexResource_) (x) using namespace vm; +using namespace avian::util; namespace { diff --git a/src/zone.h b/src/zone.h index 900ea5d3ab..d0009d77c4 100644 --- a/src/zone.h +++ b/src/zone.h @@ -14,6 +14,8 @@ #include "system.h" #include "allocator.h" +#include + namespace vm { class Zone: public Allocator { @@ -59,8 +61,8 @@ class Zone: public Allocator { bool tryEnsure(unsigned space) { if (segment == 0 or segment->position + space > segment->size) { unsigned size = padToPage - (max - (space, max + (avian::util::max + (space, avian::util::max (minimumFootprint, segment == 0 ? 0 : segment->size * 2)) + sizeof(Segment)); From 24ff91c229eca7ddb399ffe5025a59daa8d042fb Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Wed, 20 Feb 2013 10:23:20 -0700 Subject: [PATCH 6/6] move heap.h to include --- {src => include/avian/vm}/heap/heap.h | 0 src/bootimage.cpp | 2 +- src/heap/heap.cpp | 2 +- src/machine.h | 2 +- src/processor.h | 2 +- unittest/codegen/assembler-test.cpp | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename {src => include/avian/vm}/heap/heap.h (100%) diff --git a/src/heap/heap.h b/include/avian/vm/heap/heap.h similarity index 100% rename from src/heap/heap.h rename to include/avian/vm/heap/heap.h diff --git a/src/bootimage.cpp b/src/bootimage.cpp index 05fef8158d..d6046d459f 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -8,7 +8,7 @@ There is NO WARRANTY for this software. See license.txt for details. */ -#include "heap/heap.h" +#include #include "heapwalk.h" #include "common.h" #include "machine.h" diff --git a/src/heap/heap.cpp b/src/heap/heap.cpp index 1fc3cae022..0a0778797b 100644 --- a/src/heap/heap.cpp +++ b/src/heap/heap.cpp @@ -8,7 +8,7 @@ There is NO WARRANTY for this software. See license.txt for details. */ -#include "heap/heap.h" +#include #include "system.h" #include "common.h" #include "arch.h" diff --git a/src/machine.h b/src/machine.h index bba9c8dfbf..a2ebb7c538 100644 --- a/src/machine.h +++ b/src/machine.h @@ -13,7 +13,7 @@ #include "common.h" #include "system.h" -#include "heap/heap.h" +#include #include "finder.h" #include "processor.h" #include "constants.h" diff --git a/src/processor.h b/src/processor.h index 47e8d3c02d..7ce69458d4 100644 --- a/src/processor.h +++ b/src/processor.h @@ -13,7 +13,7 @@ #include "common.h" #include "system.h" -#include "heap/heap.h" +#include #include "bootimage.h" #include "heapwalk.h" #include "zone.h" diff --git a/unittest/codegen/assembler-test.cpp b/unittest/codegen/assembler-test.cpp index 760e770bd8..237b8f7209 100644 --- a/unittest/codegen/assembler-test.cpp +++ b/unittest/codegen/assembler-test.cpp @@ -11,7 +11,7 @@ #include #include "common.h" -#include "heap/heap.h" +#include #include "system.h" #include "target.h"