mirror of
https://github.com/corda/corda.git
synced 2025-02-07 19:40:25 +00:00
Merge pull request #419 from dicej/type-generator-limit
handle arbitrary class sizes in type-generator/main.cpp
This commit is contained in:
commit
7a74c2c168
@ -159,6 +159,7 @@ SUNWprivate_1.1 {
|
|||||||
JVM_GetMethodParameterAnnotations;
|
JVM_GetMethodParameterAnnotations;
|
||||||
JVM_GetPrimitiveArrayElement;
|
JVM_GetPrimitiveArrayElement;
|
||||||
JVM_GetProtectionDomain;
|
JVM_GetProtectionDomain;
|
||||||
|
JVM_GetResourceLookupCacheURLs;
|
||||||
JVM_GetSockName;
|
JVM_GetSockName;
|
||||||
JVM_GetSockOpt;
|
JVM_GetSockOpt;
|
||||||
JVM_GetStackAccessControlContext;
|
JVM_GetStackAccessControlContext;
|
||||||
@ -291,4 +292,3 @@ SUNWprivate_1.1 {
|
|||||||
# This is for Forte Analyzer profiling support.
|
# This is for Forte Analyzer profiling support.
|
||||||
AsyncGetCallTrace;
|
AsyncGetCallTrace;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -441,6 +441,11 @@ class MyClasspath : public Classpath {
|
|||||||
setObjectClass(t, c, type(t, GcJclass::Type));
|
setObjectClass(t, c, type(t, GcJclass::Type));
|
||||||
c->setName(t, name);
|
c->setName(t, name);
|
||||||
c->setVmClass(t, class_);
|
c->setVmClass(t, class_);
|
||||||
|
#ifdef HAVE_JclassClassLoader
|
||||||
|
if (class_->loader() != roots(t)->bootLoader()) {
|
||||||
|
c->setClassLoader(t, class_->loader());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@ -4564,6 +4569,12 @@ extern "C" AVIAN_EXPORT jobject JNICALL
|
|||||||
return reinterpret_cast<jobject>(run(t, jvmGetProtectionDomain, arguments));
|
return reinterpret_cast<jobject>(run(t, jvmGetProtectionDomain, arguments));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" AVIAN_EXPORT jobject JNICALL
|
||||||
|
EXPORT(JVM_GetResourceLookupCacheURLs)(Thread*, jobject)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" AVIAN_EXPORT void JNICALL
|
extern "C" AVIAN_EXPORT void JNICALL
|
||||||
EXPORT(JVM_SetProtectionDomain)(Thread*, jclass, jobject)
|
EXPORT(JVM_SetProtectionDomain)(Thread*, jclass, jobject)
|
||||||
{
|
{
|
||||||
|
@ -3101,7 +3101,7 @@ void removeString(Thread* t, object o)
|
|||||||
void bootClass(Thread* t,
|
void bootClass(Thread* t,
|
||||||
Gc::Type type,
|
Gc::Type type,
|
||||||
int superType,
|
int superType,
|
||||||
uint32_t objectMask,
|
uint32_t* objectMask,
|
||||||
unsigned fixedSize,
|
unsigned fixedSize,
|
||||||
unsigned arrayElementSize,
|
unsigned arrayElementSize,
|
||||||
unsigned vtableLength)
|
unsigned vtableLength)
|
||||||
@ -3109,15 +3109,20 @@ void bootClass(Thread* t,
|
|||||||
GcClass* super
|
GcClass* super
|
||||||
= (superType >= 0 ? vm::type(t, static_cast<Gc::Type>(superType)) : 0);
|
= (superType >= 0 ? vm::type(t, static_cast<Gc::Type>(superType)) : 0);
|
||||||
|
|
||||||
|
unsigned maskSize
|
||||||
|
= ceilingDivide(fixedSize + arrayElementSize, 32 * BytesPerWord);
|
||||||
|
|
||||||
GcIntArray* mask;
|
GcIntArray* mask;
|
||||||
if (objectMask) {
|
if (objectMask) {
|
||||||
if (super and super->objectMask()
|
if (super and super->objectMask()
|
||||||
and super->objectMask()->body()[0]
|
and super->objectMask()->length() == maskSize
|
||||||
== static_cast<int32_t>(objectMask)) {
|
and memcmp(super->objectMask()->body().begin(),
|
||||||
|
objectMask,
|
||||||
|
sizeof(uint32_t) * maskSize) == 0) {
|
||||||
mask = vm::type(t, static_cast<Gc::Type>(superType))->objectMask();
|
mask = vm::type(t, static_cast<Gc::Type>(superType))->objectMask();
|
||||||
} else {
|
} else {
|
||||||
mask = makeIntArray(t, 1);
|
mask = makeIntArray(t, maskSize);
|
||||||
mask->body()[0] = objectMask;
|
memcpy(mask->body().begin(), objectMask, sizeof(uint32_t) * maskSize);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mask = 0;
|
mask = 0;
|
||||||
|
@ -120,7 +120,7 @@ class Output {
|
|||||||
|
|
||||||
virtual void write(const std::string& s) = 0;
|
virtual void write(const std::string& s) = 0;
|
||||||
|
|
||||||
void write(int i)
|
void write(int32_t i)
|
||||||
{
|
{
|
||||||
static const int Size = 32;
|
static const int Size = 32;
|
||||||
char s[Size];
|
char s[Size];
|
||||||
@ -128,6 +128,15 @@ class Output {
|
|||||||
assert(c > 0 and c < Size);
|
assert(c > 0 and c < Size);
|
||||||
write(s);
|
write(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void writeUnsigned(uint32_t i)
|
||||||
|
{
|
||||||
|
static const int Size = 32;
|
||||||
|
char s[Size];
|
||||||
|
int c UNUSED = vm::snprintf(s, Size, "%u", i);
|
||||||
|
assert(c > 0 and c < Size);
|
||||||
|
write(s);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class FileOutput : public Output {
|
class FileOutput : public Output {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <avian/util/arg-parser.h>
|
#include <avian/util/arg-parser.h>
|
||||||
#include <avian/util/stream.h>
|
#include <avian/util/stream.h>
|
||||||
|
#include <avian/util/math.h>
|
||||||
|
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "sexpr.h"
|
#include "sexpr.h"
|
||||||
@ -1326,17 +1327,23 @@ void set(uint32_t* mask, unsigned index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t typeObjectMask(Module& module, Class* cl)
|
void set(std::vector<uint32_t>& mask, unsigned index)
|
||||||
{
|
{
|
||||||
assert(cl->fixedSize + (cl->arrayField ? cl->arrayField->elementSize : 0)
|
set(&(mask[index / 32]), index % 32);
|
||||||
< 32 * BytesPerWord);
|
}
|
||||||
|
|
||||||
uint32_t mask = 1;
|
std::vector<uint32_t> typeObjectMask(Module& module, Class* cl)
|
||||||
|
{
|
||||||
|
std::vector<uint32_t> mask(ceilingDivide(
|
||||||
|
cl->fixedSize + (cl->arrayField ? cl->arrayField->elementSize : 0),
|
||||||
|
32 * BytesPerWord));
|
||||||
|
|
||||||
|
set(mask, 0);
|
||||||
|
|
||||||
for (const auto f : cl->fields) {
|
for (const auto f : cl->fields) {
|
||||||
unsigned offset = f->offset / BytesPerWord;
|
unsigned offset = f->offset / BytesPerWord;
|
||||||
if (isFieldGcVisible(module, f)) {
|
if (isFieldGcVisible(module, f)) {
|
||||||
set(&mask, offset);
|
set(mask, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1344,13 +1351,28 @@ uint32_t typeObjectMask(Module& module, Class* cl)
|
|||||||
Field* f = cl->arrayField;
|
Field* f = cl->arrayField;
|
||||||
unsigned offset = f->offset / BytesPerWord;
|
unsigned offset = f->offset / BytesPerWord;
|
||||||
if (isFieldGcVisible(module, f)) {
|
if (isFieldGcVisible(module, f)) {
|
||||||
set(&mask, offset);
|
set(mask, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool trivialMask(const std::vector<uint32_t>& mask)
|
||||||
|
{
|
||||||
|
if (mask[0] != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 1; i < mask.size(); ++i) {
|
||||||
|
if (mask[i]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void writeInitialization(Output* out,
|
void writeInitialization(Output* out,
|
||||||
Module& module,
|
Module& module,
|
||||||
std::set<Class*>& alreadyInited,
|
std::set<Class*>& alreadyInited,
|
||||||
@ -1363,6 +1385,24 @@ void writeInitialization(Output* out,
|
|||||||
if (cl->super && cl->name != "intArray" && cl->name != "class") {
|
if (cl->super && cl->name != "intArray" && cl->name != "class") {
|
||||||
writeInitialization(out, module, alreadyInited, cl->super);
|
writeInitialization(out, module, alreadyInited, cl->super);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<uint32_t> mask = typeObjectMask(module, cl);
|
||||||
|
bool trivialMask = local::trivialMask(mask);
|
||||||
|
if (trivialMask) {
|
||||||
|
out->write("{ ");
|
||||||
|
} else {
|
||||||
|
out->write("{ uint32_t mask[");
|
||||||
|
out->write(mask.size());
|
||||||
|
out->write("] = { ");
|
||||||
|
for (size_t i = 0; i < mask.size(); ++i) {
|
||||||
|
out->writeUnsigned(mask[i]);
|
||||||
|
if (i < mask.size() - 1) {
|
||||||
|
out->write(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out->write(" };\n");
|
||||||
|
}
|
||||||
|
|
||||||
out->write("bootClass(t, Gc::");
|
out->write("bootClass(t, Gc::");
|
||||||
out->write(capitalize(cl->name));
|
out->write(capitalize(cl->name));
|
||||||
out->write("Type, ");
|
out->write("Type, ");
|
||||||
@ -1376,10 +1416,10 @@ void writeInitialization(Output* out,
|
|||||||
}
|
}
|
||||||
out->write(", ");
|
out->write(", ");
|
||||||
|
|
||||||
if (typeObjectMask(module, cl) != 1) {
|
if (trivialMask) {
|
||||||
out->write(typeObjectMask(module, cl));
|
|
||||||
} else {
|
|
||||||
out->write("0");
|
out->write("0");
|
||||||
|
} else {
|
||||||
|
out->write("mask");
|
||||||
}
|
}
|
||||||
out->write(", ");
|
out->write(", ");
|
||||||
|
|
||||||
@ -1390,7 +1430,7 @@ void writeInitialization(Output* out,
|
|||||||
out->write(", ");
|
out->write(", ");
|
||||||
|
|
||||||
out->write(cl->methods.size());
|
out->write(cl->methods.size());
|
||||||
out->write(");\n");
|
out->write("); }\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeInitializations(Output* out, Module& module)
|
void writeInitializations(Output* out, Module& module)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user