mirror of
https://github.com/corda/corda.git
synced 2025-01-19 11:16:54 +00:00
generate makeZeroed method, to return a zero-initialzed instance of a Gc* class
This commit is contained in:
parent
836cc41320
commit
8a4b043ee3
@ -9692,42 +9692,14 @@ void boot(MyThread* t, BootImage* image, uint8_t* code)
|
||||
|
||||
t->m->types = reinterpret_cast<GcArray*>(bootObject(heap, image->types));
|
||||
|
||||
t->m->roots = makeRoots(t,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
;
|
||||
t->m->roots = GcRoots::makeZeroed(t);
|
||||
|
||||
roots(t)->setBootLoader(
|
||||
t, cast<GcClassLoader>(t, bootObject(heap, image->bootLoader)));
|
||||
roots(t)->setAppLoader(
|
||||
t, cast<GcClassLoader>(t, bootObject(heap, image->appLoader)));
|
||||
|
||||
p->roots = makeCompileRoots(t, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
p->roots = GcCompileRoots::makeZeroed(t);
|
||||
|
||||
compileRoots(t)->setMethodTree(
|
||||
t, cast<GcTreeNode>(t, bootObject(heap, image->methodTree)));
|
||||
|
@ -1192,6 +1192,12 @@ void writeClasses(Output* out, Module& module)
|
||||
out->write(capitalize(cl->name));
|
||||
out->write(";\n\n");
|
||||
|
||||
out->write(" static Gc" + capitalize(cl->name) + "* makeZeroed(Thread* t");
|
||||
if (cl->arrayField) {
|
||||
out->write(", uintptr_t length");
|
||||
}
|
||||
out->write(");\n");
|
||||
|
||||
writeClassAccessors(out, module, cl);
|
||||
|
||||
out->write("};\n\n");
|
||||
@ -1269,17 +1275,40 @@ void writeConstructors(Output* out, Module& module)
|
||||
it != module.classes.end();
|
||||
++it) {
|
||||
Class* cl = it->second;
|
||||
out->write("Gc");
|
||||
out->write(capitalize(cl->name));
|
||||
out->write("* make");
|
||||
|
||||
bool hasObjectMask = cl->name == "singleton";
|
||||
|
||||
std::string name = "Gc" + capitalize(cl->name);
|
||||
|
||||
out->write(name + "* " + name + "::makeZeroed(Thread* t");
|
||||
if (cl->arrayField) {
|
||||
out->write(", uintptr_t length");
|
||||
}
|
||||
out->write(")\n{\n");
|
||||
out->write(" " + name + "* o = reinterpret_cast<" + name
|
||||
+ "*>(allocate(t, ");
|
||||
writeOffset(out, cl);
|
||||
if (hasObjectMask) {
|
||||
out->write(", true");
|
||||
} else {
|
||||
out->write(", false");
|
||||
}
|
||||
out->write("));\n");
|
||||
out->write(" setObjectClass(t, reinterpret_cast<object>(o), ");
|
||||
out->write(
|
||||
"reinterpret_cast<GcClass*>(reinterpret_cast<GcArray*>(t->m->types)->"
|
||||
"body()[Gc::");
|
||||
out->write(capitalize(cl->name));
|
||||
out->write("Type]));\n");
|
||||
out->write(" return o;\n");
|
||||
out->write("}\n\n");
|
||||
|
||||
out->write(name + "* make" + capitalize(cl->name));
|
||||
out->write("(Thread* t");
|
||||
|
||||
writeConstructorParameters(out, module, cl);
|
||||
|
||||
out->write(")\n{\n");
|
||||
|
||||
bool hasObjectMask = cl->name == "singleton";
|
||||
for (std::vector<Field*>::iterator it = cl->fields.begin();
|
||||
it != cl->fields.end();
|
||||
it++) {
|
||||
@ -1299,11 +1328,8 @@ void writeConstructors(Output* out, Module& module)
|
||||
}
|
||||
}
|
||||
|
||||
out->write(" Gc");
|
||||
out->write(capitalize(cl->name));
|
||||
out->write("* o = reinterpret_cast<Gc");
|
||||
out->write(capitalize(cl->name));
|
||||
out->write("*>(allocate(t, ");
|
||||
out->write(" " + name + "* o = reinterpret_cast<" + name
|
||||
+ "*>(allocate(t, ");
|
||||
writeOffset(out, cl);
|
||||
if (hasObjectMask) {
|
||||
out->write(", true");
|
||||
|
Loading…
Reference in New Issue
Block a user