--- a/components/python/python27/Makefile Fri May 06 05:10:00 2016 -0700
+++ b/components/python/python27/Makefile Fri May 06 09:33:24 2016 -0700
@@ -85,6 +85,10 @@
CFLAGS += -xO5 $(PYFLAGS.$(MACH))
LDFLAGS += -xO5 $(PYFLAGS.$(MACH))
+# Use the Studio VIS SDK in order to explicitly generate nonfaulting loads
+# that allow Python to work with ADI-aware memory allocators.
+CFLAGS.studio.sparc.64 += -xvis
+
# Python puts its header files in a special place.
LINT_FLAGS += -I$(SOURCE_DIR)/Include
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/python/python27/patches/29-obmalloc-adi.patch Fri May 06 09:33:24 2016 -0700
@@ -0,0 +1,38 @@
+This patch was developed in house for Bug 21658934. Python PyObject_Free()
+implementation relies on being able to read memory that might not belong to
+the current buffer. When ADIHEAP is enabled, this is detected as a violation.
+Use an explicit nonfaulting load to ignore the ADI tag.
+
+This patch only works with Studio; one which supports gcc and
+Studio is being worked on with an intent to push it upstream.
+
+--- a/Objects/obmalloc.c Wed Apr 13 11:52:46 2016 -0700
++++ b/Objects/obmalloc.c Thu Apr 14 07:00:32 2016 -0700
+@@ -42,6 +42,18 @@
+ static int running_on_valgrind = -1;
+ #endif
+
++#ifdef __sparcv9
++#include <vis.h>
++/*
++ * Py_ADDRESS_IN_RANGE needs to access memory that might be arbitrarily
++ * tagged by an ADI aware allocator. The use of a nonfaulting load
++ * guarantees that the read will succeed.
++ */
++#define POOL_INDEX(x) __vis_ldswa_ASI_PNF(&(x))
++#else /* __sparcv9 */
++#define POOL_INDEX(x) (x)
++#endif /* __sparcv9 */
++
+ /* An object allocator for Python.
+
+ Here is an introduction to the layers of the Python memory architecture,
+@@ -735,7 +747,7 @@
+ variable.
+ */
+ #define Py_ADDRESS_IN_RANGE(P, POOL) \
+- ((arenaindex_temp = (POOL)->arenaindex) < maxarenas && \
++ ((arenaindex_temp = POOL_INDEX((POOL)->arenaindex)) < maxarenas && \
+ (uptr)(P) - arenas[arenaindex_temp].address < (uptr)ARENA_SIZE && \
+ arenas[arenaindex_temp].address != 0)
+
--- a/components/python/python34/Makefile Fri May 06 05:10:00 2016 -0700
+++ b/components/python/python34/Makefile Fri May 06 09:33:24 2016 -0700
@@ -77,6 +77,10 @@
# for DWARF
CFLAGS.i386 = -preserve_argvalues=complete
+# Use the Studio VIS SDK in order to explicitly generate nonfaulting loads
+# that allow Python to work with ADI-aware memory allocators.
+CFLAGS.studio.sparc.64 = -xvis
+
CFLAGS += $(CFLAGS.$(MACH))
# 16-byte memory alignment + interpretation of non-alignment prevents SIGBUS.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/python/python34/patches/27-obmalloc-adi.patch Fri May 06 09:33:24 2016 -0700
@@ -0,0 +1,38 @@
+This patch was developed in house for Bug 21658934. Python PyObject_Free()
+implementation relies on being able to read memory that might not belong to
+the current buffer. When ADIHEAP is enabled, this is detected as a violation.
+Use an explicit nonfaulting load to ignore the ADI tag.
+
+This patch only works with Studio; one which supports gcc and
+Studio is being worked on with an intent to push it upstream.
+
+--- a/Objects/obmalloc.c Thu Apr 21 07:30:44 2016 -0700
++++ b/Objects/obmalloc.c Thu Apr 21 07:36:06 2016 -0700
+@@ -384,6 +384,18 @@
+ static int running_on_valgrind = -1;
+ #endif
+
++#ifdef __sparcv9
++#include <vis.h>
++/*
++ * Py_ADDRESS_IN_RANGE needs to access memory that might be arbitrarily
++ * tagged by an ADI aware allocator. The use of a nonfaulting load
++ * guarantees that the read will succeed.
++ */
++#define POOL_INDEX(x) __vis_ldswa_ASI_PNF(&(x))
++#else /* __sparcv9 */
++#define POOL_INDEX(x) (x)
++#endif /* __sparcv9 */
++
+ /* An object allocator for Python.
+
+ Here is an introduction to the layers of the Python memory architecture,
+@@ -1071,7 +1083,7 @@
+ variable.
+ */
+ #define Py_ADDRESS_IN_RANGE(P, POOL) \
+- ((arenaindex_temp = (POOL)->arenaindex) < maxarenas && \
++ ((arenaindex_temp = POOL_INDEX((POOL)->arenaindex)) < maxarenas && \
+ (uptr)(P) - arenas[arenaindex_temp].address < (uptr)ARENA_SIZE && \
+ arenas[arenaindex_temp].address != 0)
+
--- a/components/python/python35/Makefile Fri May 06 05:10:00 2016 -0700
+++ b/components/python/python35/Makefile Fri May 06 09:33:24 2016 -0700
@@ -77,6 +77,10 @@
# for DWARF
CFLAGS.i386 = -preserve_argvalues=complete
+# Use the Studio VIS SDK in order to explicitly generate nonfaulting loads
+# that allow Python to work with ADI-aware memory allocators.
+CFLAGS.studio.sparc.64 = -xvis
+
CFLAGS += $(CFLAGS.$(MACH))
# 16-byte memory alignment + interpretation of non-alignment prevents SIGBUS.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/python/python35/patches/30-obmalloc-adi.patch Fri May 06 09:33:24 2016 -0700
@@ -0,0 +1,38 @@
+This patch was developed in house for Bug 21658934. Python PyObject_Free()
+implementation relies on being able to read memory that might not belong to
+the current buffer. When ADIHEAP is enabled, this is detected as a violation.
+Use an explicit nonfaulting load to ignore the ADI tag.
+
+This patch only works with Studio; one which supports gcc and
+Studio is being worked on with an intent to push it upstream.
+
+--- a/Objects/obmalloc.c Thu Apr 14 10:33:32 2016 -0700
++++ b/Objects/obmalloc.c Thu Apr 14 10:38:55 2016 -0700
+@@ -428,6 +428,18 @@
+ static int running_on_valgrind = -1;
+ #endif
+
++#ifdef __sparcv9
++#include <vis.h>
++/*
++ * Py_ADDRESS_IN_RANGE needs to access memory that might be arbitrarily
++ * tagged by an ADI aware allocator. The use of a nonfaulting load
++ * guarantees that the read will succeed.
++ */
++#define POOL_INDEX(x) __vis_ldswa_ASI_PNF(&(x))
++#else /* __sparcv9 */
++#define POOL_INDEX(x) (x)
++#endif /* __sparcv9 */
++
+ /* An object allocator for Python.
+
+ Here is an introduction to the layers of the Python memory architecture,
+@@ -1115,7 +1127,7 @@
+ variable.
+ */
+ #define Py_ADDRESS_IN_RANGE(P, POOL) \
+- ((arenaindex_temp = (POOL)->arenaindex) < maxarenas && \
++ ((arenaindex_temp = POOL_INDEX((POOL)->arenaindex)) < maxarenas && \
+ (uptr)(P) - arenas[arenaindex_temp].address < (uptr)ARENA_SIZE && \
+ arenas[arenaindex_temp].address != 0)
+