From a78959a480a7ae5c862d358fcb1942f32485242e Mon Sep 17 00:00:00 2001 From: Alexey Pelykh Date: Mon, 28 Jan 2013 20:51:35 +0200 Subject: [PATCH] Replaced TODO comments with messages ; More correct AVIAN_AOT_ONLY usage --- classpath/java-lang.cpp | 15 +++++------ makefile | 1 + src/arm.cpp | 26 ++++++++++--------- src/arm.masm | 12 +++++++++ src/compile.cpp | 7 +++++- src/system.h | 4 --- src/windows.cpp | 55 ++++++++++++++++++++++------------------- src/x86.masm | 2 ++ 8 files changed, 72 insertions(+), 50 deletions(-) diff --git a/classpath/java-lang.cpp b/classpath/java-lang.cpp index 0414216194..9d2562e265 100644 --- a/classpath/java-lang.cpp +++ b/classpath/java-lang.cpp @@ -80,8 +80,8 @@ namespace { snprintf(errStr, 9, "%d", (int) err); return errStr; - //TODO: - // The better way to do this, if I could figure out how to convert LPTSTR to char* + #pragma message("TODO") + // The better way to do this, if I could figure out how to convert LPTSTR to char* //char* errStr; //LPTSTR s; //if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | @@ -390,7 +390,7 @@ Locale getLocale() { return Locale(lang, reg); #else - //TODO: CultureInfo.CurrentCulture + #pragma message("TODO: CultureInfo.CurrentCulture") return Locale("en", "US"); #endif } @@ -596,8 +596,7 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name, GetTempPath(MAX_PATH, buffer); r = e->NewStringUTF(buffer); # else - //TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ - //Windows.Storage.ApplicationData.Current.TemporaryFolder + #pragma message("TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ Windows.Storage.ApplicationData.Current.TemporaryFolder") r = 0; # endif } else if (strcmp(chars, "user.dir") == 0) { @@ -606,8 +605,7 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name, GetCurrentDirectory(MAX_PATH, buffer); r = e->NewStringUTF(buffer); # else - //TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ - //Windows.ApplicationModel.Package.Current.InstalledLocation + #pragma message("TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ Windows.ApplicationModel.Package.Current.InstalledLocation") r = 0; # endif } else if (strcmp(chars, "user.home") == 0) { @@ -621,8 +619,7 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name, r = 0; } # else - //TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ - //Windows.Storage.KnownFolders.DocumentsLibrary; + #pragma message("TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ Windows.Storage.KnownFolders.DocumentsLibrary") r = 0; # endif # else diff --git a/makefile b/makefile index 066b4327c3..5f28ef4b3a 100755 --- a/makefile +++ b/makefile @@ -642,6 +642,7 @@ ifeq ($(platform),wp8) use-lto = false supports_avian_executable = false process = compile + aot_only = true ifneq ($(process),compile) options := -$(process) endif diff --git a/src/arm.cpp b/src/arm.cpp index ae657e30d5..1d4dbc8dd1 100644 --- a/src/arm.cpp +++ b/src/arm.cpp @@ -18,7 +18,7 @@ using namespace vm; -namespace { +namespace local { namespace isa { // SYSTEM REGISTERS @@ -252,7 +252,7 @@ class MyBlock: public Assembler::Block { this->start = start; this->next = static_cast(next); - ::resolve(this); + local::resolve(this); return start + size + padding(this, size); } @@ -2150,7 +2150,7 @@ class MyArchitecture: public Assembler::Architecture { } virtual unsigned argumentFootprint(unsigned footprint) { - return ::argumentFootprint(footprint); + return local::argumentFootprint(footprint); } virtual bool argumentAlignment() { @@ -2239,7 +2239,7 @@ class MyArchitecture: public Assembler::Architecture { unsigned targetParameterFootprint, void** ip, void** stack) { - ::nextFrame(&con, static_cast(start), size, footprint, link, + local::nextFrame(&con, static_cast(start), size, footprint, link, mostRecent, targetParameterFootprint, ip, stack); } @@ -2550,11 +2550,12 @@ class MyAssembler: public Assembler { } virtual void pushFrame(unsigned argumentCount, ...) { - struct { + struct Argument { unsigned size; OperandType type; Operand* operand; - } arguments[argumentCount]; + }; + Argument* arguments = new Argument[argumentCount]; va_list a; va_start(a, argumentCount); unsigned footprint = 0; @@ -2589,6 +2590,9 @@ class MyAssembler: public Assembler { offset += ceiling(arguments[i].size, TargetBytesPerWord); } } + + delete[] arguments; + arguments = 0; } virtual void allocateFrame(unsigned footprint) { @@ -2798,7 +2802,7 @@ class MyAssembler: public Assembler { bool jump = needJump(b); if (jump) { write4 - (dst + dstOffset, ::b((poolSize + TargetBytesPerWord - 8) >> 2)); + (dst + dstOffset, isa::b((poolSize + TargetBytesPerWord - 8) >> 2)); } dstOffset += poolSize + (jump ? TargetBytesPerWord : 0); @@ -2832,7 +2836,7 @@ class MyAssembler: public Assembler { } virtual Promise* offset(bool forTrace) { - return ::offset(&con, forTrace); + return local::offset(&con, forTrace); } virtual Block* endBlock(bool startNew) { @@ -2903,15 +2907,15 @@ namespace vm { Assembler::Architecture* makeArchitecture(System* system, bool) { - return new (allocate(system, sizeof(MyArchitecture))) MyArchitecture(system); + return new (allocate(system, sizeof(local::MyArchitecture))) local::MyArchitecture(system); } Assembler* makeAssembler(System* system, Allocator* allocator, Zone* zone, Assembler::Architecture* architecture) { - return new(zone) MyAssembler(system, allocator, zone, - static_cast(architecture)); + return new(zone) local::MyAssembler(system, allocator, zone, + static_cast(architecture)); } } // namespace vm diff --git a/src/arm.masm b/src/arm.masm index 8fc09eb875..2af5048ec7 100644 --- a/src/arm.masm +++ b/src/arm.masm @@ -1,3 +1,15 @@ +; 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. +; +; ORIGIN: https://github.com/gkvas/avian/tree/wince + AREA text, CODE, ARM EXPORT vmNativeCall [FUNC] diff --git a/src/compile.cpp b/src/compile.cpp index 6989d6446d..7fa51817c7 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -7389,8 +7389,9 @@ finish(MyThread* t, FixedAllocator* allocator, Context* context) { trap(); } - +#if !defined(AVIAN_AOT_ONLY) syncInstructionCache(start, codeSize); +#endif } void @@ -9152,7 +9153,9 @@ class MyProcessor: public Processor { virtual void dispose() { if (codeAllocator.base) { +#if !defined(AVIAN_AOT_ONLY) s->freeExecutable(codeAllocator.base, codeAllocator.capacity); +#endif } compilationHandlers->dispose(allocator); @@ -9313,11 +9316,13 @@ class MyProcessor: public Processor { } virtual void boot(Thread* t, BootImage* image, uint8_t* code) { +#if !defined(AVIAN_AOT_ONLY) if (codeAllocator.base == 0) { codeAllocator.base = static_cast (s->tryAllocateExecutable(ExecutableAreaSizeInBytes)); codeAllocator.capacity = ExecutableAreaSizeInBytes; } +#endif if (image and code) { local::boot(static_cast(t), image, code); diff --git a/src/system.h b/src/system.h index ee80d2a7cb..ef69317f0b 100644 --- a/src/system.h +++ b/src/system.h @@ -97,13 +97,11 @@ class System { virtual void disposeAll() = 0; }; -#if !defined(AVIAN_AOT_ONLY) class SignalHandler { public: virtual bool handleSignal(void** ip, void** frame, void** stack, void** thread) = 0; }; -#endif class MonitorResource { public: @@ -132,12 +130,10 @@ class System { virtual Status make(Mutex**) = 0; virtual Status make(Monitor**) = 0; virtual Status make(Local**) = 0; -#if !defined(AVIAN_AOT_ONLY) virtual Status handleSegFault(SignalHandler* handler) = 0; virtual Status handleDivideByZero(SignalHandler* handler) = 0; virtual Status visit(Thread* thread, Thread* target, ThreadVisitor* visitor) = 0; -#endif virtual uint64_t call(void* function, uintptr_t* arguments, uint8_t* types, unsigned count, unsigned size, unsigned returnType) = 0; diff --git a/src/windows.cpp b/src/windows.cpp index f6b9627254..8c7512eab1 100644 --- a/src/windows.cpp +++ b/src/windows.cpp @@ -114,17 +114,15 @@ class MutexResource { HANDLE m; }; -#if !defined(AVIAN_AOT_ONLY) const unsigned SegFaultIndex = 0; const unsigned DivideByZeroIndex = 1; const unsigned HandlerCount = 2; -#endif class MySystem; MySystem* system; -#if !defined(AVIAN_AOT_ONLY) +#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) LONG CALLBACK handleException(LPEXCEPTION_POINTERS e); #endif @@ -628,7 +626,7 @@ class MySystem: public System { }; MySystem(const char* crashDumpDirectory): -#if !defined(AVIAN_AOT_ONLY) +#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) oldHandler(0), #endif crashDumpDirectory(crashDumpDirectory) @@ -636,14 +634,12 @@ class MySystem: public System { expect(this, system == 0); system = this; -#if !defined(AVIAN_AOT_ONLY) memset(handlers, 0, sizeof(handlers)); -#endif mutex = CreateMutex(0, false, 0); assert(this, mutex); } -#if !defined(AVIAN_AOT_ONLY) + bool findHandler() { for (unsigned i = 0; i < HandlerCount; ++i) { if (handlers[i]) return true; @@ -651,31 +647,38 @@ class MySystem: public System { return false; } - //TODO: http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.application.unhandledexception(v=vs.105).aspx int registerHandler(System::SignalHandler* handler, int index) { if (handler) { handlers[index] = handler; - + +#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) if (oldHandler == 0) { -#ifdef ARCH_x86_32 +# ifdef ARCH_x86_32 oldHandler = SetUnhandledExceptionFilter(handleException); -#elif defined ARCH_x86_64 +# elif defined ARCH_x86_64 AddVectoredExceptionHandler(1, handleException); oldHandler = reinterpret_cast(1); -#endif +# endif } +#else + #pragma message("TODO: http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.application.unhandledexception(v=vs.105).aspx") +#endif return 0; } else if (handlers[index]) { handlers[index] = 0; if (not findHandler()) { -#ifdef ARCH_x86_32 +#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +# ifdef ARCH_x86_32 SetUnhandledExceptionFilter(oldHandler); oldHandler = 0; -#elif defined ARCH_x86_64 +# elif defined ARCH_x86_64 // do nothing, handlers are never "unregistered" anyway -#endif +# endif +#else + #pragma message("TODO: http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.application.unhandledexception(v=vs.105).aspx") +#endif } return 0; @@ -683,7 +686,7 @@ class MySystem: public System { return 1; } } -#endif + virtual void* tryAllocate(unsigned sizeInBytes) { return malloc(sizeInBytes); } @@ -742,7 +745,6 @@ class MySystem: public System { return 0; } -#if !defined(AVIAN_AOT_ONLY) virtual Status handleSegFault(SignalHandler* handler) { return registerHandler(handler, SegFaultIndex); } @@ -754,6 +756,7 @@ class MySystem: public System { virtual Status visit(System::Thread* st UNUSED, System::Thread* sTarget, ThreadVisitor* visitor) { +#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) assert(this, st != sTarget); Thread* target = static_cast(sTarget); @@ -769,15 +772,15 @@ class MySystem: public System { rv = GetThreadContext(target->thread, &context); if (rv) { -#ifdef ARCH_x86_32 +# ifdef ARCH_x86_32 visitor->visit(reinterpret_cast(context.Eip), reinterpret_cast(context.Ebp), reinterpret_cast(context.Esp)); -#elif defined ARCH_x86_64 +# elif defined ARCH_x86_64 visitor->visit(reinterpret_cast(context.Rip), reinterpret_cast(context.Rbp), reinterpret_cast(context.Rsp)); -#endif +# endif success = true; } @@ -786,8 +789,11 @@ class MySystem: public System { } return (success ? 0 : 1); - } +#else + #pragma message("TODO: http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.application.unhandledexception(v=vs.105).aspx") + return false; #endif + } virtual uint64_t call(void* function, uintptr_t* arguments, uint8_t* types, unsigned count, unsigned size, unsigned returnType) @@ -917,8 +923,7 @@ class MySystem: public System { return append(allocator, buffer, "\\", name); } #else - //TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ - //Windows.ApplicationModel.Package.Current.InstalledLocation + #pragma message("TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ Windows.ApplicationModel.Package.Current.InstalledLocation") return name; #endif } @@ -1017,14 +1022,14 @@ class MySystem: public System { } HANDLE mutex; -#if !defined(AVIAN_AOT_ONLY) SignalHandler* handlers[HandlerCount]; +#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) LPTOP_LEVEL_EXCEPTION_FILTER oldHandler; #endif const char* crashDumpDirectory; }; -#if !defined(AVIAN_AOT_ONLY) +#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) #pragma pack(push,4) struct MINIDUMP_EXCEPTION_INFORMATION { diff --git a/src/x86.masm b/src/x86.masm index 715669f8c1..640637d5af 100644 --- a/src/x86.masm +++ b/src/x86.masm @@ -8,6 +8,8 @@ comment # There is NO WARRANTY for this software. See license.txt for details. + + ORIGIN: https://github.com/gkvas/avian/tree/wince # .586