Author: Alex Gaynor <[email protected]>
Branch:
Changeset: r44565:9cbfb3b57340
Date: 2011-05-27 18:33 -0700
http://bitbucket.org/pypy/pypy/changeset/9cbfb3b57340/
Log: Merged upstream.
diff --git a/pypy/interpreter/eval.py b/pypy/interpreter/eval.py
--- a/pypy/interpreter/eval.py
+++ b/pypy/interpreter/eval.py
@@ -2,6 +2,7 @@
This module defines the abstract base classes that support execution:
Code and Frame.
"""
+from pypy.rlib import jit
from pypy.interpreter.error import OperationError
from pypy.interpreter.baseobjspace import Wrappable
@@ -97,6 +98,7 @@
"Abstract. Get the expected number of locals."
raise TypeError, "abstract"
+ @jit.dont_look_inside
def fast2locals(self):
# Copy values from self.fastlocals_w to self.w_locals
if self.w_locals is None:
@@ -110,6 +112,7 @@
w_name = self.space.wrap(name)
self.space.setitem(self.w_locals, w_name, w_value)
+ @jit.dont_look_inside
def locals2fast(self):
# Copy values from self.w_locals to self.fastlocals_w
assert self.w_locals is not None
diff --git a/pypy/interpreter/nestedscope.py b/pypy/interpreter/nestedscope.py
--- a/pypy/interpreter/nestedscope.py
+++ b/pypy/interpreter/nestedscope.py
@@ -127,6 +127,7 @@
if self.cells is not None:
self.cells[:ncellvars] = cellvars
+ @jit.dont_look_inside
def fast2locals(self):
super_fast2locals(self)
# cellvars are values exported to inner scopes
@@ -145,6 +146,7 @@
w_name = self.space.wrap(name)
self.space.setitem(self.w_locals, w_name, w_value)
+ @jit.dont_look_inside
def locals2fast(self):
super_locals2fast(self)
freevarnames = self.pycode.co_cellvars + self.pycode.co_freevars
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -413,6 +413,7 @@
"Get the fast locals as a list."
return self.fastlocals_w
+ @jit.dont_look_inside
def setfastscope(self, scope_w):
"""Initialize the fast locals from a list of values,
where the order is according to self.pycode.signature()."""
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1089,6 +1089,7 @@
w_dict = self.space.newdict()
self.pushvalue(w_dict)
+ @jit.unroll_safe
def BUILD_SET(self, itemcount, next_instr):
w_set = self.space.call_function(self.space.w_set)
if itemcount:
diff --git a/pypy/jit/codewriter/policy.py b/pypy/jit/codewriter/policy.py
--- a/pypy/jit/codewriter/policy.py
+++ b/pypy/jit/codewriter/policy.py
@@ -63,12 +63,27 @@
contains_loop = contains_loop and not getattr(
func, '_jit_unroll_safe_', False)
- res = see_function and not contains_unsupported_variable_type(graph,
- self.supports_floats,
- self.supports_longlong)
+ unsupported = contains_unsupported_variable_type(graph,
+ self.supports_floats,
+
self.supports_longlong)
+ res = see_function and not unsupported
if res and contains_loop:
self.unsafe_loopy_graphs.add(graph)
- return res and not contains_loop
+ res = res and not contains_loop
+ if (see_function and not res and
+ getattr(graph, "access_directly", False)):
+ # This happens when we have a function which has an argument with
+ # the access_directly flag, and the annotator has determined we
will
+ # see the function. (See
+ # pypy/annotation/specialize.py:default_specialize) However,
+ # look_inside_graph just decided that we will not see it. (It has a
+ # loop or unsupported variables.) If we return False, the call will
+ # be turned into a residual call, but the graph is access_directly!
+ # If such a function is called and accesses a virtualizable, the
JIT
+ # will not notice, and the virtualizable will fall out of sync. So,
+ # we fail loudly now.
+ raise ValueError("access_directly on a function which we don't
see")
+ return res
def contains_unsupported_variable_type(graph, supports_floats,
supports_longlong):
diff --git a/pypy/jit/codewriter/test/test_policy.py
b/pypy/jit/codewriter/test/test_policy.py
--- a/pypy/jit/codewriter/test/test_policy.py
+++ b/pypy/jit/codewriter/test/test_policy.py
@@ -1,4 +1,5 @@
import sys
+import py
from pypy.jit.codewriter.policy import contains_unsupported_variable_type
from pypy.jit.codewriter.policy import JitPolicy
from pypy.jit.codewriter import support
@@ -107,3 +108,19 @@
mod = called_graph.func.__module__
assert (mod == 'pypy.rpython.rlist' or
mod == 'pypy.rpython.lltypesystem.rlist')
+
+def test_access_directly_but_not_seen():
+ class X:
+ _virtualizable2_ = ["a"]
+ def h(x, y):
+ w = 0
+ for i in range(y):
+ w += 4
+ return w
+ def f(y):
+ x = jit.hint(X(), access_directly=True)
+ h(x, y)
+ rtyper = support.annotate(f, [3])
+ h_graph = rtyper.annotator.translator.graphs[1]
+ assert h_graph.func is h
+ py.test.raises(ValueError, JitPolicy().look_inside_graph, h_graph)
diff --git a/pypy/translator/c/src/debug_print.c
b/pypy/translator/c/src/debug_print.c
--- a/pypy/translator/c/src/debug_print.c
+++ b/pypy/translator/c/src/debug_print.c
@@ -6,6 +6,8 @@
#include <stdio.h>
#ifndef _WIN32
#include <unistd.h>
+#include <time.h>
+#include <sys/time.h>
#else
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
diff --git a/pypy/translator/c/src/debug_print.h
b/pypy/translator/c/src/debug_print.h
--- a/pypy/translator/c/src/debug_print.h
+++ b/pypy/translator/c/src/debug_print.h
@@ -53,8 +53,6 @@
# ifdef _WIN32
# define READ_TIMESTAMP(val) QueryPerformanceCounter((LARGE_INTEGER*)&(val))
# else
-# include <time.h>
-# include <sys/time.h>
long long pypy_read_timestamp();
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit