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/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/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/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/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/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 8322ef8128..eb9dac265f 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/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/makefile b/makefile index bed84761d5..b80afa30f4 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 \ @@ -1133,18 +1133,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)) @@ -1517,11 +1519,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/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/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/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.cpp b/src/bootimage.cpp index f5f3314638..f8d36b81c7 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" @@ -17,7 +17,7 @@ #include "codegen/assembler.h" #include "codegen/promise.h" #include "target.h" -#include "binaryToObject/tools.h" +#include #include "lzma.h" #include "util/arg-parser.h" 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/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 85a7a0e933..3246fda79f 100644 --- a/src/codegen/arm/assembler.cpp +++ b/src/codegen/arm/assembler.cpp @@ -8,13 +8,13 @@ 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" +#include -#include "util/runtime-array.h" +#include #define CAST1(x) reinterpret_cast(x) #define CAST2(x) reinterpret_cast(x) @@ -23,6 +23,7 @@ using namespace vm; using namespace avian::codegen; +using namespace avian::util; namespace local { diff --git a/src/codegen/compiler.cpp b/src/codegen/compiler.cpp index bd67d8bdc1..1985629cfb 100644 --- a/src/codegen/compiler.cpp +++ b/src/codegen/compiler.cpp @@ -10,11 +10,11 @@ #include "target.h" -#include "util/runtime-array.h" +#include -#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..d9894eda8c 100644 --- a/src/codegen/compiler/context.h +++ b/src/codegen/compiler/context.h @@ -11,10 +11,12 @@ #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" +#include "regalloc.h" + +using namespace avian::util; namespace avian { namespace codegen { diff --git a/src/codegen/compiler/event.cpp b/src/codegen/compiler/event.cpp index 3cb37b821c..7b215e4dcc 100644 --- a/src/codegen/compiler/event.cpp +++ b/src/codegen/compiler/event.cpp @@ -9,7 +9,8 @@ details. */ #include "target.h" -#include "util/runtime-array.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 { @@ -917,11 +920,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), secondValue); - compiler::push(c, vm::ceilingDivide(firstSize, vm::TargetBytesPerWord), firstValue); + compiler::push(c, ceilingDivide(secondSize, vm::TargetBytesPerWord), secondValue); + compiler::push(c, ceilingDivide(firstSize, vm::TargetBytesPerWord), firstValue); if (threadParameter) { ++ stackSize; @@ -1041,7 +1044,7 @@ appendTranslate(Context* c, lir::BinaryOperation type, unsigned firstSize, if (thunk) { Stack* oldStack = c->stack; - compiler::push(c, vm::ceilingDivide(firstSize, vm::TargetBytesPerWord), firstValue); + compiler::push(c, ceilingDivide(firstSize, vm::TargetBytesPerWord), firstValue); Stack* argumentStack = c->stack; c->stack = oldStack; @@ -1051,7 +1054,7 @@ appendTranslate(Context* c, lir::BinaryOperation type, unsigned firstSize, (c, lir::ValueGeneral, constantSite (c, c->client->getThunk(type, firstSize, resultSize))), 0, 0, resultValue, resultSize, argumentStack, - vm::ceilingDivide(firstSize, vm::TargetBytesPerWord), 0); + ceilingDivide(firstSize, vm::TargetBytesPerWord), 0); } else { append(c, new(c->zone) TranslateEvent @@ -1398,8 +1401,8 @@ appendBranch(Context* c, lir::TernaryOperation type, unsigned size, Value* first assert(c, not threadParameter); - compiler::push(c, vm::ceilingDivide(size, vm::TargetBytesPerWord), secondValue); - compiler::push(c, vm::ceilingDivide(size, vm::TargetBytesPerWord), firstValue); + compiler::push(c, ceilingDivide(size, vm::TargetBytesPerWord), secondValue); + compiler::push(c, ceilingDivide(size, vm::TargetBytesPerWord), firstValue); Stack* argumentStack = c->stack; c->stack = oldStack; @@ -1408,7 +1411,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/codegen/compiler/regalloc.h b/src/codegen/compiler/regalloc.h index cfbf154f1f..7bc7b6e8e0 100644 --- a/src/codegen/compiler/regalloc.h +++ b/src/codegen/compiler/regalloc.h @@ -13,15 +13,20 @@ #include "common.h" -#include "codegen/lir.h" -#include "codegen/registers.h" - -class Aborter; +#include +#include 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/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 97e5cec19d..aef1e1507d 100644 --- a/src/codegen/powerpc/assembler.cpp +++ b/src/codegen/powerpc/assembler.cpp @@ -8,11 +8,11 @@ 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" +#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/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 b52e1ea4ee..79b5377959 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 "codegen/x86/context.h" #include "codegen/x86/block.h" @@ -25,14 +25,15 @@ #include "codegen/x86/detect.h" #include "codegen/x86/multimethod.h" -#include "util/runtime-array.h" -#include "util/abort.h" +#include +#include #define CAST1(x) reinterpret_cast(x) #define CAST2(x) reinterpret_cast(x) #define CAST_BRANCH(x) reinterpret_cast(x) using namespace vm; +using namespace avian::util; namespace avian { namespace codegen { diff --git a/src/codegen/x86/block.h b/src/codegen/x86/block.h index 76f7ff05a6..211cf9d9f1 100644 --- a/src/codegen/x86/block.h +++ b/src/codegen/x86/block.h @@ -11,7 +11,7 @@ #ifndef AVIAN_CODEGEN_ASSEMBLER_X86_BLOCK_H #define AVIAN_CODEGEN_ASSEMBLER_X86_BLOCK_H -#include "codegen/assembler.h" +#include namespace avian { namespace codegen { diff --git a/src/codegen/x86/context.h b/src/codegen/x86/context.h index 70233dd399..d85eb58758 100644 --- a/src/codegen/x86/context.h +++ b/src/codegen/x86/context.h @@ -15,12 +15,10 @@ #define CAST2(x) reinterpret_cast(x) #define CAST_BRANCH(x) reinterpret_cast(x) -#include "codegen/lir.h" -#include "codegen/assembler.h" +#include +#include #include "alloc-vector.h" -class Aborter; - namespace vm { class System; class Allocator; @@ -28,6 +26,11 @@ class Zone; } // namespace vm namespace avian { + +namespace util { +class Aborter; +} // namespace util + namespace codegen { namespace x86 { @@ -80,11 +83,11 @@ class Context { ArchitectureContext* ac; }; -inline Aborter* getAborter(Context* c) { +inline avian::util::Aborter* getAborter(Context* c) { return c->s; } -inline Aborter* getAborter(ArchitectureContext* c) { +inline avian::util::Aborter* getAborter(ArchitectureContext* c) { return c->s; } diff --git a/src/codegen/x86/detect.h b/src/codegen/x86/detect.h index 13c7e58be1..b7c3b0aa8f 100644 --- a/src/codegen/x86/detect.h +++ b/src/codegen/x86/detect.h @@ -11,7 +11,7 @@ #ifndef AVIAN_CODEGEN_ASSEMBLER_X86_DETECT_H #define AVIAN_CODEGEN_ASSEMBLER_X86_DETECT_H -#include "codegen/assembler.h" +#include namespace avian { namespace codegen { diff --git a/src/codegen/x86/encode.cpp b/src/codegen/x86/encode.cpp index 8c34c426f9..8293550be6 100644 --- a/src/codegen/x86/encode.cpp +++ b/src/codegen/x86/encode.cpp @@ -15,6 +15,8 @@ #include "codegen/x86/registers.h" #include "codegen/x86/fixup.h" +using namespace avian::util; + namespace avian { namespace codegen { namespace x86 { @@ -70,7 +72,7 @@ void modrm(Context* c, uint8_t mod, lir::Register* a, lir::Register* b) { } void sib(Context* c, unsigned scale, int index, int base) { - c->code.append((vm::log(scale) << 6) | (regCode(index) << 3) | regCode(base)); + c->code.append((util::log(scale) << 6) | (regCode(index) << 3) | regCode(base)); } void modrmSib(Context* c, int width, int a, int scale, int index, int base) { diff --git a/src/codegen/x86/encode.h b/src/codegen/x86/encode.h index 293eeab2a9..e8fb3f9d7f 100644 --- a/src/codegen/x86/encode.h +++ b/src/codegen/x86/encode.h @@ -11,7 +11,7 @@ #ifndef AVIAN_CODEGEN_ASSEMBLER_X86_ENCODE_H #define AVIAN_CODEGEN_ASSEMBLER_X86_ENCODE_H -#include "codegen/assembler.h" +#include #include "codegen/x86/registers.h" namespace avian { diff --git a/src/codegen/x86/fixup.cpp b/src/codegen/x86/fixup.cpp index 5892fbd9e2..d914a22bdb 100644 --- a/src/codegen/x86/fixup.cpp +++ b/src/codegen/x86/fixup.cpp @@ -8,7 +8,8 @@ There is NO WARRANTY for this software. See license.txt for details. */ -#include "codegen/assembler.h" +#include + #include "codegen/x86/context.h" #include "codegen/x86/fixup.h" #include "codegen/x86/padding.h" diff --git a/src/codegen/x86/multimethod.cpp b/src/codegen/x86/multimethod.cpp index d665fef895..5c4663c7f9 100644 --- a/src/codegen/x86/multimethod.cpp +++ b/src/codegen/x86/multimethod.cpp @@ -10,7 +10,7 @@ #include "common.h" -#include "codegen/lir.h" +#include #include "codegen/x86/context.h" #include "codegen/x86/multimethod.h" diff --git a/src/codegen/x86/operations.cpp b/src/codegen/x86/operations.cpp index bf92b399b8..56eb77c127 100644 --- a/src/codegen/x86/operations.cpp +++ b/src/codegen/x86/operations.cpp @@ -16,6 +16,8 @@ #include "codegen/x86/padding.h" #include "codegen/x86/fixup.h" +using namespace avian::util; + namespace avian { namespace codegen { namespace x86 { diff --git a/src/codegen/x86/padding.cpp b/src/codegen/x86/padding.cpp index 355c30e041..7873145bb4 100644 --- a/src/codegen/x86/padding.cpp +++ b/src/codegen/x86/padding.cpp @@ -8,7 +8,8 @@ There is NO WARRANTY for this software. See license.txt for details. */ -#include "codegen/assembler.h" +#include + #include "codegen/x86/context.h" #include "codegen/x86/fixup.h" #include "codegen/x86/padding.h" diff --git a/src/common.h b/src/common.h index d4334f3733..c055b4e112 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,27 +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 bool fitsInInt8(int64_t v) { return v == static_cast(v); } @@ -370,15 +331,6 @@ inline bool fitsInInt16(int64_t v) { inline bool fitsInInt32(int64_t v) { return v == static_cast(v); } - -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/compile.cpp b/src/compile.cpp index 5b9245df15..02a87cd4c8 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -13,12 +13,13 @@ #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 "util/runtime-array.h" +#include +#include +#include + +#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/heap/heap.cpp b/src/heap/heap.cpp index 119a250572..0a0778797b 100644 --- a/src/heap/heap.cpp +++ b/src/heap/heap.cpp @@ -8,12 +8,15 @@ 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" +#include + using namespace vm; +using namespace avian::util; namespace { 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..06a86a562c 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -17,7 +17,8 @@ #include "arch.h" #include "lzma.h" -#include "util/runtime-array.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/machine.h b/src/machine.h index 1d29cbc88a..a2ebb7c538 100644 --- a/src/machine.h +++ b/src/machine.h @@ -13,12 +13,14 @@ #include "common.h" #include "system.h" -#include "heap/heap.h" +#include #include "finder.h" #include "processor.h" #include "constants.h" #include "arch.h" +using namespace avian::util; + #ifdef PLATFORM_WINDOWS # define JNICALL __stdcall #else 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/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/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/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/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; } 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 { 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) 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)); diff --git a/unittest/codegen/assembler-test.cpp b/unittest/codegen/assembler-test.cpp index 78317c19c8..fa41ebf090 100644 --- a/unittest/codegen/assembler-test.cpp +++ b/unittest/codegen/assembler-test.cpp @@ -11,13 +11,13 @@ #include #include "common.h" -#include "heap/heap.h" +#include #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"