Author: Ronan Lamy <[email protected]>
Branch:
Changeset: r96429:a896c0b75448
Date: 2019-04-09 18:20 +0000
http://bitbucket.org/pypy/pypy/changeset/a896c0b75448/
Log: Merged in jit-cleanup (pull request #641)
Remove rpython.jit.metainterp.typesystem
diff too long, truncating to 2000 out of 4551 lines
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -9,3 +9,6 @@
Fix typo
+.. branch: jit-cleanup
+
+Remove rpython.jit.metainterp.typesystem and clean up related code in
rpython/jit/
diff --git a/pypy/module/pypyjit/test/test_jit_hook.py
b/pypy/module/pypyjit/test/test_jit_hook.py
--- a/pypy/module/pypyjit/test/test_jit_hook.py
+++ b/pypy/module/pypyjit/test/test_jit_hook.py
@@ -13,7 +13,6 @@
from pypy.module.pypyjit.interp_jit import pypyjitdriver
from pypy.module.pypyjit.hooks import pypy_hooks
from rpython.jit.tool.oparser import parse
-from rpython.jit.metainterp.typesystem import llhelper
from rpython.rlib.jit import JitDebugInfo, AsmInfo, Counters
@@ -31,7 +30,7 @@
class MockSD(object):
class cpu(object):
- ts = llhelper
+ pass
jitdrivers_sd = [MockJitDriverSD]
diff --git a/rpython/jit/backend/arm/test/test_regalloc.py
b/rpython/jit/backend/arm/test/test_regalloc.py
--- a/rpython/jit/backend/arm/test/test_regalloc.py
+++ b/rpython/jit/backend/arm/test/test_regalloc.py
@@ -150,7 +150,6 @@
EffectInfo.MOST_GENERAL)
f10_calldescr = cpu.calldescrof(F10PTR.TO, F10PTR.TO.ARGS,
F10PTR.TO.RESULT, EffectInfo.MOST_GENERAL)
- typesystem = 'lltype'
namespace = locals().copy()
class TestRegallocSimple(CustomBaseTestRegalloc):
diff --git a/rpython/jit/backend/llgraph/runner.py
b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -9,6 +9,7 @@
from rpython.jit.metainterp.resoperation import rop
from rpython.jit.metainterp.optimizeopt import intbounds
from rpython.jit.metainterp.optimize import SpeculativeError
+from rpython.jit.metainterp.support import ptr2int, int_signext
from rpython.jit.codewriter import longlong, heaptracker
from rpython.jit.codewriter.effectinfo import EffectInfo
@@ -36,7 +37,7 @@
# front-end will mutate them under our feet again. We also
# need to make sure things get freed.
_cache={}
-
+
def mapping(box):
if isinstance(box, Const) or box is None:
return box
@@ -136,7 +137,7 @@
if self._vtable is Ellipsis:
self._vtable = heaptracker.get_vtable_for_gcstruct(self._runner,
self.S)
- return heaptracker.adr2int(llmemory.cast_ptr_to_adr(self._vtable))
+ return ptr2int(self._vtable)
def is_immutable(self):
return heaptracker.is_immutable_struct(self.S)
@@ -208,7 +209,7 @@
class ArrayDescr(AbstractDescr):
all_interiorfielddescrs = None
-
+
def __init__(self, A, runner):
self.A = self.OUTERA = A
self._is_pure = A._immutable_field(None)
@@ -322,7 +323,6 @@
class LLGraphCPU(model.AbstractCPU):
- from rpython.jit.metainterp.typesystem import llhelper as ts
supports_floats = True
supports_longlong = r_uint is not r_ulonglong
supports_singlefloats = True
@@ -735,7 +735,7 @@
return rffi.LONGLONG
else:
raise NotImplementedError(size)
-
+
def bh_gc_load_indexed_i(self, struct, index, scale, base_ofs, bytes):
T = self._get_int_type_from_size(bytes)
x = llop.gc_load_indexed(T, struct, index, scale, base_ofs)
@@ -877,8 +877,7 @@
def bh_classof(self, struct):
struct = lltype.cast_opaque_ptr(rclass.OBJECTPTR, struct)
- result_adr = llmemory.cast_ptr_to_adr(struct.typeptr)
- return heaptracker.adr2int(result_adr)
+ return ptr2int(struct.typeptr)
# vector operations
vector_arith_code = """
@@ -978,7 +977,7 @@
bh_vec_expand_i = _bh_vec_expand
def bh_vec_int_signext(self, vx, ext, count):
- return [heaptracker.int_signext(_vx, ext) for _vx in vx]
+ return [int_signext(_vx, ext) for _vx in vx]
def build_load(func):
def load(self, struct, offset, scale, disp, descr, _count):
@@ -1089,7 +1088,7 @@
if box.datatype == INT:
for i,a in enumerate(arg):
if isinstance(a, bool):
- arg[i] = int(a)
+ arg[i] = int(a)
assert all([lltype.typeOf(a) == lltype.Signed for a in arg])
elif box.datatype == FLOAT:
assert all([lltype.typeOf(a) == longlong.FLOATSTORAGE or \
@@ -1552,13 +1551,12 @@
return res
def execute_restore_exception(self, descr, kls, e):
- kls = heaptracker.int2adr(kls)
if e:
value = lltype.cast_opaque_ptr(rclass.OBJECTPTR, e)
- assert llmemory.cast_ptr_to_adr(value.typeptr) == kls
+ assert ptr2int(value.typeptr) == kls
lle = LLException(value.typeptr, e)
else:
- assert kls == llmemory.NULL
+ assert kls == 0
lle = None
self.last_exception = lle
diff --git a/rpython/jit/backend/llgraph/support.py
b/rpython/jit/backend/llgraph/support.py
--- a/rpython/jit/backend/llgraph/support.py
+++ b/rpython/jit/backend/llgraph/support.py
@@ -1,7 +1,6 @@
from rpython.jit.codewriter import longlong
-from rpython.jit.codewriter import heaptracker
-
+from rpython.jit.metainterp.support import adr2int, ptr2int
from rpython.jit.metainterp.history import getkind
from rpython.rlib.rarithmetic import r_longlong, r_ulonglong, r_uint
@@ -20,9 +19,9 @@
def cast_to_int(x):
TP = lltype.typeOf(x)
if isinstance(TP, lltype.Ptr):
- return heaptracker.adr2int(llmemory.cast_ptr_to_adr(x))
+ return ptr2int(x)
if TP == llmemory.Address:
- return heaptracker.adr2int(x)
+ return adr2int(x)
if TP is lltype.SingleFloat:
return longlong.singlefloat2int(x)
return lltype.cast_primitive(lltype.Signed, x)
@@ -82,7 +81,7 @@
return longlong.int2singlefloat(x)
else:
if lltype.typeOf(x) == llmemory.Address:
- x = heaptracker.adr2int(x)
+ x = adr2int(x)
return lltype.cast_primitive(TYPE, x)
def cast_from_ptr(TYPE, x):
diff --git a/rpython/jit/backend/llgraph/test/test_llgraph.py
b/rpython/jit/backend/llgraph/test/test_llgraph.py
--- a/rpython/jit/backend/llgraph/test/test_llgraph.py
+++ b/rpython/jit/backend/llgraph/test/test_llgraph.py
@@ -1,6 +1,4 @@
import py
-from rpython.rtyper.lltypesystem import lltype, llmemory
-from rpython.jit.codewriter import heaptracker
from rpython.jit.backend.test.runner_test import LLtypeBackendTest
from rpython.jit.backend.llgraph.runner import LLGraphCPU
@@ -17,16 +15,3 @@
def test_call_release_gil_variable_function_and_arguments(self):
py.test.skip("the arguments seem not correctly casted")
-
-
-def test_cast_adr_to_int_and_back():
- X = lltype.Struct('X', ('foo', lltype.Signed))
- x = lltype.malloc(X, immortal=True)
- x.foo = 42
- a = llmemory.cast_ptr_to_adr(x)
- i = heaptracker.adr2int(a)
- assert lltype.typeOf(i) is lltype.Signed
- a2 = heaptracker.int2adr(i)
- assert llmemory.cast_adr_to_ptr(a2, lltype.Ptr(X)) == x
- assert heaptracker.adr2int(llmemory.NULL) == 0
- assert heaptracker.int2adr(0) == llmemory.NULL
diff --git a/rpython/jit/backend/llsupport/descr.py
b/rpython/jit/backend/llsupport/descr.py
--- a/rpython/jit/backend/llsupport/descr.py
+++ b/rpython/jit/backend/llsupport/descr.py
@@ -4,6 +4,7 @@
from rpython.jit.backend.llsupport import symbolic, support
from rpython.jit.metainterp.history import AbstractDescr, getkind, FLOAT, INT
from rpython.jit.metainterp import history
+from rpython.jit.metainterp.support import ptr2int, int2adr
from rpython.jit.codewriter import heaptracker, longlong
from rpython.jit.codewriter.longlong import is_longlong
from rpython.jit.metainterp.optimizeopt import intbounds
@@ -84,7 +85,7 @@
def is_valid_class_for(self, struct):
objptr = lltype.cast_opaque_ptr(rclass.OBJECTPTR, struct)
cls = llmemory.cast_adr_to_ptr(
- heaptracker.int2adr(self.get_vtable()),
+ int2adr(self.get_vtable()),
lltype.Ptr(rclass.OBJECT_VTABLE))
# this first comparison is necessary, since we want to make sure
# that vtable for JitVirtualRef is the same without actually reading
@@ -95,7 +96,7 @@
return self.immutable_flag
def get_vtable(self):
- return heaptracker.adr2int(llmemory.cast_ptr_to_adr(self.vtable))
+ return ptr2int(self.vtable)
def get_type_id(self):
assert self.tid
diff --git a/rpython/jit/backend/llsupport/gc.py
b/rpython/jit/backend/llsupport/gc.py
--- a/rpython/jit/backend/llsupport/gc.py
+++ b/rpython/jit/backend/llsupport/gc.py
@@ -11,6 +11,7 @@
from rpython.jit.codewriter import heaptracker
from rpython.jit.metainterp.history import ConstPtr, AbstractDescr, ConstInt
from rpython.jit.metainterp.resoperation import rop, ResOperation
+from rpython.jit.metainterp.support import ptr2int
from rpython.jit.backend.llsupport import symbolic, jitframe
from rpython.jit.backend.llsupport.symbolic import WORD
from rpython.jit.backend.llsupport.descr import SizeDescr, ArrayDescr,
FieldDescr
@@ -66,7 +67,7 @@
@specialize.arg(1)
def get_malloc_fn_addr(self, funcname):
ll_func = self.get_malloc_fn(funcname)
- return heaptracker.adr2int(llmemory.cast_ptr_to_adr(ll_func))
+ return ptr2int(ll_func)
def _freeze_(self):
return True
diff --git a/rpython/jit/backend/llsupport/llmodel.py
b/rpython/jit/backend/llsupport/llmodel.py
--- a/rpython/jit/backend/llsupport/llmodel.py
+++ b/rpython/jit/backend/llsupport/llmodel.py
@@ -8,7 +8,8 @@
from rpython.rlib.objectmodel import we_are_translated, specialize,
compute_hash
from rpython.jit.metainterp import history, compile
from rpython.jit.metainterp.optimize import SpeculativeError
-from rpython.jit.codewriter import heaptracker, longlong
+from rpython.jit.metainterp.support import adr2int, ptr2int
+from rpython.jit.codewriter import longlong
from rpython.jit.backend.model import AbstractCPU
from rpython.jit.backend.llsupport import symbolic, jitframe
from rpython.jit.backend.llsupport.symbolic import WORD, unroll_basic_sizes
@@ -23,8 +24,6 @@
class AbstractLLCPU(AbstractCPU):
- from rpython.jit.metainterp.typesystem import llhelper as ts
-
HAS_CODEMAP = False
done_with_this_frame_descr_int = None # overridden by pyjitpl.py
@@ -160,7 +159,7 @@
graph = mixlevelann.getgraph(realloc_frame, args_s, s_result)
fptr = mixlevelann.graph2delayed(graph, FUNC)
mixlevelann.finish()
- self.realloc_frame =
heaptracker.adr2int(llmemory.cast_ptr_to_adr(fptr))
+ self.realloc_frame = ptr2int(fptr)
if not translate_support_code:
fptr = llhelper(FUNC_TP, realloc_frame_crash)
@@ -172,7 +171,7 @@
graph = mixlevelann.getgraph(realloc_frame_crash, args_s, s_result)
fptr = mixlevelann.graph2delayed(graph, FUNC)
mixlevelann.finish()
- self.realloc_frame_crash =
heaptracker.adr2int(llmemory.cast_ptr_to_adr(fptr))
+ self.realloc_frame_crash = ptr2int(fptr)
def _setup_exception_handling_untranslated(self):
# for running un-translated only, all exceptions occurring in the
@@ -209,11 +208,11 @@
def pos_exception():
addr = llop.get_exception_addr(llmemory.Address)
- return heaptracker.adr2int(addr)
+ return adr2int(addr)
def pos_exc_value():
addr = llop.get_exc_value_addr(llmemory.Address)
- return heaptracker.adr2int(addr)
+ return adr2int(addr)
from rpython.rlib import rstack
@@ -776,8 +775,7 @@
def bh_classof(self, struct):
struct = lltype.cast_opaque_ptr(rclass.OBJECTPTR, struct)
- result_adr = llmemory.cast_ptr_to_adr(struct.typeptr)
- return heaptracker.adr2int(result_adr)
+ return ptr2int(struct.typeptr)
def bh_new_array(self, length, arraydescr):
return self.gc_ll_descr.gc_malloc_array(length, arraydescr)
diff --git a/rpython/jit/backend/llsupport/rewrite.py
b/rpython/jit/backend/llsupport/rewrite.py
--- a/rpython/jit/backend/llsupport/rewrite.py
+++ b/rpython/jit/backend/llsupport/rewrite.py
@@ -1,18 +1,15 @@
from rpython.rlib import rgc
-from rpython.rlib.objectmodel import we_are_translated, r_dict, always_inline
+from rpython.rlib.objectmodel import we_are_translated, always_inline
from rpython.rlib.rarithmetic import ovfcheck, highest_bit
from rpython.rtyper.lltypesystem import llmemory, lltype, rstr
from rpython.rtyper.annlowlevel import cast_instance_to_gcref
-from rpython.jit.metainterp import history
-from rpython.jit.metainterp.history import ConstInt, ConstPtr
+from rpython.jit.metainterp.history import (
+ ConstInt, ConstPtr, JitCellToken, new_ref_dict)
from rpython.jit.metainterp.resoperation import ResOperation, rop, OpHelpers
-from rpython.jit.metainterp.typesystem import rd_eq, rd_hash
-from rpython.jit.codewriter import heaptracker
+from rpython.jit.metainterp.support import ptr2int
from rpython.jit.backend.llsupport.symbolic import (WORD,
get_field_token, get_array_token)
-from rpython.jit.backend.llsupport.descr import SizeDescr, ArrayDescr,\
- FLAG_POINTER
-from rpython.jit.metainterp.history import JitCellToken
+from rpython.jit.backend.llsupport.descr import SizeDescr, ArrayDescr
from rpython.jit.backend.llsupport.descr import (unpack_arraydescr,
unpack_fielddescr, unpack_interiorfielddescr)
from rpython.rtyper.lltypesystem.lloperation import llop
@@ -608,12 +605,10 @@
def handle_call_assembler(self, op):
descrs = self.gc_ll_descr.getframedescrs(self.cpu)
loop_token = op.getdescr()
- assert isinstance(loop_token, history.JitCellToken)
- jfi = loop_token.compiled_loop_token.frame_info
- llfi = heaptracker.adr2int(llmemory.cast_ptr_to_adr(jfi))
+ assert isinstance(loop_token, JitCellToken)
+ llfi = ptr2int(loop_token.compiled_loop_token.frame_info)
frame = self.gen_malloc_frame(llfi)
- self.emit_setfield(frame, history.ConstInt(llfi),
- descr=descrs.jf_frame_info)
+ self.emit_setfield(frame, ConstInt(llfi), descr=descrs.jf_frame_info)
arglist = op.getarglist()
index_list = loop_token.compiled_loop_token._ll_initial_locs
for i, arg in enumerate(arglist):
@@ -948,7 +943,7 @@
def _gcref_index(self, gcref):
if self.gcrefs_map is None:
- self.gcrefs_map = r_dict(rd_eq, rd_hash)
+ self.gcrefs_map = new_ref_dict()
try:
return self.gcrefs_map[gcref]
except KeyError:
diff --git a/rpython/jit/backend/model.py b/rpython/jit/backend/model.py
--- a/rpython/jit/backend/model.py
+++ b/rpython/jit/backend/model.py
@@ -1,6 +1,9 @@
import weakref
from rpython.rlib.debug import debug_start, debug_print, debug_stop
from rpython.rtyper.lltypesystem import lltype, llmemory
+from rpython.rtyper.rclass import OBJECTPTR
+from rpython.jit.metainterp.history import ConstInt
+from rpython.jit.metainterp.support import ptr2int
class CPUTotalTracker(object):
total_compiled_loops = 0
@@ -192,6 +195,10 @@
x = llmemory.cast_int_to_adr(x)
return llmemory.cast_adr_to_ptr(x, TYPE)
+ def cls_of_box(self, box):
+ obj = lltype.cast_opaque_ptr(OBJECTPTR, box.getref_base())
+ return ConstInt(ptr2int(obj.typeptr))
+
# ---------- the backend-dependent operations ----------
diff --git a/rpython/jit/backend/test/calling_convention_test.py
b/rpython/jit/backend/test/calling_convention_test.py
--- a/rpython/jit/backend/test/calling_convention_test.py
+++ b/rpython/jit/backend/test/calling_convention_test.py
@@ -2,11 +2,12 @@
from rpython.jit.metainterp.history import BasicFinalDescr,\
JitCellToken, ConstInt, ConstFloat
from rpython.jit.metainterp.resoperation import rop, InputArgInt, InputArgFloat
+from rpython.jit.metainterp.support import ptr2int
from rpython.jit.codewriter.effectinfo import EffectInfo
from rpython.jit.tool.oparser import parse
from rpython.rtyper.lltypesystem import lltype, llmemory
from rpython.rtyper.annlowlevel import llhelper
-from rpython.jit.codewriter import heaptracker, longlong
+from rpython.jit.codewriter import longlong
from rpython.jit.backend.detect_cpu import getcpuclass
from rpython.jit.backend.test.runner_test import Runner
import py
@@ -49,8 +50,7 @@
@classmethod
def get_funcbox(cls, cpu, func_ptr):
- addr = llmemory.cast_ptr_to_adr(func_ptr)
- return ConstInt(heaptracker.adr2int(addr))
+ return ConstInt(ptr2int(func_ptr))
def test_call_aligned_with_spilled_values(self):
cpu = self.cpu
diff --git a/rpython/jit/backend/test/jitlog_test.py
b/rpython/jit/backend/test/jitlog_test.py
--- a/rpython/jit/backend/test/jitlog_test.py
+++ b/rpython/jit/backend/test/jitlog_test.py
@@ -1,19 +1,8 @@
-import re
import os
-from rpython.rlib import debug
-from rpython.jit.tool.oparser import pure_parse
-from rpython.jit.metainterp import logger
-from rpython.jit.metainterp.typesystem import llhelper
from rpython.rlib.rjitlog import rjitlog as jl
-from StringIO import StringIO
-from rpython.jit.metainterp.optimizeopt.util import equaloplists
-from rpython.jit.metainterp.history import AbstractDescr, JitCellToken,
BasicFailDescr, BasicFinalDescr
-from rpython.jit.backend.model import AbstractCPU
from rpython.rlib.jit import JitDriver
-from rpython.rlib.objectmodel import always_inline
from rpython.jit.metainterp.test.support import LLJitMixin
from rpython.rlib.rjitlog import rjitlog
-import tempfile
class LoggerTest(LLJitMixin):
@@ -34,7 +23,7 @@
file = tmpdir.join('jitlog')
monkeypatch.setenv("JITLOG", file.strpath)
f = self.run_sample_loop(None)
- self.meta_interp(f, [10,0])
+ self.meta_interp(f, [10, 0])
assert os.path.exists(file.strpath)
with file.open('rb') as fd:
# check the file header
@@ -46,28 +35,16 @@
monkeypatch.setattr(jl, 'JITLOG_VERSION_16BIT_LE', '\xff\xfe')
monkeypatch.setenv("JITLOG", file.strpath)
f = self.run_sample_loop(None)
- self.meta_interp(f, [10,0])
+ self.meta_interp(f, [10, 0])
assert os.path.exists(file.strpath)
with file.open('rb') as fd:
# check the file header
assert fd.read(3) == jl.MARK_JITLOG_HEADER + '\xff\xfe'
assert len(fd.read()) > 0
- def test_version(self, monkeypatch, tmpdir):
- file = tmpdir.join('jitlog')
- monkeypatch.setattr(jl, 'JITLOG_VERSION_16BIT_LE', '\xff\xfe')
- monkeypatch.setenv("JITLOG", file.strpath)
- f = self.run_sample_loop(None)
- self.meta_interp(f, [10,0])
- assert os.path.exists(file.strpath)
- with file.open('rb') as fd:
- # check the file header
- assert fd.read(3) == jl.MARK_JITLOG_HEADER + '\xff\xfe'
- assert len(fd.read()) > 0
-
- def run_sample_loop(self, func, myjitdriver = None):
+ def run_sample_loop(self, func, myjitdriver=None):
if not myjitdriver:
- myjitdriver = JitDriver(greens = [], reds = 'auto')
+ myjitdriver = JitDriver(greens=[], reds='auto')
def f(y, x):
res = 0
if func:
diff --git a/rpython/jit/backend/test/runner_test.py
b/rpython/jit/backend/test/runner_test.py
--- a/rpython/jit/backend/test/runner_test.py
+++ b/rpython/jit/backend/test/runner_test.py
@@ -1,22 +1,24 @@
-import py, sys, random, os, struct, operator, math
-from rpython.jit.metainterp.history import (AbstractFailDescr,
- AbstractDescr,
- BasicFailDescr,
- BasicFinalDescr,
- JitCellToken, TargetToken,
- ConstInt, ConstPtr,
- ConstFloat, Const)
-from rpython.jit.metainterp.resoperation import ResOperation, rop,
InputArgInt,\
- InputArgFloat, opname, InputArgRef
-from rpython.jit.metainterp.typesystem import deref
+import py
+import sys
+import random
+import os
+import struct
+import operator
+import math
+from rpython.jit.metainterp.history import (
+ AbstractFailDescr, AbstractDescr, BasicFailDescr, BasicFinalDescr,
+ JitCellToken, TargetToken, ConstInt, ConstPtr, ConstFloat, Const)
+from rpython.jit.metainterp.resoperation import (
+ ResOperation, rop, InputArgInt, InputArgFloat, InputArgRef)
from rpython.jit.metainterp.executor import wrap_constant
+from rpython.jit.metainterp.support import ptr2int, int_signext
from rpython.jit.codewriter.effectinfo import EffectInfo
from rpython.jit.tool.oparser import parse
from rpython.rtyper.lltypesystem import lltype, llmemory, rstr, rffi
from rpython.rtyper import rclass
from rpython.rtyper.annlowlevel import llhelper
from rpython.rtyper.llinterp import LLException
-from rpython.jit.codewriter import heaptracker, longlong
+from rpython.jit.codewriter import longlong
from rpython.rlib import longlong2float
from rpython.rlib.rarithmetic import intmask, is_valid_int
from rpython.jit.backend.detect_cpu import autodetect
@@ -55,7 +57,7 @@
add_loop_instructions = ['overload for a specific cpu']
bridge_loop_instructions = ['overload for a specific cpu']
-
+
def execute_operation(self, opname, valueboxes, result_type, descr=None):
inputargs, operations = self._get_single_operation_list(opname,
result_type,
@@ -506,7 +508,7 @@
return chr(ord(c) + 1)
FPTR = self.Ptr(self.FuncType([lltype.Char], lltype.Char))
func_ptr = llhelper(FPTR, func)
- calldescr = cpu.calldescrof(deref(FPTR), (lltype.Char,), lltype.Char,
+ calldescr = cpu.calldescrof(FPTR.TO, (lltype.Char,), lltype.Char,
EffectInfo.MOST_GENERAL)
x = cpu.bh_call_i(self.get_funcbox(cpu, func_ptr).value,
[ord('A')], None, None, calldescr)
@@ -519,7 +521,7 @@
FPTR = self.Ptr(self.FuncType([lltype.Float, lltype.Signed],
lltype.Float))
func_ptr = llhelper(FPTR, func)
- FTP = deref(FPTR)
+ FTP = FPTR.TO
calldescr = cpu.calldescrof(FTP, FTP.ARGS, FTP.RESULT,
EffectInfo.MOST_GENERAL)
x = cpu.bh_call_f(self.get_funcbox(cpu, func_ptr).value,
@@ -548,7 +550,7 @@
#
FPTR = self.Ptr(self.FuncType([TP, TP], TP))
func_ptr = llhelper(FPTR, func)
- FUNC = deref(FPTR)
+ FUNC = FPTR.TO
funcbox = self.get_funcbox(cpu, func_ptr)
# first, try it with the "normal" calldescr
calldescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
@@ -630,7 +632,7 @@
TP = lltype.Signed
FPTR = self.Ptr(self.FuncType([TP, TP], TP))
func_ptr = llhelper(FPTR, f)
- FUNC = deref(FPTR)
+ FUNC = FPTR.TO
funcconst = self.get_funcbox(self.cpu, func_ptr)
funcbox = InputArgInt(funcconst.getint())
calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
@@ -656,7 +658,7 @@
#
FPTR = self.Ptr(self.FuncType([TP] * nb_args, TP))
func_ptr = llhelper(FPTR, func_ints)
- FUNC = deref(FPTR)
+ FUNC = FPTR.TO
calldescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
EffectInfo.MOST_GENERAL)
funcbox = self.get_funcbox(cpu, func_ptr)
@@ -1820,7 +1822,7 @@
EffectInfo.OS_MATH_READ_TIMESTAMP)
FPTR = self.Ptr(self.FuncType([], lltype.SignedLongLong))
func_ptr = llhelper(FPTR, rtimer.read_timestamp)
- FUNC = deref(FPTR)
+ FUNC = FPTR.TO
funcbox = self.get_funcbox(self.cpu, func_ptr)
calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
effectinfo)
@@ -1844,8 +1846,7 @@
@classmethod
def get_funcbox(cls, cpu, func_ptr):
- addr = llmemory.cast_ptr_to_adr(func_ptr)
- return ConstInt(heaptracker.adr2int(addr))
+ return ConstInt(ptr2int(func_ptr))
MY_VTABLE = rclass.OBJECT_VTABLE # for tests only
@@ -1867,7 +1868,6 @@
def alloc_instance(self, T):
if hasattr(T, 'parent'):
vtable_for_T = lltype.malloc(self.MY_VTABLE, immortal=True)
- vtable_for_T_addr = llmemory.cast_ptr_to_adr(vtable_for_T)
else:
vtable_for_T = lltype.nullptr(rclass.OBJECT_VTABLE)
cpu = self.cpu
@@ -1896,7 +1896,7 @@
T_box = None
else:
vtable = vtable_for_T
- T_box = ConstInt(heaptracker.adr2int(vtable_for_T_addr))
+ T_box = ConstInt(ptr2int(vtable_for_T))
descr = cpu.sizeof(T, vtable)
return t_box, T_box, descr
@@ -1985,7 +1985,7 @@
def test_ooops_non_gc(self):
x = lltype.malloc(lltype.Struct('x'), flavor='raw')
- v = heaptracker.adr2int(llmemory.cast_ptr_to_adr(x))
+ v = ptr2int(x)
r = self.execute_operation(rop.PTR_EQ, [InputArgInt(v),
InputArgInt(v)], 'int')
assert r == 1
r = self.execute_operation(rop.PTR_NE, [InputArgInt(v),
InputArgInt(v)], 'int')
@@ -2777,8 +2777,7 @@
lltype.free(buffer, flavor='raw')
cpu = self.cpu
- func_adr = llmemory.cast_ptr_to_adr(c_GetCurrentDir.funcsym)
- funcbox = ConstInt(heaptracker.adr2int(func_adr))
+ funcbox = ConstInt(ptr2int(c_GetCurrentDir.funcsym))
calldescr = cpu._calldescr_dynamic_for_tests(
[types.ulong, types.pointer],
types.ulong,
@@ -3617,14 +3616,10 @@
descrfld_rx = cpu.fielddescrof(RS, 'x')
rs = lltype.malloc(RS, immortal=True)
rs.x = '?'
- x = cpu.bh_getfield_raw_i(
- heaptracker.adr2int(llmemory.cast_ptr_to_adr(rs)),
- descrfld_rx)
+ x = cpu.bh_getfield_raw_i(ptr2int(rs), descrfld_rx)
assert x == ord('?')
#
- cpu.bh_setfield_raw_i(
- heaptracker.adr2int(llmemory.cast_ptr_to_adr(rs)),
- ord('!'), descrfld_rx)
+ cpu.bh_setfield_raw_i(ptr2int(rs), ord('!'), descrfld_rx)
assert rs.x == '!'
#
@@ -3698,7 +3693,7 @@
def test_guards_nongc(self):
x = lltype.malloc(lltype.Struct('x'), flavor='raw')
- v = heaptracker.adr2int(llmemory.cast_ptr_to_adr(x))
+ v = ptr2int(x)
vbox = InputArgInt(v)
ops = [
(rop.GUARD_NONNULL, vbox, False),
@@ -3905,8 +3900,7 @@
descr = self.cpu.arraydescrof(ARRAY)
a = lltype.malloc(ARRAY, 10, flavor='raw')
a[7] = -4242
- addr = llmemory.cast_ptr_to_adr(a)
- abox = InputArgInt(heaptracker.adr2int(addr))
+ abox = InputArgInt(ptr2int(a))
r1 = self.execute_operation(rop.GETARRAYITEM_RAW_I, [abox,
InputArgInt(7)],
'int', descr=descr)
assert r1 == -4242
@@ -3916,8 +3910,7 @@
ARRAY = rffi.CArray(lltype.Signed)
descr = self.cpu.arraydescrof(ARRAY)
a = lltype.malloc(ARRAY, 10, flavor='raw')
- addr = llmemory.cast_ptr_to_adr(a)
- abox = InputArgInt(heaptracker.adr2int(addr))
+ abox = InputArgInt(ptr2int(a))
self.execute_operation(rop.SETARRAYITEM_RAW, [abox, InputArgInt(5),
InputArgInt(12345)],
'void', descr=descr)
@@ -4191,7 +4184,7 @@
value = intmask(0xFFEEDDCCBBAA9988)
expected = rffi.cast(lltype.Signed, rffi.cast(RESTYPE, value))
a[3] = rffi.cast(RESTYPE, value)
- a_rawint = heaptracker.adr2int(llmemory.cast_ptr_to_adr(a))
+ a_rawint = ptr2int(a)
x = cpu.bh_getarrayitem_raw_i(a_rawint, 3, descrarray)
assert x == expected, (
"%r: got %r, expected %r" % (RESTYPE, x, expected))
@@ -4212,7 +4205,7 @@
value = intmask(0xFFEEDDCCBBAA9988)
expected = rffi.cast(lltype.Signed, rffi.cast(RESTYPE, value))
a[3] = rffi.cast(RESTYPE, value)
- a_rawint = heaptracker.adr2int(llmemory.cast_ptr_to_adr(a))
+ a_rawint = ptr2int(a)
res = self.execute_operation(rop.GETARRAYITEM_RAW_I,
[InputArgInt(a_rawint),
InputArgInt(3)],
'int', descr=descrarray)
@@ -4454,7 +4447,7 @@
effectinfo = EffectInfo([], [], [], [], [], [],
EffectInfo.EF_CANNOT_RAISE, EffectInfo.OS_MATH_SQRT)
FPTR = self.Ptr(self.FuncType([lltype.Float], lltype.Float))
func_ptr = llhelper(FPTR, math_sqrt)
- FUNC = deref(FPTR)
+ FUNC = FPTR.TO
funcbox = self.get_funcbox(self.cpu, func_ptr)
calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
effectinfo)
@@ -4546,7 +4539,7 @@
for test_case in test_cases:
deadframe = self.cpu.execute_token(looptoken, test_case)
got = self.cpu.get_int_value(deadframe, 0)
- expected = heaptracker.int_signext(test_case, numbytes)
+ expected = int_signext(test_case, numbytes)
assert got == expected
def test_compile_asmlen(self):
@@ -4641,12 +4634,12 @@
assert a + 12 == g
assert a + 14 == h
assert a + 16 == i
- FPTR = self.Ptr(self.FuncType([lltype.Signed]*9, lltype.Void))
+ FPTR = self.Ptr(self.FuncType([lltype.Signed] * 9, lltype.Void))
func_ptr = llhelper(FPTR, func)
cpu = self.cpu
- calldescr = cpu.calldescrof(deref(FPTR), (lltype.Signed,)*9,
lltype.Void,
+ calldescr = cpu.calldescrof(FPTR.TO, (lltype.Signed,) * 9, lltype.Void,
EffectInfo.MOST_GENERAL)
- faildescr=BasicFailDescr(42)
+ faildescr = BasicFailDescr(42)
loop = parse("""
[i0]
label(i0, descr=targettoken1)
@@ -5067,8 +5060,7 @@
a = lltype.malloc(A, 2, flavor='raw')
a[0] = rffi.cast(rffi.SHORT, 666)
a[1] = rffi.cast(rffi.SHORT, 777)
- addr = llmemory.cast_ptr_to_adr(a)
- a_int = heaptracker.adr2int(addr)
+ a_int = ptr2int(a)
print 'a_int:', a_int
self.execute_operation(rop.SETARRAYITEM_RAW,
[ConstInt(a_int), ConstInt(0), ConstInt(-7654)],
@@ -5102,8 +5094,7 @@
A = lltype.GcArray(OF)
arraydescr = self.cpu.arraydescrof(A)
a = lltype.malloc(A, 100)
- addr = llmemory.cast_ptr_to_adr(a)
- a_int = heaptracker.adr2int(addr)
+ a_int = ptr2int(a)
a_ref = lltype.cast_opaque_ptr(llmemory.GCREF, a)
for (start, length) in [(0, 100), (49, 49), (1, 98),
(15, 9), (10, 10), (47, 0),
@@ -5258,7 +5249,7 @@
xptr = lltype.malloc(X)
xptr.parent.typeptr = xtp
x_box = InputArgRef(lltype.cast_opaque_ptr(llmemory.GCREF, xptr))
- X_box = ConstInt(heaptracker.adr2int(llmemory.cast_ptr_to_adr(xtp)))
+ X_box = ConstInt(ptr2int(xtp))
ytp = lltype.malloc(rclass.OBJECT_VTABLE, immortal=True)
ytp.subclassrange_min = 2
@@ -5269,7 +5260,7 @@
yptr = lltype.malloc(Y)
yptr.parent.parent.typeptr = ytp
y_box = InputArgRef(lltype.cast_opaque_ptr(llmemory.GCREF, yptr))
- Y_box = ConstInt(heaptracker.adr2int(llmemory.cast_ptr_to_adr(ytp)))
+ Y_box = ConstInt(ptr2int(ytp))
ztp = lltype.malloc(rclass.OBJECT_VTABLE, immortal=True)
ztp.subclassrange_min = 4
@@ -5281,7 +5272,7 @@
zptr = lltype.malloc(Z)
zptr.parent.typeptr = ztp
z_box = InputArgRef(lltype.cast_opaque_ptr(llmemory.GCREF, zptr))
- Z_box = ConstInt(heaptracker.adr2int(llmemory.cast_ptr_to_adr(ztp)))
+ Z_box = ConstInt(ptr2int(ztp))
for num, arg, klass, is_subclass in [
(1, x_box, X_box, True),
diff --git a/rpython/jit/backend/test/test_ll_random.py
b/rpython/jit/backend/test/test_ll_random.py
--- a/rpython/jit/backend/test/test_ll_random.py
+++ b/rpython/jit/backend/test/test_ll_random.py
@@ -5,6 +5,7 @@
from rpython.jit.backend.test.test_random import getint, getref_base, getref
from rpython.jit.metainterp.resoperation import ResOperation, rop, optypes
from rpython.jit.metainterp.history import ConstInt, ConstPtr, getkind
+from rpython.jit.metainterp.support import ptr2int
from rpython.jit.codewriter import heaptracker
from rpython.jit.codewriter.effectinfo import EffectInfo
from rpython.rtyper.annlowlevel import llhelper
@@ -218,9 +219,6 @@
# ____________________________________________________________
-def ConstAddr(addr, cpu):
- return ConstInt(heaptracker.adr2int(addr))
-
class GuardClassOperation(test_random.GuardOperation):
def gen_guard(self, builder, r):
ptrvars = [(v, S) for (v, S) in builder.ptrvars
@@ -235,7 +233,7 @@
v2, S2 = builder.get_structptr_var(r, must_have_vtable=True)
vtable = S._hints['vtable']._as_ptr()
vtable2 = S2._hints['vtable']._as_ptr()
- c_vtable2 = ConstAddr(llmemory.cast_ptr_to_adr(vtable2), builder.cpu)
+ c_vtable2 = ConstInt(ptr2int(vtable2))
op = ResOperation(self.opnum, [v, c_vtable2], None)
return op, (vtable == vtable2)
@@ -249,8 +247,7 @@
builder.loop.operations.append(op)
v2, S2 = builder.get_structptr_var(r, must_have_vtable=True)
vtable2 = S2._hints['vtable']._as_ptr()
- c_vtable2 = ConstAddr(llmemory.cast_ptr_to_adr(vtable2),
- builder.cpu)
+ c_vtable2 = ConstInt(ptr2int(vtable2))
op = ResOperation(self.opnum, [op, c_vtable2], None)
return op, False
@@ -571,7 +568,7 @@
sum = %s
return %s
""" % (funcargs, sum, result)).compile()
- d = {'intmask' : intmask}
+ d = {'intmask': intmask}
exec code in d
return subset, d['f']
@@ -587,8 +584,8 @@
vtableptr = v._hints['vtable']._as_ptr()
d = {
'ptr': getref_base(S),
- 'vtable' : vtableptr,
- 'LLException' : LLException,
+ 'vtable': vtableptr,
+ 'LLException': LLException,
}
exec code in d
return subset, d['f'], vtableptr
@@ -616,7 +613,7 @@
RES = self.getresulttype()
TP = lltype.FuncType([lltype.Signed] * len(subset), RES)
ptr = llhelper(lltype.Ptr(TP), f)
- c_addr = ConstAddr(llmemory.cast_ptr_to_adr(ptr), builder.cpu)
+ c_addr = ConstInt(ptr2int(ptr))
args = [c_addr] + subset
descr = self.getcalldescr(builder, TP)
self.put(builder, args, descr)
@@ -633,12 +630,12 @@
RES = self.getresulttype()
TP = lltype.FuncType([lltype.Signed] * len(subset), RES)
ptr = llhelper(lltype.Ptr(TP), f)
- c_addr = ConstAddr(llmemory.cast_ptr_to_adr(ptr), builder.cpu)
+ c_addr = ConstInt(ptr2int(ptr))
args = [c_addr] + subset
descr = self.getcalldescr(builder, TP)
self.put(builder, args, descr)
_, vtableptr = builder.get_random_structure_type_and_vtable(r)
- exc_box = ConstAddr(llmemory.cast_ptr_to_adr(vtableptr), builder.cpu)
+ exc_box = ConstInt(ptr2int(vtableptr))
op = ResOperation(rop.GUARD_EXCEPTION, [exc_box],
descr=builder.getfaildescr())
op.setfailargs(builder.subset_of_intvars(r))
@@ -655,11 +652,11 @@
subset, f, exc = self.raising_func_code(builder, r)
TP = lltype.FuncType([lltype.Signed] * len(subset), lltype.Void)
ptr = llhelper(lltype.Ptr(TP), f)
- c_addr = ConstAddr(llmemory.cast_ptr_to_adr(ptr), builder.cpu)
+ c_addr = ConstInt(ptr2int(ptr))
args = [c_addr] + subset
descr = self.getcalldescr(builder, TP)
self.put(builder, args, descr)
- exc_box = ConstAddr(llmemory.cast_ptr_to_adr(exc), builder.cpu)
+ exc_box = ConstInt(ptr2int(exc))
op = ResOperation(rop.GUARD_EXCEPTION, [exc_box],
descr=builder.getfaildescr())
op.setfailargs(fail_subset)
@@ -672,13 +669,13 @@
subset, f, exc = self.raising_func_code(builder, r)
TP = lltype.FuncType([lltype.Signed] * len(subset), lltype.Void)
ptr = llhelper(lltype.Ptr(TP), f)
- c_addr = ConstAddr(llmemory.cast_ptr_to_adr(ptr), builder.cpu)
+ c_addr = ConstInt(ptr2int(ptr))
args = [c_addr] + subset
descr = self.getcalldescr(builder, TP)
self.put(builder, args, descr)
op = ResOperation(rop.GUARD_NO_EXCEPTION, [],
descr=builder.getfaildescr())
- op._exc_box = ConstAddr(llmemory.cast_ptr_to_adr(exc), builder.cpu)
+ op._exc_box = ConstInt(ptr2int(exc))
op.setfailargs(builder.subset_of_intvars(r))
builder.should_fail_by = op
builder.guard_op = op
@@ -691,7 +688,7 @@
subset, f, exc = self.raising_func_code(builder, r)
TP = lltype.FuncType([lltype.Signed] * len(subset), lltype.Void)
ptr = llhelper(lltype.Ptr(TP), f)
- c_addr = ConstAddr(llmemory.cast_ptr_to_adr(ptr), builder.cpu)
+ c_addr = ConstInt(ptr2int(ptr))
args = [c_addr] + subset
descr = self.getcalldescr(builder, TP)
self.put(builder, args, descr)
@@ -699,10 +696,10 @@
_, vtableptr = builder.get_random_structure_type_and_vtable(r)
if vtableptr != exc:
break
- other_box = ConstAddr(llmemory.cast_ptr_to_adr(vtableptr), builder.cpu)
+ other_box = ConstInt(ptr2int(vtableptr))
op = ResOperation(rop.GUARD_EXCEPTION, [other_box],
descr=builder.getfaildescr())
- op._exc_box = ConstAddr(llmemory.cast_ptr_to_adr(exc), builder.cpu)
+ op._exc_box = ConstInt(ptr2int(exc))
op.setfailargs(builder.subset_of_intvars(r))
builder.should_fail_by = op
builder.guard_op = op
@@ -735,7 +732,7 @@
#
TP = lltype.FuncType([lltype.Signed] * len(subset), RESULT_TYPE)
ptr = llhelper(lltype.Ptr(TP), call_me)
- c_addr = ConstAddr(llmemory.cast_ptr_to_adr(ptr), builder.cpu)
+ c_addr = ConstInt(ptr2int(ptr))
args = [v_cond, c_addr] + subset
descr = self.getcalldescr(builder, TP)
self.put(builder, args, descr)
diff --git a/rpython/jit/codewriter/assembler.py
b/rpython/jit/codewriter/assembler.py
--- a/rpython/jit/codewriter/assembler.py
+++ b/rpython/jit/codewriter/assembler.py
@@ -1,9 +1,10 @@
from rpython.jit.metainterp.history import AbstractDescr, getkind
+from rpython.jit.metainterp.support import adr2int, int2adr
from rpython.jit.codewriter.flatten import Register, Label, TLabel, KINDS
from rpython.jit.codewriter.flatten import ListOfKind, IndirectCallTargets
from rpython.jit.codewriter.format import format_assembler
from rpython.jit.codewriter.jitcode import SwitchDictDescr, JitCode
-from rpython.jit.codewriter import heaptracker, longlong
+from rpython.jit.codewriter import longlong
from rpython.rlib.objectmodel import ComputedIntSymbolic
from rpython.rlib.rarithmetic import r_int
from rpython.flowspace.model import Constant
@@ -77,7 +78,7 @@
value = llmemory.cast_ptr_to_adr(value)
TYPE = llmemory.Address
if TYPE == llmemory.Address:
- value = heaptracker.adr2int(value)
+ value = adr2int(value)
if TYPE is lltype.SingleFloat:
value = longlong.singlefloat2int(value)
if not isinstance(value, (llmemory.AddressAsInt,
@@ -265,7 +266,7 @@
# Helper called at the end of assembling. Registers the extra
# functions shown in _callinfo_for_oopspec.
for func in callinfocollection.all_function_addresses_as_int():
- func = heaptracker.int2adr(func)
+ func = int2adr(func)
self.see_raw_object(func.ptr)
diff --git a/rpython/jit/codewriter/effectinfo.py
b/rpython/jit/codewriter/effectinfo.py
--- a/rpython/jit/codewriter/effectinfo.py
+++ b/rpython/jit/codewriter/effectinfo.py
@@ -1,9 +1,9 @@
import sys
-from rpython.jit.metainterp.typesystem import deref, fieldType, arrayItem
from rpython.rtyper.rclass import OBJECT
from rpython.rtyper.lltypesystem import lltype, llmemory
from rpython.translator.backendopt.graphanalyze import BoolGraphAnalyzer
from rpython.tool.algo import bitstring
+from rpython.jit.metainterp.support import int2adr
class UnsupportedFieldExc(Exception):
@@ -298,19 +298,19 @@
write_descrs_interiorfields = []
def add_struct(descrs_fields, (_, T, fieldname)):
- T = deref(T)
+ T = T.TO
if consider_struct(T, fieldname):
descr = cpu.fielddescrof(T, fieldname)
descrs_fields.append(descr)
def add_array(descrs_arrays, (_, T)):
- ARRAY = deref(T)
+ ARRAY = T.TO
if consider_array(ARRAY):
descr = cpu.arraydescrof(ARRAY)
descrs_arrays.append(descr)
def add_interiorfield(descrs_interiorfields, (_, T, fieldname)):
- T = deref(T)
+ T = T.TO
if not isinstance(T, lltype.Array):
return # let's not consider structs for now
if not consider_array(T):
@@ -329,7 +329,7 @@
extraef = list()
for tup in effects:
if tup[0] == "interiorfield" or tup[0] == "readinteriorfield":
- T = deref(tup[1])
+ T = tup[1].TO
if isinstance(T, lltype.Array) and consider_array(T):
val = (tup[0].replace("interiorfield", "array"),
tup[1])
@@ -377,7 +377,7 @@
can_collect)
def consider_struct(TYPE, fieldname):
- if fieldType(TYPE, fieldname) is lltype.Void:
+ if getattr(TYPE, fieldname) is lltype.Void:
return False
if not isinstance(TYPE, lltype.GcStruct): # can be a non-GC-struct
return False
@@ -389,7 +389,7 @@
return True
def consider_array(ARRAY):
- if arrayItem(ARRAY) is lltype.Void:
+ if ARRAY.OF is lltype.Void:
return False
if not isinstance(ARRAY, lltype.GcArray): # can be a non-GC-array
return False
@@ -446,9 +446,8 @@
return (None, 0)
def _funcptr_for_oopspec_memo(self, oopspecindex):
- from rpython.jit.codewriter import heaptracker
_, func_as_int = self.callinfo_for_oopspec(oopspecindex)
- funcadr = heaptracker.int2adr(func_as_int)
+ funcadr = int2adr(func_as_int)
return funcadr.ptr
_funcptr_for_oopspec_memo._annspecialcase_ = 'specialize:memo'
diff --git a/rpython/jit/codewriter/heaptracker.py
b/rpython/jit/codewriter/heaptracker.py
--- a/rpython/jit/codewriter/heaptracker.py
+++ b/rpython/jit/codewriter/heaptracker.py
@@ -1,30 +1,9 @@
-from rpython.rtyper.lltypesystem import lltype, llmemory
+from rpython.rtyper.lltypesystem import lltype
from rpython.rtyper import rclass
-from rpython.rlib.objectmodel import we_are_translated
-from rpython.rlib.rarithmetic import r_uint, intmask
-
-
-def adr2int(addr):
- # Cast an address to an int. Returns an AddressAsInt object which
- # can be cast back to an address.
- return llmemory.cast_adr_to_int(addr, "symbolic")
-
-def int2adr(int):
- return llmemory.cast_int_to_adr(int)
-
-def int_signext(value, numbytes):
- b8 = numbytes * 8
- a = r_uint(value)
- a += r_uint(1 << (b8 - 1)) # a += 128
- a &= r_uint((1 << b8) - 1) # a &= 255
- a -= r_uint(1 << (b8 - 1)) # a -= 128
- return intmask(a)
def is_immutable_struct(S):
return isinstance(S, lltype.GcStruct) and S._hints.get('immutable', False)
-# ____________________________________________________________
-
def has_gcstruct_a_vtable(GCSTRUCT):
if not isinstance(GCSTRUCT, lltype.GcStruct):
return False
@@ -132,4 +111,3 @@
return cur_index
cur_index += 1
return -cur_index - 1 # not found
-
diff --git a/rpython/jit/codewriter/jitcode.py
b/rpython/jit/codewriter/jitcode.py
--- a/rpython/jit/codewriter/jitcode.py
+++ b/rpython/jit/codewriter/jitcode.py
@@ -1,5 +1,5 @@
from rpython.jit.metainterp.history import AbstractDescr, ConstInt
-from rpython.jit.codewriter import heaptracker
+from rpython.jit.metainterp.support import adr2int
from rpython.rlib.objectmodel import we_are_translated
from rpython.rlib.rarithmetic import base_int
@@ -8,7 +8,7 @@
_empty_i = []
_empty_r = []
_empty_f = []
-
+
def __init__(self, name, fnaddr=None, calldescr=None, called_from=None):
self.name = name
self.fnaddr = fnaddr
@@ -41,7 +41,7 @@
self._resulttypes = resulttypes # debugging
def get_fnaddr_as_int(self):
- return heaptracker.adr2int(self.fnaddr)
+ return adr2int(self.fnaddr)
def num_regs_i(self):
return ord(self.c_num_regs_i)
diff --git a/rpython/jit/codewriter/jtransform.py
b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -6,10 +6,9 @@
from rpython.jit.codewriter.policy import log
from rpython.jit.metainterp import quasiimmut
from rpython.jit.metainterp.history import getkind
-from rpython.jit.metainterp.typesystem import deref, arrayItem
from rpython.jit.metainterp.blackhole import BlackholeInterpreter
-from rpython.flowspace.model import SpaceOperation, Variable, Constant,\
- c_last_exception
+from rpython.jit.metainterp.support import ptr2int
+from rpython.flowspace.model import SpaceOperation, Variable, Constant
from rpython.rlib import objectmodel
from rpython.rlib.jit import _we_are_jitted
from rpython.rlib.rgc import lltype_is_gc
@@ -1729,9 +1728,9 @@
(in which case the original call is written as a residual call).
"""
if oopspec_name.startswith('new'):
- LIST = deref(op.result.concretetype)
+ LIST = op.result.concretetype.TO
else:
- LIST = deref(args[0].concretetype)
+ LIST = args[0].concretetype.TO
resizable = isinstance(LIST, lltype.GcStruct)
assert resizable == (not isinstance(LIST, lltype.GcArray))
if resizable:
@@ -1956,8 +1955,7 @@
if isinstance(op.args[0].value, str):
pass # for tests only
else:
- func = heaptracker.adr2int(
- llmemory.cast_ptr_to_adr(op.args[0].value))
+ func = ptr2int(op.args[0].value)
self.callcontrol.callinfocollection.add(oopspecindex,
calldescr, func)
op1 = self.rewrite_call(op, 'residual_call',
@@ -1984,8 +1982,7 @@
if isinstance(c_func.value, str): # in tests only
func = c_func.value
else:
- func = heaptracker.adr2int(
- llmemory.cast_ptr_to_adr(c_func.value))
+ func = ptr2int(c_func.value)
self.callcontrol.callinfocollection.add(oopspecindex, calldescr, func)
def _handle_int_special(self, op, oopspec_name, args):
diff --git a/rpython/jit/codewriter/support.py
b/rpython/jit/codewriter/support.py
--- a/rpython/jit/codewriter/support.py
+++ b/rpython/jit/codewriter/support.py
@@ -4,7 +4,6 @@
from rpython.rtyper.llannotation import lltype_to_annotation
from rpython.annotator.policy import AnnotatorPolicy
from rpython.flowspace.model import Variable, Constant
-from rpython.jit.metainterp.typesystem import deref
from rpython.rlib import rgc
from rpython.rlib.jit import elidable, oopspec
from rpython.rlib.rarithmetic import r_longlong, r_ulonglong, r_uint, intmask
@@ -142,7 +141,7 @@
assert len(lst) == len(args_v), (
"not supported so far: 'greens' variables contain Void")
# a crash here means that you have to reorder the variable named in
- # the JitDriver.
+ # the JitDriver.
lst2 = sort_vars(lst)
assert lst == lst2, ("You have to reorder the variables named in "
"the JitDriver (both the 'greens' and 'reds' independently). "
@@ -786,7 +785,7 @@
bk = rtyper.annotator.bookkeeper
ll_restype = ll_res
if impl.need_result_type != 'exact':
- ll_restype = deref(ll_restype)
+ ll_restype = ll_restype.TO
desc = bk.getdesc(ll_restype)
else:
class TestingDesc(object):
diff --git a/rpython/jit/codewriter/test/test_assembler.py
b/rpython/jit/codewriter/test/test_assembler.py
--- a/rpython/jit/codewriter/test/test_assembler.py
+++ b/rpython/jit/codewriter/test/test_assembler.py
@@ -3,8 +3,9 @@
from rpython.jit.codewriter.flatten import SSARepr, Label, TLabel, Register
from rpython.jit.codewriter.flatten import ListOfKind, IndirectCallTargets
from rpython.jit.codewriter.jitcode import MissingLiveness
-from rpython.jit.codewriter import heaptracker, longlong
+from rpython.jit.codewriter import longlong
from rpython.jit.metainterp.history import AbstractDescr
+from rpython.jit.metainterp.support import ptr2int
from rpython.flowspace.model import Constant
from rpython.rtyper.lltypesystem import lltype, llmemory
from rpython.rlib.rarithmetic import r_int, r_uint
@@ -106,7 +107,7 @@
assert assembler.insns == {'int_return/c': 0,
'int_return/i': 1,
'ref_return/r': 2}
- f_int = heaptracker.adr2int(llmemory.cast_ptr_to_adr(f))
+ f_int = ptr2int(f)
assert jitcode.constants_i == [0x1234, f_int]
s_gcref = lltype.cast_opaque_ptr(llmemory.GCREF, s)
assert jitcode.constants_r == [s_gcref]
diff --git a/rpython/jit/codewriter/test/test_flatten.py
b/rpython/jit/codewriter/test/test_flatten.py
--- a/rpython/jit/codewriter/test/test_flatten.py
+++ b/rpython/jit/codewriter/test/test_flatten.py
@@ -1,12 +1,12 @@
import py, sys
from rpython.jit.codewriter import support
-from rpython.jit.codewriter.heaptracker import int_signext
from rpython.jit.codewriter.flatten import flatten_graph, reorder_renaming_list
from rpython.jit.codewriter.flatten import GraphFlattener, ListOfKind, Register
from rpython.jit.codewriter.format import assert_format
from rpython.jit.codewriter import longlong
from rpython.jit.codewriter.effectinfo import EffectInfo
from rpython.jit.metainterp.history import AbstractDescr
+from rpython.jit.metainterp.support import int_signext
from rpython.rtyper.lltypesystem import lltype, rstr, rffi
from rpython.rtyper import rclass
from rpython.flowspace.model import SpaceOperation, Variable, Constant
diff --git a/rpython/jit/codewriter/test/test_jtransform.py
b/rpython/jit/codewriter/test/test_jtransform.py
--- a/rpython/jit/codewriter/test/test_jtransform.py
+++ b/rpython/jit/codewriter/test/test_jtransform.py
@@ -12,6 +12,7 @@
from rpython.jit.codewriter import heaptracker, effectinfo
from rpython.jit.codewriter.flatten import ListOfKind
from rpython.jit.codewriter.jtransform import Transformer,
UnsupportedMallocFlags
+from rpython.jit.metainterp.support import int2adr
from rpython.jit.metainterp.history import getkind
def const(x):
@@ -1198,7 +1199,7 @@
got = cc.callinfocollection.seen[0]
assert got[0] == effectinfo.EffectInfo.OS_UNI_CONCAT
assert got[1] == op1.args[2] # the calldescr
- assert heaptracker.int2adr(got[2]) == llmemory.cast_ptr_to_adr(func)
+ assert int2adr(got[2]) == llmemory.cast_ptr_to_adr(func)
def test_str_slice():
# test that the oopspec is present and correctly transformed
diff --git a/rpython/jit/metainterp/blackhole.py
b/rpython/jit/metainterp/blackhole.py
--- a/rpython/jit/metainterp/blackhole.py
+++ b/rpython/jit/metainterp/blackhole.py
@@ -1,9 +1,11 @@
-from rpython.jit.codewriter import heaptracker, longlong
+from rpython.jit.codewriter import longlong
from rpython.jit.codewriter.jitcode import JitCode, SwitchDictDescr
from rpython.jit.metainterp.compile import ResumeAtPositionDescr
from rpython.jit.metainterp.jitexc import get_llexception, reraise
from rpython.jit.metainterp import jitexc
from rpython.jit.metainterp.history import MissingValue
+from rpython.jit.metainterp.support import (
+ adr2int, int2adr, ptr2int, int_signext)
from rpython.rlib import longlong2float
from rpython.rlib.debug import ll_assert, make_sure_not_resized
from rpython.rlib.debug import check_annotation
@@ -539,7 +541,7 @@
return i
@arguments("i", "i", returns="i")
def bhimpl_int_signext(a, b):
- return heaptracker.int_signext(a, b)
+ return int_signext(a, b)
@arguments("i", "i", returns="i")
def bhimpl_uint_lt(a, b):
@@ -930,7 +932,7 @@
@arguments("self", "i", "L", "pc", returns="L")
def bhimpl_goto_if_exception_mismatch(self, vtable, target, pc):
- adr = heaptracker.int2adr(vtable)
+ adr = int2adr(vtable)
bounding_class = llmemory.cast_adr_to_ptr(adr, rclass.CLASSTYPE)
real_instance = self.exception_last_value
assert real_instance
@@ -943,8 +945,7 @@
def bhimpl_last_exception(self):
real_instance = self.exception_last_value
assert real_instance
- adr = llmemory.cast_ptr_to_adr(real_instance.typeptr)
- return heaptracker.adr2int(adr)
+ return ptr2int(real_instance.typeptr)
@arguments("self", returns="r")
def bhimpl_last_exc_value(self):
@@ -1050,7 +1051,7 @@
def get_portal_runner(self, jdindex):
jitdriver_sd = self.builder.metainterp_sd.jitdrivers_sd[jdindex]
- fnptr = heaptracker.adr2int(jitdriver_sd.portal_runner_adr)
+ fnptr = adr2int(jitdriver_sd.portal_runner_adr)
calldescr = jitdriver_sd.mainjitcode.calldescr
return fnptr, calldescr
@@ -1233,45 +1234,45 @@
@arguments("cpu", "j", "R", returns="i")
def bhimpl_inline_call_r_i(cpu, jitcode, args_r):
- return cpu.bh_call_i(jitcode.get_fnaddr_as_int(),
+ return cpu.bh_call_i(adr2int(jitcode.fnaddr),
None, args_r, None, jitcode.calldescr)
@arguments("cpu", "j", "R", returns="r")
def bhimpl_inline_call_r_r(cpu, jitcode, args_r):
- return cpu.bh_call_r(jitcode.get_fnaddr_as_int(),
+ return cpu.bh_call_r(adr2int(jitcode.fnaddr),
None, args_r, None, jitcode.calldescr)
@arguments("cpu", "j", "R")
def bhimpl_inline_call_r_v(cpu, jitcode, args_r):
- return cpu.bh_call_v(jitcode.get_fnaddr_as_int(),
+ return cpu.bh_call_v(adr2int(jitcode.fnaddr),
None, args_r, None, jitcode.calldescr)
@arguments("cpu", "j", "I", "R", returns="i")
def bhimpl_inline_call_ir_i(cpu, jitcode, args_i, args_r):
- return cpu.bh_call_i(jitcode.get_fnaddr_as_int(),
+ return cpu.bh_call_i(adr2int(jitcode.fnaddr),
args_i, args_r, None, jitcode.calldescr)
@arguments("cpu", "j", "I", "R", returns="r")
def bhimpl_inline_call_ir_r(cpu, jitcode, args_i, args_r):
- return cpu.bh_call_r(jitcode.get_fnaddr_as_int(),
+ return cpu.bh_call_r(adr2int(jitcode.fnaddr),
args_i, args_r, None, jitcode.calldescr)
@arguments("cpu", "j", "I", "R")
def bhimpl_inline_call_ir_v(cpu, jitcode, args_i, args_r):
- return cpu.bh_call_v(jitcode.get_fnaddr_as_int(),
+ return cpu.bh_call_v(adr2int(jitcode.fnaddr),
args_i, args_r, None, jitcode.calldescr)
@arguments("cpu", "j", "I", "R", "F", returns="i")
def bhimpl_inline_call_irf_i(cpu, jitcode, args_i, args_r, args_f):
- return cpu.bh_call_i(jitcode.get_fnaddr_as_int(),
+ return cpu.bh_call_i(adr2int(jitcode.fnaddr),
args_i, args_r, args_f, jitcode.calldescr)
@arguments("cpu", "j", "I", "R", "F", returns="r")
def bhimpl_inline_call_irf_r(cpu, jitcode, args_i, args_r, args_f):
- return cpu.bh_call_r(jitcode.get_fnaddr_as_int(),
+ return cpu.bh_call_r(adr2int(jitcode.fnaddr),
args_i, args_r, args_f, jitcode.calldescr)
@arguments("cpu", "j", "I", "R", "F", returns="f")
def bhimpl_inline_call_irf_f(cpu, jitcode, args_i, args_r, args_f):
- return cpu.bh_call_f(jitcode.get_fnaddr_as_int(),
+ return cpu.bh_call_f(adr2int(jitcode.fnaddr),
args_i, args_r, args_f, jitcode.calldescr)
@arguments("cpu", "j", "I", "R", "F")
def bhimpl_inline_call_irf_v(cpu, jitcode, args_i, args_r, args_f):
- return cpu.bh_call_v(jitcode.get_fnaddr_as_int(),
+ return cpu.bh_call_v(adr2int(jitcode.fnaddr),
args_i, args_r, args_f, jitcode.calldescr)
@arguments("cpu", "i", "d", returns="r")
@@ -1622,7 +1623,7 @@
elif kind == 'i':
raise jitexc.DoneWithThisFrameInt(self.get_tmpreg_i())
elif kind == 'r':
- raise jitexc.DoneWithThisFrameRef(self.cpu, self.get_tmpreg_r())
+ raise jitexc.DoneWithThisFrameRef(self.get_tmpreg_r())
elif kind == 'f':
raise jitexc.DoneWithThisFrameFloat(self.get_tmpreg_f())
else:
@@ -1631,7 +1632,7 @@
def _exit_frame_with_exception(self, e):
sd = self.builder.metainterp_sd
e = lltype.cast_opaque_ptr(llmemory.GCREF, e)
- raise jitexc.ExitFrameWithExceptionRef(self.cpu, e)
+ raise jitexc.ExitFrameWithExceptionRef(e)
def _handle_jitexception_in_portal(self, e):
# This case is really rare, but can occur if
diff --git a/rpython/jit/metainterp/compile.py
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -1,6 +1,7 @@
import weakref
from rpython.rtyper.lltypesystem import lltype, llmemory
-from rpython.rtyper.annlowlevel import cast_instance_to_gcref
+from rpython.rtyper.annlowlevel import (
+ cast_instance_to_gcref, cast_gcref_to_instance)
from rpython.rlib.objectmodel import we_are_translated
from rpython.rlib.debug import debug_start, debug_stop, debug_print,
have_debug_prints
from rpython.rlib.rarithmetic import r_uint, intmask
@@ -20,7 +21,8 @@
from rpython.jit.metainterp.resume import (PENDINGFIELDSP,
ResumeDataDirectReader, AccumInfo)
from rpython.jit.metainterp.resumecode import NUMBERING
-from rpython.jit.codewriter import heaptracker, longlong
+from rpython.jit.metainterp.support import adr2int
+from rpython.jit.codewriter import longlong
def giveup():
@@ -654,6 +656,7 @@
class DoneWithThisFrameDescrInt(_DoneWithThisFrameDescr):
def get_result(self, cpu, deadframe):
return cpu.get_int_value(deadframe, 0)
+
def handle_fail(self, deadframe, metainterp_sd, jitdriver_sd):
assert jitdriver_sd.result_type == history.INT
cpu = metainterp_sd.cpu
@@ -662,14 +665,16 @@
class DoneWithThisFrameDescrRef(_DoneWithThisFrameDescr):
def get_result(self, cpu, deadframe):
return cpu.get_ref_value(deadframe, 0)
+
def handle_fail(self, deadframe, metainterp_sd, jitdriver_sd):
assert jitdriver_sd.result_type == history.REF
cpu = metainterp_sd.cpu
- raise jitexc.DoneWithThisFrameRef(cpu, self.get_result(cpu, deadframe))
+ raise jitexc.DoneWithThisFrameRef(self.get_result(cpu, deadframe))
class DoneWithThisFrameDescrFloat(_DoneWithThisFrameDescr):
def get_result(self, cpu, deadframe):
return cpu.get_float_value(deadframe, 0)
+
def handle_fail(self, deadframe, metainterp_sd, jitdriver_sd):
assert jitdriver_sd.result_type == history.FLOAT
cpu = metainterp_sd.cpu
@@ -679,7 +684,7 @@
def handle_fail(self, deadframe, metainterp_sd, jitdriver_sd):
cpu = metainterp_sd.cpu
value = cpu.get_ref_value(deadframe, 0)
- raise jitexc.ExitFrameWithExceptionRef(cpu, value)
+ raise jitexc.ExitFrameWithExceptionRef(value)
def make_and_attach_done_descrs(targets):
@@ -730,7 +735,7 @@
else:
from rpython.jit.metainterp.blackhole import resume_in_blackhole
if isinstance(self, ResumeGuardCopiedDescr):
- resume_in_blackhole(metainterp_sd, jitdriver_sd, self.prev,
deadframe)
+ resume_in_blackhole(metainterp_sd, jitdriver_sd, self.prev,
deadframe)
else:
assert isinstance(self, ResumeGuardDescr)
resume_in_blackhole(metainterp_sd, jitdriver_sd, self,
deadframe)
@@ -921,22 +926,19 @@
cloned.copy_all_attributes_from(self)
return cloned
-class AllVirtuals:
+class AllVirtuals(object):
llopaque = True
cache = None
def __init__(self, cache):
self.cache = cache
- def hide(self, cpu):
- ptr = cpu.ts.cast_instance_to_base_ref(self)
- return cpu.ts.cast_to_ref(ptr)
+ def hide(self):
+ return cast_instance_to_gcref(self)
@staticmethod
- def show(cpu, gcref):
- from rpython.rtyper.annlowlevel import cast_base_ptr_to_instance
- ptr = cpu.ts.cast_to_baseclass(gcref)
- return cast_base_ptr_to_instance(AllVirtuals, ptr)
+ def show(gcref):
+ return cast_gcref_to_instance(AllVirtuals, gcref)
def invent_fail_descr_for_op(opnum, optimizer, copied_from_descr=None):
if opnum == rop.GUARD_NOT_FORCED or opnum == rop.GUARD_NOT_FORCED_2:
@@ -971,7 +973,7 @@
# handle_async_forcing() just a moment ago.
from rpython.jit.metainterp.blackhole import resume_in_blackhole
hidden_all_virtuals = metainterp_sd.cpu.get_savedata_ref(deadframe)
- obj = AllVirtuals.show(metainterp_sd.cpu, hidden_all_virtuals)
+ obj = AllVirtuals.show(hidden_all_virtuals)
all_virtuals = obj.cache
if all_virtuals is None:
all_virtuals = ResumeDataDirectReader.VirtualCache([], [])
@@ -1014,8 +1016,7 @@
# Handle all_virtuals: keep them for later blackholing from the
# future failure of the GUARD_NOT_FORCED
obj = AllVirtuals(all_virtuals)
- hidden_all_virtuals = obj.hide(metainterp_sd.cpu)
- metainterp_sd.cpu.set_savedata_ref(deadframe, hidden_all_virtuals)
+ metainterp_sd.cpu.set_savedata_ref(deadframe, obj.hide())
class ResumeFromInterpDescr(ResumeDescr):
def __init__(self, original_greenkey):
@@ -1120,7 +1121,7 @@
if not exception:
exception = cast_instance_to_gcref(memory_error)
assert exception, "PropagateExceptionDescr: no exception??"
- raise jitexc.ExitFrameWithExceptionRef(cpu, exception)
+ raise jitexc.ExitFrameWithExceptionRef(exception)
def compile_tmp_callback(cpu, jitdriver_sd, greenboxes, redargtypes,
memory_manager=None):
@@ -1147,7 +1148,7 @@
raise AssertionError
inputargs.append(box)
k = jitdriver_sd.portal_runner_adr
- funcbox = history.ConstInt(heaptracker.adr2int(k))
+ funcbox = history.ConstInt(adr2int(k))
callargs = [funcbox] + greenboxes + inputargs
#
diff --git a/rpython/jit/metainterp/history.py
b/rpython/jit/metainterp/history.py
--- a/rpython/jit/metainterp/history.py
+++ b/rpython/jit/metainterp/history.py
@@ -1,8 +1,10 @@
import sys
from rpython.rtyper.extregistry import ExtRegistryEntry
from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
-from rpython.rlib.objectmodel import we_are_translated, Symbolic
-from rpython.rlib.objectmodel import compute_unique_id, specialize
+from rpython.rtyper.annlowlevel import (
+ cast_gcref_to_instance, cast_instance_to_gcref)
+from rpython.rlib.objectmodel import (
+ we_are_translated, Symbolic, compute_unique_id, specialize, r_dict)
from rpython.rlib.rarithmetic import r_int64, is_valid_int
from rpython.rlib.rarithmetic import LONG_BIT, intmask, r_uint
from rpython.rlib.jit import Counters
@@ -12,7 +14,8 @@
from rpython.jit.metainterp.resoperation import ResOperation, rop,\
AbstractValue, oparity, AbstractResOp, IntOp, RefOp, FloatOp,\
opclasses
-from rpython.jit.codewriter import heaptracker, longlong
+from rpython.jit.metainterp.support import ptr2int, int2adr
+from rpython.jit.codewriter import longlong
import weakref
from rpython.jit.metainterp import jitexc
@@ -97,14 +100,11 @@
return '%r' % (self,)
def hide(self, cpu):
- descr_ptr = cpu.ts.cast_instance_to_base_ref(self)
- return cpu.ts.cast_to_ref(descr_ptr)
+ return cast_instance_to_gcref(self)
@staticmethod
def show(cpu, descr_gcref):
- from rpython.rtyper.annlowlevel import cast_base_ptr_to_instance
- descr_ptr = cpu.ts.cast_to_baseclass(descr_gcref)
- return cast_base_ptr_to_instance(AbstractDescr, descr_ptr)
+ return cast_gcref_to_instance(AbstractDescr, descr_gcref)
def get_vinfo(self):
raise NotImplementedError
@@ -182,12 +182,10 @@
kind = getkind(T)
if kind == "int":
if isinstance(T, lltype.Ptr):
- intval = heaptracker.adr2int(llmemory.cast_ptr_to_adr(x))
+ intval = ptr2int(x)
else:
intval = lltype.cast_primitive(lltype.Signed, x)
return ConstInt(intval)
- elif kind == "ref":
- return cpu.ts.new_ConstRef(x)
elif kind == "float":
return ConstFloat(longlong.getfloatstorage(x))
else:
@@ -231,7 +229,7 @@
getvalue = getint
def getaddr(self):
- return heaptracker.int2adr(self.value)
+ return int2adr(self.value)
def _get_hash_(self):
return make_hashable_int(self.value)
@@ -354,7 +352,7 @@
from rpython.rtyper.lltypesystem.ll2ctypes import
NotCtypesAllocatedStructure
if not we_are_translated() and isinstance(i, llmemory.AddressAsInt):
# Warning: such a hash changes at the time of translation
- adr = heaptracker.int2adr(i)
+ adr = int2adr(i)
try:
return llmemory.cast_adr_to_int(adr, "emulated")
except NotCtypesAllocatedStructure:
@@ -389,6 +387,20 @@
return result
_const_ptr_for_unicode = {}
+# A dict whose keys are refs (like the .value of ConstPtr).
+# It is an r_dict. Note that NULL is not allowed as a key.
[email protected]_location()
+def new_ref_dict():
+ return r_dict(rd_eq, rd_hash, simple_hash_eq=True)
+
+def rd_eq(ref1, ref2):
+ return ref1 == ref2
+
+def rd_hash(ref):
+ assert ref
+ return lltype.identityhash(ref)
+
+
# ____________________________________________________________
# The JitCellToken class is the root of a tree of traces. Each branch ends
@@ -716,7 +728,7 @@
@specialize.argtype(2)
def set_op_value(self, op, value):
if value is None:
- return
+ return
elif isinstance(value, bool):
op.setint(int(value))
elif lltype.typeOf(value) == lltype.Signed:
diff --git a/rpython/jit/metainterp/jitexc.py b/rpython/jit/metainterp/jitexc.py
--- a/rpython/jit/metainterp/jitexc.py
+++ b/rpython/jit/metainterp/jitexc.py
@@ -1,6 +1,6 @@
from rpython.rtyper.annlowlevel import cast_instance_to_base_ptr
from rpython.rtyper.annlowlevel import cast_base_ptr_to_instance
-from rpython.rtyper.lltypesystem import lltype
+from rpython.rtyper.lltypesystem import lltype, llmemory
from rpython.rtyper import rclass
from rpython.rtyper.llinterp import LLException
from rpython.rlib.objectmodel import we_are_translated
@@ -22,13 +22,15 @@
def __init__(self, result):
assert lltype.typeOf(result) is lltype.Signed
self.result = result
+
def __str__(self):
return 'DoneWithThisFrameInt(%s)' % (self.result,)
class DoneWithThisFrameRef(JitException):
- def __init__(self, cpu, result):
- assert lltype.typeOf(result) == cpu.ts.BASETYPE
+ def __init__(self, result):
+ assert lltype.typeOf(result) == llmemory.GCREF
self.result = result
+
def __str__(self):
return 'DoneWithThisFrameRef(%s)' % (self.result,)
@@ -36,13 +38,15 @@
def __init__(self, result):
assert lltype.typeOf(result) is longlong.FLOATSTORAGE
self.result = result
+
def __str__(self):
return 'DoneWithThisFrameFloat(%s)' % (self.result,)
class ExitFrameWithExceptionRef(JitException):
- def __init__(self, cpu, value):
- assert lltype.typeOf(value) == cpu.ts.BASETYPE
+ def __init__(self, value):
+ assert lltype.typeOf(value) == llmemory.GCREF
self.value = value
+
def __str__(self):
return 'ExitFrameWithExceptionRef(%s)' % (self.value,)
diff --git a/rpython/jit/metainterp/logger.py b/rpython/jit/metainterp/logger.py
--- a/rpython/jit/metainterp/logger.py
+++ b/rpython/jit/metainterp/logger.py
@@ -1,4 +1,4 @@
-from rpython.jit.metainterp.history import ConstInt, ConstFloat
+from rpython.jit.metainterp.history import ConstInt, ConstFloat, ConstPtr
from rpython.jit.metainterp.resoperation import rop, AbstractInputArg
from rpython.rlib.debug import (have_debug_prints, debug_start, debug_stop,
debug_print)
@@ -135,7 +135,6 @@
"""
def __init__(self, metainterp_sd, guard_number, memo):
self.metainterp_sd = metainterp_sd
- self.ts = metainterp_sd.cpu.ts
self.guard_number = guard_number
if memo is None:
memo = {}
@@ -157,7 +156,7 @@
if name:
return 'ConstClass(' + name + ')'
return str(arg.value)
- elif isinstance(arg, self.ts.ConstRef):
+ elif isinstance(arg, ConstPtr):
if arg.value:
return 'ConstPtr(ptr' + str(mv) + ')'
return 'ConstPtr(null)'
diff --git a/rpython/jit/metainterp/opencoder.py
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -6,14 +6,14 @@
Snapshot index for guards points to snapshot stored in _snapshots of trace
"""
-from rpython.jit.metainterp.history import ConstInt, Const, ConstFloat,
ConstPtr
+from rpython.jit.metainterp.history import (
+ ConstInt, Const, ConstFloat, ConstPtr, new_ref_dict)
from rpython.jit.metainterp.resoperation import AbstractResOp,
AbstractInputArg,\
ResOperation, oparity, rop, opwithdescr, GuardResOp, IntOp, FloatOp,
RefOp,\
opclasses
from rpython.rlib.rarithmetic import intmask, r_uint
from rpython.rlib.objectmodel import we_are_translated, specialize
from rpython.rtyper.lltypesystem import rffi, lltype, llmemory
-from rpython.jit.metainterp.typesystem import llhelper
TAGINT, TAGCONSTPTR, TAGCONSTOTHER, TAGBOX = range(4)
TAGMASK = 0x3
@@ -179,7 +179,7 @@
if opwithdescr[opnum]:
descr_index = self._next()
if rop.is_guard(opnum):
- update_liveranges(self.trace._snapshots[descr_index], index,
+ update_liveranges(self.trace._snapshots[descr_index], index,
liveranges)
if opclasses[opnum].type != 'v':
return index + 1
@@ -274,7 +274,7 @@
self._consts_ptr = 0
self._descrs = [None]
self._refs = [lltype.nullptr(llmemory.GCREF.TO)]
- self._refs_dict = llhelper.new_ref_dict_3()
+ self._refs_dict = new_ref_dict()
self._bigints = []
self._bigints_dict = {}
self._floats = []
@@ -304,7 +304,7 @@
assert not self.tag_overflow
self._bigints_dict = {}
- self._refs_dict = llhelper.new_ref_dict_3()
+ self._refs_dict = new_ref_dict()
debug_start("jit-trace-done")
debug_print("trace length: " + str(self._pos))
debug_print(" total snapshots: " + str(self._total_snapshots))
diff --git a/rpython/jit/metainterp/optimizeopt/bridgeopt.py
b/rpython/jit/metainterp/optimizeopt/bridgeopt.py
--- a/rpython/jit/metainterp/optimizeopt/bridgeopt.py
+++ b/rpython/jit/metainterp/optimizeopt/bridgeopt.py
@@ -2,6 +2,7 @@
optimizer of the bridge attached to a guard. """
from rpython.jit.metainterp import resumecode
+from rpython.jit.metainterp.history import Const, ConstInt, CONST_NULL
# adds the following sections at the end of the resume code:
@@ -34,7 +35,6 @@
# maybe should be delegated to the optimization classes?
def tag_box(box, liveboxes_from_env, memo):
- from rpython.jit.metainterp.history import Const
if isinstance(box, Const):
return memo.getconst(box)
else:
@@ -43,13 +43,12 @@
def decode_box(resumestorage, tagged, liveboxes, cpu):
from rpython.jit.metainterp.resume import untag, TAGCONST, TAGINT, TAGBOX
from rpython.jit.metainterp.resume import NULLREF, TAG_CONST_OFFSET,
tagged_eq
- from rpython.jit.metainterp.history import ConstInt
num, tag = untag(tagged)
# NB: the TAGVIRTUAL case can't happen here, because this code runs after
# virtuals are already forced again
if tag == TAGCONST:
if tagged_eq(tagged, NULLREF):
- box = cpu.ts.CONST_NULL
+ box = CONST_NULL
else:
box = resumestorage.rd_consts[num - TAG_CONST_OFFSET]
elif tag == TAGINT:
@@ -61,7 +60,6 @@
return box
def serialize_optimizer_knowledge(optimizer, numb_state, liveboxes,
liveboxes_from_env, memo):
- from rpython.jit.metainterp.history import ConstInt
available_boxes = {}
for box in liveboxes:
if box is not None and box in liveboxes_from_env:
@@ -124,7 +122,6 @@
numb_state.append_int(0)
def deserialize_optimizer_knowledge(optimizer, resumestorage, frontend_boxes,
liveboxes):
- from rpython.jit.metainterp.history import ConstInt
reader = resumecode.Reader(resumestorage.rd_numb)
assert len(frontend_boxes) == len(liveboxes)
metainterp_sd = optimizer.metainterp_sd
@@ -145,7 +142,7 @@
class_known = bitfield & mask
mask >>= 1
if class_known:
- cls = optimizer.cpu.ts.cls_of_box(frontend_boxes[i])
+ cls = optimizer.cpu.cls_of_box(frontend_boxes[i])
optimizer.make_constant_class(box, cls)
# heap knowledge
diff --git a/rpython/jit/metainterp/optimizeopt/heap.py
b/rpython/jit/metainterp/optimizeopt/heap.py
--- a/rpython/jit/metainterp/optimizeopt/heap.py
+++ b/rpython/jit/metainterp/optimizeopt/heap.py
@@ -3,7 +3,7 @@
from rpython.jit.codewriter.effectinfo import EffectInfo
from rpython.jit.metainterp.optimizeopt.util import args_dict
-from rpython.jit.metainterp.history import Const, ConstInt
+from rpython.jit.metainterp.history import Const, ConstInt, new_ref_dict
from rpython.jit.metainterp.jitexc import JitException
from rpython.jit.metainterp.optimizeopt.optimizer import Optimization, REMOVED
from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method
@@ -14,7 +14,7 @@
GuardResOp
from rpython.rlib.objectmodel import we_are_translated
from rpython.jit.metainterp.optimizeopt import info
-
+
class BogusImmutableField(JitException):
@@ -97,7 +97,7 @@
# need any _lazy_set: the heap value is already right.
# Note that this may reset to None a non-None lazy_set,
# cancelling its previous effects with no side effect.
-
+
# Now, we have to force the item in the short preamble
self._getfield(structinfo, op.getdescr(), optheap)
self._lazy_set = None
@@ -251,7 +251,7 @@
def setup(self):
self.optimizer.optheap = self
# mapping const value -> info corresponding to it's heap cache
- self.const_infos = self.optimizer.cpu.ts.new_ref_dict()
+ self.const_infos = new_ref_dict()
def flush(self):
self.cached_dict_reads.clear()
diff --git a/rpython/jit/metainterp/optimizeopt/info.py
b/rpython/jit/metainterp/optimizeopt/info.py
--- a/rpython/jit/metainterp/optimizeopt/info.py
+++ b/rpython/jit/metainterp/optimizeopt/info.py
@@ -15,7 +15,7 @@
class AbstractInfo(AbstractValue):
_attrs_ = ()
-
+
is_info_class = True
def force_box(self, op, optforce):
@@ -89,7 +89,7 @@
class NonNullPtrInfo(PtrInfo):
_attrs_ = ('last_guard_pos',)
last_guard_pos = -1
-
+
def is_nonnull(self):
return True
@@ -469,7 +469,7 @@
def setitem_raw(self, offset, itemsize, descr, itemop):
self.parent.setitem_raw(self.offset+offset, itemsize, descr, itemop)
-
+
def _force_elements(self, op, optforce, descr):
if self.parent.is_virtual():
self.parent._force_elements(op, optforce, descr)
@@ -643,7 +643,7 @@
return 0 # annotation hack
one_size = len(all_fdescrs)
return index * one_size + fielddescr.get_field_descr().get_index()
-
+
def setinteriorfield_virtual(self, index, fielddescr, fld):
index = self._compute_index(index, fielddescr)
self._items[index] = fld
@@ -693,7 +693,7 @@
class ConstPtrInfo(PtrInfo):
_attrs_ = ('_const',)
-
+
def __init__(self, const):
self._const = const
@@ -719,7 +719,7 @@
if info is None:
info = ArrayPtrInfo(descr)
optheap.const_infos[ref] = info
- return info
+ return info
def getfield(self, fielddescr, optheap=None):
info = self._get_info(fielddescr.get_parent_descr(), optheap)
@@ -755,7 +755,7 @@
# guard_gc_type
if not cpu.check_is_object(self._const.getref_base()):
return None
- return cpu.ts.cls_of_box(self._const)
+ return cpu.cls_of_box(self._const)
def same_info(self, other):
if not isinstance(other, ConstPtrInfo):
@@ -804,7 +804,7 @@
return -1
return len(s)
elif mode is vstring.mode_unicode:
- s = self._unpack_str(vstring.mode_unicode)
+ s = self._unpack_str(vstring.mode_unicode)
if s is None:
return -1
return len(s)
@@ -835,7 +835,7 @@
targetbox, CONST_0, offsetbox,
lgt, mode)
-
+
class FloatConstInfo(AbstractInfo):
def __init__(self, const):
self._const = const
diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py
b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimizeopt/optimizer.py
@@ -1,6 +1,7 @@
from rpython.jit.metainterp import jitprof, resume, compile
from rpython.jit.metainterp.executor import execute_nonspec_const
-from rpython.jit.metainterp.history import Const, ConstInt, ConstPtr
+from rpython.jit.metainterp.history import (
+ Const, ConstInt, ConstPtr, CONST_NULL, new_ref_dict)
from rpython.jit.metainterp.optimizeopt.intutils import IntBound,\
ConstIntBound, MININT, MAXINT, IntUnbounded
from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method
@@ -8,7 +9,6 @@
OpHelpers
from rpython.jit.metainterp.optimizeopt import info
from rpython.jit.metainterp.optimize import InvalidLoop
-from rpython.jit.metainterp.typesystem import llhelper
from rpython.rlib.objectmodel import specialize, we_are_translated
from rpython.rlib.debug import debug_print
from rpython.rtyper import rclass
@@ -21,7 +21,6 @@
CONST_0 = ConstInt(0)
CONST_1 = ConstInt(1)
CONST_ZERO_FLOAT = Const._new(0.0)
-llhelper.CONST_NULLREF = llhelper.CONST_NULL
REMOVED = AbstractResOp()
class LoopInfo(object):
@@ -158,7 +157,7 @@
if isinstance(fw, info.AbstractRawPtrInfo):
return True
return False
-
+
def getrawptrinfo(self, op, create=False, is_object=False):
assert op.type == 'i'
op = self.get_box_replacement(op)
@@ -272,7 +271,7 @@
self.metainterp_sd = metainterp_sd
self.jitdriver_sd = jitdriver_sd
self.cpu = metainterp_sd.cpu
- self.interned_refs = self.cpu.ts.new_ref_dict()
+ self.interned_refs = new_ref_dict()
self.resumedata_memo = resume.ResumeDataLoopMemo(metainterp_sd)
self.pendingfields = None # set temporarily to a list, normally by
# heap.py, as we're about to generate a guard
@@ -464,7 +463,7 @@
def make_nonnull_str(self, op, mode):
from rpython.jit.metainterp.optimizeopt import vstring
-
+
op = self.get_box_replacement(op)
if op.is_constant():
return
@@ -475,7 +474,7 @@
def ensure_ptr_info_arg0(self, op):
from rpython.jit.metainterp.optimizeopt import vstring
-
+
arg0 = self.get_box_replacement(op.getarg(0))
if arg0.is_constant():
return info.ConstPtrInfo(arg0)
@@ -503,7 +502,7 @@
elif opnum in (rop.GUARD_CLASS, rop.GUARD_NONNULL_CLASS):
opinfo = info.InstancePtrInfo()
elif opnum in (rop.STRLEN,):
- opinfo = vstring.StrPtrInfo(vstring.mode_string)
+ opinfo = vstring.StrPtrInfo(vstring.mode_string)
elif opnum in (rop.UNICODELEN,):
opinfo = vstring.StrPtrInfo(vstring.mode_unicode)
else:
@@ -515,7 +514,7 @@
def new_const(self, fieldofs):
if fieldofs.is_pointer_field():
- return self.cpu.ts.CONST_NULL
+ return CONST_NULL
elif fieldofs.is_float_field():
return CONST_ZERO_FLOAT
else:
@@ -523,7 +522,7 @@
def new_const_item(self, arraydescr):
if arraydescr.is_array_of_pointers():
- return self.cpu.ts.CONST_NULL
+ return CONST_NULL
elif arraydescr.is_array_of_floats():
return CONST_ZERO_FLOAT
else:
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py
b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -1,8 +1,8 @@
from rpython.jit.codewriter.effectinfo import EffectInfo
from rpython.jit.codewriter import longlong
from rpython.jit.metainterp import compile
-from rpython.jit.metainterp.history import (Const, ConstInt, make_hashable_int,
- ConstFloat)
+from rpython.jit.metainterp.history import (
+ Const, ConstInt, make_hashable_int, ConstFloat, CONST_NULL)
from rpython.jit.metainterp.optimize import InvalidLoop
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit