Commit c011fb3a authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #770 from undingen/bjit_problems

bjit: fix problems when setting bjit thresholds to 1
parents ded39f2a 0bcfeb27
...@@ -819,7 +819,7 @@ RewriterVar* Rewriter::call(bool has_side_effects, void* func_addr, const Rewrit ...@@ -819,7 +819,7 @@ RewriterVar* Rewriter::call(bool has_side_effects, void* func_addr, const Rewrit
return result; return result;
} }
void Rewriter::_setupCall(RewriterVar* result, bool has_side_effects, const RewriterVar::SmallVector& args, void Rewriter::_setupCall(bool has_side_effects, const RewriterVar::SmallVector& args,
const RewriterVar::SmallVector& args_xmm) { const RewriterVar::SmallVector& args_xmm) {
if (has_side_effects) if (has_side_effects)
assert(done_guarding); assert(done_guarding);
...@@ -972,7 +972,7 @@ void Rewriter::_call(RewriterVar* result, bool has_side_effects, void* func_addr ...@@ -972,7 +972,7 @@ void Rewriter::_call(RewriterVar* result, bool has_side_effects, void* func_addr
// RewriterVarUsage scratch = createNewVar(Location::any()); // RewriterVarUsage scratch = createNewVar(Location::any());
assembler::Register r = allocReg(assembler::R11); assembler::Register r = allocReg(assembler::R11);
_setupCall(result, has_side_effects, args, args_xmm); _setupCall(has_side_effects, args, args_xmm);
for (RewriterVar* arg : args) { for (RewriterVar* arg : args) {
arg->bumpUse(); arg->bumpUse();
......
...@@ -422,7 +422,7 @@ protected: ...@@ -422,7 +422,7 @@ protected:
void _trap(); void _trap();
void _loadConst(RewriterVar* result, int64_t val); void _loadConst(RewriterVar* result, int64_t val);
void _setupCall(RewriterVar* result, bool has_side_effects, const RewriterVar::SmallVector& args, void _setupCall(bool has_side_effects, const RewriterVar::SmallVector& args,
const RewriterVar::SmallVector& args_xmm); const RewriterVar::SmallVector& args_xmm);
void _call(RewriterVar* result, bool has_side_effects, void* func_addr, const RewriterVar::SmallVector& args, void _call(RewriterVar* result, bool has_side_effects, void* func_addr, const RewriterVar::SmallVector& args,
const RewriterVar::SmallVector& args_xmm); const RewriterVar::SmallVector& args_xmm);
......
...@@ -560,7 +560,21 @@ int JitFragmentWriter::finishCompilation() { ...@@ -560,7 +560,21 @@ int JitFragmentWriter::finishCompilation() {
} }
if (assembler->hasFailed()) { if (assembler->hasFailed()) {
int bytes_written = assembler->bytesWritten();
// don't retry JITing very large blocks
const auto large_block_threshold = JitCodeBlock::code_size - 4096;
if (bytes_written > large_block_threshold) {
static StatCounter num_jit_large_blocks("num_baselinejit_skipped_large_blocks");
num_jit_large_blocks.log();
blocks_aborted.insert(block);
code_block.fragmentAbort(false);
} else {
// we ran out of space - we allow a retry and set shouldCreateNewBlock to true in order to allocate a new
// block for the next attempt.
code_block.fragmentAbort(true /* not_enough_space */); code_block.fragmentAbort(true /* not_enough_space */);
}
return 0; return 0;
} }
...@@ -803,9 +817,12 @@ void JitFragmentWriter::_emitPPCall(RewriterVar* result, void* func_addr, const ...@@ -803,9 +817,12 @@ void JitFragmentWriter::_emitPPCall(RewriterVar* result, void* func_addr, const
} }
RewriterVar::SmallVector reg_args(args.begin(), args.begin() + 6); RewriterVar::SmallVector reg_args(args.begin(), args.begin() + 6);
assert(reg_args.size() == 6); assert(reg_args.size() == 6);
_setupCall(result, false, reg_args, RewriterVar::SmallVector()); _setupCall(false, reg_args, RewriterVar::SmallVector());
} else } else
_setupCall(result, false, args, RewriterVar::SmallVector()); _setupCall(false, args, RewriterVar::SmallVector());
if (failed)
return;
// make sure setupCall doesn't use R11 // make sure setupCall doesn't use R11
assert(vars_by_location.count(assembler::R11) == 0); assert(vars_by_location.count(assembler::R11) == 0);
......
...@@ -203,7 +203,7 @@ static const char* set_bases(PyClassObject* c, PyObject* v) { ...@@ -203,7 +203,7 @@ static const char* set_bases(PyClassObject* c, PyObject* v) {
return ""; return "";
} }
static void classobjSetattr(Box* _cls, Box* _attr, Box* _value) { static Box* classobjSetattr(Box* _cls, Box* _attr, Box* _value) {
RELEASE_ASSERT(_cls->cls == classobj_cls, ""); RELEASE_ASSERT(_cls->cls == classobj_cls, "");
BoxedClassobj* cls = static_cast<BoxedClassobj*>(_cls); BoxedClassobj* cls = static_cast<BoxedClassobj*>(_cls);
...@@ -216,10 +216,11 @@ static void classobjSetattr(Box* _cls, Box* _attr, Box* _value) { ...@@ -216,10 +216,11 @@ static void classobjSetattr(Box* _cls, Box* _attr, Box* _value) {
raiseExcHelper(TypeError, "%s", error_str); raiseExcHelper(TypeError, "%s", error_str);
static BoxedString* bases_str = internStringImmortal("__bases__"); static BoxedString* bases_str = internStringImmortal("__bases__");
cls->setattr(bases_str, _value, NULL); cls->setattr(bases_str, _value, NULL);
return; return None;
} }
PyObject_GenericSetAttr(cls, _attr, _value); PyObject_GenericSetAttr(cls, _attr, _value);
checkAndThrowCAPIException(); checkAndThrowCAPIException();
return None;
} }
static int classobj_setattro(Box* cls, Box* attr, Box* value) noexcept { static int classobj_setattro(Box* cls, Box* attr, Box* value) noexcept {
......
...@@ -696,8 +696,8 @@ static Box* dict_repr(PyObject* self) noexcept { ...@@ -696,8 +696,8 @@ static Box* dict_repr(PyObject* self) noexcept {
} }
void setupDict() { void setupDict() {
dict_iterator_cls = BoxedHeapClass::create(type_cls, object_cls, &dictIteratorGCHandler, 0, 0, sizeof(BoxedDict), dict_iterator_cls = BoxedHeapClass::create(type_cls, object_cls, &dictIteratorGCHandler, 0, 0,
false, "dictionary-itemiterator"); sizeof(BoxedDictIterator), false, "dictionary-itemiterator");
dict_keys_cls = BoxedHeapClass::create(type_cls, object_cls, &dictViewGCHandler, 0, 0, sizeof(BoxedDictView), false, dict_keys_cls = BoxedHeapClass::create(type_cls, object_cls, &dictViewGCHandler, 0, 0, sizeof(BoxedDictView), false,
"dict_keys"); "dict_keys");
......
...@@ -1083,8 +1083,8 @@ extern "C" int PyList_SetSlice(PyObject* a, Py_ssize_t ilow, Py_ssize_t ihigh, P ...@@ -1083,8 +1083,8 @@ extern "C" int PyList_SetSlice(PyObject* a, Py_ssize_t ilow, Py_ssize_t ihigh, P
} }
void setupList() { void setupList() {
list_iterator_cls = BoxedHeapClass::create(type_cls, object_cls, &listIteratorGCHandler, 0, 0, sizeof(BoxedList), list_iterator_cls = BoxedHeapClass::create(type_cls, object_cls, &listIteratorGCHandler, 0, 0,
false, "listiterator"); sizeof(BoxedListIterator), false, "listiterator");
list_reverse_iterator_cls = BoxedHeapClass::create(type_cls, object_cls, &listIteratorGCHandler, 0, 0, list_reverse_iterator_cls = BoxedHeapClass::create(type_cls, object_cls, &listIteratorGCHandler, 0, 0,
sizeof(BoxedListIterator), false, "listreverseiterator"); sizeof(BoxedListIterator), false, "listreverseiterator");
......
...@@ -488,8 +488,8 @@ extern "C" PyObject* PyFrozenSet_New(PyObject* iterable) noexcept { ...@@ -488,8 +488,8 @@ extern "C" PyObject* PyFrozenSet_New(PyObject* iterable) noexcept {
using namespace pyston::set; using namespace pyston::set;
void setupSet() { void setupSet() {
set_iterator_cls = BoxedHeapClass::create(type_cls, object_cls, &setIteratorGCHandler, 0, 0, sizeof(BoxedSet), set_iterator_cls = BoxedHeapClass::create(type_cls, object_cls, &setIteratorGCHandler, 0, 0,
false, "setiterator"); sizeof(BoxedSetIterator), false, "setiterator");
set_iterator_cls->giveAttr( set_iterator_cls->giveAttr(
"__iter__", new BoxedFunction(boxRTFunction((void*)setiteratorIter, typeFromClass(set_iterator_cls), 1))); "__iter__", new BoxedFunction(boxRTFunction((void*)setiteratorIter, typeFromClass(set_iterator_cls), 1)));
set_iterator_cls->giveAttr("__hasnext__", set_iterator_cls->giveAttr("__hasnext__",
......
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