Replaced TODO comments with messages ; More correct AVIAN_AOT_ONLY usage

This commit is contained in:
Alexey Pelykh 2013-01-28 20:51:35 +02:00
parent c5adad9dce
commit a78959a480
8 changed files with 72 additions and 50 deletions

View File

@ -80,8 +80,8 @@ namespace {
snprintf(errStr, 9, "%d", (int) err); snprintf(errStr, 9, "%d", (int) err);
return errStr; return errStr;
//TODO: #pragma message("TODO")
// The better way to do this, if I could figure out how to convert LPTSTR to char* // The better way to do this, if I could figure out how to convert LPTSTR to char*
//char* errStr; //char* errStr;
//LPTSTR s; //LPTSTR s;
//if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | //if(FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
@ -390,7 +390,7 @@ Locale getLocale() {
return Locale(lang, reg); return Locale(lang, reg);
#else #else
//TODO: CultureInfo.CurrentCulture #pragma message("TODO: CultureInfo.CurrentCulture")
return Locale("en", "US"); return Locale("en", "US");
#endif #endif
} }
@ -596,8 +596,7 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name,
GetTempPath(MAX_PATH, buffer); GetTempPath(MAX_PATH, buffer);
r = e->NewStringUTF(buffer); r = e->NewStringUTF(buffer);
# else # else
//TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ #pragma message("TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ Windows.Storage.ApplicationData.Current.TemporaryFolder")
//Windows.Storage.ApplicationData.Current.TemporaryFolder
r = 0; r = 0;
# endif # endif
} else if (strcmp(chars, "user.dir") == 0) { } 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); GetCurrentDirectory(MAX_PATH, buffer);
r = e->NewStringUTF(buffer); r = e->NewStringUTF(buffer);
# else # else
//TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ #pragma message("TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ Windows.ApplicationModel.Package.Current.InstalledLocation")
//Windows.ApplicationModel.Package.Current.InstalledLocation
r = 0; r = 0;
# endif # endif
} else if (strcmp(chars, "user.home") == 0) { } else if (strcmp(chars, "user.home") == 0) {
@ -621,8 +619,7 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name,
r = 0; r = 0;
} }
# else # else
//TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ #pragma message("TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ Windows.Storage.KnownFolders.DocumentsLibrary")
//Windows.Storage.KnownFolders.DocumentsLibrary;
r = 0; r = 0;
# endif # endif
# else # else

View File

@ -642,6 +642,7 @@ ifeq ($(platform),wp8)
use-lto = false use-lto = false
supports_avian_executable = false supports_avian_executable = false
process = compile process = compile
aot_only = true
ifneq ($(process),compile) ifneq ($(process),compile)
options := -$(process) options := -$(process)
endif endif

View File

@ -18,7 +18,7 @@
using namespace vm; using namespace vm;
namespace { namespace local {
namespace isa { namespace isa {
// SYSTEM REGISTERS // SYSTEM REGISTERS
@ -252,7 +252,7 @@ class MyBlock: public Assembler::Block {
this->start = start; this->start = start;
this->next = static_cast<MyBlock*>(next); this->next = static_cast<MyBlock*>(next);
::resolve(this); local::resolve(this);
return start + size + padding(this, size); return start + size + padding(this, size);
} }
@ -2150,7 +2150,7 @@ class MyArchitecture: public Assembler::Architecture {
} }
virtual unsigned argumentFootprint(unsigned footprint) { virtual unsigned argumentFootprint(unsigned footprint) {
return ::argumentFootprint(footprint); return local::argumentFootprint(footprint);
} }
virtual bool argumentAlignment() { virtual bool argumentAlignment() {
@ -2239,7 +2239,7 @@ class MyArchitecture: public Assembler::Architecture {
unsigned targetParameterFootprint, void** ip, unsigned targetParameterFootprint, void** ip,
void** stack) void** stack)
{ {
::nextFrame(&con, static_cast<uint32_t*>(start), size, footprint, link, local::nextFrame(&con, static_cast<uint32_t*>(start), size, footprint, link,
mostRecent, targetParameterFootprint, ip, stack); mostRecent, targetParameterFootprint, ip, stack);
} }
@ -2550,11 +2550,12 @@ class MyAssembler: public Assembler {
} }
virtual void pushFrame(unsigned argumentCount, ...) { virtual void pushFrame(unsigned argumentCount, ...) {
struct { struct Argument {
unsigned size; unsigned size;
OperandType type; OperandType type;
Operand* operand; Operand* operand;
} arguments[argumentCount]; };
Argument* arguments = new Argument[argumentCount];
va_list a; va_start(a, argumentCount); va_list a; va_start(a, argumentCount);
unsigned footprint = 0; unsigned footprint = 0;
@ -2589,6 +2590,9 @@ class MyAssembler: public Assembler {
offset += ceiling(arguments[i].size, TargetBytesPerWord); offset += ceiling(arguments[i].size, TargetBytesPerWord);
} }
} }
delete[] arguments;
arguments = 0;
} }
virtual void allocateFrame(unsigned footprint) { virtual void allocateFrame(unsigned footprint) {
@ -2798,7 +2802,7 @@ class MyAssembler: public Assembler {
bool jump = needJump(b); bool jump = needJump(b);
if (jump) { if (jump) {
write4 write4
(dst + dstOffset, ::b((poolSize + TargetBytesPerWord - 8) >> 2)); (dst + dstOffset, isa::b((poolSize + TargetBytesPerWord - 8) >> 2));
} }
dstOffset += poolSize + (jump ? TargetBytesPerWord : 0); dstOffset += poolSize + (jump ? TargetBytesPerWord : 0);
@ -2832,7 +2836,7 @@ class MyAssembler: public Assembler {
} }
virtual Promise* offset(bool forTrace) { virtual Promise* offset(bool forTrace) {
return ::offset(&con, forTrace); return local::offset(&con, forTrace);
} }
virtual Block* endBlock(bool startNew) { virtual Block* endBlock(bool startNew) {
@ -2903,15 +2907,15 @@ namespace vm {
Assembler::Architecture* Assembler::Architecture*
makeArchitecture(System* system, bool) makeArchitecture(System* system, bool)
{ {
return new (allocate(system, sizeof(MyArchitecture))) MyArchitecture(system); return new (allocate(system, sizeof(local::MyArchitecture))) local::MyArchitecture(system);
} }
Assembler* Assembler*
makeAssembler(System* system, Allocator* allocator, Zone* zone, makeAssembler(System* system, Allocator* allocator, Zone* zone,
Assembler::Architecture* architecture) Assembler::Architecture* architecture)
{ {
return new(zone) MyAssembler(system, allocator, zone, return new(zone) local::MyAssembler(system, allocator, zone,
static_cast<MyArchitecture*>(architecture)); static_cast<local::MyArchitecture*>(architecture));
} }
} // namespace vm } // namespace vm

View File

@ -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 AREA text, CODE, ARM
EXPORT vmNativeCall [FUNC] EXPORT vmNativeCall [FUNC]

View File

@ -7389,8 +7389,9 @@ finish(MyThread* t, FixedAllocator* allocator, Context* context)
{ {
trap(); trap();
} }
#if !defined(AVIAN_AOT_ONLY)
syncInstructionCache(start, codeSize); syncInstructionCache(start, codeSize);
#endif
} }
void void
@ -9152,7 +9153,9 @@ class MyProcessor: public Processor {
virtual void dispose() { virtual void dispose() {
if (codeAllocator.base) { if (codeAllocator.base) {
#if !defined(AVIAN_AOT_ONLY)
s->freeExecutable(codeAllocator.base, codeAllocator.capacity); s->freeExecutable(codeAllocator.base, codeAllocator.capacity);
#endif
} }
compilationHandlers->dispose(allocator); compilationHandlers->dispose(allocator);
@ -9313,11 +9316,13 @@ class MyProcessor: public Processor {
} }
virtual void boot(Thread* t, BootImage* image, uint8_t* code) { virtual void boot(Thread* t, BootImage* image, uint8_t* code) {
#if !defined(AVIAN_AOT_ONLY)
if (codeAllocator.base == 0) { if (codeAllocator.base == 0) {
codeAllocator.base = static_cast<uint8_t*> codeAllocator.base = static_cast<uint8_t*>
(s->tryAllocateExecutable(ExecutableAreaSizeInBytes)); (s->tryAllocateExecutable(ExecutableAreaSizeInBytes));
codeAllocator.capacity = ExecutableAreaSizeInBytes; codeAllocator.capacity = ExecutableAreaSizeInBytes;
} }
#endif
if (image and code) { if (image and code) {
local::boot(static_cast<MyThread*>(t), image, code); local::boot(static_cast<MyThread*>(t), image, code);

View File

@ -97,13 +97,11 @@ class System {
virtual void disposeAll() = 0; virtual void disposeAll() = 0;
}; };
#if !defined(AVIAN_AOT_ONLY)
class SignalHandler { class SignalHandler {
public: public:
virtual bool handleSignal(void** ip, void** frame, void** stack, virtual bool handleSignal(void** ip, void** frame, void** stack,
void** thread) = 0; void** thread) = 0;
}; };
#endif
class MonitorResource { class MonitorResource {
public: public:
@ -132,12 +130,10 @@ class System {
virtual Status make(Mutex**) = 0; virtual Status make(Mutex**) = 0;
virtual Status make(Monitor**) = 0; virtual Status make(Monitor**) = 0;
virtual Status make(Local**) = 0; virtual Status make(Local**) = 0;
#if !defined(AVIAN_AOT_ONLY)
virtual Status handleSegFault(SignalHandler* handler) = 0; virtual Status handleSegFault(SignalHandler* handler) = 0;
virtual Status handleDivideByZero(SignalHandler* handler) = 0; virtual Status handleDivideByZero(SignalHandler* handler) = 0;
virtual Status visit(Thread* thread, Thread* target, virtual Status visit(Thread* thread, Thread* target,
ThreadVisitor* visitor) = 0; ThreadVisitor* visitor) = 0;
#endif
virtual uint64_t call(void* function, uintptr_t* arguments, uint8_t* types, virtual uint64_t call(void* function, uintptr_t* arguments, uint8_t* types,
unsigned count, unsigned size, unsigned count, unsigned size,
unsigned returnType) = 0; unsigned returnType) = 0;

View File

@ -114,17 +114,15 @@ class MutexResource {
HANDLE m; HANDLE m;
}; };
#if !defined(AVIAN_AOT_ONLY)
const unsigned SegFaultIndex = 0; const unsigned SegFaultIndex = 0;
const unsigned DivideByZeroIndex = 1; const unsigned DivideByZeroIndex = 1;
const unsigned HandlerCount = 2; const unsigned HandlerCount = 2;
#endif
class MySystem; class MySystem;
MySystem* system; MySystem* system;
#if !defined(AVIAN_AOT_ONLY) #if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
LONG CALLBACK LONG CALLBACK
handleException(LPEXCEPTION_POINTERS e); handleException(LPEXCEPTION_POINTERS e);
#endif #endif
@ -628,7 +626,7 @@ class MySystem: public System {
}; };
MySystem(const char* crashDumpDirectory): MySystem(const char* crashDumpDirectory):
#if !defined(AVIAN_AOT_ONLY) #if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
oldHandler(0), oldHandler(0),
#endif #endif
crashDumpDirectory(crashDumpDirectory) crashDumpDirectory(crashDumpDirectory)
@ -636,14 +634,12 @@ class MySystem: public System {
expect(this, system == 0); expect(this, system == 0);
system = this; system = this;
#if !defined(AVIAN_AOT_ONLY)
memset(handlers, 0, sizeof(handlers)); memset(handlers, 0, sizeof(handlers));
#endif
mutex = CreateMutex(0, false, 0); mutex = CreateMutex(0, false, 0);
assert(this, mutex); assert(this, mutex);
} }
#if !defined(AVIAN_AOT_ONLY)
bool findHandler() { bool findHandler() {
for (unsigned i = 0; i < HandlerCount; ++i) { for (unsigned i = 0; i < HandlerCount; ++i) {
if (handlers[i]) return true; if (handlers[i]) return true;
@ -651,30 +647,37 @@ class MySystem: public System {
return false; 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) { int registerHandler(System::SignalHandler* handler, int index) {
if (handler) { if (handler) {
handlers[index] = handler; handlers[index] = handler;
#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
if (oldHandler == 0) { if (oldHandler == 0) {
#ifdef ARCH_x86_32 # ifdef ARCH_x86_32
oldHandler = SetUnhandledExceptionFilter(handleException); oldHandler = SetUnhandledExceptionFilter(handleException);
#elif defined ARCH_x86_64 # elif defined ARCH_x86_64
AddVectoredExceptionHandler(1, handleException); AddVectoredExceptionHandler(1, handleException);
oldHandler = reinterpret_cast<LPTOP_LEVEL_EXCEPTION_FILTER>(1); oldHandler = reinterpret_cast<LPTOP_LEVEL_EXCEPTION_FILTER>(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; return 0;
} else if (handlers[index]) { } else if (handlers[index]) {
handlers[index] = 0; handlers[index] = 0;
if (not findHandler()) { if (not findHandler()) {
#ifdef ARCH_x86_32 #if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
# ifdef ARCH_x86_32
SetUnhandledExceptionFilter(oldHandler); SetUnhandledExceptionFilter(oldHandler);
oldHandler = 0; oldHandler = 0;
#elif defined ARCH_x86_64 # elif defined ARCH_x86_64
// do nothing, handlers are never "unregistered" anyway // do nothing, handlers are never "unregistered" anyway
# endif
#else
#pragma message("TODO: http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.application.unhandledexception(v=vs.105).aspx")
#endif #endif
} }
@ -683,7 +686,7 @@ class MySystem: public System {
return 1; return 1;
} }
} }
#endif
virtual void* tryAllocate(unsigned sizeInBytes) { virtual void* tryAllocate(unsigned sizeInBytes) {
return malloc(sizeInBytes); return malloc(sizeInBytes);
} }
@ -742,7 +745,6 @@ class MySystem: public System {
return 0; return 0;
} }
#if !defined(AVIAN_AOT_ONLY)
virtual Status handleSegFault(SignalHandler* handler) { virtual Status handleSegFault(SignalHandler* handler) {
return registerHandler(handler, SegFaultIndex); return registerHandler(handler, SegFaultIndex);
} }
@ -754,6 +756,7 @@ class MySystem: public System {
virtual Status visit(System::Thread* st UNUSED, System::Thread* sTarget, virtual Status visit(System::Thread* st UNUSED, System::Thread* sTarget,
ThreadVisitor* visitor) ThreadVisitor* visitor)
{ {
#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
assert(this, st != sTarget); assert(this, st != sTarget);
Thread* target = static_cast<Thread*>(sTarget); Thread* target = static_cast<Thread*>(sTarget);
@ -769,15 +772,15 @@ class MySystem: public System {
rv = GetThreadContext(target->thread, &context); rv = GetThreadContext(target->thread, &context);
if (rv) { if (rv) {
#ifdef ARCH_x86_32 # ifdef ARCH_x86_32
visitor->visit(reinterpret_cast<void*>(context.Eip), visitor->visit(reinterpret_cast<void*>(context.Eip),
reinterpret_cast<void*>(context.Ebp), reinterpret_cast<void*>(context.Ebp),
reinterpret_cast<void*>(context.Esp)); reinterpret_cast<void*>(context.Esp));
#elif defined ARCH_x86_64 # elif defined ARCH_x86_64
visitor->visit(reinterpret_cast<void*>(context.Rip), visitor->visit(reinterpret_cast<void*>(context.Rip),
reinterpret_cast<void*>(context.Rbp), reinterpret_cast<void*>(context.Rbp),
reinterpret_cast<void*>(context.Rsp)); reinterpret_cast<void*>(context.Rsp));
#endif # endif
success = true; success = true;
} }
@ -786,8 +789,11 @@ class MySystem: public System {
} }
return (success ? 0 : 1); 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 #endif
}
virtual uint64_t call(void* function, uintptr_t* arguments, uint8_t* types, virtual uint64_t call(void* function, uintptr_t* arguments, uint8_t* types,
unsigned count, unsigned size, unsigned returnType) unsigned count, unsigned size, unsigned returnType)
@ -917,8 +923,7 @@ class MySystem: public System {
return append(allocator, buffer, "\\", name); return append(allocator, buffer, "\\", name);
} }
#else #else
//TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ #pragma message("TODO:http://lunarfrog.com/blog/2012/05/21/winrt-folders-access/ Windows.ApplicationModel.Package.Current.InstalledLocation")
//Windows.ApplicationModel.Package.Current.InstalledLocation
return name; return name;
#endif #endif
} }
@ -1017,14 +1022,14 @@ class MySystem: public System {
} }
HANDLE mutex; HANDLE mutex;
#if !defined(AVIAN_AOT_ONLY)
SignalHandler* handlers[HandlerCount]; SignalHandler* handlers[HandlerCount];
#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
LPTOP_LEVEL_EXCEPTION_FILTER oldHandler; LPTOP_LEVEL_EXCEPTION_FILTER oldHandler;
#endif #endif
const char* crashDumpDirectory; const char* crashDumpDirectory;
}; };
#if !defined(AVIAN_AOT_ONLY) #if !defined(WINAPI_FAMILY) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#pragma pack(push,4) #pragma pack(push,4)
struct MINIDUMP_EXCEPTION_INFORMATION { struct MINIDUMP_EXCEPTION_INFORMATION {

View File

@ -8,6 +8,8 @@ comment #
There is NO WARRANTY for this software. See license.txt for There is NO WARRANTY for this software. See license.txt for
details. details.
ORIGIN: https://github.com/gkvas/avian/tree/wince
# #
.586 .586