2013-07-02 20:52:38 -06:00
|
|
|
/* Copyright (c) 2008-2013, Avian Contributors
|
2008-02-19 11:06:52 -07:00
|
|
|
|
|
|
|
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. */
|
|
|
|
|
2007-09-23 19:39:03 -06:00
|
|
|
#ifndef PROCESSOR_H
|
|
|
|
#define PROCESSOR_H
|
|
|
|
|
2013-02-27 13:25:50 -07:00
|
|
|
#include "avian/common.h"
|
2014-02-07 14:24:56 -07:00
|
|
|
#include <avian/system/system.h>
|
|
|
|
#include <avian/heap/heap.h>
|
2014-02-25 11:32:17 -07:00
|
|
|
#include <avian/util/allocator.h>
|
2008-11-23 16:58:01 -07:00
|
|
|
#include "bootimage.h"
|
2013-02-27 13:25:50 -07:00
|
|
|
#include "avian/heapwalk.h"
|
|
|
|
#include "avian/zone.h"
|
2007-09-23 19:39:03 -06:00
|
|
|
|
2013-02-11 08:07:46 -07:00
|
|
|
namespace avian {
|
|
|
|
namespace codegen {
|
2013-02-10 18:55:38 -07:00
|
|
|
class DelayedPromise;
|
2013-02-11 08:07:46 -07:00
|
|
|
}
|
2014-02-25 15:46:35 -07:00
|
|
|
|
|
|
|
namespace util {
|
|
|
|
template <class T>
|
|
|
|
class Slice;
|
|
|
|
}
|
2013-02-11 08:07:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace vm {
|
2013-02-10 18:55:38 -07:00
|
|
|
|
2007-09-23 19:39:03 -06:00
|
|
|
class Processor {
|
|
|
|
public:
|
2007-11-25 16:00:55 -07:00
|
|
|
class StackWalker;
|
|
|
|
|
|
|
|
class StackVisitor {
|
|
|
|
public:
|
|
|
|
virtual bool visit(StackWalker* walker) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class StackWalker {
|
|
|
|
public:
|
|
|
|
virtual void walk(StackVisitor* v) = 0;
|
|
|
|
|
|
|
|
virtual object method() = 0;
|
|
|
|
|
|
|
|
virtual int ip() = 0;
|
|
|
|
|
|
|
|
virtual unsigned count() = 0;
|
|
|
|
};
|
|
|
|
|
2012-05-02 09:49:31 -06:00
|
|
|
class CompilationHandler {
|
|
|
|
public:
|
2012-05-07 10:00:59 -06:00
|
|
|
virtual void compiled(const void* code, unsigned size, unsigned frameSize, const char* name) = 0;
|
2012-05-02 09:49:31 -06:00
|
|
|
|
|
|
|
virtual void dispose() = 0;
|
|
|
|
};
|
|
|
|
|
2007-09-23 19:39:03 -06:00
|
|
|
virtual Thread*
|
|
|
|
makeThread(Machine* m, object javaThread, Thread* parent) = 0;
|
|
|
|
|
2007-11-02 08:15:06 -06:00
|
|
|
virtual object
|
2007-11-05 14:40:17 -07:00
|
|
|
makeMethod(Thread* t,
|
|
|
|
uint8_t vmFlags,
|
|
|
|
uint8_t returnCode,
|
|
|
|
uint8_t parameterCount,
|
|
|
|
uint8_t parameterFootprint,
|
|
|
|
uint16_t flags,
|
|
|
|
uint16_t offset,
|
|
|
|
object name,
|
|
|
|
object spec,
|
2009-09-18 18:01:54 -06:00
|
|
|
object addendum,
|
2007-11-05 14:40:17 -07:00
|
|
|
object class_,
|
|
|
|
object code) = 0;
|
2007-09-25 17:53:11 -06:00
|
|
|
|
2007-11-02 08:15:06 -06:00
|
|
|
virtual object
|
2007-11-05 14:40:17 -07:00
|
|
|
makeClass(Thread* t,
|
|
|
|
uint16_t flags,
|
2009-08-18 14:26:28 -06:00
|
|
|
uint16_t vmFlags,
|
2007-11-05 14:40:17 -07:00
|
|
|
uint16_t fixedSize,
|
2009-08-18 14:26:28 -06:00
|
|
|
uint8_t arrayElementSize,
|
|
|
|
uint8_t arrayDimensions,
|
2007-11-05 14:40:17 -07:00
|
|
|
object objectMask,
|
|
|
|
object name,
|
2009-08-27 16:26:25 -06:00
|
|
|
object sourceFile,
|
2007-11-05 14:40:17 -07:00
|
|
|
object super,
|
|
|
|
object interfaceTable,
|
|
|
|
object virtualTable,
|
|
|
|
object fieldTable,
|
|
|
|
object methodTable,
|
2009-09-18 18:01:54 -06:00
|
|
|
object addendum,
|
2007-11-05 14:40:17 -07:00
|
|
|
object staticTable,
|
|
|
|
object loader,
|
|
|
|
unsigned vtableLength) = 0;
|
2007-10-01 09:19:15 -06:00
|
|
|
|
2007-12-11 14:26:59 -07:00
|
|
|
virtual void
|
|
|
|
initVtable(Thread* t, object c) = 0;
|
|
|
|
|
2007-09-23 19:39:03 -06:00
|
|
|
virtual void
|
|
|
|
visitObjects(Thread* t, Heap::Visitor* v) = 0;
|
|
|
|
|
2007-11-25 16:00:55 -07:00
|
|
|
virtual void
|
|
|
|
walkStack(Thread* t, StackVisitor* v) = 0;
|
2007-09-24 07:46:48 -06:00
|
|
|
|
2007-10-04 16:41:19 -06:00
|
|
|
virtual int
|
2007-11-25 16:00:55 -07:00
|
|
|
lineNumber(Thread* t, object method, int ip) = 0;
|
2007-10-04 16:41:19 -06:00
|
|
|
|
2007-09-24 07:46:48 -06:00
|
|
|
virtual object*
|
|
|
|
makeLocalReference(Thread* t, object o) = 0;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
disposeLocalReference(Thread* t, object* r) = 0;
|
2007-09-23 19:39:03 -06:00
|
|
|
|
2012-08-11 06:56:19 -06:00
|
|
|
virtual bool
|
|
|
|
pushLocalFrame(Thread* t, unsigned capacity) = 0;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
popLocalFrame(Thread* t) = 0;
|
|
|
|
|
2007-09-23 19:39:03 -06:00
|
|
|
virtual object
|
|
|
|
invokeArray(Thread* t, object method, object this_, object arguments) = 0;
|
|
|
|
|
2012-06-15 17:41:40 -06:00
|
|
|
virtual object
|
|
|
|
invokeArray(Thread* t, object method, object this_, const jvalue* arguments)
|
|
|
|
= 0;
|
|
|
|
|
2007-09-23 19:39:03 -06:00
|
|
|
virtual object
|
|
|
|
invokeList(Thread* t, object method, object this_, bool indirectObjects,
|
|
|
|
va_list arguments) = 0;
|
|
|
|
|
|
|
|
virtual object
|
2009-08-10 07:56:16 -06:00
|
|
|
invokeList(Thread* t, object loader, const char* className,
|
|
|
|
const char* methodName, const char* methodSpec,
|
|
|
|
object this_, va_list arguments) = 0;
|
2007-09-23 19:39:03 -06:00
|
|
|
|
2007-12-11 14:26:59 -07:00
|
|
|
virtual void
|
|
|
|
dispose(Thread* t) = 0;
|
|
|
|
|
2007-09-23 19:39:03 -06:00
|
|
|
virtual void
|
|
|
|
dispose() = 0;
|
|
|
|
|
2008-04-11 16:48:39 -06:00
|
|
|
virtual object
|
|
|
|
getStackTrace(Thread* t, Thread* target) = 0;
|
|
|
|
|
2014-02-25 15:46:35 -07:00
|
|
|
virtual void initialize(BootImage* image, avian::util::Slice<uint8_t> code)
|
|
|
|
= 0;
|
2008-11-23 16:58:01 -07:00
|
|
|
|
2012-05-02 09:49:31 -06:00
|
|
|
virtual void
|
|
|
|
addCompilationHandler(CompilationHandler* handler) = 0;
|
|
|
|
|
2008-11-23 16:58:01 -07:00
|
|
|
virtual void
|
2009-04-05 15:42:10 -06:00
|
|
|
compileMethod(Thread* t, Zone* zone, object* constants, object* calls,
|
2013-02-11 08:07:46 -07:00
|
|
|
avian::codegen::DelayedPromise** addresses, object method,
|
2011-08-31 21:18:00 -06:00
|
|
|
OffsetResolver* resolver) = 0;
|
2008-11-23 16:58:01 -07:00
|
|
|
|
|
|
|
virtual void
|
2010-09-14 10:49:41 -06:00
|
|
|
visitRoots(Thread* t, HeapWalker* w) = 0;
|
2008-11-23 16:58:01 -07:00
|
|
|
|
2011-08-31 21:18:00 -06:00
|
|
|
virtual void
|
|
|
|
normalizeVirtualThunks(Thread* t) = 0;
|
|
|
|
|
2008-12-01 19:38:00 -07:00
|
|
|
virtual unsigned*
|
2009-05-31 21:16:58 -06:00
|
|
|
makeCallTable(Thread* t, HeapWalker* w) = 0;
|
2008-12-01 19:38:00 -07:00
|
|
|
|
2008-11-28 15:02:45 -07:00
|
|
|
virtual void
|
2011-09-20 16:30:30 -06:00
|
|
|
boot(Thread* t, BootImage* image, uint8_t* code) = 0;
|
2008-11-28 15:02:45 -07:00
|
|
|
|
2009-05-03 14:57:11 -06:00
|
|
|
virtual void
|
2009-05-05 18:29:05 -06:00
|
|
|
callWithCurrentContinuation(Thread* t, object receiver) = 0;
|
2009-05-03 14:57:11 -06:00
|
|
|
|
2009-05-23 19:49:14 -06:00
|
|
|
virtual void
|
|
|
|
dynamicWind(Thread* t, object before, object thunk, object after) = 0;
|
|
|
|
|
2009-05-03 14:57:11 -06:00
|
|
|
virtual void
|
2009-05-05 18:29:05 -06:00
|
|
|
feedResultToContinuation(Thread* t, object continuation, object result) = 0;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
feedExceptionToContinuation(Thread* t, object continuation,
|
|
|
|
object exception) = 0;
|
2009-05-03 14:57:11 -06:00
|
|
|
|
|
|
|
virtual void
|
2009-05-04 19:04:17 -06:00
|
|
|
walkContinuationBody(Thread* t, Heap::Walker* w, object o, unsigned start)
|
2009-05-03 14:57:11 -06:00
|
|
|
= 0;
|
|
|
|
|
2007-09-23 19:39:03 -06:00
|
|
|
object
|
|
|
|
invoke(Thread* t, object method, object this_, ...)
|
|
|
|
{
|
|
|
|
va_list a;
|
|
|
|
va_start(a, this_);
|
|
|
|
|
|
|
|
object r = invokeList(t, method, this_, false, a);
|
|
|
|
|
|
|
|
va_end(a);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
object
|
2009-08-10 07:56:16 -06:00
|
|
|
invoke(Thread* t, object loader, const char* className,
|
|
|
|
const char* methodName, const char* methodSpec, object this_, ...)
|
2007-09-23 19:39:03 -06:00
|
|
|
{
|
|
|
|
va_list a;
|
|
|
|
va_start(a, this_);
|
|
|
|
|
2009-08-10 07:56:16 -06:00
|
|
|
object r = invokeList
|
|
|
|
(t, loader, className, methodName, methodSpec, this_, a);
|
2007-09-23 19:39:03 -06:00
|
|
|
|
|
|
|
va_end(a);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-02-21 17:06:17 -07:00
|
|
|
Processor* makeProcessor(System* system,
|
2014-02-25 11:32:17 -07:00
|
|
|
avian::util::Allocator* allocator,
|
2014-02-21 17:06:17 -07:00
|
|
|
const char* crashDumpDirectory,
|
|
|
|
bool useNativeFeatures);
|
2007-09-23 19:39:03 -06:00
|
|
|
|
|
|
|
} // namespace vm
|
|
|
|
|
|
|
|
#endif//PROCESSOR_H
|