Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r71705:71a9f28d192f
Date: 2014-05-24 13:58 -0500
http://bitbucket.org/pypy/pypy/changeset/71a9f28d192f/
Log: Removed another indirection on LowLevelTypeSystem
diff --git a/rpython/jit/codewriter/call.py b/rpython/jit/codewriter/call.py
--- a/rpython/jit/codewriter/call.py
+++ b/rpython/jit/codewriter/call.py
@@ -9,6 +9,7 @@
QuasiImmutAnalyzer, RandomEffectsAnalyzer, effectinfo_from_writeanalyze,
EffectInfo, CallInfoCollection)
from rpython.rtyper.lltypesystem import lltype, llmemory
+from rpython.rtyper.typesystem import getfunctionptr
from rpython.translator.backendopt.canraise import RaiseAnalyzer
from rpython.translator.backendopt.writeanalyze import ReadWriteAnalyzer
from rpython.translator.backendopt.graphanalyze import DependencyTracker
@@ -168,7 +169,7 @@
because it is not needed there; it is only used by the blackhole
interp to really do the call corresponding to 'inline_call' ops.
"""
- fnptr = self.rtyper.type_system.getcallable(graph)
+ fnptr = getfunctionptr(graph)
FUNC = lltype.typeOf(fnptr).TO
assert self.rtyper.type_system.name == "lltypesystem"
fnaddr = llmemory.cast_ptr_to_adr(fnptr)
diff --git a/rpython/jit/codewriter/test/test_call.py
b/rpython/jit/codewriter/test/test_call.py
--- a/rpython/jit/codewriter/test/test_call.py
+++ b/rpython/jit/codewriter/test/test_call.py
@@ -1,10 +1,12 @@
import py
+
from rpython.flowspace.model import SpaceOperation, Constant, Variable
from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
from rpython.translator.unsimplify import varoftype
from rpython.rlib import jit
+from rpython.jit.codewriter import support, call
from rpython.jit.codewriter.call import CallControl
-from rpython.jit.codewriter import support
+
class FakePolicy:
def look_inside_graph(self, graph):
@@ -151,18 +153,19 @@
# ____________________________________________________________
-def test_get_jitcode():
+def test_get_jitcode(monkeypatch):
from rpython.jit.codewriter.test.test_flatten import FakeCPU
class FakeRTyper:
class annotator:
translator = None
class type_system:
name = 'lltypesystem'
- @staticmethod
- def getcallable(graph):
- F = lltype.FuncType([], lltype.Signed)
- return lltype.functionptr(F, 'bar')
- #
+
+ def getfunctionptr(graph):
+ F = lltype.FuncType([], lltype.Signed)
+ return lltype.functionptr(F, 'bar')
+
+ monkeypatch.setattr(call, 'getfunctionptr', getfunctionptr)
cc = CallControl(FakeCPU(FakeRTyper()))
class somegraph:
name = "foo"
diff --git a/rpython/rtyper/lltypesystem/rpbc.py
b/rpython/rtyper/lltypesystem/rpbc.py
--- a/rpython/rtyper/lltypesystem/rpbc.py
+++ b/rpython/rtyper/lltypesystem/rpbc.py
@@ -13,6 +13,7 @@
AbstractFunctionsPBCRepr, AbstractMultipleUnrelatedFrozenPBCRepr,
SingleFrozenPBCRepr, MethodOfFrozenPBCRepr, none_frozen_pbc_repr,
get_concrete_calltable)
+from rpython.rtyper.typesystem import getfunctionptr
from rpython.tool.pairtype import pairtype
@@ -218,7 +219,7 @@
links[-1].llexitcase = chr(i)
startblock.closeblock(*links)
self.rtyper.annotator.translator.graphs.append(graph)
- ll_ret = self.rtyper.type_system.getcallable(graph)
+ ll_ret = getfunctionptr(graph)
#FTYPE = FuncType
c_ret = self._dispatch_cache[key] = inputconst(typeOf(ll_ret), ll_ret)
return c_ret
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -26,7 +26,7 @@
Ptr, ContainerType, FuncType, functionptr, typeOf, RuntimeTypeInfo,
attachRuntimeTypeInfo, Primitive)
from rpython.rtyper.rmodel import Repr, inputconst, BrokenReprTyperError
-from rpython.rtyper.typesystem import LowLevelTypeSystem
+from rpython.rtyper.typesystem import LowLevelTypeSystem, getfunctionptr
from rpython.rtyper.normalizecalls import perform_normalizations
from rpython.tool.pairtype import pair
from rpython.translator.unsimplify import insert_empty_block
@@ -600,7 +600,7 @@
def getconcretetype(v):
return self.bindingrepr(v).lowleveltype
- return self.type_system.getcallable(graph, getconcretetype)
+ return getfunctionptr(graph, getconcretetype)
def annotate_helper(self, ll_function, argtypes):
"""Annotate the given low-level helper function and return its graph
diff --git a/rpython/rtyper/typesystem.py b/rpython/rtyper/typesystem.py
--- a/rpython/rtyper/typesystem.py
+++ b/rpython/rtyper/typesystem.py
@@ -20,9 +20,6 @@
def null_callable(self, T):
return lltype.nullptr(T.TO)
- def getcallable(self, graph, getconcretetype=None):
- return getfunctionptr(graph, getconcretetype)
-
def getexternalcallable(self, ll_args, ll_result, name, **kwds):
FT = lltype.FuncType(ll_args, ll_result)
return lltype.functionptr(FT, name, **kwds)
@@ -49,6 +46,7 @@
def _getconcretetype(v):
return v.concretetype
+
def getfunctionptr(graph, getconcretetype=None):
"""Return callable given a Python function."""
if getconcretetype is None:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit