Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/analysis/function_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ LivenessAnalysis::LivenessAnalysis(CFG* cfg, const CodeConstants& code_constants

for (CFGBlock* b : cfg->blocks) {
auto visitor = new LivenessBBVisitor(this); // livenessCache unique_ptr will delete it.
for (BST_stmt* stmt : b->body) {
for (BST_stmt* stmt : *b) {
stmt->accept(visitor);
}
liveness_cache.insert(std::make_pair(b, std::unique_ptr<LivenessBBVisitor>(visitor)));
Expand Down Expand Up @@ -257,8 +257,8 @@ class DefinednessVisitor : public NoopBSTVisitor {
void DefinednessBBAnalyzer::processBB(Map& starting, CFGBlock* block) const {
DefinednessVisitor visitor(code_constants, starting);

for (int i = 0; i < block->body.size(); i++) {
block->body[i]->accept(&visitor);
for (BST_stmt* stmt : *block) {
stmt->accept(&visitor);
}

if (VERBOSITY("analysis") >= 3) {
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/type_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ class BasicBlockTypePropagator : public StmtVisitor {
speculation(speculation) {}

void run() {
for (int i = 0; i < block->body.size(); i++) {
block->body[i]->accept_stmt(this);
for (BST_stmt* stmt : *block) {
stmt->accept_stmt(this);
}
}

Expand Down
17 changes: 8 additions & 9 deletions src/codegen/ast_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ Box* ASTInterpreter::executeInner(ASTInterpreter& interpreter, CFGBlock* start_b
assert((start_block == NULL) == (start_at == NULL));
if (start_block == NULL) {
start_block = interpreter.source_info->cfg->getStartingBlock();
start_at = start_block->body[0];
start_at = start_block->body;
}

// Important that this happens after RegisterHelper:
Expand All @@ -395,7 +395,7 @@ Box* ASTInterpreter::executeInner(ASTInterpreter& interpreter, CFGBlock* start_b
if (!from_start) {
interpreter.current_block = start_block;
bool started = false;
for (auto s : start_block->body) {
for (auto s : *start_block) {
if (!started) {
if (s != start_at)
continue;
Expand Down Expand Up @@ -449,7 +449,7 @@ Box* ASTInterpreter::executeInner(ASTInterpreter& interpreter, CFGBlock* start_b
interpreter.startJITing(interpreter.current_block);
}

for (BST_stmt* s : interpreter.current_block->body) {
for (BST_stmt* s : *interpreter.current_block) {
interpreter.setCurrentStatement(s);
if (interpreter.jit)
interpreter.jit->emitSetCurrentInst(s);
Expand Down Expand Up @@ -2112,7 +2112,7 @@ extern "C" Box* astInterpretDeoptFromASM(BoxedCode* code, BST_stmt* enclosing_st
if (enclosing_stmt->type == BST_TYPE::Invoke) {
auto invoke = bst_cast<BST_Invoke>(enclosing_stmt);
start_block = invoke->normal_dest;
starting_statement = start_block->body[0];
starting_statement = start_block->body;
enclosing_stmt = invoke->stmt;
} else if (enclosing_stmt->has_dest_vreg()) {
int vreg_dst = ((BST_stmt_with_dest*)enclosing_stmt)->vreg_dst;
Expand All @@ -2127,12 +2127,11 @@ extern "C" Box* astInterpretDeoptFromASM(BoxedCode* code, BST_stmt* enclosing_st
if (start_block == NULL) {
// TODO innefficient
for (auto block : code->source->cfg->blocks) {
int n = block->body.size();
for (int i = 0; i < n; i++) {
if (block->body[i] == enclosing_stmt) {
ASSERT(i + 1 < n, "how could we deopt from a non-invoke terminator?");
for (auto it = block->begin(), it_end = block->end(); it != it_end; ++it) {
if (*it == enclosing_stmt) {
ASSERT(!(*it)->is_terminator(), "how could we deopt from a non-invoke terminator?");
start_block = block;
starting_statement = block->body[i + 1];
starting_statement = *(++it);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ SourceInfo::SourceInfo(BoxedModule* m, ScopingResults scoping, FutureFlags futur
}

SourceInfo::~SourceInfo() {
// TODO: release memory..
delete cfg;
}

void FunctionAddressRegistry::registerFunction(const std::string& name, void* addr, int length,
Expand Down
8 changes: 4 additions & 4 deletions src/codegen/irgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc

// Function-entry safepoint:
// TODO might be more efficient to do post-call safepoints?
generator->doSafePoint(block->body[0]);
generator->doSafePoint(block->body);
} else if (entry_descriptor && block == entry_descriptor->backedge->target) {
assert(block->predecessors.size() > 1);
assert(osr_entry_block);
Expand Down Expand Up @@ -733,7 +733,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
// are disallowed

auto pred = block->predecessors[0];
auto last_inst = pred->body.back();
auto last_inst = pred->getLastStmt();

SymbolTable* sym_table = ending_symbol_tables[pred];
bool created_new_sym_table = false;
Expand Down Expand Up @@ -800,7 +800,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
if (predecessor->idx > block->idx) {
// Loop safepoint:
// TODO does it matter which side of the backedge these are on?
generator->doSafePoint(block->body[0]);
generator->doSafePoint(block->body);
break;
}
}
Expand All @@ -815,7 +815,7 @@ static void emitBBs(IRGenState* irstate, TypeAnalysis* types, const OSREntryDesc
llvm_exit_blocks[block] = ending_st.ending_block;

if (ending_st.exception_state.size()) {
BST_stmt* last_stmt = block->body.back();
BST_stmt* last_stmt = block->getLastStmt();
assert(last_stmt->type == BST_TYPE::Invoke);
CFGBlock* exc_block = bst_cast<BST_Invoke>(last_stmt)->exc_dest;
assert(!incoming_exception_state.count(exc_block));
Expand Down
7 changes: 3 additions & 4 deletions src/codegen/irgen/irgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2951,18 +2951,17 @@ class IRGeneratorImpl : public IRGenerator {
}
printf("\n");
}
for (int i = 0; i < block->body.size(); i++) {
for (BST_stmt* stmt : *block) {
if (state == DEAD)
break;
assert(state != FINISHED);

#if ENABLE_SAMPLING_PROFILER
auto stmt = block->body[i];
if (stmt->type != BST_TYPE::Landigpad && stmt->lineno > 0)
doSafePoint(block->body[i]);
doSafePoint(stmt);
#endif

doStmt(block->body[i], UnwindInfo(irstate->getCode(), block->body[i], NULL));
doStmt(stmt, UnwindInfo(irstate->getCode(), stmt, NULL));
}
if (VERBOSITY("irgenerator") >= 2) { // print ending symbol table
printf(" %d fini:", block->idx);
Expand Down
19 changes: 19 additions & 0 deletions src/core/bst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ template <class T> static void visitVector(const std::vector<T*>& vec, BSTVisito
}
}

void BST_stmt::accept(BSTVisitor* v) {
switch (type) {
#define DISPATCH_ACCEPT(x, y) \
case BST_TYPE::x: \
return bst_cast<BST_##x>(this)->accept(v);
FOREACH_TYPE(DISPATCH_ACCEPT)
};
}

void BST_stmt::accept_stmt(StmtVisitor* v) {
switch (type) {
#define DISPATCH_ACCEPT_STMT(x, y) \
case BST_TYPE::x: \
return bst_cast<BST_##x>(this)->accept_stmt(v);
FOREACH_TYPE(DISPATCH_ACCEPT_STMT)
};
}


void BST_Assert::accept(BSTVisitor* v) {
bool skip = v->visit_assert(this);
if (skip)
Expand Down
Loading