Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
PyPy
pypy
Commits
71a9f28d192f
Commit
69e09380
authored
May 24, 2014
by
Alex Gaynor
Browse files
Removed another indirection on LowLevelTypeSystem
parent
88669e5d7fe2
Changes
5
Hide whitespace changes
Inline
Side-by-side
rpython/jit/codewriter/call.py
View file @
71a9f28d
...
...
@@ -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
)
...
...
rpython/jit/codewriter/test/test_call.py
View file @
71a9f28d
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"
...
...
rpython/rtyper/lltypesystem/rpbc.py
View file @
71a9f28d
...
...
@@ -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
...
...
rpython/rtyper/rtyper.py
View file @
71a9f28d
...
...
@@ -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
...
...
rpython/rtyper/typesystem.py
View file @
71a9f28d
...
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment