[pypy-commit] pypy jit-cleanup: More cleanup

rlamy pypy.commits at gmail.com
Mon Apr 1 11:50:09 EDT 2019


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: jit-cleanup
Changeset: r96397:4ee751fdcc36
Date: 2019-04-01 16:49 +0100
http://bitbucket.org/pypy/pypy/changeset/4ee751fdcc36/

Log:	More cleanup

diff --git a/rpython/jit/metainterp/typesystem.py b/rpython/jit/metainterp/typesystem.py
--- a/rpython/jit/metainterp/typesystem.py
+++ b/rpython/jit/metainterp/typesystem.py
@@ -29,14 +29,6 @@
 
     name = 'lltype'
 
-    def get_typeptr(self, obj):
-        return obj.typeptr
-
-    def get_FuncType(self, ARGS, RESULT):
-        FUNCTYPE = lltype.FuncType(ARGS, RESULT)
-        FUNCPTRTYPE = lltype.Ptr(FUNCTYPE)
-        return FUNCTYPE, FUNCPTRTYPE
-
     def get_superclass(self, TYPE):
         SUPER = TYPE.TO._first_struct()[1]
         if SUPER is None:
@@ -69,9 +61,6 @@
         obj = evaluebox.getref(rclass.OBJECTPTR)
         return cast_base_ptr_to_instance(Exception, obj)
 
-    def cast_to_baseclass(self, value):
-        return lltype.cast_opaque_ptr(rclass.OBJECTPTR, value)
-
     @specialize.ll()
     def getlength(self, array):
         return len(array)
diff --git a/rpython/jit/metainterp/virtualizable.py b/rpython/jit/metainterp/virtualizable.py
--- a/rpython/jit/metainterp/virtualizable.py
+++ b/rpython/jit/metainterp/virtualizable.py
@@ -293,15 +293,14 @@
         #
         all_graphs = self.warmrunnerdesc.translator.graphs
         ts = self.warmrunnerdesc.cpu.ts
-        (_, FUNCPTR) = ts.get_FuncType([self.VTYPEPTR], lltype.Void)
+        FUNC = lltype.FuncType([self.VTYPEPTR], lltype.Void)
         funcptr = self.warmrunnerdesc.helper_func(
-            FUNCPTR, force_virtualizable_if_necessary)
+            lltype.Ptr(FUNC), force_virtualizable_if_necessary)
         rvirtualizable.replace_force_virtualizable_with_call(
             all_graphs, self.VTYPEPTR, funcptr)
-        (_, FUNCPTR) = ts.get_FuncType([llmemory.GCREF], lltype.Void)
+        FUNC = lltype.FuncType([llmemory.GCREF], lltype.Void)
         self.clear_vable_ptr = self.warmrunnerdesc.helper_func(
-            FUNCPTR, self.clear_vable_token)
-        FUNC = FUNCPTR.TO
+            lltype.Ptr(FUNC), self.clear_vable_token)
         ei = EffectInfo([], [], [], [], [], [], EffectInfo.EF_CANNOT_RAISE,
                         can_invalidate=False,
                         oopspecindex=EffectInfo.OS_JIT_FORCE_VIRTUALIZABLE)
diff --git a/rpython/jit/metainterp/warmspot.py b/rpython/jit/metainterp/warmspot.py
--- a/rpython/jit/metainterp/warmspot.py
+++ b/rpython/jit/metainterp/warmspot.py
@@ -3,10 +3,10 @@
 from rpython.tool.sourcetools import func_with_new_name
 from rpython.rtyper.lltypesystem import lltype, llmemory
 from rpython.rtyper.annlowlevel import (llhelper, MixLevelHelperAnnotator,
-    cast_base_ptr_to_instance, hlstr, cast_instance_to_gcref)
+    hlstr, cast_instance_to_gcref, cast_gcref_to_instance)
 from rpython.rtyper.llannotation import lltype_to_annotation
+from rpython.rtyper.rclass import OBJECTPTR
 from rpython.annotator import model as annmodel
-from rpython.annotator.dictdef import DictDef
 from rpython.rtyper.llinterp import LLException
 from rpython.rtyper.test.test_llinterp import get_interpreter, clear_tcache
 from rpython.flowspace.model import SpaceOperation, Variable, Constant
@@ -665,10 +665,10 @@
         jd.num_green_args = len(jd._green_args_spec)
         jd.num_red_args = len(jd.red_args_types)
         RESTYPE = graph.getreturnvar().concretetype
-        (jd._JIT_ENTER_FUNCTYPE,
-         jd._PTR_JIT_ENTER_FUNCTYPE) = self.cpu.ts.get_FuncType(ALLARGS, lltype.Void)
-        (jd._PORTAL_FUNCTYPE,
-         jd._PTR_PORTAL_FUNCTYPE) = self.cpu.ts.get_FuncType(ALLARGS, RESTYPE)
+        jd._JIT_ENTER_FUNCTYPE = lltype.FuncType(ALLARGS, lltype.Void)
+        jd._PTR_JIT_ENTER_FUNCTYPE = lltype.Ptr(jd._JIT_ENTER_FUNCTYPE)
+        jd._PORTAL_FUNCTYPE = lltype.FuncType(ALLARGS, RESTYPE)
+        jd._PTR_PORTAL_FUNCTYPE = lltype.Ptr(jd._PORTAL_FUNCTYPE)
         #
         if jd.result_type == 'v':
             ASMRESTYPE = lltype.Void
@@ -680,8 +680,8 @@
             ASMRESTYPE = lltype.Float
         else:
             assert False
-        (_, jd._PTR_ASSEMBLER_HELPER_FUNCTYPE) = self.cpu.ts.get_FuncType(
-            [llmemory.GCREF, llmemory.GCREF], ASMRESTYPE)
+        jd._PTR_ASSEMBLER_HELPER_FUNCTYPE = lltype.Ptr(lltype.FuncType(
+            [llmemory.GCREF, llmemory.GCREF], ASMRESTYPE))
 
     def rewrite_jitcell_accesses(self):
         jitdrivers_by_name = {}
@@ -932,7 +932,6 @@
         RESULT = PORTALFUNC.RESULT
         result_kind = history.getkind(RESULT)
         assert result_kind.startswith(jd.result_type)
-        ts = self.cpu.ts
         state = jd.warmstate
         maybe_compile_and_run = jd._maybe_compile_and_run_fn
         EnterJitAssembler = jd._EnterJitAssembler
@@ -995,11 +994,11 @@
                         return e.result
                 #
                 if isinstance(e, jitexc.ExitFrameWithExceptionRef):
-                    value = ts.cast_to_baseclass(e.value)
                     if not we_are_translated():
-                        raise LLException(ts.get_typeptr(value), value)
+                        value = lltype.cast_opaque_ptr(OBJECTPTR, e.value)
+                        raise LLException(value.typeptr, value)
                     else:
-                        value = cast_base_ptr_to_instance(Exception, value)
+                        value = cast_gcref_to_instance(Exception, e.value)
                         assert value is not None
                         raise value
                 #
@@ -1087,10 +1086,10 @@
 
         closures = {}
         graphs = self.translator.graphs
-        _, PTR_SET_PARAM_FUNCTYPE = self.cpu.ts.get_FuncType([lltype.Signed],
-                                                             lltype.Void)
-        _, PTR_SET_PARAM_STR_FUNCTYPE = self.cpu.ts.get_FuncType(
-            [lltype.Ptr(STR)], lltype.Void)
+        SET_PARAM_FUNC = lltype.Ptr(lltype.FuncType(
+            [lltype.Signed], lltype.Void))
+        SET_PARAM_STR_FUNC = lltype.Ptr(lltype.FuncType(
+            [lltype.Ptr(STR)], lltype.Void))
         def make_closure(jd, fullfuncname, is_string):
             if jd is None:
                 def closure(i):
@@ -1105,9 +1104,9 @@
                         i = hlstr(i)
                     getattr(state, fullfuncname)(i)
             if is_string:
-                TP = PTR_SET_PARAM_STR_FUNCTYPE
+                TP = SET_PARAM_STR_FUNC
             else:
-                TP = PTR_SET_PARAM_FUNCTYPE
+                TP = SET_PARAM_FUNC
             funcptr = self.helper_func(TP, closure)
             return Constant(funcptr, TP)
         #


More information about the pypy-commit mailing list