Commit 69e09380 authored by Alex Gaynor's avatar Alex Gaynor
Browse files

Removed another indirection on LowLevelTypeSystem

parent 88669e5d7fe2
......@@ -9,6 +9,7 @@ from rpython.jit.codewriter.effectinfo import (VirtualizableAnalyzer,
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 @@ class CallControl(object):
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)
......
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_guess_call_kind_and_calls_from_graphs():
# ____________________________________________________________
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"
......
......@@ -13,6 +13,7 @@ from rpython.rtyper.rpbc import (AbstractClassesPBCRepr, AbstractMethodsPBCRepr,
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 @@ class SmallFunctionSetPBCRepr(Repr):
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
......
......@@ -26,7 +26,7 @@ from rpython.rtyper.lltypesystem.lltype import (Signed, Void, LowLevelType,
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 @@ class RPythonTyper(object):
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
......
......@@ -20,9 +20,6 @@ class LowLevelTypeSystem(object):
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 @@ class LowLevelTypeSystem(object):
def _getconcretetype(v):
return v.concretetype
def getfunctionptr(graph, getconcretetype=None):
"""Return callable given a Python function."""
if getconcretetype is None:
......
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