diff -r 735503e448a0 -r 050939c6181e jitcraft/BytecodeEmitter.cpp --- a/jitcraft/BytecodeEmitter.cpp Tue Jul 03 13:53:34 2012 -0400 +++ b/jitcraft/BytecodeEmitter.cpp Wed Jul 04 19:39:00 2012 -0400 @@ -1,4 +1,5 @@ -/* +/* vim: set ts=4 sw=4 tw=99 et: + * * Copyright (C) 2012 David Anderson * * This file is part of JITCraft. @@ -22,13 +23,13 @@ using namespace jc; -BytecodeEmitter::BytecodeEmitter() - : buffer_(inline_buffer_), +BytecodeEmitter::BytecodeEmitter(PoolAllocator &pool) + : pool_(pool), + buffer_(inline_buffer_), buffer_pos_(buffer_), buffer_end_(buffer_pos_ + ARRAY_LENGTH(inline_buffer_)), oom_(false), - maxStackDepth_(0), - stackDepth_(0) + maxStackDepth_(0) { } @@ -67,3 +68,27 @@ return true; } +void +BytecodeEmitter::recordOops() +{ + OopRecord *record = new (pool_) OopRecord(oopMap_.size(), position()); + + record->slots = (bool *)pool_.allocate(record->depth); + if (!record->slots) { + oom_ = true; + return; + } + + bool hadOops = false; + for (size_t i = 0; i < oopMap_.size(); i++) { + bool bit = oopMap_[i]; + record->slots[i] = bit; + hadOops |= bit; + } + + if (!hadOops) + return; + + oopRecords_.push_back(record); +} +