Author: Armin Rigo <ar...@tunes.org> Branch: shadowstack-perf Changeset: r45429:622cdee7ad2d Date: 2011-07-08 21:48 +0200 http://bitbucket.org/pypy/pypy/changeset/622cdee7ad2d/
Log: Disable usage of the register for non-standalone translations. diff --git a/pypy/translator/c/database.py b/pypy/translator/c/database.py --- a/pypy/translator/c/database.py +++ b/pypy/translator/c/database.py @@ -60,7 +60,8 @@ if translator is None or translator.rtyper is None: self.exctransformer = None else: - self.exctransformer = translator.getexceptiontransformer() + self.exctransformer = translator.getexceptiontransformer( + standalone=standalone) if translator is not None: self.gctransformer = self.gcpolicy.transformerclass(translator) self.completed = False diff --git a/pypy/translator/exceptiontransform.py b/pypy/translator/exceptiontransform.py --- a/pypy/translator/exceptiontransform.py +++ b/pypy/translator/exceptiontransform.py @@ -52,8 +52,9 @@ class BaseExceptionTransformer(object): - def __init__(self, translator): + def __init__(self, translator, standalone): self.translator = translator + self.standalone = standalone self.raise_analyzer = canraise.RaiseAnalyzer(translator) edata = translator.rtyper.getexceptiondata() self.lltype_of_exception_value = edata.lltype_of_exception_value @@ -73,19 +74,21 @@ assertion_error_ll_exc_type) self.c_n_i_error_ll_exc_type = constant_value(n_i_error_ll_exc_type) - if register.register_number is not None: + use_special_reg = standalone and register.register_number is not None + self.use_special_reg = use_special_reg + if use_special_reg: self.c_nonnull_specialregister = constant_value(register.nonnull) self.c_load_from_reg = constant_value(register.load_from_reg) self.c_reg_is_nonnull = constant_value(register.reg_is_nonnull) self.c_store_into_reg = constant_value(register.store_into_reg) def rpyexc_occured(): - if register.register_number is None: + if use_special_reg: + # an exception occurred iff the special register is 0 + return register.load_from_reg() == llmemory.NULL + else: exc_type = exc_data.exc_type return bool(exc_type) - else: - # an exception occurred iff the special register is 0 - return register.load_from_reg() == llmemory.NULL def rpyexc_fetch_type(): return exc_data.exc_type @@ -94,7 +97,7 @@ return exc_data.exc_value def rpyexc_clear(): - if register.register_number is not None: + if use_special_reg: register.store_into_reg(register.nonnull) exc_data.exc_type = null_type exc_data.exc_value = null_value @@ -112,14 +115,14 @@ exc_data.exc_type = etype exc_data.exc_value = evalue lloperation.llop.debug_start_traceback(lltype.Void, etype) - if register.register_number is not None: + if use_special_reg: register.store_into_reg(llmemory.NULL) def rpyexc_reraise(etype, evalue): exc_data.exc_type = etype exc_data.exc_value = evalue lloperation.llop.debug_reraise_traceback(lltype.Void, etype) - if register.register_number is not None: + if use_special_reg: register.store_into_reg(llmemory.NULL) def rpyexc_fetch_exception(): @@ -131,7 +134,7 @@ if evalue: exc_data.exc_type = rclass.ll_inst_type(evalue) exc_data.exc_value = evalue - if register.register_number is not None: + if use_special_reg: register.store_into_reg(llmemory.NULL) def rpyexc_raise_stack_overflow(): @@ -428,7 +431,7 @@ # self.gen_setfield('exc_value', self.c_null_evalue, llops) self.gen_setfield('exc_type', self.c_null_etype, llops) - if register.register_number is not None: + if self.use_special_reg: self.gen_setspecialregister(self.c_nonnull_specialregister, llops) excblock.operations[:] = llops newgraph.exceptblock.inputargs[0].concretetype = self.lltype_of_exception_type @@ -453,11 +456,11 @@ if alloc_shortcut: T = spaceop.result.concretetype var_no_exc = self.gen_nonnull(spaceop.result, llops) - elif register.register_number is None: + elif self.use_special_reg: + var_no_exc = self.gen_specialreg_no_exc(llops) + else: v_exc_type = self.gen_getfield('exc_type', llops) var_no_exc = self.gen_isnull(v_exc_type, llops) - else: - var_no_exc = self.gen_specialreg_no_exc(llops) block.operations.extend(llops) @@ -647,10 +650,10 @@ def build_extra_funcs(self): pass -def ExceptionTransformer(translator): +def ExceptionTransformer(translator, standalone): type_system = translator.rtyper.type_system.name if type_system == 'lltypesystem': - return LLTypeExceptionTransformer(translator) + return LLTypeExceptionTransformer(translator, standalone) else: assert type_system == 'ootypesystem' - return OOTypeExceptionTransformer(translator) + return OOTypeExceptionTransformer(translator, standalone) diff --git a/pypy/translator/translator.py b/pypy/translator/translator.py --- a/pypy/translator/translator.py +++ b/pypy/translator/translator.py @@ -108,13 +108,14 @@ type_system = type_system) return self.rtyper - def getexceptiontransformer(self): + def getexceptiontransformer(self, standalone): if self.rtyper is None: raise ValueError("no rtyper") if self.exceptiontransformer is not None: + assert self.exceptiontransformer.standalone == standalone return self.exceptiontransformer from pypy.translator.exceptiontransform import ExceptionTransformer - self.exceptiontransformer = ExceptionTransformer(self) + self.exceptiontransformer = ExceptionTransformer(self, standalone) return self.exceptiontransformer def checkgraphs(self): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit