mirror of
https://github.com/corda/corda.git
synced 2025-01-21 03:55:00 +00:00
remove lots of unnecessary sizeof computations with a convenient 'operator new' overload
This commit is contained in:
parent
fde7a3e7a1
commit
fa9814b86d
@ -57,4 +57,8 @@ copy(Allocator* allocator, const char* a)
|
||||
|
||||
} // namespace vm
|
||||
|
||||
inline void* operator new (size_t size, vm::Allocator* allocator) {
|
||||
return allocator->allocate(size);
|
||||
}
|
||||
|
||||
#endif//ALLOCATOR_H
|
||||
|
33
src/arm.cpp
33
src/arm.cpp
@ -228,7 +228,7 @@ class Context {
|
||||
public:
|
||||
Context(System* s, Allocator* a, Zone* zone):
|
||||
s(s), zone(zone), client(0), code(s, a, 1024), tasks(0), result(0),
|
||||
firstBlock(new (zone->allocate(sizeof(MyBlock))) MyBlock(this, 0)),
|
||||
firstBlock(new(zone) MyBlock(this, 0)),
|
||||
lastBlock(firstBlock), poolOffsetHead(0), poolOffsetTail(0),
|
||||
constantPool(0), constantPoolCount(0)
|
||||
{ }
|
||||
@ -346,8 +346,7 @@ class Offset: public Promise {
|
||||
Promise*
|
||||
offset(Context* c, bool forTrace = false)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(Offset)))
|
||||
Offset(c, c->lastBlock, c->code.length(), forTrace);
|
||||
return new(c->zone) Offset(c, c->lastBlock, c->code.length(), forTrace);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -414,8 +413,7 @@ class OffsetTask: public Task {
|
||||
void
|
||||
appendOffsetTask(Context* c, Promise* promise, Promise* instructionOffset)
|
||||
{
|
||||
c->tasks = new (c->zone->allocate(sizeof(OffsetTask))) OffsetTask
|
||||
(c->tasks, promise, instructionOffset);
|
||||
c->tasks = new(c->zone) OffsetTask(c->tasks, promise, instructionOffset);
|
||||
}
|
||||
|
||||
inline unsigned
|
||||
@ -628,17 +626,14 @@ appendConstantPoolEntry(Context* c, Promise* constant, Promise* callOffset)
|
||||
if (constant->resolved()) {
|
||||
// make a copy, since the original might be allocated on the
|
||||
// stack, and we need our copy to live until assembly is complete
|
||||
constant = new (c->zone->allocate(sizeof(ResolvedPromise)))
|
||||
ResolvedPromise(constant->value());
|
||||
constant = new(c->zone) ResolvedPromise(constant->value());
|
||||
}
|
||||
|
||||
c->constantPool = new (c->zone->allocate(sizeof(ConstantPoolEntry)))
|
||||
ConstantPoolEntry(c, constant, c->constantPool, callOffset);
|
||||
c->constantPool = new(c->zone) ConstantPoolEntry(c, constant, c->constantPool, callOffset);
|
||||
|
||||
++ c->constantPoolCount;
|
||||
|
||||
PoolOffset* o = new (c->zone->allocate(sizeof(PoolOffset))) PoolOffset
|
||||
(c->lastBlock, c->constantPool, c->code.length() - c->lastBlock->offset);
|
||||
PoolOffset* o = new(c->zone) PoolOffset(c->lastBlock, c->constantPool, c->code.length() - c->lastBlock->offset);
|
||||
|
||||
if (DebugPool) {
|
||||
fprintf(stderr, "add pool offset %p %d to block %p\n",
|
||||
@ -657,8 +652,7 @@ void
|
||||
appendPoolEvent(Context* c, MyBlock* b, unsigned offset, PoolOffset* head,
|
||||
PoolOffset* tail)
|
||||
{
|
||||
PoolEvent* e = new (c->zone->allocate(sizeof(PoolEvent))) PoolEvent
|
||||
(head, tail, offset);
|
||||
PoolEvent* e = new(c->zone) PoolEvent(head, tail, offset);
|
||||
|
||||
if (b->poolEventTail) {
|
||||
b->poolEventTail->next = e;
|
||||
@ -1522,8 +1516,7 @@ branchCM(Context* c, TernaryOperation op, unsigned size,
|
||||
ShiftMaskPromise*
|
||||
shiftMaskPromise(Context* c, Promise* base, unsigned shift, int64_t mask)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(ShiftMaskPromise)))
|
||||
ShiftMaskPromise(base, shift, mask);
|
||||
return new(c->zone) ShiftMaskPromise(base, shift, mask);
|
||||
}
|
||||
|
||||
void
|
||||
@ -2158,9 +2151,7 @@ class MyAssembler: public Assembler {
|
||||
{
|
||||
Register stack(StackRegister);
|
||||
Memory stackLimit(ThreadRegister, stackLimitOffsetFromThread);
|
||||
Constant handlerConstant
|
||||
(new (c.zone->allocate(sizeof(ResolvedPromise)))
|
||||
ResolvedPromise(handler));
|
||||
Constant handlerConstant(new(c.zone) ResolvedPromise(handler));
|
||||
branchRM(&c, JumpIfGreaterOrEqual, TargetBytesPerWord, &stack, &stackLimit,
|
||||
&handlerConstant);
|
||||
}
|
||||
@ -2465,8 +2456,7 @@ class MyAssembler: public Assembler {
|
||||
MyBlock* b = c.lastBlock;
|
||||
b->size = c.code.length() - b->offset;
|
||||
if (startNew) {
|
||||
c.lastBlock = new (c.zone->allocate(sizeof(MyBlock)))
|
||||
MyBlock(&c, c.code.length());
|
||||
c.lastBlock = new (c.zone) MyBlock(&c, c.code.length());
|
||||
} else {
|
||||
c.lastBlock = 0;
|
||||
}
|
||||
@ -2537,8 +2527,7 @@ Assembler*
|
||||
makeAssembler(System* system, Allocator* allocator, Zone* zone,
|
||||
Assembler::Architecture* architecture)
|
||||
{
|
||||
return new (zone->allocate(sizeof(MyAssembler)))
|
||||
MyAssembler(system, allocator, zone,
|
||||
return new(zone) MyAssembler(system, allocator, zone,
|
||||
static_cast<MyArchitecture*>(architecture));
|
||||
}
|
||||
|
||||
|
@ -1389,8 +1389,7 @@ class Frame {
|
||||
Compiler::Operand* append(object o) {
|
||||
BootContext* bc = context->bootContext;
|
||||
if (bc) {
|
||||
Promise* p = new (bc->zone->allocate(sizeof(ListenPromise)))
|
||||
ListenPromise(t->m->system, bc->zone);
|
||||
Promise* p = new (bc->zone) ListenPromise(t->m->system, bc->zone);
|
||||
|
||||
PROTECT(t, o);
|
||||
object pointer = makePointer(t, p);
|
||||
@ -1408,9 +1407,7 @@ class Frame {
|
||||
}
|
||||
}
|
||||
|
||||
context->objectPool = new
|
||||
(context->zone.allocate(sizeof(PoolElement)))
|
||||
PoolElement(t, o, context->objectPool);
|
||||
context->objectPool = new(&context->zone) PoolElement(t, o, context->objectPool);
|
||||
|
||||
++ context->objectPoolCount;
|
||||
|
||||
@ -1615,8 +1612,7 @@ class Frame {
|
||||
Promise* addressPromise(Promise* p) {
|
||||
BootContext* bc = context->bootContext;
|
||||
if (bc) {
|
||||
bc->addresses = new (bc->zone->allocate(sizeof(DelayedPromise)))
|
||||
DelayedPromise(t->m->system, bc->zone, p, bc->addresses);
|
||||
bc->addresses = new(bc->zone) DelayedPromise(t->m->system, bc->zone, p, bc->addresses);
|
||||
return bc->addresses;
|
||||
} else {
|
||||
return p;
|
||||
@ -1633,7 +1629,7 @@ class Frame {
|
||||
(TargetBytesPerWord, c->memory
|
||||
(c->register_(t->arch->thread()), Compiler::AddressType,
|
||||
TargetThreadCodeImage), c->promiseConstant
|
||||
(new (context->zone.allocate(sizeof(OffsetPromise)))
|
||||
(new(&context->zone)
|
||||
OffsetPromise
|
||||
(p, - reinterpret_cast<intptr_t>(codeAllocator(t)->base)),
|
||||
Compiler::AddressType))
|
||||
@ -3417,8 +3413,7 @@ compileDirectInvoke(MyThread* t, Frame* frame, object target, bool tailCall)
|
||||
and (not (TailCalls and tailCall
|
||||
and (methodFlags(t, target) & ACC_NATIVE))))
|
||||
{
|
||||
Promise* p = new (bc->zone->allocate(sizeof(ListenPromise)))
|
||||
ListenPromise(t->m->system, bc->zone);
|
||||
Promise* p = new(bc->zone) ListenPromise(t->m->system, bc->zone);
|
||||
|
||||
PROTECT(t, target);
|
||||
object pointer = makePointer(t, p);
|
||||
@ -6636,7 +6631,7 @@ calculateFrameMaps(MyThread* t, Context* context, uintptr_t* originalRoots,
|
||||
}
|
||||
|
||||
if (path == 0) {
|
||||
path = new (context->zone.allocate(sizeof(SubroutinePath)))
|
||||
path = new(&context->zone)
|
||||
SubroutinePath(call, subroutinePath,
|
||||
makeRootTable(t, &(context->zone), context->method));
|
||||
}
|
||||
@ -7061,8 +7056,7 @@ finish(MyThread* t, FixedAllocator* allocator, Context* context)
|
||||
p != bc->addressSentinal;
|
||||
p = p->next)
|
||||
{
|
||||
p->basis = new (bc->zone->allocate(sizeof(ResolvedPromise)))
|
||||
ResolvedPromise(p->basis->value());
|
||||
p->basis = new(bc->zone) ResolvedPromise(p->basis->value());
|
||||
}
|
||||
}
|
||||
|
||||
@ -9724,8 +9718,7 @@ compileCall(MyThread* t, Context* c, ThunkIndex index, bool call = true)
|
||||
(call ? Call : Jump, TargetBytesPerWord, RegisterOperand, &scratch);
|
||||
} else {
|
||||
Assembler::Constant proc
|
||||
(new (c->zone.allocate(sizeof(ResolvedPromise)))
|
||||
ResolvedPromise(reinterpret_cast<intptr_t>(t->thunkTable[index])));
|
||||
(new(&c->zone) ResolvedPromise(reinterpret_cast<intptr_t>(t->thunkTable[index])));
|
||||
|
||||
a->apply
|
||||
(call ? LongCall : LongJump, TargetBytesPerWord, ConstantOperand, &proc);
|
||||
|
@ -576,7 +576,7 @@ count(Cell* c)
|
||||
Cell*
|
||||
cons(Context* c, void* value, Cell* next)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(Cell))) Cell(next, value);
|
||||
return new (c->zone) Cell(next, value);
|
||||
}
|
||||
|
||||
Cell*
|
||||
@ -648,7 +648,7 @@ Link*
|
||||
link(Context* c, Event* predecessor, Link* nextPredecessor, Event* successor,
|
||||
Link* nextSuccessor, ForkState* forkState)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(Link))) Link
|
||||
return new(c->zone) Link
|
||||
(predecessor, nextPredecessor, successor, nextSuccessor, forkState);
|
||||
}
|
||||
|
||||
@ -1602,15 +1602,13 @@ constantSite(Context* c, Promise* value);
|
||||
ShiftMaskPromise*
|
||||
shiftMaskPromise(Context* c, Promise* base, unsigned shift, int64_t mask)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(ShiftMaskPromise)))
|
||||
ShiftMaskPromise(base, shift, mask);
|
||||
return new(c->zone) ShiftMaskPromise(base, shift, mask);
|
||||
}
|
||||
|
||||
CombinedPromise*
|
||||
combinedPromise(Context* c, Promise* low, Promise* high)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(CombinedPromise)))
|
||||
CombinedPromise(low, high);
|
||||
return new(c->zone) CombinedPromise(low, high);
|
||||
}
|
||||
|
||||
class ConstantSite: public Site {
|
||||
@ -1686,14 +1684,13 @@ class ConstantSite: public Site {
|
||||
ConstantSite*
|
||||
constantSite(Context* c, Promise* value)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(ConstantSite))) ConstantSite(value);
|
||||
return new(c->zone) ConstantSite(value);
|
||||
}
|
||||
|
||||
ResolvedPromise*
|
||||
resolved(Context* c, int64_t value)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(ResolvedPromise)))
|
||||
ResolvedPromise(value);
|
||||
return new(c->zone) ResolvedPromise(value);
|
||||
}
|
||||
|
||||
ConstantSite*
|
||||
@ -1776,7 +1773,7 @@ class AddressSite: public Site {
|
||||
AddressSite*
|
||||
addressSite(Context* c, Promise* address)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(AddressSite))) AddressSite(address);
|
||||
return new(c->zone) AddressSite(address);
|
||||
}
|
||||
|
||||
RegisterSite*
|
||||
@ -1978,15 +1975,13 @@ registerSite(Context* c, int number)
|
||||
assert(c, (1 << number) & (c->arch->generalRegisterMask()
|
||||
| c->arch->floatRegisterMask()));
|
||||
|
||||
return new (c->zone->allocate(sizeof(RegisterSite)))
|
||||
RegisterSite(1 << number, number);
|
||||
return new(c->zone) RegisterSite(1 << number, number);
|
||||
}
|
||||
|
||||
RegisterSite*
|
||||
freeRegisterSite(Context* c, uint32_t mask)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(RegisterSite)))
|
||||
RegisterSite(mask, NoRegister);
|
||||
return new(c->zone) RegisterSite(mask, NoRegister);
|
||||
}
|
||||
|
||||
MemorySite*
|
||||
@ -2219,8 +2214,7 @@ class MemorySite: public Site {
|
||||
MemorySite*
|
||||
memorySite(Context* c, int base, int offset, int index, unsigned scale)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(MemorySite)))
|
||||
MemorySite(base, offset, index, scale);
|
||||
return new(c->zone) MemorySite(base, offset, index, scale);
|
||||
}
|
||||
|
||||
MemorySite*
|
||||
@ -2341,8 +2335,7 @@ read(Context* c, const SiteMask& mask, Value* successor = 0)
|
||||
{
|
||||
assert(c, (mask.typeMask != 1 << MemoryOperand) or mask.frameIndex >= 0);
|
||||
|
||||
return new (c->zone->allocate(sizeof(SingleRead)))
|
||||
SingleRead(mask, successor);
|
||||
return new(c->zone) SingleRead(mask, successor);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -2762,7 +2755,7 @@ class MultiRead: public Read {
|
||||
MultiRead*
|
||||
multiRead(Context* c)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(MultiRead))) MultiRead;
|
||||
return new(c->zone) MultiRead;
|
||||
}
|
||||
|
||||
class StubRead: public Read {
|
||||
@ -2811,7 +2804,7 @@ class StubRead: public Read {
|
||||
StubRead*
|
||||
stubRead(Context* c)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(StubRead))) StubRead;
|
||||
return new(c->zone) StubRead;
|
||||
}
|
||||
|
||||
Site*
|
||||
@ -3121,15 +3114,13 @@ clean(Context* c, Event* e, Stack* stack, Local* locals, Read* reads,
|
||||
CodePromise*
|
||||
codePromise(Context* c, Event* e)
|
||||
{
|
||||
return e->promises = new (c->zone->allocate(sizeof(CodePromise)))
|
||||
CodePromise(c, e->promises);
|
||||
return e->promises = new(c->zone) CodePromise(c, e->promises);
|
||||
}
|
||||
|
||||
CodePromise*
|
||||
codePromise(Context* c, Promise* offset)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(CodePromise)))
|
||||
CodePromise(c, offset);
|
||||
return new (c->zone) CodePromise(c, offset);
|
||||
}
|
||||
|
||||
void
|
||||
@ -3467,7 +3458,7 @@ appendCall(Context* c, Value* address, unsigned flags,
|
||||
Stack* argumentStack, unsigned argumentCount,
|
||||
unsigned stackArgumentFootprint)
|
||||
{
|
||||
append(c, new (c->zone->allocate(sizeof(CallEvent)))
|
||||
append(c, new(c->zone)
|
||||
CallEvent(c, address, flags, traceHandler, result,
|
||||
resultSize, argumentStack, argumentCount,
|
||||
stackArgumentFootprint));
|
||||
@ -3515,8 +3506,7 @@ class ReturnEvent: public Event {
|
||||
void
|
||||
appendReturn(Context* c, unsigned size, Value* value)
|
||||
{
|
||||
append(c, new (c->zone->allocate(sizeof(ReturnEvent)))
|
||||
ReturnEvent(c, size, value));
|
||||
append(c, new(c->zone) ReturnEvent(c, size, value));
|
||||
}
|
||||
|
||||
void
|
||||
@ -3714,7 +3704,7 @@ pickSiteOrMove(Context* c, Value* src, Value* dst, Site* nextWord,
|
||||
Value*
|
||||
value(Context* c, ValueType type, Site* site = 0, Site* target = 0)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(Value))) Value(site, target, type);
|
||||
return new(c->zone) Value(site, target, type);
|
||||
}
|
||||
|
||||
void
|
||||
@ -3914,7 +3904,7 @@ appendMove(Context* c, BinaryOperation type, unsigned srcSize,
|
||||
|
||||
assert(c, not thunk);
|
||||
|
||||
append(c, new (c->zone->allocate(sizeof(MoveEvent)))
|
||||
append(c, new(c->zone)
|
||||
MoveEvent
|
||||
(c, type, srcSize, srcSelectSize, src, dstSize, dst,
|
||||
SiteMask(srcTypeMask, srcRegisterMask, AnyFrameIndex),
|
||||
@ -4173,7 +4163,7 @@ snapshot(Context* c, Value* value, Snapshot* next)
|
||||
value, value->buddy, buffer);
|
||||
}
|
||||
|
||||
return new (c->zone->allocate(sizeof(Snapshot))) Snapshot(c, value, next);
|
||||
return new(c->zone) Snapshot(c, value, next);
|
||||
}
|
||||
|
||||
Snapshot*
|
||||
@ -4189,8 +4179,7 @@ makeSnapshots(Context* c, Value* value, Snapshot* next)
|
||||
Stack*
|
||||
stack(Context* c, Value* value, Stack* next)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(Stack)))
|
||||
Stack(next ? next->index + 1 : 0, value, next);
|
||||
return new(c->zone) Stack(next ? next->index + 1 : 0, value, next);
|
||||
}
|
||||
|
||||
Value*
|
||||
@ -4450,7 +4439,7 @@ appendCombine(Context* c, TernaryOperation type,
|
||||
resultSize, argumentStack, stackSize, 0);
|
||||
} else {
|
||||
append
|
||||
(c, new (c->zone->allocate(sizeof(CombineEvent)))
|
||||
(c, new(c->zone)
|
||||
CombineEvent
|
||||
(c, type,
|
||||
firstSize, first,
|
||||
@ -4568,7 +4557,7 @@ appendTranslate(Context* c, BinaryOperation type, unsigned firstSize,
|
||||
0, 0, result, resultSize, argumentStack,
|
||||
ceiling(firstSize, TargetBytesPerWord), 0);
|
||||
} else {
|
||||
append(c, new (c->zone->allocate(sizeof(TranslateEvent)))
|
||||
append(c, new(c->zone)
|
||||
TranslateEvent
|
||||
(c, type, firstSize, first, resultSize, result,
|
||||
SiteMask(firstTypeMask, firstRegisterMask, AnyFrameIndex),
|
||||
@ -4597,7 +4586,7 @@ void
|
||||
appendOperation(Context* c, Operation op)
|
||||
{
|
||||
append
|
||||
(c, new (c->zone->allocate(sizeof(OperationEvent))) OperationEvent(c, op));
|
||||
(c, new(c->zone) OperationEvent(c, op));
|
||||
}
|
||||
|
||||
class MemoryEvent: public Event {
|
||||
@ -4677,7 +4666,7 @@ void
|
||||
appendMemory(Context* c, Value* base, int displacement, Value* index,
|
||||
unsigned scale, Value* result)
|
||||
{
|
||||
append(c, new (c->zone->allocate(sizeof(MemoryEvent)))
|
||||
append(c, new(c->zone)
|
||||
MemoryEvent(c, base, displacement, index, scale, result));
|
||||
}
|
||||
|
||||
@ -4908,7 +4897,7 @@ appendBranch(Context* c, TernaryOperation type, unsigned size, Value* first,
|
||||
result, address);
|
||||
} else {
|
||||
append
|
||||
(c, new (c->zone->allocate(sizeof(BranchEvent)))
|
||||
(c, new(c->zone)
|
||||
BranchEvent
|
||||
(c, type, size, first, second, address,
|
||||
SiteMask(firstTypeMask, firstRegisterMask, AnyFrameIndex),
|
||||
@ -4972,8 +4961,7 @@ void
|
||||
appendJump(Context* c, UnaryOperation type, Value* address, bool exit = false,
|
||||
bool cleanLocals = false)
|
||||
{
|
||||
append(c, new (c->zone->allocate(sizeof(JumpEvent)))
|
||||
JumpEvent(c, type, address, exit, cleanLocals));
|
||||
append(c, new(c->zone) JumpEvent(c, type, address, exit, cleanLocals));
|
||||
}
|
||||
|
||||
class BoundsCheckEvent: public Event {
|
||||
@ -5051,8 +5039,7 @@ void
|
||||
appendBoundsCheck(Context* c, Value* object, unsigned lengthOffset,
|
||||
Value* index, intptr_t handler)
|
||||
{
|
||||
append(c, new (c->zone->allocate(sizeof(BoundsCheckEvent)))
|
||||
BoundsCheckEvent(c, object, lengthOffset, index, handler));
|
||||
append(c, new(c->zone) BoundsCheckEvent(c, object, lengthOffset, index, handler));
|
||||
}
|
||||
|
||||
class FrameSiteEvent: public Event {
|
||||
@ -5078,8 +5065,7 @@ class FrameSiteEvent: public Event {
|
||||
void
|
||||
appendFrameSite(Context* c, Value* value, int index)
|
||||
{
|
||||
append(c, new (c->zone->allocate(sizeof(FrameSiteEvent)))
|
||||
FrameSiteEvent(c, value, index));
|
||||
append(c, new(c->zone) FrameSiteEvent(c, value, index));
|
||||
}
|
||||
|
||||
unsigned
|
||||
@ -5157,8 +5143,7 @@ class BuddyEvent: public Event {
|
||||
void
|
||||
appendBuddy(Context* c, Value* original, Value* buddy)
|
||||
{
|
||||
append(c, new (c->zone->allocate(sizeof(BuddyEvent)))
|
||||
BuddyEvent(c, original, buddy));
|
||||
append(c, new(c->zone) BuddyEvent(c, original, buddy));
|
||||
}
|
||||
|
||||
class SaveLocalsEvent: public Event {
|
||||
@ -5183,8 +5168,7 @@ class SaveLocalsEvent: public Event {
|
||||
void
|
||||
appendSaveLocals(Context* c)
|
||||
{
|
||||
append(c, new (c->zone->allocate(sizeof(SaveLocalsEvent)))
|
||||
SaveLocalsEvent(c));
|
||||
append(c, new(c->zone) SaveLocalsEvent(c));
|
||||
}
|
||||
|
||||
class DummyEvent: public Event {
|
||||
@ -5210,7 +5194,7 @@ appendDummy(Context* c)
|
||||
c->stack = i->stack;
|
||||
c->locals = i->locals;
|
||||
|
||||
append(c, new (c->zone->allocate(sizeof(DummyEvent))) DummyEvent(c));
|
||||
append(c, new(c->zone) DummyEvent(c));
|
||||
|
||||
c->stack = stack;
|
||||
c->locals = locals;
|
||||
@ -5746,7 +5730,7 @@ class Block {
|
||||
Block*
|
||||
block(Context* c, Event* head)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(Block))) Block(head);
|
||||
return new(c->zone) Block(head);
|
||||
}
|
||||
|
||||
void
|
||||
@ -6057,8 +6041,7 @@ class MyCompiler: public Compiler {
|
||||
}
|
||||
|
||||
virtual Subroutine* startSubroutine() {
|
||||
return c.subroutine = new (c.zone->allocate(sizeof(MySubroutine)))
|
||||
MySubroutine;
|
||||
return c.subroutine = new(c.zone) MySubroutine;
|
||||
}
|
||||
|
||||
virtual void returnFromSubroutine(Subroutine* subroutine, Operand* address) {
|
||||
@ -6199,7 +6182,7 @@ class MyCompiler: public Compiler {
|
||||
}
|
||||
|
||||
virtual Promise* machineIp(unsigned logicalIp) {
|
||||
return new (c.zone->allocate(sizeof(IpPromise))) IpPromise(&c, logicalIp);
|
||||
return new(c.zone) IpPromise(&c, logicalIp);
|
||||
}
|
||||
|
||||
virtual Promise* poolAppend(intptr_t value) {
|
||||
@ -6207,12 +6190,9 @@ class MyCompiler: public Compiler {
|
||||
}
|
||||
|
||||
virtual Promise* poolAppendPromise(Promise* value) {
|
||||
Promise* p = new (c.zone->allocate(sizeof(PoolPromise)))
|
||||
PoolPromise(&c, c.constantCount);
|
||||
Promise* p = new(c.zone) PoolPromise(&c, c.constantCount);
|
||||
|
||||
ConstantPoolNode* constant
|
||||
= new (c.zone->allocate(sizeof(ConstantPoolNode)))
|
||||
ConstantPoolNode(value);
|
||||
ConstantPoolNode* constant = new (c.zone) ConstantPoolNode(value);
|
||||
|
||||
if (c.firstConstant) {
|
||||
c.lastConstant->next = constant;
|
||||
@ -6997,8 +6977,7 @@ Compiler*
|
||||
makeCompiler(System* system, Assembler* assembler, Zone* zone,
|
||||
Compiler::Client* client)
|
||||
{
|
||||
return new (zone->allocate(sizeof(local::MyCompiler)))
|
||||
local::MyCompiler(system, assembler, zone, client);
|
||||
return new(zone) local::MyCompiler(system, assembler, zone, client);
|
||||
}
|
||||
|
||||
} // namespace vm
|
||||
|
@ -233,7 +233,7 @@ class Context {
|
||||
public:
|
||||
Context(System* s, Allocator* a, Zone* zone):
|
||||
s(s), zone(zone), client(0), code(s, a, 1024), tasks(0), result(0),
|
||||
firstBlock(new (zone->allocate(sizeof(MyBlock))) MyBlock(this, 0)),
|
||||
firstBlock(new(zone) MyBlock(this, 0)),
|
||||
lastBlock(firstBlock), jumpOffsetHead(0), jumpOffsetTail(0),
|
||||
constantPool(0), constantPoolCount(0)
|
||||
{ }
|
||||
@ -349,8 +349,7 @@ class Offset: public Promise {
|
||||
Promise*
|
||||
offset(Context* c)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(Offset)))
|
||||
Offset(c, c->lastBlock, c->code.length());
|
||||
return new(c->zone) Offset(c, c->lastBlock, c->code.length());
|
||||
}
|
||||
|
||||
bool
|
||||
@ -468,14 +467,13 @@ void
|
||||
appendOffsetTask(Context* c, Promise* promise, Promise* instructionOffset,
|
||||
bool conditional)
|
||||
{
|
||||
OffsetTask* task = new (c->zone->allocate(sizeof(OffsetTask))) OffsetTask
|
||||
(c->tasks, promise, instructionOffset, conditional);
|
||||
OffsetTask* task = new(c->zone) OffsetTask(c->tasks, promise, instructionOffset, conditional);
|
||||
|
||||
c->tasks = task;
|
||||
|
||||
if (conditional) {
|
||||
JumpOffset* offset = new (c->zone->allocate(sizeof(JumpOffset))) JumpOffset
|
||||
(c->lastBlock, task, c->code.length() - c->lastBlock->offset);
|
||||
JumpOffset* offset =
|
||||
new(c->zone) JumpOffset(c->lastBlock, task, c->code.length() - c->lastBlock->offset);
|
||||
|
||||
if (c->lastBlock->jumpOffsetTail) {
|
||||
c->lastBlock->jumpOffsetTail->next = offset;
|
||||
@ -490,7 +488,7 @@ void
|
||||
appendJumpEvent(Context* c, MyBlock* b, unsigned offset, JumpOffset* head,
|
||||
JumpOffset* tail)
|
||||
{
|
||||
JumpEvent* e = new (c->zone->allocate(sizeof(JumpEvent))) JumpEvent
|
||||
JumpEvent* e = new(c->zone) JumpEvent
|
||||
(head, tail, offset);
|
||||
|
||||
if (b->jumpEventTail) {
|
||||
@ -858,8 +856,7 @@ void
|
||||
appendImmediateTask(Context* c, Promise* promise, Promise* offset,
|
||||
unsigned size, unsigned promiseOffset, bool address)
|
||||
{
|
||||
c->tasks = new (c->zone->allocate(sizeof(ImmediateTask))) ImmediateTask
|
||||
(c->tasks, promise, offset, size, promiseOffset, address);
|
||||
c->tasks = new(c->zone) ImmediateTask(c->tasks, promise, offset, size, promiseOffset, address);
|
||||
}
|
||||
|
||||
class ConstantPoolEntry: public Promise {
|
||||
@ -890,8 +887,7 @@ class ConstantPoolEntry: public Promise {
|
||||
ConstantPoolEntry*
|
||||
appendConstantPoolEntry(Context* c, Promise* constant)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(ConstantPoolEntry)))
|
||||
ConstantPoolEntry(c, constant);
|
||||
return new (c->zone) ConstantPoolEntry(c, constant);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1785,8 +1781,7 @@ branchCM(Context* c, TernaryOperation op, unsigned size,
|
||||
ShiftMaskPromise*
|
||||
shiftMaskPromise(Context* c, Promise* base, unsigned shift, int64_t mask)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(ShiftMaskPromise)))
|
||||
ShiftMaskPromise(base, shift, mask);
|
||||
return new (c->zone) ShiftMaskPromise(base, shift, mask);
|
||||
}
|
||||
|
||||
void
|
||||
@ -2462,8 +2457,7 @@ class MyAssembler: public Assembler {
|
||||
Register stack(StackRegister);
|
||||
Memory stackLimit(ThreadRegister, stackLimitOffsetFromThread);
|
||||
Constant handlerConstant
|
||||
(new (c.zone->allocate(sizeof(ResolvedPromise)))
|
||||
ResolvedPromise(handler));
|
||||
(new(c.zone) ResolvedPromise(handler));
|
||||
branchRM(&c, JumpIfGreaterOrEqual, TargetBytesPerWord, &stack, &stackLimit,
|
||||
&handlerConstant);
|
||||
}
|
||||
@ -2783,8 +2777,7 @@ class MyAssembler: public Assembler {
|
||||
MyBlock* b = c.lastBlock;
|
||||
b->size = c.code.length() - b->offset;
|
||||
if (startNew) {
|
||||
c.lastBlock = new (c.zone->allocate(sizeof(MyBlock)))
|
||||
MyBlock(&c, c.code.length());
|
||||
c.lastBlock = new(c.zone) MyBlock(&c, c.code.length());
|
||||
} else {
|
||||
c.lastBlock = 0;
|
||||
}
|
||||
@ -2855,9 +2848,9 @@ Assembler*
|
||||
makeAssembler(System* system, Allocator* allocator, Zone* zone,
|
||||
Assembler::Architecture* architecture)
|
||||
{
|
||||
return new (zone->allocate(sizeof(MyAssembler)))
|
||||
MyAssembler(system, allocator, zone,
|
||||
static_cast<MyArchitecture*>(architecture));
|
||||
return
|
||||
new(zone) MyAssembler(system, allocator, zone,
|
||||
static_cast<MyArchitecture*>(architecture));
|
||||
}
|
||||
|
||||
} // namespace vm
|
||||
|
@ -58,8 +58,7 @@ class TreeContext {
|
||||
TreeContext::Path*
|
||||
path(TreeContext* c, object node, TreeContext::Path* next)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(TreeContext::Path)))
|
||||
TreeContext::Path(node, next);
|
||||
return new(c->zone) TreeContext::Path(node, next);
|
||||
}
|
||||
|
||||
inline object
|
||||
|
38
src/x86.cpp
38
src/x86.cpp
@ -157,7 +157,7 @@ class Context {
|
||||
public:
|
||||
Context(System* s, Allocator* a, Zone* zone, ArchitectureContext* ac):
|
||||
s(s), zone(zone), client(0), code(s, a, 1024), tasks(0), result(0),
|
||||
firstBlock(new (zone->allocate(sizeof(MyBlock))) MyBlock(0)),
|
||||
firstBlock(new(zone) MyBlock(0)),
|
||||
lastBlock(firstBlock), ac(ac)
|
||||
{ }
|
||||
|
||||
@ -207,8 +207,7 @@ expect(Context* c, bool v)
|
||||
ResolvedPromise*
|
||||
resolved(Context* c, int64_t value)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(ResolvedPromise)))
|
||||
ResolvedPromise(value);
|
||||
return new(c->zone) ResolvedPromise(value);
|
||||
}
|
||||
|
||||
class CodePromise: public Promise {
|
||||
@ -234,7 +233,7 @@ class CodePromise: public Promise {
|
||||
CodePromise*
|
||||
codePromise(Context* c, unsigned offset)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(CodePromise))) CodePromise(c, offset);
|
||||
return new (c->zone) CodePromise(c, offset);
|
||||
}
|
||||
|
||||
class Offset: public Promise {
|
||||
@ -268,8 +267,7 @@ class Offset: public Promise {
|
||||
Promise*
|
||||
offset(Context* c)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(Offset)))
|
||||
Offset(c, c->lastBlock, c->code.length(), c->lastBlock->lastPadding);
|
||||
return new(c->zone) Offset(c, c->lastBlock, c->code.length(), c->lastBlock->lastPadding);
|
||||
}
|
||||
|
||||
class Task {
|
||||
@ -346,8 +344,8 @@ void
|
||||
appendOffsetTask(Context* c, Promise* promise, Promise* instructionOffset,
|
||||
unsigned instructionSize)
|
||||
{
|
||||
OffsetTask* task = new (c->zone->allocate(sizeof(OffsetTask))) OffsetTask
|
||||
(c->tasks, promise, instructionOffset, instructionSize);
|
||||
OffsetTask* task =
|
||||
new(c->zone) OffsetTask(c->tasks, promise, instructionOffset, instructionSize);
|
||||
|
||||
c->tasks = task;
|
||||
}
|
||||
@ -418,7 +416,7 @@ void
|
||||
appendImmediateTask(Context* c, Promise* promise, Promise* offset,
|
||||
unsigned size, unsigned promiseOffset = 0)
|
||||
{
|
||||
c->tasks = new (c->zone->allocate(sizeof(ImmediateTask))) ImmediateTask
|
||||
c->tasks = new(c->zone) ImmediateTask
|
||||
(c->tasks, promise, offset, size, promiseOffset);
|
||||
}
|
||||
|
||||
@ -839,7 +837,7 @@ callM(Context* c, unsigned size UNUSED, Assembler::Memory* a)
|
||||
void
|
||||
alignedCallC(Context* c, unsigned size, Assembler::Constant* a)
|
||||
{
|
||||
new (c->zone->allocate(sizeof(AlignmentPadding))) AlignmentPadding(c, 1, 4);
|
||||
new(c->zone) AlignmentPadding(c, 1, 4);
|
||||
callC(c, size, a);
|
||||
}
|
||||
|
||||
@ -849,8 +847,7 @@ alignedLongCallC(Context* c, unsigned size, Assembler::Constant* a)
|
||||
assert(c, size == TargetBytesPerWord);
|
||||
|
||||
if (TargetBytesPerWord == 8) {
|
||||
new (c->zone->allocate(sizeof(AlignmentPadding)))
|
||||
AlignmentPadding(c, 2, 8);
|
||||
new (c->zone) AlignmentPadding(c, 2, 8);
|
||||
longCallC(c, size, a);
|
||||
} else {
|
||||
alignedCallC(c, size, a);
|
||||
@ -860,7 +857,7 @@ alignedLongCallC(Context* c, unsigned size, Assembler::Constant* a)
|
||||
void
|
||||
alignedJumpC(Context* c, unsigned size, Assembler::Constant* a)
|
||||
{
|
||||
new (c->zone->allocate(sizeof(AlignmentPadding))) AlignmentPadding(c, 1, 4);
|
||||
new (c->zone) AlignmentPadding(c, 1, 4);
|
||||
jumpC(c, size, a);
|
||||
}
|
||||
|
||||
@ -870,8 +867,7 @@ alignedLongJumpC(Context* c, unsigned size, Assembler::Constant* a)
|
||||
assert(c, size == TargetBytesPerWord);
|
||||
|
||||
if (TargetBytesPerWord == 8) {
|
||||
new (c->zone->allocate(sizeof(AlignmentPadding)))
|
||||
AlignmentPadding(c, 2, 8);
|
||||
new (c->zone) AlignmentPadding(c, 2, 8);
|
||||
longJumpC(c, size, a);
|
||||
} else {
|
||||
alignedJumpC(c, size, a);
|
||||
@ -1296,8 +1292,7 @@ moveAR(Context* c, unsigned aSize, Assembler::Address* a,
|
||||
ShiftMaskPromise*
|
||||
shiftMaskPromise(Context* c, Promise* base, unsigned shift, int64_t mask)
|
||||
{
|
||||
return new (c->zone->allocate(sizeof(ShiftMaskPromise)))
|
||||
ShiftMaskPromise(base, shift, mask);
|
||||
return new(c->zone) ShiftMaskPromise(base, shift, mask);
|
||||
}
|
||||
|
||||
void
|
||||
@ -3707,8 +3702,7 @@ class MyAssembler: public Assembler {
|
||||
MyBlock* b = c.lastBlock;
|
||||
b->size = c.code.length() - b->offset;
|
||||
if (startNew) {
|
||||
c.lastBlock = new (c.zone->allocate(sizeof(MyBlock)))
|
||||
MyBlock(c.code.length());
|
||||
c.lastBlock = new(c.zone) MyBlock(c.code.length());
|
||||
} else {
|
||||
c.lastBlock = 0;
|
||||
}
|
||||
@ -3752,9 +3746,9 @@ Assembler*
|
||||
makeAssembler(System* system, Allocator* allocator, Zone* zone,
|
||||
Assembler::Architecture* architecture)
|
||||
{
|
||||
return new (zone->allocate(sizeof(local::MyAssembler)))
|
||||
local::MyAssembler(system, allocator, zone,
|
||||
static_cast<local::MyArchitecture*>(architecture));
|
||||
return
|
||||
new(zone) local::MyAssembler(system, allocator, zone,
|
||||
static_cast<local::MyArchitecture*>(architecture));
|
||||
}
|
||||
|
||||
} // namespace vm
|
||||
|
Loading…
Reference in New Issue
Block a user