From fd047bd6e97e75bf9d7e2527cd7bc56521e4213b Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 20 Feb 2013 17:20:10 -0700 Subject: [PATCH 01/11] find headers regardless of directory layout in vm-depends definition --- makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/makefile b/makefile index 38872186bf..076145e1ba 100755 --- a/makefile +++ b/makefile @@ -939,7 +939,8 @@ generated-code = \ $(build)/type-name-initializations.cpp \ $(build)/type-maps.cpp -vm-depends := $(generated-code) $(wildcard $(src)/*.h) $(wildcard $(src)/codegen/*.h) $(wildcard $(src)/codegen/compiler/*.h) +vm-depends := $(generated-code) \ + $(shell find src include -name '*.h' -or -name '*.inc.cpp') vm-sources = \ $(src)/$(system).cpp \ @@ -1019,7 +1020,7 @@ heapwalk-sources = $(src)/heapwalk.cpp heapwalk-objects = \ $(call cpp-objects,$(heapwalk-sources),$(src),$(build)) -unittest-objects = $(call cpp-objects,$(unittest-sources),$(unittest),$(build)/unittest/) +unittest-objects = $(call cpp-objects,$(unittest-sources),$(unittest),$(build)/unittest) ifeq ($(heapdump),true) vm-sources += $(src)/heapdump.cpp From f04f444f2348f41465bc8566a31f9a17728cb7b2 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 20 Feb 2013 17:20:17 -0700 Subject: [PATCH 02/11] modify (THREAD_)RUNTIME_ARRAY definition so RUNTIME_ARRAY_BODY must be used Previously, if you forgot to use RUNTIME_ARRAY_BODY to reference an array declared with (THREAD_)RUNTIME_ARRAY, you wouldn't get a compiler error until you tried to build on e.g. MSVC, where runtime-sized stack arrays aren't supported. This change ensures you find out regardless of what compiler you're using, which ought to protect us from regressions going forward. --- include/avian/util/runtime-array.h | 6 +-- src/bootimage.cpp | 65 ++++++++++++++++-------------- src/interpret.cpp | 11 ++--- src/machine.cpp | 8 ++-- src/machine.h | 3 +- 5 files changed, 49 insertions(+), 44 deletions(-) diff --git a/include/avian/util/runtime-array.h b/include/avian/util/runtime-array.h index ffd8e3348b..5d169ed95e 100644 --- a/include/avian/util/runtime-array.h +++ b/include/avian/util/runtime-array.h @@ -32,9 +32,9 @@ class RuntimeArray { #else // not _MSC_VER -# define RUNTIME_ARRAY(type, name, size) type name[size]; -# define RUNTIME_ARRAY_BODY(name) name +# define RUNTIME_ARRAY(type, name, size) type name##_body[size]; +# define RUNTIME_ARRAY_BODY(name) name##_body #endif -#endif // AVIAN_UTIL_RUNTIME_ARRAY_H \ No newline at end of file +#endif // AVIAN_UTIL_RUNTIME_ARRAY_H diff --git a/src/bootimage.cpp b/src/bootimage.cpp index 5f33a489b3..6d7b36c995 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -18,6 +18,7 @@ #include #include "target.h" #include +#include #include "lzma.h" // since we aren't linking against libstdc++, we must implement this @@ -345,20 +346,20 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, unsigned count = s.read2() - 1; if (count) { THREAD_RUNTIME_ARRAY(t, Type, types, count + 2); - types[0] = Type_object; - types[1] = Type_intptr_t; + RUNTIME_ARRAY_BODY(types)[0] = Type_object; + RUNTIME_ARRAY_BODY(types)[1] = Type_intptr_t; for (unsigned i = 2; i < count + 2; ++i) { switch (s.read1()) { case CONSTANT_Class: case CONSTANT_String: - types[i] = Type_object; + RUNTIME_ARRAY_BODY(types)[i] = Type_object; s.skip(2); break; case CONSTANT_Integer: case CONSTANT_Float: - types[i] = Type_int32_t; + RUNTIME_ARRAY_BODY(types)[i] = Type_int32_t; s.skip(4); break; @@ -366,24 +367,24 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, case CONSTANT_Fieldref: case CONSTANT_Methodref: case CONSTANT_InterfaceMethodref: - types[i] = Type_object; + RUNTIME_ARRAY_BODY(types)[i] = Type_object; s.skip(4); break; case CONSTANT_Long: - types[i++] = Type_int64_t; - types[i] = Type_int64_t_pad; + RUNTIME_ARRAY_BODY(types)[i++] = Type_int64_t; + RUNTIME_ARRAY_BODY(types)[i] = Type_int64_t_pad; s.skip(8); break; case CONSTANT_Double: - types[i++] = Type_double; - types[i] = Type_double_pad; + RUNTIME_ARRAY_BODY(types)[i++] = Type_double; + RUNTIME_ARRAY_BODY(types)[i] = Type_double_pad; s.skip(8); break; case CONSTANT_Utf8: - types[i] = Type_object; + RUNTIME_ARRAY_BODY(types)[i] = Type_object; s.skip(s.read2()); break; @@ -403,7 +404,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, map->targetFixedOffsets()[i * BytesPerWord] = i * TargetBytesPerWord; - init(new (map->fixedFields() + i) Field, types[i], + init(new (map->fixedFields() + i) Field, RUNTIME_ARRAY_BODY(types)[i], i * BytesPerWord, BytesPerWord, i * TargetBytesPerWord, TargetBytesPerWord); } @@ -439,15 +440,15 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, for (unsigned j = 0; j < map->fixedFieldCount; ++j) { Field* f = map->fixedFields() + j; - memberFields[memberIndex] = *f; + RUNTIME_ARRAY_BODY(memberFields)[memberIndex] = *f; targetMemberOffset = f->targetOffset + f->targetSize; ++ memberIndex; } } else { - init(new (&memberFields[0]) Field, Type_object, 0, BytesPerWord, 0, - TargetBytesPerWord); + init(new (RUNTIME_ARRAY_BODY(memberFields)) Field, Type_object, 0, + BytesPerWord, 0, TargetBytesPerWord); memberIndex = 1; buildMemberOffset = BytesPerWord; @@ -458,14 +459,16 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, THREAD_RUNTIME_ARRAY(t, Field, staticFields, count + StaticHeader); - init(new (&staticFields[0]) Field, Type_object, 0, BytesPerWord, 0, + init(new (RUNTIME_ARRAY_BODY(staticFields)) Field, Type_object, 0, + BytesPerWord, 0, TargetBytesPerWord); + + init(new (RUNTIME_ARRAY_BODY(staticFields) + 1) Field, Type_intptr_t, + BytesPerWord, BytesPerWord, TargetBytesPerWord, TargetBytesPerWord); - init(new (&staticFields[1]) Field, Type_intptr_t, BytesPerWord, - BytesPerWord, TargetBytesPerWord, TargetBytesPerWord); - - init(new (&staticFields[2]) Field, Type_object, BytesPerWord * 2, - BytesPerWord, TargetBytesPerWord * 2, TargetBytesPerWord); + init(new (RUNTIME_ARRAY_BODY(staticFields) + 2) Field, Type_object, + BytesPerWord * 2, BytesPerWord, TargetBytesPerWord * 2, + TargetBytesPerWord); unsigned staticIndex = StaticHeader; unsigned buildStaticOffset = BytesPerWord * StaticHeader; @@ -514,8 +517,8 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, buildStaticOffset = fieldOffset(t, field); - init(new (&staticFields[staticIndex]) Field, type, - buildStaticOffset, buildSize, targetStaticOffset, + init(new (RUNTIME_ARRAY_BODY(staticFields) + staticIndex) Field, + type, buildStaticOffset, buildSize, targetStaticOffset, targetSize); targetStaticOffset += targetSize; @@ -528,8 +531,8 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, buildMemberOffset = fieldOffset(t, field); - init(new (&memberFields[memberIndex]) Field, type, - buildMemberOffset, buildSize, targetMemberOffset, + init(new (RUNTIME_ARRAY_BODY(memberFields) + memberIndex) Field, + type, buildMemberOffset, buildSize, targetMemberOffset, targetSize); targetMemberOffset += targetSize; @@ -551,7 +554,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, ceilingDivide(targetMemberOffset, TargetBytesPerWord), memberIndex); for (unsigned i = 0; i < memberIndex; ++i) { - Field* f = &memberFields[i]; + Field* f = RUNTIME_ARRAY_BODY(memberFields) + i; expect(t, f->buildOffset < map->buildFixedSizeInWords * BytesPerWord); @@ -575,7 +578,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, TypeMap::SingletonKind); for (unsigned i = 0; i < staticIndex; ++i) { - Field* f = &staticFields[i]; + Field* f = RUNTIME_ARRAY_BODY(staticFields) + i; expect(t, f->buildOffset < map->buildFixedSizeInWords * BytesPerWord); @@ -1338,8 +1341,8 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp THREAD_RUNTIME_ARRAY(t, Field, fields, count); - init(new (&fields[0]) Field, Type_object, 0, BytesPerWord, 0, - TargetBytesPerWord); + init(new (RUNTIME_ARRAY_BODY(fields)) Field, Type_object, 0, + BytesPerWord, 0, TargetBytesPerWord); unsigned buildOffset = BytesPerWord; unsigned targetOffset = TargetBytesPerWord; @@ -1416,8 +1419,8 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp ++ targetOffset; } - init(new (&fields[j]) Field, type, buildOffset, buildSize, - targetOffset, targetSize); + init(new (RUNTIME_ARRAY_BODY(fields) + j) Field, type, buildOffset, + buildSize, targetOffset, targetSize); buildOffset += buildSize; targetOffset += targetSize; @@ -1451,7 +1454,7 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp targetArrayElementSize, arrayElementType); for (unsigned j = 0; j < fixedFieldCount; ++j) { - Field* f = &fields[j]; + Field* f = RUNTIME_ARRAY_BODY(fields) + j; expect(t, f->buildOffset < map->buildFixedSizeInWords * BytesPerWord); diff --git a/src/interpret.cpp b/src/interpret.cpp index c025957d48..8d7dc425e2 100644 --- a/src/interpret.cpp +++ b/src/interpret.cpp @@ -2325,19 +2325,20 @@ interpret3(Thread* t, const int base) THREAD_RUNTIME_ARRAY(t, int32_t, counts, dimensions); for (int i = dimensions - 1; i >= 0; --i) { - counts[i] = popInt(t); - if (UNLIKELY(counts[i] < 0)) { + RUNTIME_ARRAY_BODY(counts)[i] = popInt(t); + if (UNLIKELY(RUNTIME_ARRAY_BODY(counts)[i] < 0)) { exception = makeThrowable - (t, Machine::NegativeArraySizeExceptionType, "%d", counts[i]); + (t, Machine::NegativeArraySizeExceptionType, "%d", + RUNTIME_ARRAY_BODY(counts)[i]); goto throw_; } } - object array = makeArray(t, counts[0]); + object array = makeArray(t, RUNTIME_ARRAY_BODY(counts)[0]); setObjectClass(t, array, class_); PROTECT(t, array); - populateMultiArray(t, array, counts, 0, dimensions); + populateMultiArray(t, array, RUNTIME_ARRAY_BODY(counts), 0, dimensions); pushObject(t, array); } goto loop; diff --git a/src/machine.cpp b/src/machine.cpp index 06a86a562c..bcb7ec0876 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -4777,13 +4777,13 @@ logTrace(FILE* f, const char* fmt, ...) RUNTIME_ARRAY(char, buffer, length + 1); va_start(a, fmt); - vsnprintf(&buffer[0], length + 1, fmt, a); + vsnprintf(RUNTIME_ARRAY_BODY(buffer), length + 1, fmt, a); va_end(a); - buffer[length] = 0; + RUNTIME_ARRAY_BODY(buffer)[length] = 0; - ::fprintf(f, "%s", &buffer[0]); + ::fprintf(f, "%s", RUNTIME_ARRAY_BODY(buffer)); #ifdef PLATFORM_WINDOWS - ::OutputDebugStringA(&buffer[0]); + ::OutputDebugStringA(RUNTIME_ARRAY_BODY(buffer)); #endif } diff --git a/src/machine.h b/src/machine.h index a2ebb7c538..22fe7f3845 100644 --- a/src/machine.h +++ b/src/machine.h @@ -1603,7 +1603,8 @@ class ThreadRuntimeArray: public Thread::Resource { #else // not _MSC_VER -# define THREAD_RUNTIME_ARRAY(thread, type, name, size) type name[size]; +# define THREAD_RUNTIME_ARRAY(thread, type, name, size) \ + type name##_body[size]; #endif // not _MSC_VER From f17b8cef08d69b6c58ef420ddfebf0747282755f Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Wed, 20 Feb 2013 20:42:09 -0700 Subject: [PATCH 03/11] move system.h to include --- include/avian/vm/codegen/assembler.h | 2 +- include/avian/vm/codegen/compiler.h | 2 +- include/avian/vm/heap/heap.h | 2 +- {src => include/avian/vm/system}/system.h | 0 src/alloc-vector.h | 2 +- src/finder.cpp | 2 +- src/finder.h | 2 +- src/heap/heap.cpp | 2 +- src/interpret.cpp | 2 +- src/lzma-util.h | 2 +- src/lzma.h | 2 +- src/machine.h | 2 +- src/main.cpp | 2 +- src/posix.cpp | 2 +- src/process.h | 2 +- src/processor.h | 2 +- src/windows.cpp | 2 +- src/zone.h | 2 +- unittest/codegen/assembler-test.cpp | 2 +- 19 files changed, 18 insertions(+), 18 deletions(-) rename {src => include/avian/vm/system}/system.h (100%) diff --git a/include/avian/vm/codegen/assembler.h b/include/avian/vm/codegen/assembler.h index 593e0e6fe7..d61684c92e 100644 --- a/include/avian/vm/codegen/assembler.h +++ b/include/avian/vm/codegen/assembler.h @@ -11,7 +11,7 @@ #ifndef AVIAN_CODEGEN_ASSEMBLER_H #define AVIAN_CODEGEN_ASSEMBLER_H -#include "system.h" +#include #include "zone.h" #include diff --git a/include/avian/vm/codegen/compiler.h b/include/avian/vm/codegen/compiler.h index b7aeeed2dc..663cb071ea 100644 --- a/include/avian/vm/codegen/compiler.h +++ b/include/avian/vm/codegen/compiler.h @@ -11,7 +11,7 @@ #ifndef AVIAN_CODEGEN_COMPILER_H #define AVIAN_CODEGEN_COMPILER_H -#include "system.h" +#include #include "zone.h" #include "assembler.h" diff --git a/include/avian/vm/heap/heap.h b/include/avian/vm/heap/heap.h index 2a6734438d..5b0fbc1ba1 100644 --- a/include/avian/vm/heap/heap.h +++ b/include/avian/vm/heap/heap.h @@ -11,7 +11,7 @@ #ifndef HEAP_H #define HEAP_H -#include "system.h" +#include #include "allocator.h" namespace vm { diff --git a/src/system.h b/include/avian/vm/system/system.h similarity index 100% rename from src/system.h rename to include/avian/vm/system/system.h diff --git a/src/alloc-vector.h b/src/alloc-vector.h index 4032987655..fbdd1f5561 100644 --- a/src/alloc-vector.h +++ b/src/alloc-vector.h @@ -11,7 +11,7 @@ #ifndef VECTOR_H #define VECTOR_H -#include "system.h" +#include #include "target.h" #include diff --git a/src/finder.cpp b/src/finder.cpp index 93e95250fd..879796075b 100644 --- a/src/finder.cpp +++ b/src/finder.cpp @@ -9,7 +9,7 @@ details. */ #include "zlib-custom.h" -#include "system.h" +#include #include "tokenizer.h" #include "finder.h" #include "lzma.h" diff --git a/src/finder.h b/src/finder.h index f4582417fa..d9f8480577 100644 --- a/src/finder.h +++ b/src/finder.h @@ -12,7 +12,7 @@ #define FINDER_H #include "common.h" -#include "system.h" +#include #include "allocator.h" namespace vm { diff --git a/src/heap/heap.cpp b/src/heap/heap.cpp index 0a0778797b..6257e45618 100644 --- a/src/heap/heap.cpp +++ b/src/heap/heap.cpp @@ -9,7 +9,7 @@ details. */ #include -#include "system.h" +#include #include "common.h" #include "arch.h" diff --git a/src/interpret.cpp b/src/interpret.cpp index c025957d48..9812b07091 100644 --- a/src/interpret.cpp +++ b/src/interpret.cpp @@ -9,7 +9,7 @@ details. */ #include "common.h" -#include "system.h" +#include #include "constants.h" #include "machine.h" #include "processor.h" diff --git a/src/lzma-util.h b/src/lzma-util.h index e7fc3093a0..76a249b378 100644 --- a/src/lzma-util.h +++ b/src/lzma-util.h @@ -13,7 +13,7 @@ #include "lzma.h" #include "C/Types.h" -#include "system.h" +#include #include "allocator.h" namespace vm { diff --git a/src/lzma.h b/src/lzma.h index 5e6ba35a82..e0b9dd1e49 100644 --- a/src/lzma.h +++ b/src/lzma.h @@ -11,7 +11,7 @@ #ifndef LZMA_H #define LZMA_H -#include "system.h" +#include #include "allocator.h" namespace vm { diff --git a/src/machine.h b/src/machine.h index a2ebb7c538..ff5741c0a2 100644 --- a/src/machine.h +++ b/src/machine.h @@ -12,7 +12,7 @@ #define MACHINE_H #include "common.h" -#include "system.h" +#include #include #include "finder.h" #include "processor.h" diff --git a/src/main.cpp b/src/main.cpp index ccd8255940..f6ae72eec7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,7 +13,7 @@ #include "string.h" #include "jni.h" -#include "system.h" +#include #include "finder.h" #include diff --git a/src/posix.cpp b/src/posix.cpp index 1f643d93d6..5fcfd4d3ae 100644 --- a/src/posix.cpp +++ b/src/posix.cpp @@ -49,7 +49,7 @@ #include "dirent.h" #include "sched.h" #include "arch.h" -#include "system.h" +#include #include diff --git a/src/process.h b/src/process.h index 04fcf57c7d..71430c02b5 100644 --- a/src/process.h +++ b/src/process.h @@ -12,7 +12,7 @@ #define PROCESS_H #include "common.h" -#include "system.h" +#include #include "machine.h" #include "constants.h" diff --git a/src/processor.h b/src/processor.h index 7ce69458d4..63bf1c1d00 100644 --- a/src/processor.h +++ b/src/processor.h @@ -12,7 +12,7 @@ #define PROCESSOR_H #include "common.h" -#include "system.h" +#include #include #include "bootimage.h" #include "heapwalk.h" diff --git a/src/windows.cpp b/src/windows.cpp index 640117ed2c..be3cfbeeef 100644 --- a/src/windows.cpp +++ b/src/windows.cpp @@ -24,7 +24,7 @@ #undef min #include "arch.h" -#include "system.h" +#include #include #if defined(WINAPI_FAMILY) diff --git a/src/zone.h b/src/zone.h index d0009d77c4..ca467de7d6 100644 --- a/src/zone.h +++ b/src/zone.h @@ -11,7 +11,7 @@ #ifndef ZONE_H #define ZONE_H -#include "system.h" +#include #include "allocator.h" #include diff --git a/unittest/codegen/assembler-test.cpp b/unittest/codegen/assembler-test.cpp index 237b8f7209..f0135d2d64 100644 --- a/unittest/codegen/assembler-test.cpp +++ b/unittest/codegen/assembler-test.cpp @@ -12,7 +12,7 @@ #include "common.h" #include -#include "system.h" +#include #include "target.h" #include From 48691bb50a543f7841c97f661dc1921d0a016162 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Wed, 20 Feb 2013 21:26:34 -0700 Subject: [PATCH 04/11] move stream.h to include, and type-generator to src/tools --- {src => include/avian/util}/stream.h | 0 makefile | 2 +- src/bootimage.cpp | 2 +- src/machine.cpp | 2 +- src/{type-generator.cpp => tools/type-generator/main.cpp} | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename {src => include/avian/util}/stream.h (100%) rename src/{type-generator.cpp => tools/type-generator/main.cpp} (99%) diff --git a/src/stream.h b/include/avian/util/stream.h similarity index 100% rename from src/stream.h rename to include/avian/util/stream.h diff --git a/makefile b/makefile index 38872186bf..30cf4faf70 100755 --- a/makefile +++ b/makefile @@ -1071,7 +1071,7 @@ boot-object = $(build)/boot.o generator-depends := $(wildcard $(src)/*.h) generator-sources = \ - $(src)/type-generator.cpp \ + $(src)/tools/type-generator/main.cpp \ $(src)/$(build-system).cpp \ $(src)/finder.cpp diff --git a/src/bootimage.cpp b/src/bootimage.cpp index 5f33a489b3..8d0fe3d302 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -13,7 +13,7 @@ #include "common.h" #include "machine.h" #include "util.h" -#include "stream.h" +#include #include #include #include "target.h" diff --git a/src/machine.cpp b/src/machine.cpp index 06a86a562c..f093eb6b0b 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -11,7 +11,7 @@ #include "jnienv.h" #include "machine.h" #include "util.h" -#include "stream.h" +#include #include "constants.h" #include "processor.h" #include "arch.h" diff --git a/src/type-generator.cpp b/src/tools/type-generator/main.cpp similarity index 99% rename from src/type-generator.cpp rename to src/tools/type-generator/main.cpp index 290aec459a..e0ba6a0169 100644 --- a/src/type-generator.cpp +++ b/src/tools/type-generator/main.cpp @@ -16,7 +16,7 @@ #include "constants.h" #include "finder.h" -#include "stream.h" +#include #include "assert.h" From 810a0676138c7162c33e05f9fce809a1e72d9586 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Wed, 20 Feb 2013 22:14:18 -0700 Subject: [PATCH 05/11] move java-specific declarations out of common.h --- src/bootimage.h | 1 + src/common.h | 53 +----------------------------------- src/heapwalk.h | 1 + src/java-common.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++ src/machine.h | 1 + 5 files changed, 73 insertions(+), 52 deletions(-) create mode 100644 src/java-common.h diff --git a/src/bootimage.h b/src/bootimage.h index bf96cdaf17..6baf15ec00 100644 --- a/src/bootimage.h +++ b/src/bootimage.h @@ -12,6 +12,7 @@ #define BOOTIMAGE_H #include "common.h" +#include "java-common.h" #include "target.h" #include "machine.h" diff --git a/src/common.h b/src/common.h index b7408e289a..498c96b7be 100644 --- a/src/common.h +++ b/src/common.h @@ -535,57 +535,6 @@ equal(const void* a, unsigned al, const void* b, unsigned bl) } } -class Machine; -class Thread; - -struct Object { }; - -typedef Object* object; - -typedef uint8_t jboolean; -typedef int8_t jbyte; -typedef uint16_t jchar; -typedef int16_t jshort; -typedef int32_t jint; -typedef int64_t jlong; -typedef float jfloat; -typedef double jdouble; - -typedef jint jsize; - -typedef object* jobject; - -typedef jobject jclass; -typedef jobject jthrowable; -typedef jobject jstring; -typedef jobject jweak; - -typedef jobject jarray; -typedef jarray jbooleanArray; -typedef jarray jbyteArray; -typedef jarray jcharArray; -typedef jarray jshortArray; -typedef jarray jintArray; -typedef jarray jlongArray; -typedef jarray jfloatArray; -typedef jarray jdoubleArray; -typedef jarray jobjectArray; - -typedef uintptr_t jfieldID; -typedef uintptr_t jmethodID; - -union jvalue { - jboolean z; - jbyte b; - jchar c; - jshort s; - jint i; - jlong j; - jfloat f; - jdouble d; - jobject l; -}; - } // namespace vm -#endif//COMMON_H +#endif // COMMON_H diff --git a/src/heapwalk.h b/src/heapwalk.h index 25c681d6a3..96c2374745 100644 --- a/src/heapwalk.h +++ b/src/heapwalk.h @@ -12,6 +12,7 @@ #define HEAPWALK_H #include "common.h" +#include "java-common.h" namespace vm { diff --git a/src/java-common.h b/src/java-common.h new file mode 100644 index 0000000000..ba1be9269a --- /dev/null +++ b/src/java-common.h @@ -0,0 +1,69 @@ +/* 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 JAVA_COMMON_H +#define JAVA_COMMON_H + +namespace vm { + +class Machine; +class Thread; + +struct Object { }; + +typedef Object* object; + +typedef uint8_t jboolean; +typedef int8_t jbyte; +typedef uint16_t jchar; +typedef int16_t jshort; +typedef int32_t jint; +typedef int64_t jlong; +typedef float jfloat; +typedef double jdouble; + +typedef jint jsize; + +typedef object* jobject; + +typedef jobject jclass; +typedef jobject jthrowable; +typedef jobject jstring; +typedef jobject jweak; + +typedef jobject jarray; +typedef jarray jbooleanArray; +typedef jarray jbyteArray; +typedef jarray jcharArray; +typedef jarray jshortArray; +typedef jarray jintArray; +typedef jarray jlongArray; +typedef jarray jfloatArray; +typedef jarray jdoubleArray; +typedef jarray jobjectArray; + +typedef uintptr_t jfieldID; +typedef uintptr_t jmethodID; + +union jvalue { + jboolean z; + jbyte b; + jchar c; + jshort s; + jint i; + jlong j; + jfloat f; + jdouble d; + jobject l; +}; + +} // namespace vm + +#endif // JAVA_COMMON_H diff --git a/src/machine.h b/src/machine.h index ff5741c0a2..c39505d20c 100644 --- a/src/machine.h +++ b/src/machine.h @@ -12,6 +12,7 @@ #define MACHINE_H #include "common.h" +#include "java-common.h" #include #include #include "finder.h" From 05b90b65449537a4dc3775001252b8f13a38eeb3 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Thu, 21 Feb 2013 07:51:42 -0700 Subject: [PATCH 06/11] begin splitting up type-generator --- src/tools/type-generator/io.h | 149 ++++++++++++++++++++ src/tools/type-generator/main.cpp | 227 +----------------------------- src/tools/type-generator/sexpr.h | 102 ++++++++++++++ 3 files changed, 258 insertions(+), 220 deletions(-) create mode 100644 src/tools/type-generator/io.h create mode 100644 src/tools/type-generator/sexpr.h diff --git a/src/tools/type-generator/io.h b/src/tools/type-generator/io.h new file mode 100644 index 0000000000..f8c7116636 --- /dev/null +++ b/src/tools/type-generator/io.h @@ -0,0 +1,149 @@ +/* Copyright (c) 2008-2011, 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. */ + +#include "assert.h" + +#ifndef AVIAN_TOOLS_TYPE_GENERATOR_IO_H +#define AVIAN_TOOLS_TYPE_GENERATOR_IO_H + +namespace avian { +namespace tools { +namespace typegenerator { + +class Input { + public: + virtual ~Input() { } + + virtual void dispose() = 0; + + virtual int peek() = 0; + + virtual int read() = 0; + + virtual unsigned line() = 0; + + virtual unsigned column() = 0; + + void skipSpace() { + bool quit = false; + while (not quit) { + int c = peek(); + switch (c) { + case ' ': case '\t': case '\n': + read(); + break; + + default: quit = true; + } + } + } +}; + +class FileInput : public Input { + public: + const char* file; + FILE* stream; + unsigned line_; + unsigned column_; + bool close; + + FileInput(const char* file, FILE* stream = 0, bool close = true): + file(file), stream(stream), line_(1), column_(1), close(close) + { } + + virtual ~FileInput() { + dispose(); + } + + virtual void dispose() { + if (stream and close) { + fclose(stream); + stream = 0; + } + } + + virtual int peek() { + int c = getc(stream); + ungetc(c, stream); + return c; + } + + virtual int read() { + int c = getc(stream); + if (c == '\n') { + ++ line_; + column_ = 1; + } else { + ++ column_; + } + return c; + } + + virtual unsigned line() { + return line_; + } + + virtual unsigned column() { + return column_; + } +}; + +class Output { + public: + virtual ~Output() { } + + virtual void dispose() = 0; + + virtual void write(const char* s) = 0; + + void write(int i) { + static const int Size = 32; + char s[Size]; + int c UNUSED = ::snprintf(s, Size, "%d", i); + assert(c > 0 and c < Size); + write(s); + } +}; + +class FileOutput : public Output { + public: + const char* file; + FILE* stream; + bool close; + + FileOutput(const char* file, FILE* stream = 0, bool close = true): + file(file), stream(stream), close(close) + { } + + virtual ~FileOutput() { + dispose(); + } + + virtual void dispose() { + if (stream and close) { + fclose(stream); + stream = 0; + } + } + + virtual void write(const char* s) { + fputs(s, stream); + } + + const char* filename() { + return file; + } +}; + +} // namespace typegenerator +} // namespace tools +} // namespace avian + +#endif // AVIAN_TOOLS_TYPE_GENERATOR_IO_H diff --git a/src/tools/type-generator/main.cpp b/src/tools/type-generator/main.cpp index e0ba6a0169..9186bc68ae 100644 --- a/src/tools/type-generator/main.cpp +++ b/src/tools/type-generator/main.cpp @@ -18,6 +18,9 @@ #include "finder.h" #include +#include "io.h" +#include "sexpr.h" + #include "assert.h" #define UNREACHABLE abort() @@ -29,6 +32,7 @@ inline void operator delete(void*) { abort(); } extern "C" void __cxa_pure_virtual(void) { abort(); } using namespace vm; +using namespace avian::tools::typegenerator; namespace { @@ -55,15 +59,6 @@ pad(unsigned n) return (extra ? n + BytesPerWord - extra : n); } -template -T* -allocate() -{ - T* t = static_cast(malloc(sizeof(T))); - assert(t); - return t; -} - inline bool equal(const char* a, const char* b) { @@ -88,214 +83,6 @@ take(unsigned n, const char* c) return r; } -class Input { - public: - virtual ~Input() { } - - virtual void dispose() = 0; - - virtual int peek() = 0; - - virtual int read() = 0; - - virtual unsigned line() = 0; - - virtual unsigned column() = 0; - - void skipSpace() { - bool quit = false; - while (not quit) { - int c = peek(); - switch (c) { - case ' ': case '\t': case '\n': - read(); - break; - - default: quit = true; - } - } - } -}; - -class FileInput : public Input { - public: - const char* file; - FILE* stream; - unsigned line_; - unsigned column_; - bool close; - - FileInput(const char* file, FILE* stream = 0, bool close = true): - file(file), stream(stream), line_(1), column_(1), close(close) - { } - - virtual ~FileInput() { - dispose(); - } - - virtual void dispose() { - if (stream and close) { - fclose(stream); - stream = 0; - } - } - - virtual int peek() { - int c = getc(stream); - ungetc(c, stream); - return c; - } - - virtual int read() { - int c = getc(stream); - if (c == '\n') { - ++ line_; - column_ = 1; - } else { - ++ column_; - } - return c; - } - - virtual unsigned line() { - return line_; - } - - virtual unsigned column() { - return column_; - } -}; - -class Output { - public: - virtual ~Output() { } - - virtual void dispose() = 0; - - virtual void write(const char* s) = 0; - - void write(int i) { - static const int Size = 32; - char s[Size]; - int c UNUSED = ::snprintf(s, Size, "%d", i); - assert(c > 0 and c < Size); - write(s); - } -}; - -class FileOutput : public Output { - public: - const char* file; - FILE* stream; - bool close; - - FileOutput(const char* file, FILE* stream = 0, bool close = true): - file(file), stream(stream), close(close) - { } - - virtual ~FileOutput() { - dispose(); - } - - virtual void dispose() { - if (stream and close) { - fclose(stream); - stream = 0; - } - } - - virtual void write(const char* s) { - fputs(s, stream); - } - - const char* filename() { - return file; - } -}; - -class Object { - public: - typedef enum { - Scalar, - Array, - Method, - Type, - Pair, - Number, - Character, - String, - Eos - } ObjectType; - - ObjectType type; -}; - -class Pair : public Object { - public: - Object* car; - Object* cdr; - - static Pair* make(Object* car, Object* cdr) { - Pair* o = allocate(); - o->type = Object::Pair; - o->car = car; - o->cdr = cdr; - return o; - } -}; - -Object* -cons(Object* car, Object* cdr) -{ - return Pair::make(car, cdr); -} - -Object*& -car(Object* o) -{ - assert(o->type == Object::Pair); - return static_cast(o)->car; -} - -void -setCar(Object* o, Object* v) -{ - assert(o->type == Object::Pair); - static_cast(o)->car = v; -} - -Object*& -cdr(Object* o) -{ - assert(o->type == Object::Pair); - return static_cast(o)->cdr; -} - -void -setCdr(Object* o, Object* v) -{ - assert(o->type == Object::Pair); - static_cast(o)->cdr = v; -} - -class List { - public: - Object* first; - Object* last; - - List(): first(0), last(0) { } - - void append(Object* o) { - Object* p = cons(o, 0); - if (last) { - setCdr(last, p); - last = p; - } else { - first = last = p; - } - } -}; - class Scalar : public Object { public: Object* owner; @@ -2176,9 +1963,9 @@ main(int ac, char** av) fprintf(stderr, "unable to open %s: %s\n", av[2], strerror(errno)); return -1; } - local::FileInput in(0, inStream, false); + FileInput in(0, inStream, false); - local::Object* declarations = local::parse(finder, &in); + Object* declarations = local::parse(finder, &in); finder->dispose(); system->dispose(); @@ -2188,7 +1975,7 @@ main(int ac, char** av) fprintf(stderr, "unable to open %s: %s\n", av[3], strerror(errno)); return -1; } - local::FileOutput out(0, outStream, false); + FileOutput out(0, outStream, false); if (local::equal(av[4], "enums")) { local::writeEnums(&out, declarations); diff --git a/src/tools/type-generator/sexpr.h b/src/tools/type-generator/sexpr.h new file mode 100644 index 0000000000..cc0b7dc750 --- /dev/null +++ b/src/tools/type-generator/sexpr.h @@ -0,0 +1,102 @@ +/* Copyright (c) 2008-2011, 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_TOOLS_TYPE_GENERATOR_SEXPR_H +#define AVIAN_TOOLS_TYPE_GENERATOR_SEXPR_H + +namespace avian { +namespace tools { +namespace typegenerator { + +template +inline T* allocate() { + T* t = static_cast(malloc(sizeof(T))); + assert(t); + return t; +} + +class Object { + public: + typedef enum { + Scalar, + Array, + Method, + Type, + Pair, + Number, + Character, + String, + Eos + } ObjectType; + + ObjectType type; +}; + +class Pair : public Object { + public: + Object* car; + Object* cdr; + + static Pair* make(Object* car, Object* cdr) { + Pair* o = allocate(); + o->type = Object::Pair; + o->car = car; + o->cdr = cdr; + return o; + } +}; + +inline Object* cons(Object* car, Object* cdr) { + return Pair::make(car, cdr); +} + +inline Object*& car(Object* o) { + assert(o->type == Object::Pair); + return static_cast(o)->car; +} + +inline void setCar(Object* o, Object* v) { + assert(o->type == Object::Pair); + static_cast(o)->car = v; +} + +inline Object*& cdr(Object* o) { + assert(o->type == Object::Pair); + return static_cast(o)->cdr; +} + +inline void setCdr(Object* o, Object* v) { + assert(o->type == Object::Pair); + static_cast(o)->cdr = v; +} + +class List { + public: + Object* first; + Object* last; + + List(): first(0), last(0) { } + + void append(Object* o) { + Object* p = cons(o, 0); + if (last) { + setCdr(last, p); + last = p; + } else { + first = last = p; + } + } +}; + +} // namespace typegenerator +} // namespace tools +} // namespace avian + +#endif // AVIAN_TOOLS_TYPE_GENERATOR_SEXPR_H From 186a3993b59f4593fa1368590c37ecbd8db07011 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Thu, 21 Feb 2013 13:11:29 -0700 Subject: [PATCH 07/11] move system implementations to src/vm/system/ --- makefile | 4 ++-- src/{ => vm/system}/posix.cpp | 0 src/{ => vm/system}/windows.cpp | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/{ => vm/system}/posix.cpp (100%) rename src/{ => vm/system}/windows.cpp (100%) diff --git a/makefile b/makefile index 30cf4faf70..ac70fe3f1b 100755 --- a/makefile +++ b/makefile @@ -942,7 +942,7 @@ generated-code = \ vm-depends := $(generated-code) $(wildcard $(src)/*.h) $(wildcard $(src)/codegen/*.h) $(wildcard $(src)/codegen/compiler/*.h) vm-sources = \ - $(src)/$(system).cpp \ + $(src)/vm/system/$(system).cpp \ $(src)/finder.cpp \ $(src)/machine.cpp \ $(src)/util.cpp \ @@ -1072,7 +1072,7 @@ boot-object = $(build)/boot.o generator-depends := $(wildcard $(src)/*.h) generator-sources = \ $(src)/tools/type-generator/main.cpp \ - $(src)/$(build-system).cpp \ + $(src)/vm/system/$(build-system).cpp \ $(src)/finder.cpp ifneq ($(lzma),) diff --git a/src/posix.cpp b/src/vm/system/posix.cpp similarity index 100% rename from src/posix.cpp rename to src/vm/system/posix.cpp diff --git a/src/windows.cpp b/src/vm/system/windows.cpp similarity index 100% rename from src/windows.cpp rename to src/vm/system/windows.cpp From 32044637cd220b7c682b4bcbed802139da73b535 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Thu, 21 Feb 2013 13:15:45 -0700 Subject: [PATCH 08/11] move bootimage generator to src/tools --- makefile | 2 +- src/{bootimage.cpp => tools/bootimage-generator/main.cpp} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/{bootimage.cpp => tools/bootimage-generator/main.cpp} (100%) diff --git a/makefile b/makefile index ac70fe3f1b..7524a163c1 100755 --- a/makefile +++ b/makefile @@ -1036,7 +1036,7 @@ ifeq ($(continuations),true) asmflags += -DAVIAN_CONTINUATIONS endif -bootimage-generator-sources = $(src)/bootimage.cpp +bootimage-generator-sources = $(src)/tools/bootimage-generator/main.cpp ifneq ($(lzma),) bootimage-generator-sources += $(src)/lzma-encode.cpp endif diff --git a/src/bootimage.cpp b/src/tools/bootimage-generator/main.cpp similarity index 100% rename from src/bootimage.cpp rename to src/tools/bootimage-generator/main.cpp From ab9f9550cf28060b7e78472b20911c0c867327fd Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Thu, 21 Feb 2013 16:18:20 -0700 Subject: [PATCH 09/11] move tokenizer.h to include/avian/util/string.h, merge in the String declaration from object-writer/tools.h --- include/avian/tools/object-writer/tools.h | 21 +++------ .../avian/util/string.h | 43 ++++++++++++------- makefile | 6 ++- src/classpath-common.h | 9 ++-- src/finder.cpp | 18 ++++---- src/tools/object-writer/elf.cpp | 1 + src/tools/object-writer/mach-o.cpp | 1 + src/tools/object-writer/pe.cpp | 1 + src/tools/object-writer/tools.cpp | 6 +-- 9 files changed, 58 insertions(+), 48 deletions(-) rename src/tokenizer.h => include/avian/util/string.h (56%) diff --git a/include/avian/tools/object-writer/tools.h b/include/avian/tools/object-writer/tools.h index 46bcd691e8..411dfaec9e 100644 --- a/include/avian/tools/object-writer/tools.h +++ b/include/avian/tools/object-writer/tools.h @@ -12,6 +12,9 @@ #define AVIAN_TOOLS_H_ #include + +#include + #include "environment.h" namespace avian { @@ -38,24 +41,12 @@ public: virtual void write(uint8_t byte); }; -class String { -public: - const char* text; - size_t length; - - String(const char* text); - - inline String(const char* text, size_t length): - text(text), - length(length) {} -}; - class SymbolInfo { public: unsigned addr; - String name; + util::String name; - inline SymbolInfo(uint64_t addr, const String& name): + inline SymbolInfo(uint64_t addr, const util::String& name): addr(addr), name(name) {} @@ -78,7 +69,7 @@ public: class StringTable : public Buffer { public: - unsigned add(String str); + unsigned add(util::String str); }; template diff --git a/src/tokenizer.h b/include/avian/util/string.h similarity index 56% rename from src/tokenizer.h rename to include/avian/util/string.h index 5699227c74..b0b338abfa 100644 --- a/src/tokenizer.h +++ b/include/avian/util/string.h @@ -8,27 +8,37 @@ There is NO WARRANTY for this software. See license.txt for details. */ -#ifndef TOKENIZER_H -#define TOKENIZER_H +#ifndef AVIAN_UTIL_STRING_H +#define AVIAN_UTIL_STRING_H -namespace vm { +#include + +namespace avian { +namespace util { + +class String { +public: + const char* text; + size_t length; + + String(const char* text): + text(text), + length(strlen(text)) {} + + inline String(const char* text, size_t length): + text(text), + length(length) {} +}; class Tokenizer { public: - class Token { - public: - Token(const char* s, unsigned length): s(s), length(length) { } - - const char* s; - unsigned length; - }; Tokenizer(const char* s, char delimiter): s(s), limit(0), delimiter(delimiter) { } - Tokenizer(const char* s, unsigned length, char delimiter): - s(s), limit(s + length), delimiter(delimiter) + Tokenizer(String str, char delimiter): + s(str.text), limit(str.text + str.length), delimiter(delimiter) { } bool hasMore() { @@ -36,10 +46,10 @@ class Tokenizer { return s != limit and *s != 0; } - Token next() { + String next() { const char* p = s; while (s != limit and *s and *s != delimiter) ++s; - return Token(p, s - p); + return String(p, s - p); } const char* s; @@ -47,6 +57,7 @@ class Tokenizer { char delimiter; }; -} // namespace +} // namespace util +} // namespace avain -#endif//TOKENIZER_H +#endif//AVIAN_UTIL_STRING_H diff --git a/makefile b/makefile index 7524a163c1..1251933442 100755 --- a/makefile +++ b/makefile @@ -939,7 +939,11 @@ generated-code = \ $(build)/type-name-initializations.cpp \ $(build)/type-maps.cpp -vm-depends := $(generated-code) $(wildcard $(src)/*.h) $(wildcard $(src)/codegen/*.h) $(wildcard $(src)/codegen/compiler/*.h) +vm-depends := $(generated-code) \ + $(wildcard $(src)/*.h) \ + $(wildcard $(src)/codegen/*.h) \ + $(wildcard $(src)/codegen/compiler/*.h) \ + $(shell find include -name '*.h') vm-sources = \ $(src)/vm/system/$(system).cpp \ diff --git a/src/classpath-common.h b/src/classpath-common.h index 6298d47695..92ae23c165 100644 --- a/src/classpath-common.h +++ b/src/classpath-common.h @@ -11,10 +11,11 @@ #ifndef CLASSPATH_COMMON_H #define CLASSPATH_COMMON_H -#include "tokenizer.h" - +#include #include +using namespace avian::util; + namespace vm { object @@ -217,13 +218,13 @@ loadLibrary(Thread* t, const char* path, const char* name, bool mapName, for (Tokenizer tokenizer(path, t->m->system->pathSeparator()); tokenizer.hasMore();) { - Tokenizer::Token token(tokenizer.next()); + String token(tokenizer.next()); unsigned fullNameLength = token.length + 1 + nameLength; THREAD_RUNTIME_ARRAY(t, char, fullName, fullNameLength + 1); snprintf(RUNTIME_ARRAY_BODY(fullName), fullNameLength + 1, - "%.*s/%s", token.length, token.s, name); + "%.*s/%s", token.length, token.text, name); lib = loadLibrary(t, RUNTIME_ARRAY_BODY(fullName)); if (lib) break; diff --git a/src/finder.cpp b/src/finder.cpp index 879796075b..a3fa539910 100644 --- a/src/finder.cpp +++ b/src/finder.cpp @@ -8,15 +8,17 @@ There is NO WARRANTY for this software. See license.txt for details. */ -#include "zlib-custom.h" #include -#include "tokenizer.h" +#include +#include + +#include "zlib-custom.h" #include "finder.h" #include "lzma.h" -#include using namespace vm; +using namespace avian::util; namespace { @@ -658,12 +660,12 @@ addTokens(System* s, Element** first, Element** last, Allocator* allocator, const char* jarName, unsigned jarNameBase, const char* tokens, unsigned tokensLength, const char* bootLibrary) { - for (Tokenizer t(tokens, tokensLength, ' '); t.hasMore();) { - Tokenizer::Token token(t.next()); + for (Tokenizer t(String(tokens, tokensLength), ' '); t.hasMore();) { + String token(t.next()); RUNTIME_ARRAY(char, n, jarNameBase + token.length + 1); memcpy(RUNTIME_ARRAY_BODY(n), jarName, jarNameBase); - memcpy(RUNTIME_ARRAY_BODY(n) + jarNameBase, token.s, token.length); + memcpy(RUNTIME_ARRAY_BODY(n) + jarNameBase, token.text, token.length); RUNTIME_ARRAY_BODY(n)[jarNameBase + token.length] = 0; add(s, first, last, allocator, RUNTIME_ARRAY_BODY(n), @@ -813,9 +815,9 @@ parsePath(System* s, Allocator* allocator, const char* path, Element* first = 0; Element* last = 0; for (Tokenizer t(path, s->pathSeparator()); t.hasMore();) { - Tokenizer::Token token(t.next()); + String token(t.next()); - add(s, &first, &last, allocator, token.s, token.length, bootLibrary); + add(s, &first, &last, allocator, token.text, token.length, bootLibrary); } return first; diff --git a/src/tools/object-writer/elf.cpp b/src/tools/object-writer/elf.cpp index bf220e1e04..555d6fd9ca 100644 --- a/src/tools/object-writer/elf.cpp +++ b/src/tools/object-writer/elf.cpp @@ -72,6 +72,7 @@ namespace { using namespace avian::tools; +using namespace avian::util; template struct ElfTypes { diff --git a/src/tools/object-writer/mach-o.cpp b/src/tools/object-writer/mach-o.cpp index fac134f272..03066fc247 100644 --- a/src/tools/object-writer/mach-o.cpp +++ b/src/tools/object-writer/mach-o.cpp @@ -43,6 +43,7 @@ namespace { using namespace avian::tools; +using namespace avian::util; typedef int cpu_type_t; typedef int cpu_subtype_t; diff --git a/src/tools/object-writer/pe.cpp b/src/tools/object-writer/pe.cpp index 0fdc4a16e0..b96124582b 100644 --- a/src/tools/object-writer/pe.cpp +++ b/src/tools/object-writer/pe.cpp @@ -86,6 +86,7 @@ pad(unsigned n) } using namespace avian::tools; +using namespace avian::util; template class WindowsPlatform : public Platform { diff --git a/src/tools/object-writer/tools.cpp b/src/tools/object-writer/tools.cpp index 49726245c7..4284778550 100644 --- a/src/tools/object-writer/tools.cpp +++ b/src/tools/object-writer/tools.cpp @@ -15,14 +15,12 @@ #include +using namespace avian::util; + namespace avian { namespace tools { -String::String(const char* text): - text(text), - length(strlen(text)) {} - Buffer::Buffer(): capacity(100), length(0), From 68d28eab2e62697f568013c4cb352a6a1cc54f4c Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Thu, 21 Feb 2013 16:29:19 -0700 Subject: [PATCH 10/11] insert RUNTIME_ARRAY_BODY to fix windows.cpp --- src/vm/system/windows.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/vm/system/windows.cpp b/src/vm/system/windows.cpp index be3cfbeeef..45b03f6dfe 100644 --- a/src/vm/system/windows.cpp +++ b/src/vm/system/windows.cpp @@ -806,12 +806,12 @@ class MySystem: public System { Status status = 1; size_t nameLen = strlen(name) * 2; RUNTIME_ARRAY(wchar_t, wideName, nameLen + 1); - MultiByteToWideChar(CP_UTF8, 0, name, -1, wideName, nameLen + 1); + MultiByteToWideChar(CP_UTF8, 0, name, -1, RUNTIME_ARRAY_BODY(wideName), nameLen + 1); #if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) - HANDLE file = CreateFileW(wideName, FILE_READ_DATA, FILE_SHARE_READ, 0, + HANDLE file = CreateFileW(RUNTIME_ARRAY_BODY(wideName), FILE_READ_DATA, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); #else - HANDLE file = CreateFile2(wideName, GENERIC_READ, FILE_SHARE_READ, + HANDLE file = CreateFile2(RUNTIME_ARRAY_BODY(wideName), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, 0); #endif if (file != INVALID_HANDLE_VALUE) { @@ -883,10 +883,10 @@ class MySystem: public System { virtual FileType stat(const char* name, unsigned* length) { size_t nameLen = strlen(name) * 2; RUNTIME_ARRAY(wchar_t, wideName, nameLen + 1); - MultiByteToWideChar(CP_UTF8, 0, name, -1, wideName, nameLen + 1); + MultiByteToWideChar(CP_UTF8, 0, name, -1, RUNTIME_ARRAY_BODY(wideName), nameLen + 1); WIN32_FILE_ATTRIBUTE_DATA data; if (GetFileAttributesExW - (wideName, GetFileExInfoStandard, &data)) + (RUNTIME_ARRAY_BODY(wideName), GetFileExInfoStandard, &data)) { if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { return TypeDirectory; @@ -935,12 +935,12 @@ class MySystem: public System { if (name) { size_t nameLen = nameLength * 2; RUNTIME_ARRAY(wchar_t, wideName, nameLen + 1); - MultiByteToWideChar(CP_UTF8, 0, name, -1, wideName, nameLen + 1); + MultiByteToWideChar(CP_UTF8, 0, name, -1, RUNTIME_ARRAY_BODY(wideName), nameLen + 1); #if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) - handle = LoadLibraryW(wideName); + handle = LoadLibraryW(RUNTIME_ARRAY_BODY(wideName)); #else - handle = LoadPackagedLibrary(wideName, 0); + handle = LoadPackagedLibrary(RUNTIME_ARRAY_BODY(wideName), 0); #endif } else { #if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) From a9e2984aaf60c16981d3124ed2179796e3670d65 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Thu, 21 Feb 2013 16:51:31 -0700 Subject: [PATCH 11/11] fix arm and powerpc build --- src/arm.h | 12 ++++++------ src/codegen/arm/assembler.cpp | 8 -------- src/codegen/powerpc/assembler.cpp | 8 -------- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/arm.h b/src/arm.h index 5b8cdab3db..47c79ff099 100644 --- a/src/arm.h +++ b/src/arm.h @@ -206,7 +206,7 @@ dynamicCall(void* function, uintptr_t* arguments, uint8_t* argumentTypes, ++ stackIndex; } - memcpy(stack + stackIndex, arguments + ai, 8); + memcpy(RUNTIME_ARRAY_BODY(stack) + stackIndex, arguments + ai, 8); stackIndex += 8 / BytesPerWord; } ai += 8 / BytesPerWord; @@ -219,7 +219,7 @@ dynamicCall(void* function, uintptr_t* arguments, uint8_t* argumentTypes, } else if (vfpIndex < VfpCount) { vfpTable[vfpIndex++] = arguments[ai]; } else { - stack[stackIndex++] = arguments[ai]; + RUNTIME_ARRAY_BODY(stack)[stackIndex++] = arguments[ai]; } ++ ai; break; @@ -231,7 +231,7 @@ dynamicCall(void* function, uintptr_t* arguments, uint8_t* argumentTypes, and gprIndex + Alignment == GprCount) { gprTable[gprIndex++] = arguments[ai]; - stack[stackIndex++] = arguments[ai + 1]; + RUNTIME_ARRAY_BODY(stack)[stackIndex++] = arguments[ai + 1]; } else { if (gprIndex % Alignment) { ++gprIndex; @@ -246,7 +246,7 @@ dynamicCall(void* function, uintptr_t* arguments, uint8_t* argumentTypes, ++stackIndex; } - memcpy(stack + stackIndex, arguments + ai, 8); + memcpy(RUNTIME_ARRAY_BODY(stack) + stackIndex, arguments + ai, 8); stackIndex += 8 / BytesPerWord; } ai += 8 / BytesPerWord; @@ -256,7 +256,7 @@ dynamicCall(void* function, uintptr_t* arguments, uint8_t* argumentTypes, if (gprIndex < GprCount) { gprTable[gprIndex++] = arguments[ai]; } else { - stack[stackIndex++] = arguments[ai]; + RUNTIME_ARRAY_BODY(stack)[stackIndex++] = arguments[ai]; } ++ ai; } break; @@ -274,7 +274,7 @@ dynamicCall(void* function, uintptr_t* arguments, uint8_t* argumentTypes, unsigned stackSize = stackIndex*BytesPerWord + ((stackIndex & 1) << 2); return vmNativeCall - (function, stackSize, stack, stackIndex * BytesPerWord, + (function, stackSize, RUNTIME_ARRAY_BODY(stack), stackIndex * BytesPerWord, (gprIndex ? gprTable : 0), (vfpIndex ? vfpTable : 0), returnType); } diff --git a/src/codegen/arm/assembler.cpp b/src/codegen/arm/assembler.cpp index 56bd71938d..26e57a5cb5 100644 --- a/src/codegen/arm/assembler.cpp +++ b/src/codegen/arm/assembler.cpp @@ -2236,14 +2236,6 @@ class MyArchitecture: public Assembler::Architecture { virtual int framePointerOffset() { return 0; } - - virtual lir::BinaryOperation hasBinaryIntrinsic(Thread*, object) { - return lir::NoBinaryOperation; - } - - virtual lir::TernaryOperation hasTernaryIntrinsic(Thread*, object) { - return lir::NoTernaryOperation; - } virtual bool alwaysCondensed(lir::BinaryOperation) { return false; diff --git a/src/codegen/powerpc/assembler.cpp b/src/codegen/powerpc/assembler.cpp index 1ef611be1a..5086d48403 100644 --- a/src/codegen/powerpc/assembler.cpp +++ b/src/codegen/powerpc/assembler.cpp @@ -2240,14 +2240,6 @@ class MyArchitecture: public Assembler::Architecture { virtual int framePointerOffset() { return 0; } - - virtual lir::BinaryOperation hasBinaryIntrinsic(Thread*, object) { - return lir::NoBinaryOperation; - } - - virtual lir::TernaryOperation hasTernaryIntrinsic(Thread*, object) { - return lir::NoTernaryOperation; - } virtual bool alwaysCondensed(lir::BinaryOperation) { return false;