[pypy-commit] pypy guard-compatible: a shorter pre-optimized trace
cfbolz
pypy.commits at gmail.com
Wed Mar 30 03:37:54 EDT 2016
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: guard-compatible
Changeset: r83427:9fee3802b752
Date: 2016-03-29 15:50 +0200
http://bitbucket.org/pypy/pypy/changeset/9fee3802b752/
Log: a shorter pre-optimized trace
diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py
--- a/pypy/objspace/std/callmethod.py
+++ b/pypy/objspace/std/callmethod.py
@@ -42,18 +42,22 @@
w_value = None
safe = False
+ w_descr = None
if space.config.objspace.std.withmapdict and jit.we_are_jitted():
# compute safeness without reading the type
map = w_obj._get_mapdict_map_no_promote()
if map is not None and map._type_safe_to_do_getattr():
safe = True
+ name = space.str_w(w_name)
+ w_descr = map._type_lookup_safe(name)
else:
w_type = space.type(w_obj)
safe = w_type.has_object_getattribute()
+ if safe:
+ name = space.str_w(w_name)
+ w_descr = space.lookup(w_obj, name)
if safe:
- name = space.str_w(w_name)
- w_descr = space.lookup(w_obj, name)
if w_descr is None:
# this handles directly the common case
# module.function(args..)
@@ -129,11 +133,12 @@
map = w_obj._get_mapdict_map_no_promote()
if map is not None and map._type_safe_to_do_getattr():
safe = True
+ w_descr = map._type_lookup_safe(methname)
else:
w_type = space.type(w_obj)
safe = w_type.has_object_getattribute()
+ w_descr = space.lookup(w_obj, methname)
if safe:
- w_descr = space.lookup(w_obj, methname)
typ = type(w_descr)
if typ is function.Function or typ is function.FunctionWithFixedCode:
w_value = w_obj.getdictvalue(space, methname)
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -327,6 +327,9 @@
def _type_lookup(self, name):
if not self._type_safe_to_do_getattr():
return self.getclass_from_terminator().lookup(name)
+ return self._type_lookup_safe(name)
+
+ def _type_lookup_safe(self, name):
w_descr = self._type_lookup_pure(name)
if isinstance(w_descr, MutableCell):
w_descr = w_descr.unwrap_cell(self.space)
More information about the pypy-commit
mailing list