1.1 --- a/jitcraft/BytecodeEmitter.cpp Tue Jul 03 13:53:34 2012 -0400
1.2 +++ b/jitcraft/BytecodeEmitter.cpp Wed Jul 04 19:39:00 2012 -0400
1.3 @@ -1,4 +1,5 @@
1.4 -/*
1.5 +/* vim: set ts=4 sw=4 tw=99 et:
1.6 + *
1.7 * Copyright (C) 2012 David Anderson
1.8 *
1.9 * This file is part of JITCraft.
1.10 @@ -22,13 +23,13 @@
1.11
1.12 using namespace jc;
1.13
1.14 -BytecodeEmitter::BytecodeEmitter()
1.15 - : buffer_(inline_buffer_),
1.16 +BytecodeEmitter::BytecodeEmitter(PoolAllocator &pool)
1.17 + : pool_(pool),
1.18 + buffer_(inline_buffer_),
1.19 buffer_pos_(buffer_),
1.20 buffer_end_(buffer_pos_ + ARRAY_LENGTH(inline_buffer_)),
1.21 oom_(false),
1.22 - maxStackDepth_(0),
1.23 - stackDepth_(0)
1.24 + maxStackDepth_(0)
1.25 {
1.26 }
1.27
1.28 @@ -67,3 +68,27 @@
1.29 return true;
1.30 }
1.31
1.32 +void
1.33 +BytecodeEmitter::recordOops()
1.34 +{
1.35 + OopRecord *record = new (pool_) OopRecord(oopMap_.size(), position());
1.36 +
1.37 + record->slots = (bool *)pool_.allocate(record->depth);
1.38 + if (!record->slots) {
1.39 + oom_ = true;
1.40 + return;
1.41 + }
1.42 +
1.43 + bool hadOops = false;
1.44 + for (size_t i = 0; i < oopMap_.size(); i++) {
1.45 + bool bit = oopMap_[i];
1.46 + record->slots[i] = bit;
1.47 + hadOops |= bit;
1.48 + }
1.49 +
1.50 + if (!hadOops)
1.51 + return;
1.52 +
1.53 + oopRecords_.push_back(record);
1.54 +}
1.55 +