Merge branch 'master' into wip

Conflicts:
	src/codegen/compiler/event.cpp
	src/codegen/x86/assembler.cpp
	src/common.h
This commit is contained in:
Joshua Warner 2013-02-20 11:27:39 -07:00
commit 1f0833252d
63 changed files with 207 additions and 154 deletions

View File

@ -15,7 +15,7 @@
#include "stdlib.h" #include "stdlib.h"
#include "string.h" #include "string.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
#undef JNIEXPORT #undef JNIEXPORT

View File

@ -11,6 +11,9 @@
#ifndef AVIAN_UTIL_ABORT_H #ifndef AVIAN_UTIL_ABORT_H
#define AVIAN_UTIL_ABORT_H #define AVIAN_UTIL_ABORT_H
namespace avian {
namespace util {
class Aborter { class Aborter {
public: public:
virtual void NO_RETURN abort() = 0; virtual void NO_RETURN abort() = 0;
@ -37,5 +40,8 @@ inline void assert(T t, bool v) {
expect(t, v); expect(t, v);
} }
#endif #endif
} // namespace util
} // namespace avian
#endif // AVIAN_UTIL_ABORT_H #endif // AVIAN_UTIL_ABORT_H

53
include/avian/util/math.h Normal file
View File

@ -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

View File

@ -14,8 +14,8 @@
#include "system.h" #include "system.h"
#include "zone.h" #include "zone.h"
#include "codegen/lir.h" #include <avian/vm/codegen/lir.h>
#include "codegen/promise.h" #include <avian/vm/codegen/promise.h>
namespace avian { namespace avian {
namespace codegen { namespace codegen {

View File

@ -11,7 +11,7 @@
#ifndef AVIAN_CODEGEN_TARGETS_H #ifndef AVIAN_CODEGEN_TARGETS_H
#define AVIAN_CODEGEN_TARGETS_H #define AVIAN_CODEGEN_TARGETS_H
#include "codegen/assembler.h" #include <avian/vm/codegen/assembler.h>
namespace avian { namespace avian {
namespace codegen { namespace codegen {

View File

@ -214,7 +214,7 @@ warnings = -Wall -Wextra -Werror -Wunused-parameter -Winit-self \
target-cflags = -DTARGET_BYTES_PER_WORD=$(pointer-size) target-cflags = -DTARGET_BYTES_PER_WORD=$(pointer-size)
common-cflags = $(warnings) -fno-rtti -fno-exceptions -I$(classpath-src) \ 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)\" \ -D__STDC_LIMIT_MACROS -D_JNI_IMPLEMENTATION_ -DAVIAN_VERSION=\"$(version)\" \
-DAVIAN_INFO="\"$(info)\"" \ -DAVIAN_INFO="\"$(info)\"" \
-DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \ -DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \
@ -232,7 +232,7 @@ endif
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \ build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
"-I$(JAVA_HOME)/include/linux" -I$(src) -pthread "-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 \ -fno-rtti -fno-exceptions \
-DAVIAN_TARGET_ARCH=AVIAN_ARCH_UNKNOWN \ -DAVIAN_TARGET_ARCH=AVIAN_ARCH_UNKNOWN \
-DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_UNKNOWN \ -DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_UNKNOWN \
@ -1133,18 +1133,20 @@ generator-lzma-objects = \
$(call generator-c-objects,$(lzma-decode-sources),$(lzma)/C,$(build)) $(call generator-c-objects,$(lzma-decode-sources),$(lzma)/C,$(build))
generator = $(build)/generator generator = $(build)/generator
converter-depends = \ all-depends = $(shell find include -name '*.h')
$(src)/binaryToObject/tools.h \
$(src)/binaryToObject/endianness.h
converter-sources = \ object-writer-depends = $(shell find $(src)/tools/object-writer -name '*.h')
$(src)/binaryToObject/tools.cpp \ object-writer-sources = $(shell find $(src)/tools/object-writer -name '*.cpp')
$(src)/binaryToObject/elf.cpp \ object-writer-objects = $(call cpp-objects,$(object-writer-sources),$(src),$(build))
$(src)/binaryToObject/mach-o.cpp \
$(src)/binaryToObject/pe.cpp
converter-tool-sources = \ binary-to-object-depends = $(shell find $(src)/tools/binary-to-object/ -name '*.h')
$(src)/binaryToObject/main.cpp 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-objects = $(call cpp-objects,$(converter-sources),$(src),$(build))
converter-tool-objects = $(call cpp-objects,$(converter-tool-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 $(boot-javahome-object): $(src)/boot-javahome.cpp
$(compile-object) $(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 $(@)) @mkdir -p $(dir $(@))
$(build-cxx) $(converter-cflags) -c $(<) -o $(@) $(build-cxx) $(converter-cflags) -c $(<) -o $(@)
$(converter): $(converter-objects) $(converter-tool-objects) $(converter): $(converter-objects) $(converter-tool-objects)
@mkdir -p $(dir $(@))
$(build-cc) $(^) -g -o $(@) $(build-cc) $(^) -g -o $(@)
$(lzma-encoder-objects): $(build)/lzma/%.o: $(src)/lzma/%.cpp $(lzma-encoder-objects): $(build)/lzma/%.o: $(src)/lzma/%.cpp

View File

@ -14,6 +14,8 @@
#include "system.h" #include "system.h"
#include "target.h" #include "target.h"
#include <avian/util/math.h>
namespace vm { namespace vm {
class Vector { class Vector {
@ -51,8 +53,8 @@ class Vector {
if (position + space > capacity) { if (position + space > capacity) {
assert(s, minimumCapacity >= 0); assert(s, minimumCapacity >= 0);
unsigned newCapacity = max unsigned newCapacity = avian::util::max
(position + space, max(minimumCapacity, capacity * 2)); (position + space, avian::util::max(minimumCapacity, capacity * 2));
uint8_t* newData = static_cast<uint8_t*> uint8_t* newData = static_cast<uint8_t*>
(allocator->allocate(newCapacity)); (allocator->allocate(newCapacity));
if (data) { if (data) {

View File

@ -13,7 +13,7 @@
#include "types.h" #include "types.h"
#include "common.h" #include "common.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
#ifdef __APPLE__ #ifdef __APPLE__
# include "libkern/OSAtomic.h" # include "libkern/OSAtomic.h"

View File

@ -9,13 +9,13 @@ const unsigned NAME(BootHeapOffset) = 1 << (NAME(BootShift) + 1);
inline unsigned inline unsigned
LABEL(codeMapSize)(unsigned codeSize) LABEL(codeMapSize)(unsigned codeSize)
{ {
return ceilingDivide(codeSize, TargetBitsPerWord) * TargetBytesPerWord; return avian::util::ceilingDivide(codeSize, TargetBitsPerWord) * TargetBytesPerWord;
} }
inline unsigned inline unsigned
LABEL(heapMapSize)(unsigned heapSize) LABEL(heapMapSize)(unsigned heapSize)
{ {
return ceilingDivide(heapSize, TargetBitsPerWord * TargetBytesPerWord) return avian::util::ceilingDivide(heapSize, TargetBitsPerWord * TargetBytesPerWord)
* TargetBytesPerWord; * TargetBytesPerWord;
} }

View File

@ -8,7 +8,7 @@
There is NO WARRANTY for this software. See license.txt for There is NO WARRANTY for this software. See license.txt for
details. */ details. */
#include "heap/heap.h" #include <avian/vm/heap/heap.h>
#include "heapwalk.h" #include "heapwalk.h"
#include "common.h" #include "common.h"
#include "machine.h" #include "machine.h"
@ -17,7 +17,7 @@
#include "codegen/assembler.h" #include "codegen/assembler.h"
#include "codegen/promise.h" #include "codegen/promise.h"
#include "target.h" #include "target.h"
#include "binaryToObject/tools.h" #include <avian/tools/object-writer/tools.h>
#include "lzma.h" #include "lzma.h"
#include "util/arg-parser.h" #include "util/arg-parser.h"

View File

@ -15,6 +15,8 @@
#include "target.h" #include "target.h"
#include "machine.h" #include "machine.h"
#include <avian/util/math.h>
namespace vm { namespace vm {
class BootImage { class BootImage {

View File

@ -13,7 +13,7 @@
#include "processor.h" #include "processor.h"
#include "util.h" #include "util.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
using namespace vm; using namespace vm;

View File

@ -12,7 +12,7 @@
#include "classpath-common.h" #include "classpath-common.h"
#include "process.h" #include "process.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
using namespace vm; using namespace vm;

View File

@ -13,7 +13,7 @@
#include "tokenizer.h" #include "tokenizer.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
namespace vm { namespace vm {

View File

@ -8,13 +8,13 @@
There is NO WARRANTY for this software. See license.txt for There is NO WARRANTY for this software. See license.txt for
details. */ details. */
#include "codegen/assembler.h" #include <avian/vm/codegen/assembler.h>
#include "codegen/registers.h" #include <avian/vm/codegen/registers.h>
#include "alloc-vector.h" #include "alloc-vector.h"
#include "util/abort.h" #include <avian/util/abort.h>
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
#define CAST1(x) reinterpret_cast<UnaryOperationType>(x) #define CAST1(x) reinterpret_cast<UnaryOperationType>(x)
#define CAST2(x) reinterpret_cast<BinaryOperationType>(x) #define CAST2(x) reinterpret_cast<BinaryOperationType>(x)
@ -23,6 +23,7 @@
using namespace vm; using namespace vm;
using namespace avian::codegen; using namespace avian::codegen;
using namespace avian::util;
namespace local { namespace local {

View File

@ -10,11 +10,11 @@
#include "target.h" #include "target.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
#include "codegen/compiler.h" #include <avian/vm/codegen/compiler.h>
#include "codegen/assembler.h" #include <avian/vm/codegen/assembler.h>
#include "codegen/promise.h" #include <avian/vm/codegen/promise.h>
#include "codegen/compiler/regalloc.h" #include "codegen/compiler/regalloc.h"
#include "codegen/compiler/context.h" #include "codegen/compiler/context.h"

View File

@ -11,10 +11,12 @@
#ifndef AVIAN_CODEGEN_COMPILER_CONTEXT_H #ifndef AVIAN_CODEGEN_COMPILER_CONTEXT_H
#define AVIAN_CODEGEN_COMPILER_CONTEXT_H #define AVIAN_CODEGEN_COMPILER_CONTEXT_H
#include "codegen/assembler.h" #include <avian/vm/codegen/assembler.h>
#include "codegen/compiler.h" #include <avian/vm/codegen/compiler.h>
#include "codegen/compiler/regalloc.h" #include "regalloc.h"
using namespace avian::util;
namespace avian { namespace avian {
namespace codegen { namespace codegen {

View File

@ -9,7 +9,8 @@
details. */ details. */
#include "target.h" #include "target.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
#include <avian/util/math.h>
#include "codegen/compiler/context.h" #include "codegen/compiler/context.h"
#include "codegen/compiler/event.h" #include "codegen/compiler/event.h"
@ -20,6 +21,8 @@
#include "codegen/compiler/frame.h" #include "codegen/compiler/frame.h"
#include "codegen/compiler/ir.h" #include "codegen/compiler/ir.h"
using namespace avian::util;
namespace avian { namespace avian {
namespace codegen { namespace codegen {
namespace compiler { namespace compiler {
@ -917,11 +920,11 @@ appendCombine(Context* c, lir::TernaryOperation type,
intptr_t handler = c->client->getThunk intptr_t handler = c->client->getThunk
(type, firstSize, resultSize, &threadParameter); (type, firstSize, resultSize, &threadParameter);
unsigned stackSize = vm::ceilingDivide(secondSize, vm::TargetBytesPerWord) unsigned stackSize = ceilingDivide(secondSize, vm::TargetBytesPerWord)
+ vm::ceilingDivide(firstSize, vm::TargetBytesPerWord); + ceilingDivide(firstSize, vm::TargetBytesPerWord);
compiler::push(c, vm::ceilingDivide(secondSize, vm::TargetBytesPerWord), secondValue); compiler::push(c, ceilingDivide(secondSize, vm::TargetBytesPerWord), secondValue);
compiler::push(c, vm::ceilingDivide(firstSize, vm::TargetBytesPerWord), firstValue); compiler::push(c, ceilingDivide(firstSize, vm::TargetBytesPerWord), firstValue);
if (threadParameter) { if (threadParameter) {
++ stackSize; ++ stackSize;
@ -1041,7 +1044,7 @@ appendTranslate(Context* c, lir::BinaryOperation type, unsigned firstSize,
if (thunk) { if (thunk) {
Stack* oldStack = c->stack; 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; Stack* argumentStack = c->stack;
c->stack = oldStack; c->stack = oldStack;
@ -1051,7 +1054,7 @@ appendTranslate(Context* c, lir::BinaryOperation type, unsigned firstSize,
(c, lir::ValueGeneral, constantSite (c, lir::ValueGeneral, constantSite
(c, c->client->getThunk(type, firstSize, resultSize))), (c, c->client->getThunk(type, firstSize, resultSize))),
0, 0, resultValue, resultSize, argumentStack, 0, 0, resultValue, resultSize, argumentStack,
vm::ceilingDivide(firstSize, vm::TargetBytesPerWord), 0); ceilingDivide(firstSize, vm::TargetBytesPerWord), 0);
} else { } else {
append(c, new(c->zone) append(c, new(c->zone)
TranslateEvent TranslateEvent
@ -1398,8 +1401,8 @@ appendBranch(Context* c, lir::TernaryOperation type, unsigned size, Value* first
assert(c, not threadParameter); assert(c, not threadParameter);
compiler::push(c, vm::ceilingDivide(size, vm::TargetBytesPerWord), secondValue); compiler::push(c, ceilingDivide(size, vm::TargetBytesPerWord), secondValue);
compiler::push(c, vm::ceilingDivide(size, vm::TargetBytesPerWord), firstValue); compiler::push(c, ceilingDivide(size, vm::TargetBytesPerWord), firstValue);
Stack* argumentStack = c->stack; Stack* argumentStack = c->stack;
c->stack = oldStack; c->stack = oldStack;
@ -1408,7 +1411,7 @@ appendBranch(Context* c, lir::TernaryOperation type, unsigned size, Value* first
appendCall appendCall
(c, value (c, value
(c, lir::ValueGeneral, constantSite(c, handler)), 0, 0, result, 4, (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 appendBranch(c, thunkBranch(c, type), 4, value
(c, lir::ValueGeneral, constantSite(c, static_cast<int64_t>(0))), (c, lir::ValueGeneral, constantSite(c, static_cast<int64_t>(0))),

View File

@ -13,15 +13,20 @@
#include "common.h" #include "common.h"
#include "codegen/lir.h" #include <avian/vm/codegen/lir.h>
#include "codegen/registers.h" #include <avian/vm/codegen/registers.h>
class Aborter;
namespace avian { namespace avian {
namespace util {
class Aborter;
} // namespace util
namespace codegen { namespace codegen {
namespace compiler { namespace compiler {
using namespace avian::util;
class Context; class Context;
class Value; class Value;
class SiteMask; class SiteMask;

View File

@ -11,9 +11,8 @@
#ifndef AVIAN_CODEGEN_COMPILER_VALUE_H #ifndef AVIAN_CODEGEN_COMPILER_VALUE_H
#define AVIAN_CODEGEN_COMPILER_VALUE_H #define AVIAN_CODEGEN_COMPILER_VALUE_H
#include "codegen/lir.h" #include <avian/vm/codegen/lir.h>
#include <avian/vm/codegen/compiler.h>
#include "codegen/compiler.h"
namespace avian { namespace avian {
namespace codegen { namespace codegen {

View File

@ -8,11 +8,11 @@
There is NO WARRANTY for this software. See license.txt for There is NO WARRANTY for this software. See license.txt for
details. */ details. */
#include "codegen/assembler.h" #include <avian/vm/codegen/assembler.h>
#include "codegen/registers.h" #include <avian/vm/codegen/registers.h>
#include "alloc-vector.h" #include "alloc-vector.h"
#include "util/abort.h" #include <avian/util/abort.h>
#define CAST1(x) reinterpret_cast<UnaryOperationType>(x) #define CAST1(x) reinterpret_cast<UnaryOperationType>(x)
#define CAST2(x) reinterpret_cast<BinaryOperationType>(x) #define CAST2(x) reinterpret_cast<BinaryOperationType>(x)
@ -21,6 +21,7 @@
using namespace vm; using namespace vm;
using namespace avian::codegen; using namespace avian::codegen;
using namespace avian::util;
namespace { namespace {

View File

@ -8,7 +8,7 @@
There is NO WARRANTY for this software. See license.txt for There is NO WARRANTY for this software. See license.txt for
details. */ details. */
#include "codegen/registers.h" #include <avian/vm/codegen/registers.h>
namespace avian { namespace avian {
namespace codegen { namespace codegen {

View File

@ -8,7 +8,8 @@
There is NO WARRANTY for this software. See license.txt for There is NO WARRANTY for this software. See license.txt for
details. */ details. */
#include "codegen/targets.h" #include <avian/vm/codegen/targets.h>
#include "environment.h" #include "environment.h"
namespace avian { namespace avian {

View File

@ -12,8 +12,8 @@
#include "target.h" #include "target.h"
#include "alloc-vector.h" #include "alloc-vector.h"
#include "codegen/assembler.h" #include <avian/vm/codegen/assembler.h>
#include "codegen/registers.h" #include <avian/vm/codegen/registers.h>
#include "codegen/x86/context.h" #include "codegen/x86/context.h"
#include "codegen/x86/block.h" #include "codegen/x86/block.h"
@ -25,14 +25,15 @@
#include "codegen/x86/detect.h" #include "codegen/x86/detect.h"
#include "codegen/x86/multimethod.h" #include "codegen/x86/multimethod.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
#include "util/abort.h" #include <avian/util/abort.h>
#define CAST1(x) reinterpret_cast<UnaryOperationType>(x) #define CAST1(x) reinterpret_cast<UnaryOperationType>(x)
#define CAST2(x) reinterpret_cast<BinaryOperationType>(x) #define CAST2(x) reinterpret_cast<BinaryOperationType>(x)
#define CAST_BRANCH(x) reinterpret_cast<BranchOperationType>(x) #define CAST_BRANCH(x) reinterpret_cast<BranchOperationType>(x)
using namespace vm; using namespace vm;
using namespace avian::util;
namespace avian { namespace avian {
namespace codegen { namespace codegen {

View File

@ -11,7 +11,7 @@
#ifndef AVIAN_CODEGEN_ASSEMBLER_X86_BLOCK_H #ifndef AVIAN_CODEGEN_ASSEMBLER_X86_BLOCK_H
#define AVIAN_CODEGEN_ASSEMBLER_X86_BLOCK_H #define AVIAN_CODEGEN_ASSEMBLER_X86_BLOCK_H
#include "codegen/assembler.h" #include <avian/vm/codegen/assembler.h>
namespace avian { namespace avian {
namespace codegen { namespace codegen {

View File

@ -15,12 +15,10 @@
#define CAST2(x) reinterpret_cast<BinaryOperationType>(x) #define CAST2(x) reinterpret_cast<BinaryOperationType>(x)
#define CAST_BRANCH(x) reinterpret_cast<BranchOperationType>(x) #define CAST_BRANCH(x) reinterpret_cast<BranchOperationType>(x)
#include "codegen/lir.h" #include <avian/vm/codegen/lir.h>
#include "codegen/assembler.h" #include <avian/vm/codegen/assembler.h>
#include "alloc-vector.h" #include "alloc-vector.h"
class Aborter;
namespace vm { namespace vm {
class System; class System;
class Allocator; class Allocator;
@ -28,6 +26,11 @@ class Zone;
} // namespace vm } // namespace vm
namespace avian { namespace avian {
namespace util {
class Aborter;
} // namespace util
namespace codegen { namespace codegen {
namespace x86 { namespace x86 {
@ -80,11 +83,11 @@ class Context {
ArchitectureContext* ac; ArchitectureContext* ac;
}; };
inline Aborter* getAborter(Context* c) { inline avian::util::Aborter* getAborter(Context* c) {
return c->s; return c->s;
} }
inline Aborter* getAborter(ArchitectureContext* c) { inline avian::util::Aborter* getAborter(ArchitectureContext* c) {
return c->s; return c->s;
} }

View File

@ -11,7 +11,7 @@
#ifndef AVIAN_CODEGEN_ASSEMBLER_X86_DETECT_H #ifndef AVIAN_CODEGEN_ASSEMBLER_X86_DETECT_H
#define AVIAN_CODEGEN_ASSEMBLER_X86_DETECT_H #define AVIAN_CODEGEN_ASSEMBLER_X86_DETECT_H
#include "codegen/assembler.h" #include <avian/vm/codegen/assembler.h>
namespace avian { namespace avian {
namespace codegen { namespace codegen {

View File

@ -15,6 +15,8 @@
#include "codegen/x86/registers.h" #include "codegen/x86/registers.h"
#include "codegen/x86/fixup.h" #include "codegen/x86/fixup.h"
using namespace avian::util;
namespace avian { namespace avian {
namespace codegen { namespace codegen {
namespace x86 { 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) { 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) { void modrmSib(Context* c, int width, int a, int scale, int index, int base) {

View File

@ -11,7 +11,7 @@
#ifndef AVIAN_CODEGEN_ASSEMBLER_X86_ENCODE_H #ifndef AVIAN_CODEGEN_ASSEMBLER_X86_ENCODE_H
#define AVIAN_CODEGEN_ASSEMBLER_X86_ENCODE_H #define AVIAN_CODEGEN_ASSEMBLER_X86_ENCODE_H
#include "codegen/assembler.h" #include <avian/vm/codegen/assembler.h>
#include "codegen/x86/registers.h" #include "codegen/x86/registers.h"
namespace avian { namespace avian {

View File

@ -8,7 +8,8 @@
There is NO WARRANTY for this software. See license.txt for There is NO WARRANTY for this software. See license.txt for
details. */ details. */
#include "codegen/assembler.h" #include <avian/vm/codegen/assembler.h>
#include "codegen/x86/context.h" #include "codegen/x86/context.h"
#include "codegen/x86/fixup.h" #include "codegen/x86/fixup.h"
#include "codegen/x86/padding.h" #include "codegen/x86/padding.h"

View File

@ -10,7 +10,7 @@
#include "common.h" #include "common.h"
#include "codegen/lir.h" #include <avian/vm/codegen/lir.h>
#include "codegen/x86/context.h" #include "codegen/x86/context.h"
#include "codegen/x86/multimethod.h" #include "codegen/x86/multimethod.h"

View File

@ -16,6 +16,8 @@
#include "codegen/x86/padding.h" #include "codegen/x86/padding.h"
#include "codegen/x86/fixup.h" #include "codegen/x86/fixup.h"
using namespace avian::util;
namespace avian { namespace avian {
namespace codegen { namespace codegen {
namespace x86 { namespace x86 {

View File

@ -8,7 +8,8 @@
There is NO WARRANTY for this software. See license.txt for There is NO WARRANTY for this software. See license.txt for
details. */ details. */
#include "codegen/assembler.h" #include <avian/vm/codegen/assembler.h>
#include "codegen/x86/context.h" #include "codegen/x86/context.h"
#include "codegen/x86/fixup.h" #include "codegen/x86/fixup.h"
#include "codegen/x86/padding.h" #include "codegen/x86/padding.h"

View File

@ -296,24 +296,6 @@ const uintptr_t PointerMask
const unsigned LikelyPageSizeInBytes = 4 * 1024; 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 inline unsigned
pad(unsigned n, unsigned alignment) pad(unsigned n, unsigned alignment)
{ {
@ -338,27 +320,6 @@ padWord(uintptr_t n)
return padWord(n, BytesPerWord); 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) { inline bool fitsInInt8(int64_t v) {
return v == static_cast<int8_t>(v); return v == static_cast<int8_t>(v);
} }
@ -370,15 +331,6 @@ inline bool fitsInInt16(int64_t v) {
inline bool fitsInInt32(int64_t v) { inline bool fitsInInt32(int64_t v) {
return v == static_cast<int32_t>(v); return v == static_cast<int32_t>(v);
} }
inline unsigned
log(unsigned n)
{
unsigned r = 0;
for (unsigned i = 1; i < n; ++r) i <<= 1;
return r;
}
template <class T> template <class T>
inline unsigned inline unsigned
wordOf(unsigned i) wordOf(unsigned i)

View File

@ -13,12 +13,13 @@
#include "alloc-vector.h" #include "alloc-vector.h"
#include "process.h" #include "process.h"
#include "target.h" #include "target.h"
#include "codegen/assembler.h"
#include "codegen/compiler.h"
#include "codegen/targets.h"
#include "arch.h" #include "arch.h"
#include "util/runtime-array.h" #include <avian/vm/codegen/assembler.h>
#include <avian/vm/codegen/compiler.h>
#include <avian/vm/codegen/targets.h>
#include <avian/util/runtime-array.h>
using namespace vm; using namespace vm;

View File

@ -14,7 +14,7 @@
#include "finder.h" #include "finder.h"
#include "lzma.h" #include "lzma.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
using namespace vm; using namespace vm;

View File

@ -8,12 +8,15 @@
There is NO WARRANTY for this software. See license.txt for There is NO WARRANTY for this software. See license.txt for
details. */ details. */
#include "heap/heap.h" #include <avian/vm/heap/heap.h>
#include "system.h" #include "system.h"
#include "common.h" #include "common.h"
#include "arch.h" #include "arch.h"
#include <avian/util/math.h>
using namespace vm; using namespace vm;
using namespace avian::util;
namespace { namespace {

View File

@ -16,7 +16,7 @@
#include "process.h" #include "process.h"
#include "arch.h" #include "arch.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
using namespace vm; using namespace vm;

View File

@ -14,7 +14,7 @@
#include "processor.h" #include "processor.h"
#include "constants.h" #include "constants.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
using namespace vm; using namespace vm;

View File

@ -17,7 +17,8 @@
#include "arch.h" #include "arch.h"
#include "lzma.h" #include "lzma.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
#include <avian/util/math.h>
#if defined(PLATFORM_WINDOWS) #if defined(PLATFORM_WINDOWS)
# define WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN
@ -25,6 +26,7 @@
#endif #endif
using namespace vm; using namespace vm;
using namespace avian::util;
namespace { namespace {

View File

@ -13,12 +13,14 @@
#include "common.h" #include "common.h"
#include "system.h" #include "system.h"
#include "heap/heap.h" #include <avian/vm/heap/heap.h>
#include "finder.h" #include "finder.h"
#include "processor.h" #include "processor.h"
#include "constants.h" #include "constants.h"
#include "arch.h" #include "arch.h"
using namespace avian::util;
#ifdef PLATFORM_WINDOWS #ifdef PLATFORM_WINDOWS
# define JNICALL __stdcall # define JNICALL __stdcall
#else #else

View File

@ -16,7 +16,7 @@
#include "system.h" #include "system.h"
#include "finder.h" #include "finder.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
#if (defined __MINGW32__) || (defined _MSC_VER) #if (defined __MINGW32__) || (defined _MSC_VER)
# define PATH_SEPARATOR ';' # define PATH_SEPARATOR ';'

View File

@ -51,10 +51,13 @@
#include "arch.h" #include "arch.h"
#include "system.h" #include "system.h"
#include <avian/util/math.h>
#define ACQUIRE(x) MutexResource MAKE_NAME(mutexResource_) (x) #define ACQUIRE(x) MutexResource MAKE_NAME(mutexResource_) (x)
using namespace vm; using namespace vm;
using namespace avian::util;
namespace { namespace {

View File

@ -10,7 +10,7 @@
#include "process.h" #include "process.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
using namespace vm; using namespace vm;

View File

@ -13,7 +13,7 @@
#include "common.h" #include "common.h"
#include "system.h" #include "system.h"
#include "heap/heap.h" #include <avian/vm/heap/heap.h>
#include "bootimage.h" #include "bootimage.h"
#include "heapwalk.h" #include "heapwalk.h"
#include "zone.h" #include "zone.h"

View File

@ -13,11 +13,11 @@
#include "common.h" #include "common.h"
#include "allocator.h" #include "allocator.h"
#include "util/abort.h" #include <avian/util/abort.h>
namespace vm { namespace vm {
class System : public Aborter { class System : public avian::util::Aborter {
public: public:
typedef intptr_t Status; typedef intptr_t Status;
@ -165,7 +165,7 @@ allocate(System* s, unsigned size)
#define ACQUIRE_MONITOR(t, m) \ #define ACQUIRE_MONITOR(t, m) \
System::MonitorResource MAKE_NAME(monitorResource_) (t, m) System::MonitorResource MAKE_NAME(monitorResource_) (t, m)
inline Aborter* getAborter(System* s) { inline avian::util::Aborter* getAborter(System* s) {
return s; return s;
} }

View File

@ -22,7 +22,7 @@
#endif #endif
#include <fcntl.h> #include <fcntl.h>
#include "tools.h" #include <avian/tools/object-writer/tools.h>
extern "C" extern "C"
void __cxa_pure_virtual() { void __cxa_pure_virtual() {

View File

@ -15,7 +15,7 @@
#include "endianness.h" #include "endianness.h"
#include "tools.h" #include <avian/tools/object-writer/tools.h>
#define EI_NIDENT 16 #define EI_NIDENT 16

View File

@ -14,7 +14,7 @@
#include "endianness.h" #include "endianness.h"
#include "tools.h" #include <avian/tools/object-writer/tools.h>
#define MH_MAGIC_64 0xfeedfacf #define MH_MAGIC_64 0xfeedfacf
#define MH_MAGIC 0xfeedface #define MH_MAGIC 0xfeedface

View File

@ -13,7 +13,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "tools.h" #include <avian/tools/object-writer/tools.h>
namespace { namespace {

View File

@ -13,7 +13,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "tools.h" #include <avian/tools/object-writer/tools.h>
namespace avian { namespace avian {

View File

@ -25,7 +25,7 @@
#include "arch.h" #include "arch.h"
#include "system.h" #include "system.h"
#include "util/runtime-array.h" #include <avian/util/runtime-array.h>
#if defined(WINAPI_FAMILY) #if defined(WINAPI_FAMILY)

View File

@ -14,6 +14,8 @@
#include "system.h" #include "system.h"
#include "allocator.h" #include "allocator.h"
#include <avian/util/math.h>
namespace vm { namespace vm {
class Zone: public Allocator { class Zone: public Allocator {
@ -59,8 +61,8 @@ class Zone: public Allocator {
bool tryEnsure(unsigned space) { bool tryEnsure(unsigned space) {
if (segment == 0 or segment->position + space > segment->size) { if (segment == 0 or segment->position + space > segment->size) {
unsigned size = padToPage unsigned size = padToPage
(max (avian::util::max
(space, max (space, avian::util::max
(minimumFootprint, segment == 0 ? 0 : segment->size * 2)) (minimumFootprint, segment == 0 ? 0 : segment->size * 2))
+ sizeof(Segment)); + sizeof(Segment));

View File

@ -11,13 +11,13 @@
#include <stdio.h> #include <stdio.h>
#include "common.h" #include "common.h"
#include "heap/heap.h" #include <avian/vm/heap/heap.h>
#include "system.h" #include "system.h"
#include "target.h" #include "target.h"
#include "codegen/assembler.h" #include <avian/vm/codegen/assembler.h>
#include "codegen/targets.h" #include <avian/vm/codegen/targets.h>
#include "codegen/lir.h" #include <avian/vm/codegen/lir.h>
#include "test-harness.h" #include "test-harness.h"