Commit eb501e00 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Don't switch exception styles in some cases

if we OSR out of a function, make sure we use the same exception
style for the OSR'd version.

We could also have the OSR exit code deal with switching exception
styles, but for now it doesn't feel worth it.
parent 92598427
...@@ -985,6 +985,7 @@ $1: nosearch_$1 ...@@ -985,6 +985,7 @@ $1: nosearch_$1
$1: $(TESTS_DIR)/nosearch_$1 ; $1: $(TESTS_DIR)/nosearch_$1 ;
$1: $(TEST_DIR)/cpython/nosearch_$1 ; $1: $(TEST_DIR)/cpython/nosearch_$1 ;
$1: $(TEST_DIR)/testsuite/integration/nosearch_$1 ; $1: $(TEST_DIR)/testsuite/integration/nosearch_$1 ;
$1: $(TEST_DIR)/testsuite/extra/nosearch_$1 ;
$1: $(TEST_DIR)/extra/nosearch_$1 ; $1: $(TEST_DIR)/extra/nosearch_$1 ;
$1: ./microbenchmarks/nosearch_$1 ; $1: ./microbenchmarks/nosearch_$1 ;
$1: ./minibenchmarks/nosearch_$1 ; $1: ./minibenchmarks/nosearch_$1 ;
......
...@@ -714,7 +714,7 @@ Box* ASTInterpreter::doOSR(AST_Jump* node) { ...@@ -714,7 +714,7 @@ Box* ASTInterpreter::doOSR(AST_Jump* node) {
sorted_symbol_table[source_info->getInternedStrings().get(FRAME_INFO_PTR_NAME)] = (Box*)&frame_info; sorted_symbol_table[source_info->getInternedStrings().get(FRAME_INFO_PTR_NAME)] = (Box*)&frame_info;
if (found_entry == nullptr) { if (found_entry == nullptr) {
OSREntryDescriptor* entry = OSREntryDescriptor::create(clfunc, node); OSREntryDescriptor* entry = OSREntryDescriptor::create(clfunc, node, CXX);
for (auto& it : sorted_symbol_table) { for (auto& it : sorted_symbol_table) {
if (isIsDefinedName(it.first)) if (isIsDefinedName(it.first))
......
...@@ -184,7 +184,8 @@ static void compileIR(CompiledFunction* cf, EffortLevel effort) { ...@@ -184,7 +184,8 @@ static void compileIR(CompiledFunction* cf, EffortLevel effort) {
// should only be called after checking to see if the other versions would work. // should only be called after checking to see if the other versions would work.
// The codegen_lock needs to be held in W mode before calling this function: // The codegen_lock needs to be held in W mode before calling this function:
CompiledFunction* compileFunction(CLFunction* f, FunctionSpecialization* spec, EffortLevel effort, CompiledFunction* compileFunction(CLFunction* f, FunctionSpecialization* spec, EffortLevel effort,
const OSREntryDescriptor* entry_descriptor) { const OSREntryDescriptor* entry_descriptor, bool force_exception_style,
ExceptionStyle forced_exception_style) {
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_compileFunction"); UNAVOIDABLE_STAT_TIMER(t0, "us_timer_compileFunction");
Timer _t("for compileFunction()", 1000); Timer _t("for compileFunction()", 1000);
...@@ -197,13 +198,17 @@ CompiledFunction* compileFunction(CLFunction* f, FunctionSpecialization* spec, E ...@@ -197,13 +198,17 @@ CompiledFunction* compileFunction(CLFunction* f, FunctionSpecialization* spec, E
ASSERT(f->versions.size() < 20, "%s %ld", name.c_str(), f->versions.size()); ASSERT(f->versions.size() < 20, "%s %ld", name.c_str(), f->versions.size());
ExceptionStyle exception_style = CXX; ExceptionStyle exception_style;
if (FORCE_LLVM_CAPI_THROWS) if (force_exception_style)
exception_style = forced_exception_style;
else if (FORCE_LLVM_CAPI_THROWS)
exception_style = CAPI; exception_style = CAPI;
if (name == "next") else if (name == "next")
exception_style = CAPI; exception_style = CAPI;
if (f->propagated_cxx_exceptions >= 100) else if (f->propagated_cxx_exceptions >= 100)
exception_style = CAPI; exception_style = CAPI;
else
exception_style = CXX;
if (VERBOSITY("irgen") >= 1) { if (VERBOSITY("irgen") >= 1) {
std::string s; std::string s;
...@@ -766,9 +771,8 @@ static CompiledFunction* _doReopt(CompiledFunction* cf, EffortLevel new_effort) ...@@ -766,9 +771,8 @@ static CompiledFunction* _doReopt(CompiledFunction* cf, EffortLevel new_effort)
if (versions[i] == cf) { if (versions[i] == cf) {
versions.erase(versions.begin() + i); versions.erase(versions.begin() + i);
CompiledFunction* new_cf // this pushes the new CompiledVersion to the back of the version list
= compileFunction(clfunc, cf->spec, new_effort, CompiledFunction* new_cf = compileFunction(clfunc, cf->spec, new_effort, NULL, true, cf->exception_style);
NULL); // this pushes the new CompiledVersion to the back of the version list
cf->dependent_callsites.invalidateAll(); cf->dependent_callsites.invalidateAll();
...@@ -799,7 +803,8 @@ CompiledFunction* compilePartialFuncInternal(OSRExit* exit) { ...@@ -799,7 +803,8 @@ CompiledFunction* compilePartialFuncInternal(OSRExit* exit) {
CompiledFunction*& new_cf = clfunc->osr_versions[exit->entry]; CompiledFunction*& new_cf = clfunc->osr_versions[exit->entry];
if (new_cf == NULL) { if (new_cf == NULL) {
EffortLevel new_effort = EffortLevel::MAXIMAL; EffortLevel new_effort = EffortLevel::MAXIMAL;
CompiledFunction* compiled = compileFunction(clfunc, NULL, new_effort, exit->entry); CompiledFunction* compiled
= compileFunction(clfunc, NULL, new_effort, exit->entry, true, exit->entry->exception_style);
assert(compiled == new_cf); assert(compiled == new_cf);
stat_osr_compiles.log(); stat_osr_compiles.log();
...@@ -809,7 +814,9 @@ CompiledFunction* compilePartialFuncInternal(OSRExit* exit) { ...@@ -809,7 +814,9 @@ CompiledFunction* compilePartialFuncInternal(OSRExit* exit) {
} }
void* compilePartialFunc(OSRExit* exit) { void* compilePartialFunc(OSRExit* exit) {
return compilePartialFuncInternal(exit)->code; CompiledFunction* new_cf = compilePartialFuncInternal(exit);
assert(new_cf->exception_style == exit->entry->exception_style);
return new_cf->code;
} }
......
...@@ -2140,7 +2140,7 @@ private: ...@@ -2140,7 +2140,7 @@ private:
// Emitting the actual OSR: // Emitting the actual OSR:
emitter.getBuilder()->SetInsertPoint(onramp); emitter.getBuilder()->SetInsertPoint(onramp);
OSREntryDescriptor* entry = OSREntryDescriptor::create(irstate->getCL(), osr_key); OSREntryDescriptor* entry = OSREntryDescriptor::create(irstate->getCL(), osr_key, irstate->getExceptionStyle());
OSRExit* exit = new OSRExit(entry); OSRExit* exit = new OSRExit(entry);
llvm::Value* partial_func = emitter.getBuilder()->CreateCall(g.funcs.compilePartialFunc, llvm::Value* partial_func = emitter.getBuilder()->CreateCall(g.funcs.compilePartialFunc,
embedRelocatablePtr(exit, g.i8->getPointerTo())); embedRelocatablePtr(exit, g.i8->getPointerTo()));
......
...@@ -31,16 +31,20 @@ struct StackMap; ...@@ -31,16 +31,20 @@ struct StackMap;
class OSREntryDescriptor { class OSREntryDescriptor {
private: private:
OSREntryDescriptor(CLFunction* clfunc, AST_Jump* backedge) : clfunc(clfunc), backedge(backedge) { assert(clfunc); } OSREntryDescriptor(CLFunction* clfunc, AST_Jump* backedge, ExceptionStyle exception_style)
: clfunc(clfunc), backedge(backedge), exception_style(exception_style) {
assert(clfunc);
}
public: public:
CLFunction* clfunc; CLFunction* clfunc;
AST_Jump* const backedge; AST_Jump* const backedge;
ExceptionStyle exception_style;
typedef std::map<InternedString, ConcreteCompilerType*> ArgMap; typedef std::map<InternedString, ConcreteCompilerType*> ArgMap;
ArgMap args; ArgMap args;
static OSREntryDescriptor* create(CLFunction* clfunc, AST_Jump* backedge) { static OSREntryDescriptor* create(CLFunction* clfunc, AST_Jump* backedge, ExceptionStyle exception_style) {
return new OSREntryDescriptor(clfunc, backedge); return new OSREntryDescriptor(clfunc, backedge, exception_style);
} }
}; };
......
...@@ -440,7 +440,8 @@ CLFunction* unboxRTFunction(Box*); ...@@ -440,7 +440,8 @@ CLFunction* unboxRTFunction(Box*);
// Compiles a new version of the function with the given signature and adds it to the list; // Compiles a new version of the function with the given signature and adds it to the list;
// should only be called after checking to see if the other versions would work. // should only be called after checking to see if the other versions would work.
CompiledFunction* compileFunction(CLFunction* f, FunctionSpecialization* spec, EffortLevel effort, CompiledFunction* compileFunction(CLFunction* f, FunctionSpecialization* spec, EffortLevel effort,
const OSREntryDescriptor* entry); const OSREntryDescriptor* entry, bool force_exception_style = false,
ExceptionStyle forced_exception_style = CXX);
EffortLevel initialEffort(); EffortLevel initialEffort();
typedef bool i1; typedef bool i1;
......
...@@ -92,7 +92,7 @@ void doOsrTest(bool is_osr, bool i_maybe_undefined) { ...@@ -92,7 +92,7 @@ void doOsrTest(bool is_osr, bool i_maybe_undefined) {
std::unique_ptr<PhiAnalysis> phis; std::unique_ptr<PhiAnalysis> phis;
if (is_osr) { if (is_osr) {
OSREntryDescriptor* entry_descriptor = OSREntryDescriptor::create(clfunc, backedge); OSREntryDescriptor* entry_descriptor = OSREntryDescriptor::create(clfunc, backedge, CXX);
entry_descriptor->args[i_str] = NULL; entry_descriptor->args[i_str] = NULL;
if (i_maybe_undefined) if (i_maybe_undefined)
entry_descriptor->args[idi_str] = NULL; entry_descriptor->args[idi_str] = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment