From: <dgr...@us...> - 2010-10-05 02:26:50
|
Revision: 16975 http://x10.svn.sourceforge.net/x10/?rev=16975&view=rev Author: dgrove-oss Date: 2010-10-05 02:26:43 +0000 (Tue, 05 Oct 2010) Log Message: ----------- remove the 'uncounted' boolean from various copyTo/copyFrom APIs I didn't understand what was actually required when I did this part of the API. What we actually need is a ()=>void function to be registered as a notifier if we are going to do an uncounted copyTo. Will add that functionality in the right way in 2.1.1. But the uncounted copyTo without a notifier is not of any practical use, so removing it from the API before the 2.1.0 release. Modified Paths: -------------- trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.cc trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.h trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.struct_h trunk/x10.runtime/src-x10/x10/array/Array.x10 trunk/x10.runtime/src-x10/x10/util/CUDAUtilities.x10 trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk.x10 trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk__NativeRep.x10 trunk/x10.tests/examples/Constructs/Array/ArrayCopyTo.x10 Modified: trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.cc 2010-10-05 02:23:39 UTC (rev 16974) +++ trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.cc 2010-10-05 02:26:43 UTC (rev 16975) @@ -52,7 +52,7 @@ buf.write(fs); } - void IMC_copyToBody(void *srcAddr, void *dstAddr, x10_int numBytes, Place dstPlace, bool overlap, bool uncounted) { + void IMC_copyToBody(void *srcAddr, void *dstAddr, x10_int numBytes, Place dstPlace, bool overlap) { if (dstPlace->FMGL(id) == x10aux::here) { if (overlap) { // potentially overlapping, use memmove @@ -64,16 +64,12 @@ x10aux::place dst_place = dstPlace->FMGL(id); x10aux::serialization_buffer buf; buf.write((x10_long)(size_t)(dstAddr)); - if (uncounted) { - x10aux::send_put(dst_place, IMC_uncounted_copy_to_serialization_id, buf, srcAddr, numBytes); - } else { - IMC_serialize_finish_state(dst_place, buf); - x10aux::send_put(dst_place, IMC_copy_to_serialization_id, buf, srcAddr, numBytes); - } + IMC_serialize_finish_state(dst_place, buf); + x10aux::send_put(dst_place, IMC_copy_to_serialization_id, buf, srcAddr, numBytes); } } - void IMC_copyFromBody(void *srcAddr, void *dstAddr, x10_int numBytes, Place srcPlace, bool overlap, bool uncounted) { + void IMC_copyFromBody(void *srcAddr, void *dstAddr, x10_int numBytes, Place srcPlace, bool overlap) { if (srcPlace->FMGL(id) == x10aux::here) { if (overlap) { // potentially overlapping, use memmove @@ -85,12 +81,8 @@ x10aux::place src_place = srcPlace->FMGL(id); x10aux::serialization_buffer buf; buf.write((x10_long)(size_t)(srcAddr)); - if (uncounted) { - x10aux::send_get(src_place, IMC_uncounted_copy_from_serialization_id, buf, dstAddr, numBytes); - } else { - IMC_serialize_finish_state(x10aux::here, buf); - x10aux::send_get(src_place, IMC_copy_from_serialization_id, buf, dstAddr, numBytes); - } + IMC_serialize_finish_state(x10aux::here, buf); + x10aux::send_get(src_place, IMC_copy_from_serialization_id, buf, dstAddr, numBytes); } } @@ -113,6 +105,10 @@ // this if every x10rt_net backend would check the callback is // non-null before calling it, and I think some of them do, just not all. + // FIX for 2.1.1. + // Need to be able to register an arbitrary ()=>void function at the X10 + // level as a call back function and then encode that such that the approproate + // function will be executed here. } } } Modified: trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.h 2010-10-05 02:23:39 UTC (rev 16974) +++ trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.h 2010-10-05 02:26:43 UTC (rev 16975) @@ -40,9 +40,9 @@ extern void IMC_uncounted_notifier(x10aux::deserialization_buffer&, x10_int); extern void IMC_copyToBody(void *srcAddr, void *dstAddr, x10_int numBytes, - x10::lang::Place dstPlace, bool overlap, bool uncounted); + x10::lang::Place dstPlace, bool overlap); extern void IMC_copyFromBody(void *srcAddr, void *dstAddr, x10_int numBytes, - x10::lang::Place srcPlace, bool overlap, bool uncounted); + x10::lang::Place srcPlace, bool overlap); template<class T> class IndexedMemoryChunk_ithunk0 : public x10::util::IndexedMemoryChunk<T> { public: @@ -85,21 +85,21 @@ x10::lang::Place dstPlace, x10::util::IndexedMemoryChunk<T> dst, x10_int dstIndex, - x10_int numElems, x10_boolean uncounted) { + x10_int numElems) { void* srcAddr = (void*)(&raw()[srcIndex]); void* dstAddr = (void*)(&dst->raw()[dstIndex]); size_t numBytes = numElems * sizeof(T); - IMC_copyToBody(srcAddr, dstAddr, numBytes, dstPlace, data == dst->data, uncounted); + IMC_copyToBody(srcAddr, dstAddr, numBytes, dstPlace, data == dst->data); } template<class T> void x10::util::IndexedMemoryChunk<T>::copyFrom(x10_int dstIndex, x10::lang::Place srcPlace, x10::util::IndexedMemoryChunk<T> src, - x10_int srcIndex, x10_int numElems, x10_boolean uncounted) { + x10_int srcIndex, x10_int numElems) { void* srcAddr = (void*)(&src->raw()[srcIndex]); void* dstAddr = (void*)(&raw()[dstIndex]); size_t numBytes = numElems * sizeof(T); - IMC_copyFromBody(srcAddr, dstAddr, numBytes, srcPlace, data == src->data, uncounted); + IMC_copyFromBody(srcAddr, dstAddr, numBytes, srcPlace, data == src->data); } Modified: trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.struct_h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.struct_h 2010-10-05 02:23:39 UTC (rev 16974) +++ trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.struct_h 2010-10-05 02:26:43 UTC (rev 16975) @@ -45,11 +45,11 @@ void copyTo(x10_int srcIndex, x10::lang::Place dstPlace, x10::util::IndexedMemoryChunk<T> dst, - x10_int dstIndex, x10_int numElems, x10_boolean uncounted); + x10_int dstIndex, x10_int numElems); void copyFrom(x10_int dstIndex, x10::lang::Place srcPlace, x10::util::IndexedMemoryChunk<T> src, - x10_int srcIndex, x10_int numElems, x10_boolean uncounted); + x10_int srcIndex, x10_int numElems); x10::util::IndexedMemoryChunk<T>* operator->() { return this; } Modified: trunk/x10.runtime/src-x10/x10/array/Array.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Array.x10 2010-10-05 02:23:39 UTC (rev 16974) +++ trunk/x10.runtime/src-x10/x10/array/Array.x10 2010-10-05 02:26:43 UTC (rev 16975) @@ -285,7 +285,7 @@ layout = RectLayout(region); val n = layout.size(); val r = IndexedMemoryChunk.allocate[T](n); - init.raw.asyncCopyTo(0, here, r, 0, n, false); + init.raw.asyncCopyTo(0, here, r, 0, n); raw = r; rawLength = n; cachedRail = rail; @@ -769,36 +769,8 @@ * of the two arrays. */ public static def asyncCopy[T](src:Array[T], dst:RemoteArray[T]) { - asyncCopy(src, dst, false); - } - - - /** - * Asynchronously copy all of the values from the source Array to the - * Array referenced by the destination RemoteArray. - * The two arrays must be defined over Regions with equal size - * bounding boxes; if the backing storage for the two arrays is - * not of equal size, then an IllegalArgumentExeption will be raised.<p> - * - * Depending on the value of the uncounted parameter, the activity performing - * the copy will either be registered with the dynamically enclosing finish or - * treated as if it was annotated with @Uncounted (not registered with any finish).</p> - * - * Warning: This method is only intended to be used on Arrays containing - * non-Object data elements. The elements are actually copied via an - * optimized DMA operation if available. Therefore object-references will - * not be properly transferred. Ideally, future versions of the X10 type - * system would enable this restriction to be checked statically.</p> - * - * @param src the source array. - * @param dst the destination array. May actually be local or remote - * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted - * @throws IllegalArgumentException if mismatch in size of backing storage - * of the two arrays. - */ - public static def asyncCopy[T](src:Array[T], dst:RemoteArray[T], uncounted:boolean) { if (src.rawLength != dst.rawLength) throw new IllegalArgumentException("source and destination do not have equal size"); - src.raw.asyncCopyTo(0, dst.home, dst.rawData, 0, src.rawLength, uncounted); + src.raw.asyncCopyTo(0, dst.home, dst.rawData, 0, src.rawLength); } @@ -831,44 +803,9 @@ public static def asyncCopy[T](src:Array[T], srcPoint:Point, dst:RemoteArray[T], dstPoint:Point, numElems:int) { - asyncCopy(src, srcPoint, dst, dstPoint, numElems, false); - } - - - /** - * Asynchronously copy the specified values from the source Array to the - * specified portion of the Array referenced by the destination RemoteArray. - * If accessing any point in either the specified source or the - * specified destination range would in an ArrayIndexOutOfBoundsError - * being raised, then this method will throw an IllegalArgumentException.<p> - * - * Depending on the value of the uncounted parameter, the activity performing - * the copy will either be registered with the dynamically enclosing finish or - * treated as if it was annotated with @Uncounted (not registered with any finish).</p> - * - * Warning: This method is only intended to be used on Arrays containing - * non-Object data elements. The elements are actually copied via an - * optimized DMA operation if available. Therefore object-references will - * not be properly transferred. Ideally, future versions of the X10 type - * system would enable this restriction to be checked statically.</p> - * - * @param src the source array. - * @param srcPoint the first element in this array to be copied. - * @param dst the destination array. May actually be local or remote - * @param dstPoint the first element in the destination - * array where copied data elements will be stored. - * @param numElems the number of elements to be copied. - * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted - * - * @throws IllegalArgumentException if the specified copy regions would - * result in an ArrayIndexOutOfBoundsException. - */ - public static def asyncCopy[T](src:Array[T], srcPoint:Point, - dst:RemoteArray[T], dstPoint:Point, - numElems:int, uncounted:boolean) { val gra = dst.array; val dstIndex = at (gra) gra().region.indexOf(dstPoint); - asyncCopy(src, src.region.indexOf(srcPoint), dst, dstIndex, numElems, uncounted); + asyncCopy(src, src.region.indexOf(srcPoint), dst, dstIndex, numElems); } @@ -910,57 +847,13 @@ public static def asyncCopy[T](src:Array[T], srcIndex:int, dst:RemoteArray[T], dstIndex:int, numElems:int) { - asyncCopy(src, srcIndex, dst, dstIndex, numElems, false); - } - - - /** - * Asynchronously copy the specified values from the source Array to the - * specified portion of the Array referenced by the destination RemoteArray. - * The index arguments that are used to specify the start of the source - * and destination regions are interpreted as of they were the result - * of calling @link{Region@indexOf} on the Point that specifies the - * start of the copy region. Note that for Arrays that have the - * <code>rail</code> property, this exactly corresponds to the index - * that would be used to access the element via apply or set. - * If accessing any point in either the specified source or the - * specified destination range would in an ArrayIndexOutOfBoundsError - * being raised, then this method will throw an IllegalArgumentException.<p> - * - * Depending on the value of the uncounted parameter, the activity performing - * the copy will either be registered with the dynamically enclosing finish or - * treated as if it was annotated with @Uncounted (not registered with any finish).</p> - * - * Warning: This method is only intended to be used on Arrays containing - * non-Object data elements. The elements are actually copied via an - * optimized DMA operation if available. Therefore object-references will - * not be properly transferred. Ideally, future versions of the X10 type - * system would enable this restriction to be checked statically.</p> - * - * @param src the source array. - * @param srcIndex the index of the first element in this array - * to be copied. - * @param dst the destination array. May actually be local or remote - * @param dstIndex the index of the first element in the destination - * array where copied data elements will be stored. - * @param numElems the number of elements to be copied. - * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted - * - * @see Region#indexOf - * - * @throws IllegalArgumentException if the specified copy regions would - * result in an ArrayIndexOutOfBoundsException. - */ - public static def asyncCopy[T](src:Array[T], srcIndex:int, - dst:RemoteArray[T], dstIndex:int, - numElems:int, uncounted:boolean) { if (srcIndex < 0 || ((srcIndex+numElems) > src.rawLength)) { throw new IllegalArgumentException("Specified range is beyond bounds of source array"); } if (dstIndex < 0 || ((dstIndex+numElems) > dst.rawLength)) { throw new IllegalArgumentException("Specified range is beyond bounds of destination array"); } - src.raw.asyncCopyTo(srcIndex, dst.home, dst.rawData, dstIndex, numElems, uncounted); + src.raw.asyncCopyTo(srcIndex, dst.home, dst.rawData, dstIndex, numElems); } @@ -986,36 +879,8 @@ * of the two arrays. */ public static def asyncCopy[T](src:RemoteArray[T], dst:Array[T]) { - asyncCopy(src, dst, false); - } - - - /** - * Asynchronously copy all of the values from the source Array - * referenced by the RemoteArray to the destination Array. - * The two arrays must be defined over Regions with equal size - * bounding boxes; if the backing storage for the two arrays is - * not of equal size, then an IllegalArgumentExeption will be raised.<p> - * - * Depending on the value of the uncounted parameter, the activity performing - * the copy will either be registered with the dynamically enclosing finish or - * treated as if it was annotated with @Uncounted (not registered with any finish).</p> - * - * Warning: This method is only intended to be used on Arrays containing - * non-Object data elements. The elements are actually copied via an - * optimized DMA operation if available. Therefore object-references will - * not be properly transferred. Ideally, future versions of the X10 type - * system would enable this restriction to be checked statically.</p> - * - * @param src the source array. - * @param dst the destination array. May actually be local or remote - * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted - * @throws IllegalArgumentException if mismatch in size of backing storage - * of the two arrays. - */ - public static def asyncCopy[T](src:RemoteArray[T], dst:Array[T], uncounted:boolean) { if (src.rawLength != dst.rawLength) throw new IllegalArgumentException("source and destination do not have equal size"); - dst.raw.asyncCopyFrom(0, src.home, src.rawData, 0, dst.rawLength, uncounted); + dst.raw.asyncCopyFrom(0, src.home, src.rawData, 0, dst.rawLength); } @@ -1048,44 +913,9 @@ public static def asyncCopy[T](src:RemoteArray[T], srcPoint:Point, dst:Array[T], dstPoint:Point, numElems:int) { - asyncCopy(src, srcPoint, dst, dstPoint, numElems, false); - } - - - /** - * Asynchronously copy the specified values from the Array referenced by - * the source RemoteArray to the specified portion of the destination Array. - * If accessing any point in either the specified source or the - * specified destination range would in an ArrayIndexOutOfBoundsError - * being raised, then this method will throw an IllegalArgumentException.<p> - * - * Depending on the value of the uncounted parameter, the activity performing - * the copy will either be registered with the dynamically enclosing finish or - * treated as if it was annotated with @Uncounted (not registered with any finish).</p> - * - * Warning: This method is only intended to be used on Arrays containing - * non-Object data elements. The elements are actually copied via an - * optimized DMA operation if available. Therefore object-references will - * not be properly transferred. Ideally, future versions of the X10 type - * system would enable this restriction to be checked statically.</p> - * - * @param src the source array. - * @param srcPoint the first element in this array to be copied. - * @param dst the destination array. May actually be local or remote - * @param dstPoint the first element in the destination - * array where copied data elements will be stored. - * @param numElems the number of elements to be copied. - * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted - * - * @throws IllegalArgumentException if the specified copy regions would - * result in an ArrayIndexOutOfBoundsException. - */ - public static def asyncCopy[T](src:RemoteArray[T], srcPoint:Point, - dst:Array[T], dstPoint:Point, - numElems:int, uncounted:boolean) { val gra = src.array; val srcIndex = at (gra) gra().region.indexOf(srcPoint); - asyncCopy(src, srcIndex, dst, dst.region.indexOf(dstPoint), numElems, uncounted); + asyncCopy(src, srcIndex, dst, dst.region.indexOf(dstPoint), numElems); } @@ -1127,57 +957,13 @@ public static def asyncCopy[T](src:RemoteArray[T], srcIndex:int, dst:Array[T], dstIndex:int, numElems:int) { - asyncCopy(src, srcIndex, dst, dstIndex, numElems, false); - } - - - /** - * Asynchronously copy the specified values from the Array referenced by - * the source RemoteArray to the specified portion of the destination Array. - * The index arguments that are used to specify the start of the source - * and destination regions are interpreted as of they were the result - * of calling @link{Region@indexOf} on the Point that specifies the - * start of the copy region. Note that for Arrays that have the - * <code>rail</code> property, this exactly corresponds to the index - * that would be used to access the element via apply or set. - * If accessing any point in either the specified source or the - * specified destination range would in an ArrayIndexOutOfBoundsError - * being raised, then this method will throw an IllegalArgumentException.<p> - * - * Depending on the value of the uncounted parameter, the activity performing - * the copy will either be registered with the dynamically enclosing finish or - * treated as if it was annotated with @Uncounted (not registered with any finish).</p> - * - * Warning: This method is only intended to be used on Arrays containing - * non-Object data elements. The elements are actually copied via an - * optimized DMA operation if available. Therefore object-references will - * not be properly transferred. Ideally, future versions of the X10 type - * system would enable this restriction to be checked statically.</p> - * - * @param src the source array. - * @param srcIndex the index of the first element in this array - * to be copied. - * @param dst the destination array. May actually be local or remote - * @param dstIndex the index of the first element in the destination - * array where copied data elements will be stored. - * @param numElems the number of elements to be copied. - * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted - * - * @see Region#indexOf - * - * @throws IllegalArgumentException if the specified copy regions would - * result in an ArrayIndexOutOfBoundsException. - */ - public static def asyncCopy[T](src:RemoteArray[T], srcIndex:int, - dst:Array[T], dstIndex:int, - numElems:int, uncounted:boolean) { if (srcIndex < 0 || ((srcIndex+numElems) > src.rawLength)) { throw new IllegalArgumentException("Specified range is beyond bounds of source array"); } if (dstIndex < 0 || ((dstIndex+numElems) > dst.rawLength)) { throw new IllegalArgumentException("Specified range is beyond bounds of destination array"); } - dst.raw.asyncCopyFrom(dstIndex, src.home, src.rawData, srcIndex, numElems, uncounted); + dst.raw.asyncCopyFrom(dstIndex, src.home, src.rawData, srcIndex, numElems); } @@ -1194,7 +980,7 @@ */ public static def copy[T](src:Array[T], dst:Array[T]) { if (src.rawLength != dst.rawLength) throw new IllegalArgumentException("source and destination do not have equal size"); - src.raw.asyncCopyTo(0, here, dst.raw, 0, src.rawLength, false); + src.raw.asyncCopyTo(0, here, dst.raw, 0, src.rawLength); } @@ -1257,7 +1043,7 @@ if (dstIndex < 0 || ((dstIndex+numElems) > dst.rawLength)) { throw new IllegalArgumentException("Specified range is beyond bounds of destination array"); } - src.raw.asyncCopyTo(srcIndex, here, dst.raw, dstIndex, numElems, false); + src.raw.asyncCopyTo(srcIndex, here, dst.raw, dstIndex, numElems); } Modified: trunk/x10.runtime/src-x10/x10/util/CUDAUtilities.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/CUDAUtilities.x10 2010-10-05 02:23:39 UTC (rev 16974) +++ trunk/x10.runtime/src-x10/x10/util/CUDAUtilities.x10 2010-10-05 02:26:43 UTC (rev 16975) @@ -44,7 +44,7 @@ local:IndexedMemoryChunk[T], remote:IndexedMemoryChunk[T], numElements:Int) : Void { - finish local.asyncCopyTo(0,gpu,remote,0,numElements,false); + finish local.asyncCopyTo(0,gpu,remote,0,numElements); } private static def makeCUDAArray[T] (gpu:Place, numElements:Int, init:IndexedMemoryChunk[T]) Modified: trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk.x10 2010-10-05 02:23:39 UTC (rev 16974) +++ trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk.x10 2010-10-05 02:26:43 UTC (rev 16975) @@ -114,9 +114,9 @@ * to a destination IndexedMemoryChunk at the specified place. * If the destination place is the current place, then the copy happens synchronously. * If the destination place is not the same as the current place, then - * the copy happens asynchronously and the created remote activity is optionally + * the copy happens asynchronously and the created remote activity will be * registered with the dynamically enclosing finish of the activity that invoked - * asyncCopyTo depending on the value of the uncounted parameter.</p> + * asyncCopyTo.</p> * * Note: No checking is performed to verify that this operation is safe; * it is the responsibility of higher-level abstractions built on top of @@ -127,14 +127,12 @@ * @param dst the destination IndexedMemoryChunk. * @param dstIndex the index of the first element to store in the destination. * @param numElems the number of elements to copy. - * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted */ - @Native("java", "x10.util.IndexedMemoryChunk__NativeRep.copyTo_0_$_x10$util$IndexedMemoryChunk__NativeRep_T_$_3_$_x10$util$IndexedMemoryChunk__NativeRep_T_$(#9, #0,#1,#2,#3,#4,#5,#6)") - @Native("c++", "(#0)->copyTo(#1,#2,#3,#4,#5,#6)") + @Native("java", "x10.util.IndexedMemoryChunk__NativeRep.copyTo_0_$_x10$util$IndexedMemoryChunk__NativeRep_T_$_3_$_x10$util$IndexedMemoryChunk__NativeRep_T_$(#8, #0,#1,#2,#3,#4,#5)") + @Native("c++", "(#0)->copyTo(#1,#2,#3,#4,#5)") public native def asyncCopyTo (srcIndex:int, dstPlace:Place, dst:IndexedMemoryChunk[T], dstIndex:int, - numElems:int, - uncounted:boolean):void; + numElems:int):void; /** @@ -142,9 +140,9 @@ * at the specified place into this IndexedMemoryChunk. * If the source place is the current place, then the copy happens synchronously. * If the source place is not the same as the current place, then - * the copy happens asynchronously and the created remote activity is optionally + * the copy happens asynchronously and the created remote activity will be * registered with the dynamically enclosing finish of the activity that invoked - * asyncCopyFrom depending on the value of the uncounted paramater.</p> + * asyncCopyFrom.<p> * * Note: No checking is performed to verify that this operation is safe; * it is the responsibility of higher-level abstractions built on top of @@ -155,14 +153,12 @@ * @param src the destination IndexedMemoryChunk. * @param srcIndex the index of the first element to copy in the source. * @param numElems the number of elements to copy. - * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted */ - @Native("java", "x10.util.IndexedMemoryChunk__NativeRep.copyFrom_0_$_x10$util$IndexedMemoryChunk__NativeRep_T_$_3_$_x10$util$IndexedMemoryChunk__NativeRep_T_$(#9, #0,#1,#2,#3,#4,#5,#6)") - @Native("c++", "(#0)->copyFrom(#1,#2,#3,#4,#5,#6)") + @Native("java", "x10.util.IndexedMemoryChunk__NativeRep.copyFrom_0_$_x10$util$IndexedMemoryChunk__NativeRep_T_$_3_$_x10$util$IndexedMemoryChunk__NativeRep_T_$(#8, #0,#1,#2,#3,#4,#5)") + @Native("c++", "(#0)->copyFrom(#1,#2,#3,#4,#5)") public native def asyncCopyFrom(dstIndex:int, srcPlace:Place, src:IndexedMemoryChunk[T], srcIndex:int, - numElems:int, - uncounted:boolean):void; + numElems:int):void; /* Modified: trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk__NativeRep.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk__NativeRep.x10 2010-10-05 02:23:39 UTC (rev 16974) +++ trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk__NativeRep.x10 2010-10-05 02:26:43 UTC (rev 16975) @@ -29,8 +29,7 @@ public static def copyTo[T](src:IndexedMemoryChunk[T], srcIndex:int, dstPlace:Place, dst:IndexedMemoryChunk[T], dstIndex:int, - numElems:int, - uncounted:boolean):void { + numElems:int):void { if (dstPlace == here) { copyToLocal(src, srcIndex, dst, dstIndex, numElems); } else { @@ -45,8 +44,7 @@ public static def copyFrom[T](dst:IndexedMemoryChunk[T], dstIndex:int, srcPlace:Place, src:IndexedMemoryChunk[T], srcIndex:int, - numElems:int, - uncounted:boolean):void { + numElems:int):void { if (srcPlace == here) { copyFromLocal(dst, dstIndex, src, srcIndex, numElems); } else { Modified: trunk/x10.tests/examples/Constructs/Array/ArrayCopyTo.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayCopyTo.x10 2010-10-05 02:23:39 UTC (rev 16974) +++ trunk/x10.tests/examples/Constructs/Array/ArrayCopyTo.x10 2010-10-05 02:26:43 UTC (rev 16975) @@ -16,7 +16,7 @@ */ public class ArrayCopyTo extends x10Test { static R1 = 20..100; - static R2:Region(2) = [0..9,0..9]; + static R2:Region(2) = (0..9)*(0..9); public def run() { val localA = new Array[int](R1,(p:Point)=>p(0)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2010-10-05 07:36:58
|
Revision: 16980 http://x10.svn.sourceforge.net/x10/?rev=16980&view=rev Author: vj0 Date: 2010-10-05 07:36:52 +0000 (Tue, 05 Oct 2010) Log Message: ----------- Ensure that macro expansion does not proceed beyond a pre-set limit. Modified Paths: -------------- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java Added Paths: ----------- trunk/x10.tests/examples/Constructs/Typedefs/RecursiveTypeDefs_MustFailCompile.x10 Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-10-05 05:04:37 UTC (rev 16979) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-10-05 07:36:52 UTC (rev 16980) @@ -111,6 +111,7 @@ */ public class X10TypeSystem_c extends TypeSystem_c implements X10TypeSystem { public static final String DUMMY_ASYNC = "$dummyAsync"; + public static final int EXPAND_MACROS_DEPTH=25; public X10TypeSystem_c() { super(); @@ -1587,14 +1588,21 @@ } public Type expandMacros(Type t) { + return expandMacros(t, 0); + } + private Type expandMacros(Type t, int depth) { + if (depth > EXPAND_MACROS_DEPTH) { + System.err.println("Reached max macro expansion depth with " + t + " (at " + t.position()); + return unknownType(Position.COMPILER_GENERATED); // bottom + } if (t instanceof AnnotatedType) - return expandMacros(((AnnotatedType) t).baseType()); + return expandMacros(((AnnotatedType) t).baseType(), depth+1); if (t instanceof MacroType) - return expandMacros(((MacroType) t).definedType()); + return expandMacros(((MacroType) t).definedType(), depth+1); if (t instanceof ConstrainedType) { ConstrainedType ct = (ConstrainedType) t; Type base = ct.baseType().get(); - Type ebase = expandMacros(base); + Type ebase = expandMacros(base, depth+1); if (base == ebase) return t; CConstraint c = ct.constraint().get(); Added: trunk/x10.tests/examples/Constructs/Typedefs/RecursiveTypeDefs_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Typedefs/RecursiveTypeDefs_MustFailCompile.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/Typedefs/RecursiveTypeDefs_MustFailCompile.x10 2010-10-05 07:36:52 UTC (rev 16980) @@ -0,0 +1,32 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +/** + * See whether recursion is handled properly. This program + * should not run forever. In fact the compiler should determine + * that it cannot compute this type (e.g. by tripping across a pre-determined + * maximum recursion depth) and then return an unknown type. + * + * @author vj 10/10 + */ +public class RecursiveTypeDefs_MustFailCompile extends x10Test { + static type foo = fum; + static type fum = foo; + + public def run()=true; + + public static def main(var args: Array[String](1)): void = { + new RecursiveTypeDefs_MustFailCompile().execute(); + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2010-10-05 07:39:33
|
Revision: 16981 http://x10.svn.sourceforge.net/x10/?rev=16981&view=rev Author: vj0 Date: 2010-10-05 07:39:26 +0000 (Tue, 05 Oct 2010) Log Message: ----------- Support suppression of fake fields (fields used by type-checker that do not correspond to runtime fields on the object) on print out. The only fake field at the moment is here, used to track the place at which an object was created. Modified Paths: -------------- trunk/x10.compiler/src/x10/types/XTypeTranslator.java trunk/x10.constraints/src/x10/constraint/XConstraint.java trunk/x10.constraints/src/x10/constraint/XField.java trunk/x10.constraints/src/x10/constraint/XLit.java trunk/x10.constraints/src/x10/constraint/XPromise.java trunk/x10.constraints/src/x10/constraint/XPromise_c.java trunk/x10.constraints/src/x10/constraint/XTerms.java Modified: trunk/x10.compiler/src/x10/types/XTypeTranslator.java =================================================================== --- trunk/x10.compiler/src/x10/types/XTypeTranslator.java 2010-10-05 07:36:52 UTC (rev 16980) +++ trunk/x10.compiler/src/x10/types/XTypeTranslator.java 2010-10-05 07:39:26 UTC (rev 16981) @@ -143,7 +143,7 @@ public XTerm transFakeField(CConstraint c, XTerm target, String name) { //XName field = XTerms.makeName(fi.def(), Types.get(fi.def().container()) + "#" + fi.name().toString()); XName field = XTerms.makeName(fakeKey, name); - return XTerms.makeField((XVar) target, field); + return XTerms.makeFakeField((XVar) target, field); } public XTerm trans(CConstraint c, XTerm target, FieldInstance fi, Type t) throws SemanticException { XTerm v; Modified: trunk/x10.constraints/src/x10/constraint/XConstraint.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XConstraint.java 2010-10-05 07:36:52 UTC (rev 16980) +++ trunk/x10.constraints/src/x10/constraint/XConstraint.java 2010-10-05 07:39:26 UTC (rev 16981) @@ -336,7 +336,7 @@ // that do not involve X1,..., Xn are entailed by c. //if (p.term() ==null || p.term().isEQV()) // continue; - p.dump(null, result, true); + p.dump(null, result, true, false); } return result; } @@ -352,6 +352,9 @@ public List<XTerm> extConstraints() { return extConstraints(new ArrayList<XTerm>()); } + public List<XTerm> extConstraintsHideFake() { + return extConstraintsHideFake(new ArrayList<XTerm>()); + } /** * Return (appended to result) a list of bindings t1-> t2 equivalent to the current @@ -364,11 +367,18 @@ if (roots == null) return result; for (XPromise p : roots.values()) { - p.dump(null, result, false); + p.dump(null, result, false, false); } return result; } - + public List<XTerm> extConstraintsHideFake(List<XTerm> result) { + if (roots == null) + return result; + for (XPromise p : roots.values()) { + p.dump(null, result, false, true); + } + return result; + } /** * Does this entail a != b? * @param a @@ -569,7 +579,7 @@ str += constr.substring(1, constr.length() - 1); } else { - String constr = c.extConstraints().toString(); + String constr = c.extConstraintsHideFake().toString(); str += constr.substring(1, constr.length() - 1); } Modified: trunk/x10.constraints/src/x10/constraint/XField.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XField.java 2010-10-05 07:36:52 UTC (rev 16980) +++ trunk/x10.constraints/src/x10/constraint/XField.java 2010-10-05 07:39:26 UTC (rev 16981) @@ -22,12 +22,22 @@ public XVar receiver; public XName field; + // used by XPromise_c to determine if this field should occur in the output + // representation of a constraint or not. + boolean hidden; public XField(XVar receiver, XName field) { super(); this.receiver = receiver; this.field = field; + this.hidden=false; } + public XField(XVar receiver, XName field, boolean hidden) { + super(); + this.receiver = receiver; + this.field = field; + this.hidden=hidden; + } public XTermKind kind() { return XTermKind.FIELD_ACCESS;} @Override Modified: trunk/x10.constraints/src/x10/constraint/XLit.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XLit.java 2010-10-05 07:36:52 UTC (rev 16980) +++ trunk/x10.constraints/src/x10/constraint/XLit.java 2010-10-05 07:39:26 UTC (rev 16981) @@ -151,7 +151,7 @@ } - public void dump(XVar path, List<XTerm> result, boolean dumpEQV) { + public void dump(XVar path, List<XTerm> result, boolean dumpEQV, boolean hideFake) { // nothing to dump. } Modified: trunk/x10.constraints/src/x10/constraint/XPromise.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XPromise.java 2010-10-05 07:36:52 UTC (rev 16980) +++ trunk/x10.constraints/src/x10/constraint/XPromise.java 2010-10-05 07:39:26 UTC (rev 16981) @@ -158,7 +158,8 @@ /** * Let t1 be path (if path is not null), else the term labeling this promise. * If this promise has an outgoing edge to t2, and either dumpEQV is true or - * ! t1.hasEQV(), then output t1==t2 to result. + * ! t1.hasEQV(), then output t1==t2 to result, unless hideFake is true and one of t1 or t2 is + * a fake field. * If this promise has fields, then recursively continue dumping with * the children, passing them a path t1.f (for field f) if * t1 is an instance of XVar, otherwise passing a path null (in this case t1 is an @@ -167,7 +168,7 @@ * @param result * @param oldSelf */ - void dump(XVar path, List<XTerm> result, boolean dumpEQV); + void dump(XVar path, List<XTerm> result, boolean dumpEQV, boolean hideFake); /** * Return the term that labels this promise. This term is intended to be the canonical XTerm Modified: trunk/x10.constraints/src/x10/constraint/XPromise_c.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XPromise_c.java 2010-10-05 07:36:52 UTC (rev 16980) +++ trunk/x10.constraints/src/x10/constraint/XPromise_c.java 2010-10-05 07:39:26 UTC (rev 16981) @@ -366,7 +366,7 @@ return false; } - public void dump(XVar path, List<XTerm> result, boolean dumpEQV) { + public void dump(XVar path, List<XTerm> result, boolean dumpEQV, boolean hideFake) { XTerm t1 = path == null? term() : path; if (t1 == null) return; @@ -377,6 +377,10 @@ if (value != null) { if (dumpEQV || ! t1.hasEQV()) { XTerm t2 = lookup().var(); + if (hideFake && t1 instanceof XField && ((XField) t1).hidden) + return; + if (hideFake && t2 instanceof XField && ((XField) t2).hidden) + return; result.add( XTerms.makeEquals(t1, t2)); } return; @@ -391,7 +395,7 @@ XName name = m.getKey(); XPromise p = m.getValue(); XVar path2 = v==null? null : XTerms.makeField(v, name); - p.dump(path2, result, dumpEQV); + p.dump(path2, result, dumpEQV, hideFake); } } if (disEquals != null) { Modified: trunk/x10.constraints/src/x10/constraint/XTerms.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XTerms.java 2010-10-05 07:36:52 UTC (rev 16980) +++ trunk/x10.constraints/src/x10/constraint/XTerms.java 2010-10-05 07:39:26 UTC (rev 16981) @@ -169,6 +169,9 @@ public static final XField makeField(XVar receiver, XName field) { return new XField(receiver, field); } + public static final XField makeFakeField(XVar receiver, XName field) { + return new XField(receiver, field, true); + } /** Make and return a literal containing o. null, true and false are This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2010-10-05 08:55:45
|
Revision: 16984 http://x10.svn.sourceforge.net/x10/?rev=16984&view=rev Author: sparksparkspark Date: 2010-10-05 08:55:38 +0000 (Tue, 05 Oct 2010) Log Message: ----------- Fix bugs in KMeansCUDA and CUDABlackScholes due to new Place.x10 code and [] type rules Replace asserts with error messages in CUDACodeGenerator Modified Paths: -------------- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java trunk/x10.dist/samples/CUDA/CUDABlackScholes.x10 trunk/x10.dist/samples/CUDA/KMeansCUDA.x10 Modified: trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-10-05 08:22:27 UTC (rev 16983) +++ trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-10-05 08:55:38 UTC (rev 16984) @@ -218,21 +218,30 @@ } private String env = "__env"; + + private void complainIfNot (boolean cond, String exp, Node n) { + complainIfNot2(cond, "Expected: "+exp, n); + } + private void complainIfNot2 (boolean cond, String exp, Node n) { + if (!cond) { + tr.job().compiler().errorQueue().enqueue(ErrorInfo.SEMANTIC_ERROR, exp, n.position()); + } + } private Type arrayCargo(Type typ) { if (xts().isArray(typ)) { typ = typ.toClass(); X10ClassType ctyp = (X10ClassType) typ; - assert ctyp.typeArguments().size() == 1; + assert ctyp.typeArguments().size() == 1; // Array[T] return ctyp.typeArguments().get(0); } if (xts().isRemoteArray(typ)) { typ = typ.toClass(); X10ClassType ctyp = (X10ClassType) typ; - assert ctyp.typeArguments().size() == 1; + assert ctyp.typeArguments().size() == 1; // RemoteRef[Array[T]] Type type2 = ctyp.typeArguments().get(0); X10ClassType ctyp2 = (X10ClassType) typ; - assert ctyp2.typeArguments().size() == 1; + assert ctyp2.typeArguments().size() == 1; // Array[T] return ctyp2.typeArguments().get(0); } return null; @@ -370,137 +379,91 @@ protected MultipleValues processLoop(X10Loop loop) { MultipleValues r = new MultipleValues(); Formal loop_formal = loop.formal(); - assert loop_formal instanceof X10Formal; // FIXME: proper error + complainIfNot(loop_formal instanceof X10Formal, "Exploded point syntax", loop); X10Formal loop_x10_formal = (X10Formal) loop_formal; - assert loop_x10_formal.hasExplodedVars(); // FIXME: proper error - assert loop_x10_formal.vars().size() == 1; // FIXME: proper error + complainIfNot(loop_x10_formal.hasExplodedVars(), "Exploded point syntax", loop_formal); + complainIfNot(loop_x10_formal.vars().size() == 1, "A 1 dimensional iteration", loop_formal); r.var = loop_x10_formal.vars().get(0).name().id(); Expr domain = loop.domain(); - assert domain instanceof RegionMaker; // FIXME: proper error + complainIfNot(domain instanceof RegionMaker, "An iteration over a region literal of the form 0..", domain); RegionMaker region = (RegionMaker) domain; - assert region.name().toString().equals("makeRectangular") : region - .name(); // FIXME: proper error + complainIfNot(region.name().toString().equals("makeRectangular"), "An iteration over a region literal of the form 0..", domain); Receiver target = region.target(); - assert target instanceof CanonicalTypeNode; // FIXME: proper error + complainIfNot(target instanceof CanonicalTypeNode, "An iteration over a region literal of the form 0..", target); CanonicalTypeNode target_type_node = (CanonicalTypeNode) target; - assert target_type_node.nameString().equals("Region") : target_type_node - .nameString(); // FIXME: proper error - assert region.arguments().size() == 2; // FIXME: proper error + complainIfNot(target_type_node.nameString().equals("Region"), "An iteration over a region literal of the form 0..", target); + complainIfNot(region.arguments().size() == 2, "An iteration over a region literal of the form 0..", region); Expr from_ = region.arguments().get(0); Expr to_ = region.arguments().get(1); - assert from_ instanceof IntLit; // FIXME: proper error - // assert to_ instanceof IntLit; // FIXME: proper error + complainIfNot(from_ instanceof IntLit, "An iteration over a region literal of the form 0..", from_); IntLit from = (IntLit) from_; - // IntLit to = (IntLit) to_; - assert from.value() == 0; // FIXME: proper error - // r.iterations = to.value() + 1; + complainIfNot(from.value() == 0, "An iteration over a region literal of the form 0..", from_); r.max = to_; r.body = (Block) loop.body(); return r; } protected MultipleValues processLoop(Block for_block) { - /* - * example of the loop we're trying to absorb { final - * x10.lang.Int{self==0} block321min322 = 0; final x10.lang.Int - * block321max323 = x10.lang.Int{self==8, blocks==8}.operator-(blocks, - * 1); for (x10.lang.Int{self==0} block321 = block321min322;; - * x10.lang.Int{self==0}.operator<=(block321, - * block321max323)eval(block321 += 1);) { final x10.lang.Int block = - * block321; { ... } } } - */ - assert for_block.statements().size() == 3 : for_block.statements() - .size(); + complainIfNot(for_block.statements().size() == 3, "A 1-dimensional iteration of the form 0..", for_block); + // test that it is of the form for (blah in region) Stmt i_ = for_block.statements().get(0); Stmt j_ = for_block.statements().get(1); Stmt for_block2 = for_block.statements().get(2); - assert for_block2 instanceof For : for_block2.getClass(); // FIXME: - // proper + complainIfNot(for_block2 instanceof For, "A 1-dimensional iteration of the form 0..", for_block2); + // error For loop = (For) for_block2; MultipleValues r = new MultipleValues(); - assert loop.inits().size() == 1 : loop.inits(); + complainIfNot(loop.inits().size() == 1, "A 1-dimensional iteration of the form 0..", loop); // loop inits are not actually used - // ForInit i_ = loop.inits().get(0); - assert i_ instanceof LocalDecl : i_.getClass(); + complainIfNot(i_ instanceof LocalDecl, "A 1-dimensional iteration of the form 0..", i_); LocalDecl i = (LocalDecl) i_; - // ForInit j_ = loop.inits().get(1); - assert j_ instanceof LocalDecl : j_.getClass(); + complainIfNot(j_ instanceof LocalDecl, "A 1-dimensional iteration of the form 0..", j_); LocalDecl j = (LocalDecl) j_; - assert loop.cond() instanceof X10Call : loop.cond().getClass(); + complainIfNot(loop.cond() instanceof X10Call, "A 1-dimensional iteration of the form 0..", loop.cond()); X10Call cond = (X10Call) loop.cond(); - assert cond.name().id() == X10Binary_c.binaryMethodName(Binary.LE) : cond - .name(); + complainIfNot(cond.name().id() == X10Binary_c.binaryMethodName(Binary.LE), "The <= operator", cond); List<Expr> args = cond.arguments(); - assert args.size() == 2 : args.size(); - assert args.get(0) instanceof Local : args.get(0).getClass(); + complainIfNot(args.size() == 2, "The <= operator", cond); + complainIfNot(args.get(0) instanceof Local, "The LHS of <= to be the loop variable", args.get(0)); Local cond_left = (Local) args.get(0); - assert args.get(1) instanceof Local : args.get(1).getClass(); + complainIfNot(args.get(1) instanceof Local, "The RHS of <= to be the max variable", args.get(1)); Local cond_right = (Local) args.get(1); - /* - * assert loop.cond() instanceof Binary : loop.cond().getClass(); Binary - * cond = (Binary) loop.cond(); assert cond.operator() == Binary.LE : - * cond.operator(); assert cond.left() instanceof Local : - * cond.left().getClass(); Local cond_left = (Local) cond.left(); assert - * cond_left.name().id() == i.name().id() : cond_left; assert - * cond.right() instanceof Local : cond.right().getClass(); Local - * cond_right = (Local) cond.right(); - */ - assert cond_right.name().id() == j.name().id() : cond_right; + complainIfNot(cond_right.name().id() == j.name().id(), "The RHS of <= to be the max variable", cond_right); Expr from_ = i.init(); Expr to_ = j.init(); - assert from_ instanceof IntLit : from_.getClass(); // FIXME: proper + complainIfNot(from_ instanceof IntLit, "An iteration that begins from zero", from_); // error - // assert to_ instanceof IntLit : to_.getClass(); // FIXME: proper error IntLit from = (IntLit) from_; - // IntLit to = (IntLit) to_; - assert from.value() == 0 : from.value(); // FIXME: proper error - // r.iterations = to.value() + 1; + complainIfNot(from.value() == 0, "An iteration that begins from zero", from_); r.max = to_; - assert loop.body() instanceof Block : loop.body().getClass(); + complainIfNot(loop.body() instanceof Block, "Body of the loop to be a block", loop.body()); Block block = (Block) loop.body(); - assert block.statements().size() == 2 : block.statements(); + complainIfNot(block.statements().size() == 2, "Body of the loop to be a block containing 2 statements", block); Stmt first = block.statements().get(0); - assert first instanceof LocalDecl : first.getClass(); + complainIfNot(first instanceof LocalDecl, "First statement to be a local variable declaration", first); LocalDecl real_var = (LocalDecl) first; Stmt second = block.statements().get(1); - assert second instanceof Block : second.getClass(); + complainIfNot(second instanceof Block, "Second statement to be a block", second); r.body = (Block) second; r.var = real_var.name().id(); return r; } - - public void checkAutoVar(Stmt s) { - assert s instanceof LocalDecl : s.getClass(); // FIXME: proper error - LocalDecl s_ = (LocalDecl) s; - Expr init_expr = s_.init(); - assert init_expr instanceof X10Call_c : init_expr.getClass(); // FIXME: - // proper - // error - X10Call_c init_call = (X10Call_c) init_expr; - Receiver init_call_target = init_call.target(); - assert init_call_target instanceof CanonicalTypeNode : init_call_target - .getClass(); // FIXME: proper error - CanonicalTypeNode init_call_target_node = (CanonicalTypeNode) init_call_target; - assert init_call_target_node.nameString().equals("CUDAUtilities") : init_call_target_node - .nameString(); - assert init_call.typeArguments().size() == 0 : init_call - .typeArguments(); - if (init_call.name().toString().equals("autoBlocks")) { - assert context().autoBlocks() == null : "Already have autoBlocks: " - + context().autoBlocks(); - context().autoBlocks(s_); - context().established().autoBlocks(s_); - } else if (init_call.name().toString().equals("autoThreads")) { - assert context().autoThreads() == null : "Already have autoThreads: " - + context().autoThreads(); - context().autoThreads(s_); - context().established().autoThreads(s_); - } else { - assert false : init_call.name(); + + public static boolean checkStaticCall(Stmt s, String class_name, String method_name, int args) + { + try { + Call async_call = (Call) ((Eval) s).expr(); + if (!async_call.name().toString().equals(method_name)) return false; + CanonicalTypeNode async_target_type_node = (CanonicalTypeNode) (async_call.target()); + if (!async_target_type_node.nameString().equals(class_name)) return false; + if (async_call.arguments().size() != args) return false; + } catch (ClassCastException e) { + return false; } + return true; } public void visit(Block_c b) { @@ -509,23 +472,23 @@ Block_c closure_body = b; //System.out.println(b); // useful for finding out what the frontend is actually giving us - assert !generatingKernel() : "Nesting of cuda annotation makes no sense."; + complainIfNot2(!generatingKernel(), "CUDA kernels may not be nested.", b); // TODO: assert the block is the body of an async - assert b.statements().size()>=1 : b.statements(); + complainIfNot(b.statements().size()>=1, "A block containing at least one statement.", b); // handle autoblocks/autothreads and constant memory declarations for (int i=0 ; i<b.statements().size()-1 ; ++i) { Stmt ld_ = b.statements().get(i); - assert ld_ instanceof LocalDecl : ld_.getClass(); // FIXME: proper error + complainIfNot(ld_ instanceof LocalDecl, "val <something> = CUDAUtilities.autoBlocks/autoThreads()", ld_); LocalDecl s_ = (LocalDecl)ld_; Expr init_expr = s_.init(); - assert init_expr instanceof X10Call_c : init_expr.getClass(); // FIXME: proper error + complainIfNot(init_expr instanceof X10Call, "val <something> = CUDAUtilities.autoBlocks/autoThreads", init_expr); X10Call_c init_call = (X10Call_c) init_expr; Receiver init_call_target = init_call.target(); - assert init_call_target instanceof CanonicalTypeNode : init_call_target.getClass(); // FIXME: proper error + complainIfNot(init_call_target instanceof CanonicalTypeNode, "val <something> = CUDAUtilities.autoBlocks/Vars()", init_call_target); CanonicalTypeNode init_call_target_node = (CanonicalTypeNode) init_call_target; String classname = init_call_target_node.nameString(); @@ -534,22 +497,22 @@ String methodname = init_call.name().toString(); if (classname.equals("CUDAUtilities") && targs==0 && args==0 && methodname.equals("autoBlocks")) { - assert context().autoBlocks()==null : "Already have autoBlocks: "+context().autoBlocks(); + complainIfNot2(context().autoBlocks() == null, "Already have autoBlocks", init_call); context().autoBlocks(s_); context().established().autoBlocks(s_); } else if (classname.equals("CUDAUtilities") && targs==0 && args==0 && methodname.equals("autoThreads")) { - assert context().autoThreads()==null : "Already have autoThreads: "+context().autoThreads(); + complainIfNot2(context().autoThreads() == null, "Already have autoThreads", init_call); context().autoThreads(s_); context().established().autoThreads(s_); } else if (classname.equals("Rail") && targs==2 && args==2 && methodname.equals("make")) { - // + complainIfNot(false, "A call to CUDAUtilities.autoBlocks/autoThreads", init_call); } else { - assert false : init_call; + complainIfNot(false, "A call to CUDAUtilities.autoBlocks/autoThreads", init_call); } } - Stmt for_block_ = b.statements().get(b.statements().size()-1); - assert for_block_ instanceof Block : for_block_.getClass(); // FIXME: proper + Stmt for_block_ = b.statements().get(b.statements().size()-1); + complainIfNot(for_block_ instanceof Block, "A loop over CUDA blocks", for_block_); // error Block for_block = (Block) for_block_; @@ -560,7 +523,7 @@ Stmt last = b.statements().get(b.statements().size() - 1); //System.out.println(last); - assert last instanceof Block; // FIXME: proper error + complainIfNot(last instanceof Block, "A loop over CUDA blocks", last); Block for_block2 = (Block) last; SharedMem shm = new SharedMem(); @@ -568,37 +531,27 @@ for (Stmt st : b.statements()) { if (st == last) continue; - assert st instanceof LocalDecl; // FIXME: proper error + complainIfNot(st instanceof LocalDecl, "Shared memory definition", st); LocalDecl ld = (LocalDecl) st; Expr init_expr = ld.init(); // TODO: primitive vals and shared vars - assert init_expr instanceof X10New_c; + complainIfNot(init_expr instanceof X10New_c, "val <var> = new Array[T](...)", init_expr); X10New_c init_new = (X10New_c) init_expr; Type instantiatedType = init_new.objectType().type(); - assert xts().isArray(instantiatedType) : instantiatedType; + complainIfNot(xts().isArray(instantiatedType), "Initialisation expression to have Array[T] type.", init_new); TypeNode rail_type_arg_node = init_new.typeArguments().get(0); - //assert init_expr instanceof X10Call_c : init_expr.getClass(); // FIXME: proper error - //X10Call_c init_call = (X10Call_c) init_expr; - // TODO: makeVal too - //Receiver init_call_target = init_call.target(); - //assert init_call_target instanceof CanonicalTypeNode; // FIXME: proper error - //CanonicalTypeNode init_call_target_node = (CanonicalTypeNode) init_call_target; - //assert init_call_target_node.nameString().equals("Rail"); - //assert init_call.name().toString().equals("make") : init_call.name(); // FIXME: proper error - //assert init_call.typeArguments().size() == 1; - //TypeNode rail_type_arg_node = init_call.typeArguments().get(0); Type rail_type_arg = rail_type_arg_node.type(); // TODO: support other types - assert rail_type_arg.isFloat() : rail_type_arg; + complainIfNot(rail_type_arg.isFloat(), "An array of type float", rail_type_arg_node); if (init_new.arguments().size()==2) { Expr num_elements = init_new.arguments().get(0); Expr rail_init_closure = init_new.arguments().get(1); shm.addArrayInitClosure(ld, num_elements, rail_init_closure); } else { - assert init_new.arguments().size() == 1 : init_new.arguments().size(); + complainIfNot(init_new.arguments().size() == 1, "val <var> = new Array[T](other_array)", init_new); Expr src_array = init_new.arguments().get(0); - assert xts().isArray(src_array.type()) || xts().isRemoteArray(src_array.type()) : src_array; + complainIfNot(xts().isArray(src_array.type()) || xts().isRemoteArray(src_array.type()), "SHM to be initialised from array or remote array type", src_array); shm.addArrayInitArray(ld, src_array); } } @@ -608,36 +561,19 @@ // "+outer.iterations); b = (Block_c) inner.body; - assert b.statements().size() == 1; // FIXME: proper error - Stmt async = b.statements().get(0); - assert async instanceof Eval; // FIXME: proper error - Eval async_eval = (Eval) async; - Expr async_expr = async_eval.expr(); - assert async_expr instanceof Call; // FIXME: proper error - Call async_call = (Call) async_expr; - assert async_call.name().toString().equals("runAsync") : async_call - .name(); // FIXME: proper error - Receiver async_target = async_call.target(); - assert async_target instanceof CanonicalTypeNode; // FIXME: proper - // error - CanonicalTypeNode async_target_type_node = (CanonicalTypeNode) async_target; - assert async_target_type_node.nameString().equals("Runtime"); // FIXME: - // proper - // error - assert async_call.arguments().size() == 1 : async_call.arguments(); // FIXME: - // proper - // error + complainIfNot(b.statements().size() == 1, "A block with a single statement", b); + Stmt async = b.statements().get(0); + complainIfNot(checkStaticCall(async,"Runtime","runAsync",1), "An async block", async); + Call async_call = (Call) (((Eval) async).expr()); Expr async_arg = async_call.arguments().get(0); - assert async_arg instanceof Closure; // FIXME: proper error + complainIfNot(async_arg instanceof Closure, "An async block", async_arg); Closure async_closure = (Closure) async_arg; - assert async_closure.formals().size() == 0; + complainIfNot(async_closure.formals().size() == 0, "An async block", async_closure); Block async_body = async_closure.body(); //b = (Block_c) async_body; - context().setCUDAKernelCFG(outer.max, outer.var, - inner.max, inner.var, shm, kernelWantsDirectParams(closure_body)); - context().established().setCUDAKernelCFG(outer.max, outer.var, - inner.max, inner.var, shm, kernelWantsDirectParams(closure_body)); + context().setCUDAKernelCFG(outer.max, outer.var,inner.max, inner.var, shm, kernelWantsDirectParams(closure_body)); + context().established().setCUDAKernelCFG(outer.max, outer.var,inner.max, inner.var, shm, kernelWantsDirectParams(closure_body)); generatingKernel(true); handleKernel((Block_c)async_body); generatingKernel(false); @@ -876,13 +812,13 @@ } public void visit(New_c n) { - assert !generatingKernel() : "New not allowed in @CUDA code."; + complainIfNot2(!generatingKernel(),"New not allowed in @CUDA code.", n); super.visit(n); } @Override public void visit(Assert_c n) { - assert !generatingKernel() : "Throwing exceptions not allowed in @CUDA code."; + complainIfNot2(!generatingKernel(),"Throwing exceptions not allowed in @CUDA code.", n); super.visit(n); } @@ -900,7 +836,7 @@ @Override public void visit(Await_c n) { - assert !generatingKernel() : "Await not allowed in @CUDA code."; + complainIfNot2(!generatingKernel(),"Await not allowed in @CUDA code.", n); super.visit(n); } @@ -930,7 +866,7 @@ @Override public void visit(Catch_c n) { - assert !generatingKernel() : "Catching exceptions not allowed in @CUDA code."; + complainIfNot2(!generatingKernel(),"Catching exceptions not allowed in @CUDA code.", n); super.visit(n); } @@ -941,9 +877,9 @@ } @Override - public void visit(ClosureCall_c c) { - assert !generatingKernel() : "Closure calls not allowed in @CUDA code."; - super.visit(c); + public void visit(ClosureCall_c n) { + complainIfNot2(!generatingKernel(),"Closure calls not allowed in @CUDA code.", n); + super.visit(n); } @Override @@ -1106,13 +1042,13 @@ @Override public void visit(Throw_c n) { - assert !generatingKernel() : "Throwing exceptions not allowed in @CUDA code."; + complainIfNot2(!generatingKernel(),"Throwing exceptions not allowed in @CUDA code.", n); super.visit(n); } @Override public void visit(Try_c n) { - assert !generatingKernel() : "Catching exceptions not allowed in @CUDA code."; + complainIfNot2(!generatingKernel(),"Catching exceptions not allowed in @CUDA code.", n); super.visit(n); } @@ -1150,8 +1086,6 @@ public void visit(X10Call_c n) { // In fact they are allowed, as long as they are implemented with // @Native - // assert !generatingKernel() : - // "Calling functions not allowed in @CUDA code."; super.visit(n); } @@ -1175,7 +1109,7 @@ @Override public void visit(X10Instanceof_c n) { - assert !generatingKernel() : "Runtime types not available in @CUDA code."; + complainIfNot2(!generatingKernel(),"Runtime types not available in @CUDA code.", n); super.visit(n); } Modified: trunk/x10.dist/samples/CUDA/CUDABlackScholes.x10 =================================================================== --- trunk/x10.dist/samples/CUDA/CUDABlackScholes.x10 2010-10-05 08:22:27 UTC (rev 16983) +++ trunk/x10.dist/samples/CUDA/CUDABlackScholes.x10 2010-10-05 08:55:38 UTC (rev 16984) @@ -88,7 +88,7 @@ val RISKFREE = 0.02f; val VOLATILITY = 0.30f; - if (here.children().length==0) { + if (here.children().size==0) { Console.OUT.println("Set X10RT_ACCELS=ALL to enable your GPUs if you have them."); Console.OUT.println("Will run the test on the CPU."); } else { @@ -96,7 +96,7 @@ Console.OUT.println("This program only supports a single GPU."); } - val gpu = here.children().length==0 ? here : here.child(0); + val gpu = here.children().size==0 ? here : here.child(0); val cpu = here; val rand = new Random(); Modified: trunk/x10.dist/samples/CUDA/KMeansCUDA.x10 =================================================================== --- trunk/x10.dist/samples/CUDA/KMeansCUDA.x10 2010-10-05 08:22:27 UTC (rev 16983) +++ trunk/x10.dist/samples/CUDA/KMeansCUDA.x10 2010-10-05 08:55:38 UTC (rev 16984) @@ -77,9 +77,7 @@ Console.OUT.println("If that's not what you want, set X10RT_ACCELS=ALL to use all gpus at each place."); Console.OUT.println("For more information, see the X10/CUDA docuemntation."); } else { - Console.OUT.println("Running without using GPUs."); - Console.OUT.println("If that's not what you want, set X10RT_ACCELS=ALL to use all gpus at each place."); - Console.OUT.println("For more information, see the X10/CUDA docuemntation."); + Console.OUT.println("Running using "+Place.NUM_ACCELS+" GPUs."); } } @@ -89,9 +87,9 @@ for (h in Place.places) { - val workers = Place.NUM_ACCELS==0 ? [h] : h.children(); + val workers = Place.NUM_ACCELS==0 ? new Array[Place][h] : h.children(); - for (gpu in workers) async at (h) { + for (gpu in workers.items()) async at (h) { val role = gpu==h ? h.id : gpu.id - Place.MAX_PLACES; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2010-10-05 11:48:30
|
Revision: 16988 http://x10.svn.sourceforge.net/x10/?rev=16988&view=rev Author: sparksparkspark Date: 2010-10-05 11:48:24 +0000 (Tue, 05 Oct 2010) Log Message: ----------- Fix CUDATopology for recent changes to Place.x10 Some cleanups to CUDACodeGenerator and make it gracefully handle bad kernels Modified Paths: -------------- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java trunk/x10.dist/samples/CUDA/CUDATopology.x10 Modified: trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-10-05 11:40:50 UTC (rev 16987) +++ trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-10-05 11:48:24 UTC (rev 16988) @@ -219,14 +219,19 @@ private String env = "__env"; - private void complainIfNot (boolean cond, String exp, Node n) { - complainIfNot2(cond, "Expected: "+exp, n); + private static class Complaint extends RuntimeException { } + + private void complainIfNot (boolean cond, String exp, Node n, boolean except) { + complainIfNot2(cond, "Expected: "+exp, n, except); } - private void complainIfNot2 (boolean cond, String exp, Node n) { + private void complainIfNot2 (boolean cond, String exp, Node n, boolean except) { if (!cond) { - tr.job().compiler().errorQueue().enqueue(ErrorInfo.SEMANTIC_ERROR, exp, n.position()); + tr.job().compiler().errorQueue().enqueue(ErrorInfo.SEMANTIC_ERROR, exp, n.position()); + if (except) throw new Complaint(); } } + private void complainIfNot (boolean cond, String exp, Node n) { complainIfNot(cond,exp, n, true); } + private void complainIfNot2 (boolean cond, String exp, Node n) { complainIfNot2(cond,exp, n, true); } private Type arrayCargo(Type typ) { if (xts().isArray(typ)) { @@ -468,115 +473,124 @@ public void visit(Block_c b) { super.visit(b); - if (blockIsKernel(b)) { - Block_c closure_body = b; - //System.out.println(b); // useful for finding out what the frontend is actually giving us - - complainIfNot2(!generatingKernel(), "CUDA kernels may not be nested.", b); - // TODO: assert the block is the body of an async - - complainIfNot(b.statements().size()>=1, "A block containing at least one statement.", b); - - // handle autoblocks/autothreads and constant memory declarations - for (int i=0 ; i<b.statements().size()-1 ; ++i) { - Stmt ld_ = b.statements().get(i); - complainIfNot(ld_ instanceof LocalDecl, "val <something> = CUDAUtilities.autoBlocks/autoThreads()", ld_); - LocalDecl s_ = (LocalDecl)ld_; - - Expr init_expr = s_.init(); - complainIfNot(init_expr instanceof X10Call, "val <something> = CUDAUtilities.autoBlocks/autoThreads", init_expr); - X10Call_c init_call = (X10Call_c) init_expr; - - Receiver init_call_target = init_call.target(); - complainIfNot(init_call_target instanceof CanonicalTypeNode, "val <something> = CUDAUtilities.autoBlocks/Vars()", init_call_target); - CanonicalTypeNode init_call_target_node = (CanonicalTypeNode) init_call_target; - - String classname = init_call_target_node.nameString(); - int targs = init_call.typeArguments().size(); - int args = init_call.arguments().size(); - String methodname = init_call.name().toString(); - - if (classname.equals("CUDAUtilities") && targs==0 && args==0 && methodname.equals("autoBlocks")) { - complainIfNot2(context().autoBlocks() == null, "Already have autoBlocks", init_call); - context().autoBlocks(s_); - context().established().autoBlocks(s_); - } else if (classname.equals("CUDAUtilities") && targs==0 && args==0 && methodname.equals("autoThreads")) { - complainIfNot2(context().autoThreads() == null, "Already have autoThreads", init_call); - context().autoThreads(s_); - context().established().autoThreads(s_); - } else if (classname.equals("Rail") && targs==2 && args==2 && methodname.equals("make")) { - complainIfNot(false, "A call to CUDAUtilities.autoBlocks/autoThreads", init_call); - } else { - complainIfNot(false, "A call to CUDAUtilities.autoBlocks/autoThreads", init_call); - } - } - - Stmt for_block_ = b.statements().get(b.statements().size()-1); - complainIfNot(for_block_ instanceof Block, "A loop over CUDA blocks", for_block_); - // error - Block for_block = (Block) for_block_; - - MultipleValues outer = processLoop(for_block); - // System.out.println("outer loop: "+outer.var+" - // "+outer.iterations); - b = (Block_c) outer.body; - - Stmt last = b.statements().get(b.statements().size() - 1); - //System.out.println(last); - complainIfNot(last instanceof Block, "A loop over CUDA blocks", last); - Block for_block2 = (Block) last; - - SharedMem shm = new SharedMem(); - // look at all but the last statement to find shm decls - for (Stmt st : b.statements()) { - if (st == last) - continue; - complainIfNot(st instanceof LocalDecl, "Shared memory definition", st); - LocalDecl ld = (LocalDecl) st; - Expr init_expr = ld.init(); - // TODO: primitive vals and shared vars - complainIfNot(init_expr instanceof X10New_c, "val <var> = new Array[T](...)", init_expr); - X10New_c init_new = (X10New_c) init_expr; - Type instantiatedType = init_new.objectType().type(); - complainIfNot(xts().isArray(instantiatedType), "Initialisation expression to have Array[T] type.", init_new); - TypeNode rail_type_arg_node = init_new.typeArguments().get(0); - - Type rail_type_arg = rail_type_arg_node.type(); - // TODO: support other types - complainIfNot(rail_type_arg.isFloat(), "An array of type float", rail_type_arg_node); - if (init_new.arguments().size()==2) { - Expr num_elements = init_new.arguments().get(0); - Expr rail_init_closure = init_new.arguments().get(1); - shm.addArrayInitClosure(ld, num_elements, rail_init_closure); - } else { - complainIfNot(init_new.arguments().size() == 1, "val <var> = new Array[T](other_array)", init_new); - Expr src_array = init_new.arguments().get(0); - complainIfNot(xts().isArray(src_array.type()) || xts().isRemoteArray(src_array.type()), "SHM to be initialised from array or remote array type", src_array); - shm.addArrayInitArray(ld, src_array); - } - } - - MultipleValues inner = processLoop(for_block2); - // System.out.println("outer loop: "+outer.var+" - // "+outer.iterations); - b = (Block_c) inner.body; - - complainIfNot(b.statements().size() == 1, "A block with a single statement", b); - Stmt async = b.statements().get(0); - complainIfNot(checkStaticCall(async,"Runtime","runAsync",1), "An async block", async); - Call async_call = (Call) (((Eval) async).expr()); - Expr async_arg = async_call.arguments().get(0); - complainIfNot(async_arg instanceof Closure, "An async block", async_arg); - Closure async_closure = (Closure) async_arg; - complainIfNot(async_closure.formals().size() == 0, "An async block", async_closure); - Block async_body = async_closure.body(); - - //b = (Block_c) async_body; - context().setCUDAKernelCFG(outer.max, outer.var,inner.max, inner.var, shm, kernelWantsDirectParams(closure_body)); - context().established().setCUDAKernelCFG(outer.max, outer.var,inner.max, inner.var, shm, kernelWantsDirectParams(closure_body)); - generatingKernel(true); - handleKernel((Block_c)async_body); - generatingKernel(false); + try { + if (blockIsKernel(b)) { + Block_c closure_body = b; + //System.out.println(b); // useful for finding out what the frontend is actually giving us + + complainIfNot2(!generatingKernel(), "CUDA kernels may not be nested.", b); + // TODO: assert the block is the body of an async + + complainIfNot(b.statements().size()>=1, "A block containing at least one statement.", b); + + // handle autoblocks/autothreads and constant memory declarations + for (int i=0 ; i<b.statements().size()-1 ; ++i) { + Stmt ld_ = b.statements().get(i); + complainIfNot(ld_ instanceof LocalDecl, "val <something> = CUDAUtilities.autoBlocks/autoThreads()", ld_); + LocalDecl s_ = (LocalDecl)ld_; + + Expr init_expr = s_.init(); + complainIfNot(init_expr instanceof X10Call, "val <something> = CUDAUtilities.autoBlocks/autoThreads", init_expr); + X10Call_c init_call = (X10Call_c) init_expr; + + Receiver init_call_target = init_call.target(); + complainIfNot(init_call_target instanceof CanonicalTypeNode, "val <something> = CUDAUtilities.autoBlocks/Vars()", init_call_target); + CanonicalTypeNode init_call_target_node = (CanonicalTypeNode) init_call_target; + + String classname = init_call_target_node.nameString(); + int targs = init_call.typeArguments().size(); + int args = init_call.arguments().size(); + String methodname = init_call.name().toString(); + + if (classname.equals("CUDAUtilities") && targs==0 && args==0 && methodname.equals("autoBlocks")) { + complainIfNot2(context().autoBlocks() == null, "Already have autoBlocks", init_call); + context().autoBlocks(s_); + context().established().autoBlocks(s_); + } else if (classname.equals("CUDAUtilities") && targs==0 && args==0 && methodname.equals("autoThreads")) { + complainIfNot2(context().autoThreads() == null, "Already have autoThreads", init_call); + context().autoThreads(s_); + context().established().autoThreads(s_); + } else if (classname.equals("Rail") && targs==2 && args==2 && methodname.equals("make")) { + complainIfNot(false, "A call to CUDAUtilities.autoBlocks/autoThreads", init_call); + } else { + complainIfNot(false, "A call to CUDAUtilities.autoBlocks/autoThreads", init_call); + } + } + + Stmt for_block_ = b.statements().get(b.statements().size()-1); + complainIfNot(for_block_ instanceof Block, "A loop over CUDA blocks", for_block_); + // error + Block for_block = (Block) for_block_; + + MultipleValues outer = processLoop(for_block); + // System.out.println("outer loop: "+outer.var+" + // "+outer.iterations); + b = (Block_c) outer.body; + + Stmt last = b.statements().get(b.statements().size() - 1); + //System.out.println(last); + complainIfNot(last instanceof Block, "A loop over CUDA blocks", last); + Block for_block2 = (Block) last; + + SharedMem shm = new SharedMem(); + // look at all but the last statement to find shm decls + for (Stmt st : b.statements()) { + if (st == last) + continue; + complainIfNot(st instanceof LocalDecl, "Shared memory definition", st); + LocalDecl ld = (LocalDecl) st; + Expr init_expr = ld.init(); + // TODO: primitive vals and shared vars + complainIfNot(init_expr instanceof X10New_c, "val <var> = new Array[T](...)", init_expr); + X10New_c init_new = (X10New_c) init_expr; + Type instantiatedType = init_new.objectType().type(); + complainIfNot(xts().isArray(instantiatedType), "Initialisation expression to have Array[T] type.", init_new); + TypeNode rail_type_arg_node = init_new.typeArguments().get(0); + + Type rail_type_arg = rail_type_arg_node.type(); + // TODO: support other types + complainIfNot(rail_type_arg.isFloat(), "An array of type float", rail_type_arg_node); + if (init_new.arguments().size()==2) { + Expr num_elements = init_new.arguments().get(0); + Expr rail_init_closure = init_new.arguments().get(1); + shm.addArrayInitClosure(ld, num_elements, rail_init_closure); + } else { + complainIfNot(init_new.arguments().size() == 1, "val <var> = new Array[T](other_array)", init_new); + Expr src_array = init_new.arguments().get(0); + complainIfNot(xts().isArray(src_array.type()) || xts().isRemoteArray(src_array.type()), "SHM to be initialised from array or remote array type", src_array); + shm.addArrayInitArray(ld, src_array); + } + } + + MultipleValues inner = processLoop(for_block2); + // System.out.println("outer loop: "+outer.var+" + // "+outer.iterations); + b = (Block_c) inner.body; + + complainIfNot(b.statements().size() == 1, "A block with a single statement", b); + Stmt async = b.statements().get(0); + complainIfNot(checkStaticCall(async,"Runtime","runAsync",1), "An async block", async); + Call async_call = (Call) (((Eval) async).expr()); + Expr async_arg = async_call.arguments().get(0); + complainIfNot(async_arg instanceof Closure, "An async block", async_arg); + Closure async_closure = (Closure) async_arg; + complainIfNot(async_closure.formals().size() == 0, "An async block", async_closure); + Block async_body = async_closure.body(); + + //b = (Block_c) async_body; + context().setCUDAKernelCFG(outer.max, outer.var,inner.max, inner.var, shm, kernelWantsDirectParams(closure_body)); + context().established().setCUDAKernelCFG(outer.max, outer.var,inner.max, inner.var, shm, kernelWantsDirectParams(closure_body)); + generatingKernel(true); + try { + handleKernel((Block_c)async_body); + } finally { + generatingKernel(false); + } + } + } catch (Complaint e) { + // don't bother doing anything more with this kernel, + // just try and continue with the code after + // (note that we've already done the regular CPU code) } } @@ -584,12 +598,9 @@ context().establishClosure(); String last = context().wrappingClosure(); String lastHostClassName = context().wrappingClass(); - X10ClassType hostClassType = (X10ClassType) n.closureDef() - .typeContainer().get(); - String nextHostClassName = Emitter.translate_mangled_FQN(hostClassType - .fullName().toString(), "_"); - String next = getClosureName(nextHostClassName, - context().closureId() + 1); + X10ClassType hostClassType = (X10ClassType) n.closureDef().typeContainer().get(); + String nextHostClassName = Emitter.translate_mangled_FQN(hostClassType.fullName().toString(), "_"); + String next = getClosureName(nextHostClassName, context().closureId() + 1); // System.out.println(last+" goes to "+next); context().wrappingClosure(next); context().wrappingClass(nextHostClassName); @@ -696,13 +707,9 @@ Type t = var.type(); String name = var.name().toString(); inc.write(Emitter.translateType(t, true) + " " + name); - if (context().autoBlocks() != null - && var == context().autoBlocks().localDef() - .asInstance()) { + if (context().autoBlocks() != null && var == context().autoBlocks().localDef().asInstance()) { inc.write(";"); - } else if (context().autoThreads() != null - && var == context().autoThreads().localDef() - .asInstance()) { + } else if (context().autoThreads() != null && var == context().autoThreads().localDef().asInstance()) { inc.write(";"); } else { inc.write(" = __this->" + name + ";"); @@ -717,14 +724,14 @@ inc.end(); inc.newline(); - if (context().autoBlocks() != null - && context().autoThreads() != null) { + // this is probably broken when only one is given. + if (context().autoBlocks()!=null && context().autoThreads()!=null) { String bname = context().autoBlocks().name().id().toString(); String tname = context().autoThreads().name().id().toString(); inc.write("x10aux::blocks_threads(__gpu, x10aux::DeserializationDispatcher::getMsgType(_serialization_id), __shm, " + bname + ", " + tname + ");"); inc.newline(); - }// else { + } inc.write("__blocks = ("); inc.begin(0); tr.print(null, context().blocks(), inc); @@ -738,7 +745,7 @@ inc.write(")+1;"); inc.end(); inc.newline(); - // } + inc.write("__cuda_env __env;"); inc.newline(); @@ -812,13 +819,13 @@ } public void visit(New_c n) { - complainIfNot2(!generatingKernel(),"New not allowed in @CUDA code.", n); + complainIfNot2(!generatingKernel(),"New not allowed in @CUDA code.", n, false); super.visit(n); } @Override public void visit(Assert_c n) { - complainIfNot2(!generatingKernel(),"Throwing exceptions not allowed in @CUDA code.", n); + complainIfNot2(!generatingKernel(),"Throwing exceptions not allowed in @CUDA code.", n, false); super.visit(n); } @@ -836,7 +843,7 @@ @Override public void visit(Await_c n) { - complainIfNot2(!generatingKernel(),"Await not allowed in @CUDA code.", n); + complainIfNot2(!generatingKernel(),"Await not allowed in @CUDA code.", n, false); super.visit(n); } @@ -866,7 +873,7 @@ @Override public void visit(Catch_c n) { - complainIfNot2(!generatingKernel(),"Catching exceptions not allowed in @CUDA code.", n); + complainIfNot2(!generatingKernel(),"Catching exceptions not allowed in @CUDA code.", n, false); super.visit(n); } @@ -878,7 +885,7 @@ @Override public void visit(ClosureCall_c n) { - complainIfNot2(!generatingKernel(),"Closure calls not allowed in @CUDA code.", n); + complainIfNot2(!generatingKernel(),"Closure calls not allowed in @CUDA code.", n, false); super.visit(n); } @@ -1042,13 +1049,13 @@ @Override public void visit(Throw_c n) { - complainIfNot2(!generatingKernel(),"Throwing exceptions not allowed in @CUDA code.", n); + complainIfNot2(!generatingKernel(),"Throwing exceptions not allowed in @CUDA code.", n, false); super.visit(n); } @Override public void visit(Try_c n) { - complainIfNot2(!generatingKernel(),"Catching exceptions not allowed in @CUDA code.", n); + complainIfNot2(!generatingKernel(),"Catching exceptions not allowed in @CUDA code.", n, false); super.visit(n); } @@ -1109,7 +1116,7 @@ @Override public void visit(X10Instanceof_c n) { - complainIfNot2(!generatingKernel(),"Runtime types not available in @CUDA code.", n); + complainIfNot2(!generatingKernel(),"Runtime types not available in @CUDA code.", n, false); super.visit(n); } Modified: trunk/x10.dist/samples/CUDA/CUDATopology.x10 =================================================================== --- trunk/x10.dist/samples/CUDA/CUDATopology.x10 2010-10-05 11:40:50 UTC (rev 16987) +++ trunk/x10.dist/samples/CUDA/CUDATopology.x10 2010-10-05 11:48:24 UTC (rev 16988) @@ -25,7 +25,7 @@ if (p2.isHost()) Console.OUT.println(" Is a Host place"); if (p2.isSPE()) Console.OUT.println(" Is a SPE place"); val children = p2.children(); - for (c in children) { + for (c in children.items()) { Console.OUT.println(" Child "+c.childIndex()+": "+c); Console.OUT.println(" Parent: "+c.parent()); Console.OUT.println(" NumChildren: "+c.numChildren()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-10-05 13:01:13
|
Revision: 16994 http://x10.svn.sourceforge.net/x10/?rev=16994&view=rev Author: dgrove-oss Date: 2010-10-05 13:01:07 +0000 (Tue, 05 Oct 2010) Log Message: ----------- clear out last of Val classes in x10.util; not needed in 2.1 Removed Paths: ------------- trunk/TODO_21_OBJ_MODEL.txt trunk/x10.runtime/src-x10/x10/util/ValMap.x10 Deleted: trunk/TODO_21_OBJ_MODEL.txt =================================================================== --- trunk/TODO_21_OBJ_MODEL.txt 2010-10-05 12:49:54 UTC (rev 16993) +++ trunk/TODO_21_OBJ_MODEL.txt 2010-10-05 13:01:07 UTC (rev 16994) @@ -1,9 +0,0 @@ -x10.io.GlobalStringWriter - Do we really want this class? See todo in the class header. - In general, normalize APIs for Global vs.Local operations, - Need to think about StringBuilder, Printers, Writers, etc. - Need to think about Console, Files, etc. - -x10.util. - Kill various Val<Foo> classes. No longer needed in 2.1 - Deleted: trunk/x10.runtime/src-x10/x10/util/ValMap.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/ValMap.x10 2010-10-05 12:49:54 UTC (rev 16993) +++ trunk/x10.runtime/src-x10/x10/util/ValMap.x10 2010-10-05 13:01:07 UTC (rev 16994) @@ -1,26 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -package x10.util; - -public interface ValMap[K,V] { - public def containsKey(k: K): boolean; - public def get(k: K): Box[V]; - public def getOrElse(k: K, orelse: V): V; - public def getOrThrow(k: K): V; //throws NoSuchElementException - public def keySet(): Set[K]; - public def entries(): Set[Entry[K,V]]; - - public static interface Entry[Key,Val] { - public def getKey(): Key; - public def getValue(): Val; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-10-05 17:29:30
|
Revision: 17009 http://x10.svn.sourceforge.net/x10/?rev=17009&view=rev Author: dgrove-oss Date: 2010-10-05 17:29:23 +0000 (Tue, 05 Oct 2010) Log Message: ----------- Switch the signature of Array.values return Iterable instead of Iterator (more generally useful). To match Sequence change to Dist.places() Dist.regions() now also returns a Sequence. Adjust test cases to new API. Modified Paths: -------------- trunk/x10.dist/samples/CUDA/CUDATopology.x10 trunk/x10.dist/samples/CUDA/KMeansCUDA.x10 trunk/x10.runtime/src-x10/x10/array/Array.x10 trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 trunk/x10.runtime/src-x10/x10/array/BlockWorldDist.x10 trunk/x10.runtime/src-x10/x10/array/Mat.x10 trunk/x10.runtime/src-x10/x10/array/UniqueDist.x10 trunk/x10.runtime/src-x10/x10/array/WrappedDistPlaceRestricted.x10 trunk/x10.runtime/src-x10/x10/array/WrappedDistRegionRestricted.x10 trunk/x10.runtime/src-x10/x10/lang/MultipleExceptions.x10 trunk/x10.runtime/src-x10/x10/lang/Place.x10 trunk/x10.runtime/src-x10/x10/util/OptionsParser.x10 trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest.x10 trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1.x10 trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1_MustFailCompile.x10 Modified: trunk/x10.dist/samples/CUDA/CUDATopology.x10 =================================================================== --- trunk/x10.dist/samples/CUDA/CUDATopology.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.dist/samples/CUDA/CUDATopology.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -25,7 +25,7 @@ if (p2.isHost()) Console.OUT.println(" Is a Host place"); if (p2.isSPE()) Console.OUT.println(" Is a SPE place"); val children = p2.children(); - for (c in children.items()) { + for (c in children.values()) { Console.OUT.println(" Child "+c.childIndex()+": "+c); Console.OUT.println(" Parent: "+c.parent()); Console.OUT.println(" NumChildren: "+c.numChildren()); Modified: trunk/x10.dist/samples/CUDA/KMeansCUDA.x10 =================================================================== --- trunk/x10.dist/samples/CUDA/KMeansCUDA.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.dist/samples/CUDA/KMeansCUDA.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -89,7 +89,7 @@ val workers = Place.NUM_ACCELS==0 ? new Array[Place][h] : h.children(); - for (gpu in workers.items()) async at (h) { + for (gpu in workers.values()) async at (h) { val role = gpu==h ? h.id : gpu.id - Place.MAX_PLACES; Modified: trunk/x10.runtime/src-x10/x10/array/Array.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Array.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.runtime/src-x10/x10/array/Array.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -310,14 +310,17 @@ */ public def iterator():Iterator[Point(rank)] = region.iterator() as Iterator[Point(rank)]; + /** - * Return an iterator over the data values of this array - * @return an iterator over the data values of this array. + * Return an Iterable[T] that can construct iterators + * over this array.<p> + * @return an Iterable[T] over this array. */ - public def values():Iterator[T] { - return new ValueIterator[T](this); + public def values():Iterable[T] { + // NOTE: If we could actually implement two instances of the + // Iterable interface, then we woudn't need this code. + return new ValueIterable[T](); } - // TODO: Should be annonymous nested class in values, // but that's too fragile with the 2.1 implementation of generics. @@ -333,23 +336,17 @@ public def hasNext() = regIt.hasNext(); public def next() = array(regIt.next()); } - /** - * Permits the syntax for (i:T in array.items()) { ...} - */ - public def items():Iterable[T] = new ItemIterable(); - // TODO: Should be annonymous nested class in values, - // but that's too fragile with the 2.1 implementation of generics. - private class ItemIterable implements Iterable[T] { - public def iterator()=Array.this.values(); + private class ValueIterable implements Iterable[T] { + public def iterator()= new ValueIterator[T](Array.this); } - + - public def sequence(){rank==1}:Sequence[T] = new ItemSequence(); + public def sequence(){rank==1}:Sequence[T] = new ValueSequence(); // TODO: Should be annonymous nested class in values, // but that's too fragile with the 2.1 implementation of generics. - private class ItemSequence(size:int) implements Sequence[T] { + private class ValueSequence(size:int) implements Sequence[T] { val array = Array.this as Array[T](1); - public def iterator() = Array.this.values(); + public def iterator() = new ValueIterator(Array.this); def this() { property(Array.this.size); } Modified: trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -102,7 +102,7 @@ public def places():Sequence[Place] = places.sequence(); public def numPlaces():int = places.size; - public def regions():Iterable[Region(rank)] = regions.items(); + public def regions():Sequence[Region(rank)] = regions.sequence(); public def get(p: Place): Region(rank) { return regionMap(p.id) as Region(rank); // XXXX } Modified: trunk/x10.runtime/src-x10/x10/array/BlockWorldDist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BlockWorldDist.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.runtime/src-x10/x10/array/BlockWorldDist.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -104,8 +104,8 @@ public def numPlaces():int = Place.MAX_PLACES; - public def regions():Iterable[Region(rank)] { - return new Array[Region(rank)](Place.MAX_PLACES, (i:int)=>blockRegionForPlace(Place.place(i))).items(); + public def regions():Sequence[Region(rank)] { + return new Array[Region(rank)](Place.MAX_PLACES, (i:int)=>blockRegionForPlace(Place.place(i))).sequence(); } public def get(p:Place):Region(rank) { Modified: trunk/x10.runtime/src-x10/x10/array/Mat.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Mat.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.runtime/src-x10/x10/array/Mat.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -25,7 +25,7 @@ public def apply(i:Int) = mat(i); - public def iterator() = mat.values(); + public def iterator() = mat.values().iterator(); public def printInfo(ps:Printer, label:String): void { ps.printf("%s\n", label); Modified: trunk/x10.runtime/src-x10/x10/array/UniqueDist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/UniqueDist.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.runtime/src-x10/x10/array/UniqueDist.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -33,8 +33,8 @@ public def numPlaces():int = Place.MAX_PLACES; - public def regions():Iterable[Region(rank)] { - return new Array[Region(rank)](Place.MAX_PLACES, (i:int)=>((i..i) as Region(rank))).items(); + public def regions():Sequence[Region(rank)] { + return new Array[Region(rank)](Place.MAX_PLACES, (i:int)=>((i..i) as Region(rank))).sequence(); } public def get(p:Place):Region(rank) { Modified: trunk/x10.runtime/src-x10/x10/array/WrappedDistPlaceRestricted.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/WrappedDistPlaceRestricted.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.runtime/src-x10/x10/array/WrappedDistPlaceRestricted.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -31,8 +31,8 @@ public def numPlaces() = 1; - public def regions():Iterable[Region(rank)] { - return new Array[Region(rank)](1, (int)=>region).items(); + public def regions():Sequence[Region(rank)] { + return new Array[Region(rank)](1, (int)=>region).sequence(); } public def get(p:Place):Region(rank) { Modified: trunk/x10.runtime/src-x10/x10/array/WrappedDistRegionRestricted.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/WrappedDistRegionRestricted.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.runtime/src-x10/x10/array/WrappedDistRegionRestricted.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -31,9 +31,9 @@ public def numPlaces() = base.numPlaces(); - public def regions():Iterable[Region(rank)] { + public def regions():Sequence[Region(rank)] { return new Array[Region(rank)](Place.MAX_PLACES, - (i:int)=>base.get(Place(i)).intersection(filter)).items(); + (i:int)=>base.get(Place(i)).intersection(filter)).sequence(); } public def get(p:Place):Region(rank) { Modified: trunk/x10.runtime/src-x10/x10/lang/MultipleExceptions.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/MultipleExceptions.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.runtime/src-x10/x10/lang/MultipleExceptions.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -26,7 +26,7 @@ // flatten MultipleExceptions in the stack for (t in stack) { if (t instanceof MultipleExceptions) { - for (u: Throwable in (t as MultipleExceptions).exceptions.items()) + for (u: Throwable in (t as MultipleExceptions).exceptions.values()) s.push(u); } else { s.push(t); @@ -38,7 +38,7 @@ public def this(t: Throwable) { val s = new Stack[Throwable](); if (t instanceof MultipleExceptions) { - for (u: Throwable in (t as MultipleExceptions).exceptions.items()) + for (u: Throwable in (t as MultipleExceptions).exceptions.values()) s.push(u); } else { s.push(t); @@ -50,14 +50,14 @@ public def printStackTrace(): void { //super.printStackTrace(); - for (t: Throwable in exceptions.items()) { + for (t: Throwable in exceptions.values()) { t.printStackTrace(); } } public def printStackTrace(p:Printer): void { //super.printStackTrace(p); - for (t: Throwable in exceptions.items()) { + for (t: Throwable in exceptions.values()) { t.printStackTrace(p); } } Modified: trunk/x10.runtime/src-x10/x10/lang/Place.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Place.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.runtime/src-x10/x10/lang/Place.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -85,7 +85,7 @@ private static places = new Array[Place](MAX_PLACES, ((id:Int) => Place(id))); public static def places():Sequence[Place]=places.sequence(); - public static children = childrenArray.items(); + public static children = childrenArray.values(); public static NUM_ACCELS = ALL_PLACES - MAX_PLACES; public static FIRST_PLACE:Place(0) = Place(0); Modified: trunk/x10.runtime/src-x10/x10/util/OptionsParser.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/OptionsParser.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.runtime/src-x10/x10/util/OptionsParser.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -43,7 +43,7 @@ continue; } if (!ended) { - if (flags!=null) for (flag in flags.items()) { + if (flags!=null) for (flag in flags.values()) { if (recognised) break; if (s.equals(flag.short_) || s.equals(flag.long_)) { if (flag.short_!=null) set.put(flag.short_, true); @@ -51,7 +51,7 @@ recognised = true; } } - if (specs!=null) for (spec in specs.items()) { + if (specs!=null) for (spec in specs.values()) { if (recognised) break; if (s.equals(spec.short_) || s.equals(spec.long_)) { recognised = true; Modified: trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -23,8 +23,8 @@ val r = [1, 2, 3]; val a = new Array[Int][1,2,3]; var sumr:int=0, suma:int=0; - for (i in a.items()) suma += i; - for (i in r.items()) sumr +=i; + for (i in a.values()) suma += i; + for (i in r.values()) sumr +=i; return suma==6 && sumr==6; } Modified: trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -23,8 +23,8 @@ val r = [1, 2, 3]; val a = new Array[Int{self!=0}][1,2,3]; var sumr:int=0, suma:int=0; - for (i in a.items()) suma += i; - for (i in r.items()) sumr +=i; + for (i in a.values()) suma += i; + for (i in r.values()) sumr +=i; return suma==6 && sumr==6; } Modified: trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1_MustFailCompile.x10 2010-10-05 16:45:16 UTC (rev 17008) +++ trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1_MustFailCompile.x10 2010-10-05 17:29:23 UTC (rev 17009) @@ -25,8 +25,8 @@ 0, // this should give a compilation error. 1,2,3]; var sumr:int=0, suma:int=0; - for (i in a.items()) suma += i; - for (i in r.items()) sumr +=i; + for (i in a.values()) suma += i; + for (i in r.values()) sumr +=i; return suma==6 && sumr==6; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-10-05 19:23:53
|
Revision: 17015 http://x10.svn.sourceforge.net/x10/?rev=17015&view=rev Author: yzibin Date: 2010-10-05 19:23:45 +0000 (Tue, 05 Oct 2010) Log Message: ----------- I removed the extra parameter from @NonEscaping, and created instead another annotation @NoThisAccess that allows you to do dynamic dispatching in a constructor. Fixed test cases and XRX. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java trunk/x10.compiler/src/x10/types/X10TypeMixin.java trunk/x10.compiler/src/x10/types/checker/ThisChecker.java trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java trunk/x10.runtime/src-x10/x10/compiler/NonEscaping.x10 trunk/x10.runtime/src-x10/x10/lang/Any.x10 trunk/x10.runtime/src-x10/x10/util/HashMap.x10 trunk/x10.runtime/src-x10/x10/util/Random.x10 trunk/x10.tests/examples/Constructs/Array/Array1.x10 trunk/x10.tests/examples/Constructs/Closures/ClosureEnclosingScope6.x10 trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 trunk/x10.tests/examples/Constructs/Init/InitFieldWithCall.x10 trunk/x10.tests/examples/Issues/XTENLANG_1565.x10 trunk/x10.tests/examples/Issues/XTENLANG_198.x10 trunk/x10.tests/examples/Issues/XTENLANG_52.x10 trunk/x10.tests/examples/Misc/RecursiveConstraint.x10 Added Paths: ----------- trunk/x10.runtime/src-x10/x10/compiler/NoThisAccess.x10 Modified: trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java 2010-10-05 19:23:45 UTC (rev 17015) @@ -498,7 +498,7 @@ public Node typeCheck(ContextVisitor tc) throws SemanticException { X10ConstructorDecl_c n = this; - ThisChecker thisC = (ThisChecker) new ThisChecker(tc.job()).context(tc.context()); + ThisChecker thisC = new ThisChecker(tc.job()); if (formals != null) { visitList(formals, thisC); if (thisC.error()) { Modified: trunk/x10.compiler/src/x10/types/X10TypeMixin.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2010-10-05 19:23:45 UTC (rev 17015) @@ -1133,23 +1133,12 @@ public static boolean isSuppressTransientErrorField(X10FieldDef def,X10TypeSystem ts) { return isDefAnnotated(def,ts,"x10.compiler.SuppressTransientError"); } - public static String getNonEscapingReadsFrom(X10Def def,X10TypeSystem ts) { - try { - Type at = (Type) ts.systemResolver().find(QName.make("x10.compiler.NonEscaping")); - final List<Type> annotations = def.annotationsMatching(at); - if (annotations.isEmpty()) return null; - Type first = annotations.get(0); - if (!(first instanceof X10ParsedClassType_c)) return null; - X10ParsedClassType_c nonEscaping = (X10ParsedClassType_c) first; - final List<Expr> list = nonEscaping.propertyInitializers(); - if (list.size()!=1) return ""; // @NonEscaping is like @NonEscaping("") - Expr arg = list.get(0); - if (arg==null || !(arg instanceof X10StringLit_c)) return ""; // @NonEscaping(null) is like @NonEscaping("") - return ((X10StringLit_c) arg).stringValue(); - } catch (SemanticException e) { - return null; - } + public static boolean isNoThisAccess(X10ProcedureDef def,X10TypeSystem ts) { + return isDefAnnotated(def,ts,"x10.compiler.NoThisAccess"); } + public static boolean isNonEscaping(X10ProcedureDef def,X10TypeSystem ts) { + return isDefAnnotated(def,ts,"x10.compiler.NonEscaping"); + } public static boolean isDefAnnotated(X10Def def,X10TypeSystem ts, String name) { try { Type at = (Type) ts.systemResolver().find(QName.make(name)); Modified: trunk/x10.compiler/src/x10/types/checker/ThisChecker.java =================================================================== --- trunk/x10.compiler/src/x10/types/checker/ThisChecker.java 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.compiler/src/x10/types/checker/ThisChecker.java 2010-10-05 19:23:45 UTC (rev 17015) @@ -10,6 +10,7 @@ import polyglot.frontend.Globals; import polyglot.frontend.Job; import polyglot.visit.ContextVisitor; +import polyglot.visit.ErrorHandlingVisitor; import x10.ast.X10CanonicalTypeNode; import x10.ast.X10Field_c; import x10.ast.X10NodeFactory; @@ -25,10 +26,11 @@ * @author vj * */ -public class ThisChecker extends ContextVisitor { +public class ThisChecker extends ErrorHandlingVisitor { public ThisChecker(Job job) { super(job, job.extensionInfo().typeSystem(), job.extensionInfo().nodeFactory()); } + protected boolean catchErrors(Node n) { return false; } @Override public Node override(Node n) { if (n instanceof X10Special) { @@ -53,6 +55,10 @@ } return null; } - public boolean error() { return error;} - public void clearError() { error = false;} + public boolean error() { + return error; + } + public void clearError() { + error = false; + } } \ No newline at end of file Modified: trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java =================================================================== --- trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java 2010-10-05 19:23:45 UTC (rev 17015) @@ -30,6 +30,7 @@ import x10.types.X10ParsedClassType_c; import x10.types.X10ProcedureDef; import x10.types.X10MethodDef; +import x10.types.checker.ThisChecker; import java.util.HashMap; import java.util.Set; @@ -235,21 +236,18 @@ MethodInfo info = allMethods.get(currDecl.procedureInstance()); final boolean ctor = isCtor(); if (!ctor) assert info!=null : currDecl; - final Set<FieldDef> canReadFrom = ctor ? Collections.<FieldDef>emptySet() : info.canReadFrom; // can't read from an un-init var in the ctors (I want to catch it here, so I can give the exact position info) - // can't read from any var not in @NonEscaping(...) - if (canReadFrom!=null) { + // can't read from any var if @NoThisAccess + if (ctor) { for (FieldDef f : fields) { boolean readBefore = isRead(inItem.initStatus.get(f)); final int fRes = res.initStatus.get(f); if (!readBefore && isRead(fRes)) { - if (!canReadFrom.contains(f)) { - // wasn't read before, and we read it now (either because of Field access, or X10Call) - reportError("Cannot read from field '"+f.name()+"' before it is definitely assigned.",n.position()); - // I want to report more errors with this field, so I remove the read status - res.initStatus.put(f,build(false, isWrite(fRes),isSeqWrite(fRes))); - wasError = true; - } + // wasn't read before, and we read it now (either because of Field access, or X10Call) + reportError("Cannot read from field '"+f.name()+"' before it is definitely assigned.",n.position()); + // I want to report more errors with this field, so I remove the read status + res.initStatus.put(f,build(false, isWrite(fRes),isSeqWrite(fRes))); + wasError = true; } } } @@ -302,15 +300,8 @@ } else { MethodInfo oldInfo = allMethods.get(procDef); assert oldInfo!=null : currDecl; - if (hasNonEscapingAnnot(procDef)) { - // the read-set should not change (we already reported an error if it did change) - newInfo.read.clear(); - newInfo.read.addAll(oldInfo.read); - } - if (noWrites(procDef)) { - newInfo.write.clear(); - newInfo.seqWrite.clear(); - } + assert !X10TypeMixin.isNoThisAccess((X10ProcedureDef)procDef,(X10TypeSystem)ts); + // proof that the fix-point terminates: write set decreases while the read set increases assert oldInfo.write.containsAll(newInfo.write); assert oldInfo.seqWrite.containsAll(newInfo.seqWrite); @@ -324,29 +315,20 @@ // no change! } else { wasChange = true; - newInfo.canReadFrom = oldInfo.canReadFrom; allMethods.put(procDef,newInfo); } } } } private MethodInfo getInfo(X10Call call) { - if (isTargetThis(call) && findMethod(call)!=null) { - final MethodInfo info = allMethods.get(call.methodInstance().def()); + final X10MethodDef def = (X10MethodDef) call.methodInstance().def(); + if (isTargetThis(call) && findMethod(call)!=null && !X10TypeMixin.isNoThisAccess(def,ts)) { + final MethodInfo info = allMethods.get(def); assert info!=null; return info; } return null; } - private boolean hasNonEscapingAnnot(ProcedureDef def) { - return X10TypeMixin.getNonEscapingReadsFrom((X10ProcedureDef) def, ts) != null; - } - private boolean noWrites(ProcedureDef def) { - // if it is not a final/private method (which can be the case for @NonEscaping), - // then the write-set must be empty (because it might be overriden and then the write doesn't happen) - final boolean hasNonEscapingAnnot = hasNonEscapingAnnot(def); - return hasNonEscapingAnnot && !isPrivateOrFinal(def); - } private boolean isProperty(FieldDef def) { final X10Flags flags = X10Flags.toX10Flags(def.flags()); return flags.isProperty(); @@ -407,13 +389,18 @@ Position pos = n.position(); if (!canUseThis() && n instanceof X10Call) { final X10Call call = (X10Call) n; - MethodInfo info = getInfo(call); - if (info!=null) { - if (info.read.size()==0 && info.write.size()==0) { + if (isTargetThis(call)) { + if (X10TypeMixin.isNoThisAccess((X10MethodDef)call.methodInstance().def(),ts)) { + // && X10TypeMixin.getNonEscapingReadsFrom((X10MethodDef)call.methodInstance().def(),ts)==null) { // @NonEscaping methods cannot write to any fields // even though we use "this.call(...)", this is legal // because the call doesn't read nor write to "this" } else { - reportError("You can use 'this' before 'property(...)' to call only methods that do not read nor write any fields.",pos); + MethodInfo info = getInfo(call); + if (info!=null && info.read.size()==0 && info.write.size()==0) { + // ok + } else { + reportError("You can use 'this' before 'property(...)' to call only @NoThisAccess methods or NonEscaping methods that do not read nor write any fields.",pos); + } } for (Expr e : call.arguments()) e.visit(this); @@ -475,9 +462,8 @@ } - // we gather info on every private/final/@NonEscaping method + // we gather info on every private/final/@NonEscaping method called during construction (@NoThisAccess do not access "this", so no need to analyze them) private static class MethodInfo { - private Set<FieldDef> canReadFrom = null; private final Set<FieldDef> read = new HashSet<FieldDef>(); private final Set<FieldDef> write = new HashSet<FieldDef>(); private final Set<FieldDef> seqWrite = new HashSet<FieldDef>(); @@ -492,7 +478,7 @@ // the keys are either X10ConstructorDecl_c or X10MethodDecl_c private final HashMap<ProcedureDef,MethodInfo> allMethods = new LinkedHashMap<ProcedureDef, MethodInfo>(); // all ctors and methods recursively called from allMethods on receiver "this" private final ArrayList<ProcedureDecl> dfsMethods = new ArrayList<ProcedureDecl>(); // to accelerate the fix-point alg - // the set of all VAR and VAL fields, including those in the superclass due to @NonEscaping (we need to check that VAL are read properly, and that VAR are written and read properly.) + // the set of all VAR and VAL fields (without properties), including those in the superclass because of super() call (we need to check that VAL are read properly, and that VAR are written and read properly.) // InitChecker already checks that VAL are assigned in every ctor exactly once (and never assigned in other methods) // Therefore we can now treat both VAL and VAR identically. private final HashSet<FieldDef> fields = new HashSet<FieldDef>(); @@ -593,8 +579,6 @@ // Find globalRefs calcGlobalRefs(nonStaticFields); - - // inline the field-initializers in every ctor ArrayList<Stmt> fieldInits = new ArrayList<Stmt>(); final Position pos = Position.COMPILER_GENERATED; @@ -607,12 +591,12 @@ fieldInstance(def.asInstance()). type(init.type()); fieldInits.add(nf.Eval(pos, fieldAssign)); - if (!globalRef.contains(def)) init.visit(this); // field init are implicitly NonEscaping + if (!globalRef.contains(def)) init.visit(this); // field init are like a ctor } Block newInit = nf.Block(pos,fieldInits); - // visit every ctor, every @NonEscaping method, and every method recursively called from them, and check that this and super do not escape + // visit every ctor, every @NoThisAccess/@NonEscaping method, and every method recursively called from them, and check that this and super do not escape ArrayList<X10ConstructorDecl_c> allCtors = new ArrayList<X10ConstructorDecl_c>(); for (ClassMember classMember : body.members()) { if (classMember instanceof ProcedureDecl) { @@ -621,52 +605,54 @@ final Block procBody = proc.body(); if (def instanceof X10MethodDef) { - String readsFrom = X10TypeMixin.getNonEscapingReadsFrom(def,ts); - - // check that overriding perserves the exact @NonEscaping annotation X10MethodDef x10def = (X10MethodDef) def; - final MethodInstance instance = x10def.asInstance(); - final Context emptyContext = ts.emptyContext(); - final List<MethodInstance> overriddenMethods = ts.overrides(instance, emptyContext); - for (MethodInstance overriddenMI : overriddenMethods) { - MethodDef overriddenDef = overriddenMI.def(); - if (overriddenDef==def) continue; // me - String overriddenReadsFrom = X10TypeMixin.getNonEscapingReadsFrom((X10MethodDef)overriddenDef,ts); - if (overriddenReadsFrom!=null) { - if (readsFrom==null || !overriddenReadsFrom.equals(readsFrom)) { - reportError("You must annotate "+proc+" with @NonEscaping(\""+overriddenReadsFrom+"\") because it overrides a method annotated with that.", proc.position()); + boolean isNoThisAccess = X10TypeMixin.isNoThisAccess(x10def,ts); + boolean isNonEscaping = X10TypeMixin.isNonEscaping(x10def,ts); + + // if we overrode a method with @NoThisAccess, then we must be annotated with @NoThisAccess + // (NonEscaping is private/final, so cannot be overriden) + if (!isNoThisAccess) { + final MethodInstance instance = x10def.asInstance(); + final Context emptyContext = ts.emptyContext(); + final List<MethodInstance> overriddenMethods = ts.overrides(instance, emptyContext); + for (MethodInstance overriddenMI : overriddenMethods) { + MethodDef overriddenDef = overriddenMI.def(); + if (overriddenDef==def) continue; // me + boolean overriddenIsNoThisAccess = X10TypeMixin.isNoThisAccess((X10MethodDef)overriddenDef,ts); + if (overriddenIsNoThisAccess) { + reportError("You must annotate "+proc+" with @NoThisAccess because it overrides a method annotated with that.", proc.position()); break; // one such error msg is enough } } } - - if (readsFrom==null) continue; - // check all the fields in the annotation are found - final MethodInfo info = new MethodInfo(); - info.canReadFrom = new HashSet<FieldDef>(); - String[] fieldNames = readsFrom.split(","); - for (String fieldName : fieldNames) { - String trimmed = fieldName.trim(); - if (trimmed.equals("")) continue; - FieldDef field = findField(trimmed); - if (field==null) reportError("Could not find field '"+trimmed+"' used in the annotation @NonEscaping.", proc.position()); - info.canReadFrom.add(field); - info.read.add(field); - } - if (procBody==null) continue; // for native methods/ctors, we don't have a body - allMethods.put(proc.procedureInstance(), info); - dfsMethods.add(proc); - + if (isNoThisAccess) { // NoThisAccess is stronger than NonEscaping so we check it first (in case someone wrote both annotations) + // check "this" is not accessed at all + if (procBody!=null) { // native/abstract methods + ThisChecker thisChecker = new ThisChecker(job); + procBody.visit(thisChecker); + if (thisChecker.error()) + reportError("You cannot use 'this' or 'super' in a method annotated with @NoThisAccess",procBody.position()); + } + // No need to do procBody.visit(this) because "this"/"super" are not used in a NoThisAccess method. + } else if (isNonEscaping) { + if (!isPrivateOrFinal(x10def)) + reportError("A @NonEscaping method must be private or final.", proc.position()); + if (procBody!=null && !allMethods.containsKey(def)) { // for native methods/ctors, we don't have a body + final MethodInfo info = new MethodInfo(); + allMethods.put(def, info); + procBody.visit(this); + dfsMethods.add(proc); + } + } } else { - if (procBody==null) continue; + if (procBody==null) continue; // native ctors assert proc instanceof X10ConstructorDecl_c : proc; final X10ConstructorDecl_c ctor = (X10ConstructorDecl_c) proc; allCtors.add(ctor); + procBody.visit(this); } - procBody.visit(this); - } } // we still need to CheckCtor (make sure super, this and property is correct) @@ -675,10 +661,8 @@ // do init for the fixed point alg for (Map.Entry<ProcedureDef, MethodInfo> entry : allMethods.entrySet()) { MethodInfo info = entry.getValue(); - if (!noWrites(entry.getKey())) { - info.write.addAll(fields); - info.seqWrite.addAll(fields); - } + info.write.addAll(fields); + info.seqWrite.addAll(fields); } // run fix point alg: ctors do not need to be in the fixed point alg because nobody can call them directly final FieldChecker fieldChecker = new FieldChecker(INIT); @@ -703,7 +687,6 @@ ctor.visit(checkCtor); checkCtor.postCheck(); - // ctors are implicitly NonEscaping final ConstructorCall cc = getConstructorCall(ctor); if (cc!=null && cc.kind() == ConstructorCall.THIS) { // ignore in dataflow ctors that call other ctors (using "this(...)"). @@ -715,13 +698,6 @@ } } } - private FieldDef findField(String name) { - for (FieldDef fieldDef : fields) - if (fieldDef.name().toString().equals(name)) { - return fieldDef; - } - return null; - } private static ConstructorCall getConstructorCall(X10ConstructorDecl_c ctor) { // We can reuse ConstructorCallChecker, but for better efficiency, we just check it directly final Block ctorBody = ctor.body(); @@ -772,22 +748,29 @@ final MethodInstance methodInstance = call.methodInstance(); final X10ProcedureDef procDef = (X10ProcedureDef) methodInstance.def(); if (isThis(call.target())) { - if (isProperty(procDef)) { - // property-method calls are ok + boolean hasNoThisAccess = X10TypeMixin.isNoThisAccess(procDef,ts); + if (isProperty(procDef) || hasNoThisAccess) { + // property-method calls and calls to @NoThisAccess are ok } else { - // the method must be final or private or NonEscaping - String readsFrom = X10TypeMixin.getNonEscapingReadsFrom(procDef,ts); - if (readsFrom==null && !isPrivateOrFinal(procDef)) - reportError("The call "+call+" is illegal because you can only call private/final/@NonEscaping methods from a NonEscaping method (such as a constructor, a field initializer, or a @NonEscaping method)", call.position()); + // the method must be final or private (or @NoThisAccess) + final Position callPos = call.position(); + boolean isNonEscaping = X10TypeMixin.isNonEscaping(procDef,ts); X10MethodDecl_c method = findMethod(call); if (method==null) { - if (readsFrom==null) - reportError("The call "+call+" is illegal because you can only call @NonEscaping methods of a superclass from a constructor or from methods called from a constructor",call.position()); + // in the future: we could infer nonescaping from the superclass. The problem is that it is hard to understand the error messages that result from such inference + // Igor: I think we should disallow the call to foo() when we infer that foo() escapes this. The error message may mention @NonEscaping -- once the user annotates foo() with @NonEscaping, the compiler will tell him/her where the potential points of escape are. + if (!isNonEscaping) + reportError("The call "+call+" is illegal because you can only call a superclass method during construction only if it is annotated with @NonEscaping.", callPos); } else { + if (!isPrivateOrFinal(procDef) && !isNonEscaping) // if it is NonEscaping, we will already report the error: "A @NonEscaping method must be private or final." + reportError("The call "+call+" is illegal because you can only call private/final @NonEscaping methods or @NoThisAccess methods during construction.", callPos); + ProcedureDef pd = method.procedureInstance(); if (allMethods.containsKey(pd)) { // we already analyzed this method (or it is an error method) } else { + if (!isNonEscaping) + job.compiler().errorQueue().enqueue(ErrorInfo.WARNING,"Method '"+procDef.signature()+"' is called during construction and therefore should be marked as @NonEscaping.", method.position()); final Block body = method.body(); if (body!=null) { allMethods.put(pd,new MethodInfo()); // prevent infinite recursion Added: trunk/x10.runtime/src-x10/x10/compiler/NoThisAccess.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/NoThisAccess.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/NoThisAccess.x10 2010-10-05 19:23:45 UTC (rev 17015) @@ -0,0 +1,34 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +package x10.compiler; + +import x10.lang.annotations.MethodAnnotation; + +/** + * @NoThisAccess is an annotation that can be used on methods for doing dynamic dispatching during construction. + * (See also @NonEscaping annotation.) + * + * <p>@NoThisAccess marks the fact that "this" cannot be used at all in the method. + * The compiler checks @NoThisAccess as follows: + * 1) @NoThisAccess must be preserved by overriding, i.e., when overriding a method annotated with + * @NoThisAccess then the overriding method must be annotated with @NoThisAccess. + * 2) The method cannot access "this" or "super" at all (cannot escape "this", read, nor write from any field). + * + * @NoThisAccess is different from @NonEscaping as follows: + * 1) @NoThisAccess methods cannot access "this" at all, whereas @NonEscaping can read and write to the fields of "this". + * 2) @NoThisAccess methods can be called after the constructor call (either super(...) or this(...)), + * whereas @NonEscaping methods can be called only after the property call (property(...)). + * 3) @NoThisAccess can be overriden, whereas @NonEscaping methods must be private/final. + * + * <p>@NoThisAccess is not checked on native methods because they do not have a body. + */ +public interface NoThisAccess extends MethodAnnotation { } Property changes on: trunk/x10.runtime/src-x10/x10/compiler/NoThisAccess.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.runtime/src-x10/x10/compiler/NonEscaping.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/NonEscaping.x10 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.runtime/src-x10/x10/compiler/NonEscaping.x10 2010-10-05 19:23:45 UTC (rev 17015) @@ -14,33 +14,26 @@ import x10.lang.annotations.MethodAnnotation; /** - * NonEscaping is an annotation that can be used on methods for two purposes: - * 1) for calling a super method during construction, and - * 2) for doing dynamic dispatching during construction. + * NonEscaping is an annotation that can be used on methods to mark the fact the method + * does not escape "this" nor "super" during construction. + * (See also @NoThisAccess annotation.) * + * <p>All constructors and field initializers are implicitly NonEscaping. + * + * <p>It is considered good practice to mark all methods called from a constructor as @NonEscaping. + * * Object construction (or initialization) in X10 is more strict than Java: * X10 has restricting rules that prevent seeing the default value of val fields * (as opposed to final fields in Java, because it is possible to see the default value of final fields in Java) * You can read the value of a val field only after it is definitely been assigned. * - * * <p>@NonEscaping marks the fact that "this" does not escape (also called leak) from the method. * A method is NonEscaping if: - * 1) the method is either final, private, annotated with @NonEscaping, or the entire class is final. - * 2) in the method body, "this" is only used in field access, field assignment, + * 1) the method is either final, private, or the entire class is final. + * 2) in the method body, "this" and "super" are only used in field access, field assignment, * and as the reciever of NonEscaping methods. - * 2) in the method body, "super" is only used in field access, field assignment, - * and as the reciever of methods annotated with @NonEscaping. + * Calling a superclass method is legal only of the method is explicitly NonEscaping. * - * The compiler checks @NonEscaping as follows: - * 1) @NonEscaping must be preserved by overriding, i.e., when overriding a method annotated with - * @NonEscaping(readFromFields) then the overriding method must be annotated with exactly the same annotation. - * 2) The method can read only from fields in readFromFields. - * NonEscaping is of course not checked on native methods because they do not have a body. - * - * All constructors and field initializers in X10 must be NonEscaping. - * - * <p>It is considered good practice to mark all methods called from a constructor as @NonEscaping. - * + * <p>@NonEscaping is not checked on native methods because they do not have a body. */ -public interface NonEscaping(readFromFields:String) extends MethodAnnotation { } +public interface NonEscaping extends MethodAnnotation { } Modified: trunk/x10.runtime/src-x10/x10/lang/Any.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Any.x10 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.runtime/src-x10/x10/lang/Any.x10 2010-10-05 19:23:45 UTC (rev 17015) @@ -13,7 +13,7 @@ import x10.compiler.Native; import x10.compiler.NativeRep; -import x10.compiler.NonEscaping; +import x10.compiler.NoThisAccess; /** * The top of the type hierarchy. @@ -52,7 +52,7 @@ */ @Native("java", "x10.rtt.Types.typeName(#0)") @Native("c++", "x10aux::type_name(#0)") - @NonEscaping("") + @NoThisAccess def typeName():String; /** Modified: trunk/x10.runtime/src-x10/x10/util/HashMap.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/HashMap.x10 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.runtime/src-x10/x10/util/HashMap.x10 2010-10-05 19:23:45 UTC (rev 17015) @@ -13,6 +13,7 @@ import x10.compiler.TempNoInline_1; import x10.io.CustomSerialization; +import x10.compiler.NonEscaping; public class HashMap[K,V] implements Map[K,V], CustomSerialization { static class HashEntry[Key,Value] implements Map.Entry[Key,Value] { @@ -63,7 +64,7 @@ init(pow2); } - final @TempNoInline_1 def init(sz: int): void { + @NonEscaping final @TempNoInline_1 def init(sz: int): void { // check that sz is a power of 2 assert (sz & -sz) == sz; assert sz >= MIN_SIZE; @@ -81,7 +82,7 @@ } protected def hash(k: K): Int = hashInternal(k); - protected final def hashInternal(k: K): Int { + @NonEscaping protected final def hashInternal(k: K): Int { return k.hashCode() * 17; } @@ -144,7 +145,7 @@ } public def put(k: K, v: V): Box[V] = putInternal(k,v); - protected final def putInternal(k: K, v: V): Box[V] { + @NonEscaping protected final def putInternal(k: K, v: V): Box[V] { if (occupation == table.length || (shouldRehash && occupation >= table.length / 2)) rehashInternal(); @@ -180,7 +181,7 @@ } public def rehash():void = rehashInternal(); - protected final def rehashInternal(): void { + @NonEscaping protected final def rehashInternal(): void { modCount++; val t = table; val oldSize = size; Modified: trunk/x10.runtime/src-x10/x10/util/Random.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/Random.x10 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.runtime/src-x10/x10/util/Random.x10 2010-10-05 19:23:45 UTC (rev 17015) @@ -10,6 +10,7 @@ */ package x10.util; +import x10.compiler.NonEscaping; /** Random number generator. */ public class Random { @@ -21,7 +22,7 @@ setSeed(seed); } - public final def setSeed(seed: Long): void { + @NonEscaping public final def setSeed(seed: Long): void { init(seed); } @@ -131,7 +132,7 @@ private var index: int; private var MT: Rail[int]; - public final def init(seed: long): Void { + @NonEscaping public final def init(seed: long): Void { val mt = Rail.make[int](N); MT=mt; // Ensure the seed is nonzero. Modified: trunk/x10.tests/examples/Constructs/Array/Array1.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/Array1.x10 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.tests/examples/Constructs/Array/Array1.x10 2010-10-05 19:23:45 UTC (rev 17015) @@ -23,7 +23,7 @@ public def run(): boolean = { val e = 1..10; - val r= [1..10, 1..10] as Region(2); + val r= e*e; val ia = new Array[int](r, (Point)=>0); for (p[i] in e) { Modified: trunk/x10.tests/examples/Constructs/Closures/ClosureEnclosingScope6.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Closures/ClosureEnclosingScope6.x10 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.tests/examples/Constructs/Closures/ClosureEnclosingScope6.x10 2010-10-05 19:23:45 UTC (rev 17015) @@ -26,7 +26,7 @@ class C { def a() = 2; class D { - final def a() = 4; + @NonEscaping final def a() = 4; val sum = (()=>( ClosureEnclosingScope6.this.a // DYNAMIC_CHECK + Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-05 19:23:45 UTC (rev 17015) @@ -1,13 +1,13 @@ +import x10.compiler.*; // @Uncounted @NonEscaping @NoThisAccess // test object initialization -import x10.compiler.*; // @Uncounted @NonEscaping class InfiniteInit234 { var i:Int{self!=0}; def this() { foo(); } - private def foo() = foo(); + @NonEscaping private def foo() = foo(); } class AllowCallsIfNoReadNorWrite { @@ -16,32 +16,49 @@ val w = this.foo1(); property(4); } - private def foo1() = 3 + foo2(); - private def foo2() = 3; + @NonEscaping private def foo1() = 3 + foo2(); + @NonEscaping private def foo2() = 3; } } -class DisallowCallsIfReadOrWrite { + +class DisallowCallsUnlessNoThisAccess { class Inner(i:Int) { static y=5; var x:Int=2; val z:Int=3; def this() { - val w = this.foo1(); // ERR: You can use 'this' before 'property(...)' to call only methods that do not read nor write any fields. + val w = this.foo1(); // ERR: You can use 'this' before 'property(...)' to call only @NoThisAccess methods or NonEscaping methods that do not read nor write any fields. property(4); } def this(i:Int) { - val w = this.bar1(); // ERR: You can use 'this' before 'property(...)' to call only methods that do not read nor write any fields. + val w = this.bar1(); // ERR: You can use 'this' before 'property(...)' to call only @NoThisAccess methods or NonEscaping methods that do not read nor write any fields. property(4); } - private def foo1() = foo2()+2; - private def foo2() = foo3()+3; - private def foo3() { + def this(i:Boolean) { + val w = this.ok1(); // ok + property(4); + } + @NoThisAccess def noThisAccess() { // subclasses cannot read nor write as well + return y; + } + def this(i:String) { + val w = this.noThisAccess(); // ok + property(4); + } + @NonEscaping private def ok1() = ok2()+2; + @NonEscaping private def ok2() = ok3()+3; + @NonEscaping private def ok3() { + return y; + } + @NonEscaping private def foo1() = foo2()+2; + @NonEscaping private def foo2() = foo3()+3; + @NonEscaping private def foo3() { x=2; // There is a write to a field in this method! return y; } - private def bar1() = bar2()+2; - final def bar2() { + @NonEscaping private def bar1() = bar2()+2; + @NonEscaping final def bar2() { return z; // There is a read from a field in this method! } } @@ -133,7 +150,7 @@ var z:Int = 2; val q:Int; def this(r:Int, c:Int{self == r}) { - val mShape = [1..r, 1..c] as Region; + val mShape:Region = null; val mDist = Dist.makeBlock(mShape); z++; // ERR: Can use 'this' only after 'property(...)' val closure = () => z++; // ERR: Can use 'this' only after 'property(...)' @@ -146,6 +163,13 @@ val initMat : (Point) => int = ([x,y]:Point) => x+y; } +class TwoErrorsInOneLineTest(o:Int) { + var k:Int; + def this() { + k=o; // ERR ERR + property(2); + } +} class SomeSuper87 { def this(i:Int) {} @@ -297,6 +321,18 @@ +class ClosureExample { + def this() { + val closure1 = () =>i; // OK, "i" is initialized here + } + val closure2 = () =>i; // ERR: Cannot read from field 'i' before it is definitely assigned. + val i = 3; +} +class ClosureIsNotAWrite { + var i:Int{self != 0}; // ERR: Semantic Error: Field 'i' was not definitely assigned. + val closure = () => { i=2; } ; +} + class TestPropertiesAndFields(i:Int, j:Int) { def this() { val x = 3; @@ -359,7 +395,7 @@ def a() = q*3; val q = 4; final class D { - def a() = q+4; + @NonEscaping def a() = q+4; val sum = (()=>(ClosureTest57.this.a() +C.this.a() +D.this.a() // ERR: The method call reads from field 'q' before it is definitely assigned. @@ -425,23 +461,39 @@ - class DynamicDispatchingInCtorTest { abstract class Super { val x:Int; - var size:Int; + val size:Int; def this() { - this.x = 3*4; - size = calcSize(); + this.x = 42; + size = calcSize(x); } - @NonEscaping("x") abstract def calcSize():Int; + @NoThisAccess abstract def calcSize(x:Int):Int; + @NonEscaping def useError(i:Int):Void {} // ERR: A @NonEscaping method must be private or final. + @NonEscaping final def use(i:Int):Void {} + @NonEscaping private def useOk2(i:Int):Void {} } class Sub1 extends Super { - @NonEscaping("x") def calcSize():Int = x*2; + @NoThisAccess def calcSize(x:Int):Int { return x*2; } } class Sub2 extends Super { - @NonEscaping("x") def calcSize():Int = x+2; + def calcSize(x:Int):Int { // ERR: You must annotate x10.lang.Int calcSize(...) with @NoThisAccess because it overrides a method annotated with that. + return x*4; + } } + class Sub3(p:Int) extends Super { + val w = 3; + var k:Int{self==p}; + def this() { + property(4); + k = p; + } + @NoThisAccess def calcSize(x:Int):Int { // ERR: You cannot use 'this' or 'super' in a method annotated with @NoThisAccess + use(w); + return x+2; + } + } } class TestAsync { @@ -478,76 +530,59 @@ var z:Int{self!=0}; def this(i:Int) { this(); x = y; } - def this() { // ERR: Field 'x' was not definitely assigned in this conprivate structor. (because assignments in non final/private @NonEscaping methods do not count, cause they might be overriden) + def this() { super(); q(); f0(); // ERR: Cannot read from field 'c' before it is definitely assigned. c = 2; f0(); setX(); - setY(); + setY(); + setY(); setZ(); - f1(); + f1(); d=4; } - @NonEscaping("") def setX() { + @NonEscaping def setX() { // ERR: A @NonEscaping method must be private or final. x = 42; } - @NonEscaping("") final def setZ() { + @NonEscaping final def setZ() { z = 42; } - final def setY() { + final def setY() { // ERR: (warning) Methods 'setY()' is called during construction and therefore should be marked as @NonEscaping. y = 42; } def g():Int = 1; - abstract @NonEscaping("a,b") def q():Int; - @NonEscaping("b,a") def ba():Int = a+b; - @NonEscaping("a,b,c") def f0():Int = a+b+c; - @NonEscaping("a,c") def f1():Int = a+c; - @NonEscaping("a,e") def e1():Int = 1; // ERR: Could not find field 'e' used in the annotation @NonEscaping. - @NonEscaping("a,c") def e2():Int = a+b+c; // ERR: reading from "b" + abstract @NonEscaping def q():Int; // ERR: A @NonEscaping method must be private or final. + @NonEscaping final def ba():Int = a+b; + @NonEscaping private def f0():Int = a+b+c; + @NonEscaping protected def f1():Int = a+c; // ERR: A @NonEscaping method must be private or final. + @NonEscaping final native def e1():Int; + @NonEscaping native def e2():Int; // ERR: A @NonEscaping method must be private or final. } + class Sub1Test extends SuperClassTest { val w = 1; var q:Int{self!=0} = 1; def this(i:Int) { this(); x = y; } def this() { super(); - readD(); - g(); - f2(); // ERR: The call Sub1.this.f2() is illegal because you can only call private/final/@NonEscaping methods from a NonEscaping method (such as a conprivate structor, a field initializer, or a @NonEscaping method) + readD(); + g(); // ERR: The call Sub1Test.this.g() is illegal because you can only call a superclass method during construction only if it is annotated with @NonEscaping. + setX(); + setZ(); + f2(); } - final def readD() { + final def readD() { // ERR: (warning) val q = d; } - @NonEscaping("a,b,c") def f0():Int = a+b+c+d; // ERR: Cannot read from field 'd' before it is definitely assigned. - @NonEscaping("a,b") def q():Int { - f0(); // ERR: Cannot read from field 'c' before it is definitely assigned. - readD(); // ERR: Cannot read from field 'd' before it is definitely assigned. - super.ba(); - val t = w; // ERR: Cannot read from field 'w' before it is definitely assigned. - return a+b; - } - @NonEscaping("g") def e3():Int = 1; // ERR: Could not find field 'g' used in the annotation @NonEscaping. - @NonEscaping("w") def g():Int = 1; - @NonEscaping("c,a") def f1():Int = 1; // ERR: You must annotate x10.lang.Int f1(...) with @NonEscaping("a,c") because it overrides a method annotated with that. - def f2():Int = 1; + @NonEscaping private def f2():Int = 1; + def q():Int = 2; } -class Sub2Test extends Sub1Test { - @NonEscaping("a,b") def q():Int { - val t = w; // ERR: Cannot read from field 'w' before it is definitely assigned. - return a+b; - } - def g():Int = 1; // ERR (annotation @NonEscaping must be preserved) - @NonEscaping("a,c") def f0():Int = 1; // ERR: You must annotate x10.lang.Int f0(...) with @NonEscaping("a,b,c") because it overrides a method annotated with that. - def f2():Int = 1; - def f3():Int = 1; -} - class TypeNameTest { val n = typeName(); } @@ -560,20 +595,20 @@ class TestNonEscaping { val x = foo(); - @NonEscaping("") def f1() {} + @NonEscaping private def f1() {} - @NonEscaping("") final def f5() { - bar(); // ERR: The call TestNonEscaping.this.bar() is illegal because you can only call private/final/@NonEscaping methods from a NonEscaping method (such as a conprivate structor, a field initializer, or a @NonEscaping method) + @NonEscaping final def f5() { + bar(); // ERR: The call TestNonEscaping.this.bar() is illegal because you can only call private/final @NonEscaping methods or @NoThisAccess methods during construction. } - def bar() {} + def bar() {} // ERR: (warning) - @NonEscaping("") final def foo() { - this.foo2(); + @NonEscaping final def foo() { + this.foo2(); return 3; } - final def foo2() { + final def foo2() { // ERR: (warning) } } @@ -584,20 +619,21 @@ } class TestAnonymousClass { static val anonymous1 = new Object() {}; - val anonymous2 = new TestAnonymousClass() {}; // ERR + val anonymous2 = new Object() {}; // ERR: 'this' and 'super' cannot escape from a constructor or from methods called from a constructor + val anonymous3 = new TestAnonymousClass() {}; // ERR: 'this' and 'super' cannot escape from a constructor or from methods called from a constructor def foo() { val x = new Object() {}; } - @NonEscaping("") final def foo2() { - val x = new Object() {}; // ERR + @NonEscaping final def foo2() { + val x = new Object() {}; // ERR: 'this' and 'super' cannot escape from a constructor or from methods called from a constructor } - val anonymous = new BlaInterface() { // ERR + val anonymous = new BlaInterface() { // ERR: 'this' and 'super' cannot escape from a constructor or from methods called from a constructor public def bla():Int{self!=0} { return k; } }; - val inner = new Inner(); // ERR + val inner = new Inner(); // ERR: 'this' and 'super' cannot escape from a constructor or from methods called from a constructor val w:Int{self!=0} = anonymous.bla(); val k:Int{self!=0}; def this() { @@ -615,7 +651,7 @@ class C57 { var m: Int{self!=0}, n:Int{self!=0}; - private final def ctorLike() { + @NonEscaping private final def ctorLike() { n = m; } def this() { @@ -628,7 +664,7 @@ class TestGlobalRefInheritance { private var k:GlobalRef[TestGlobalRefInheritance] = GlobalRef[TestGlobalRefInheritance](this); final def getK() = k; - @NonEscaping("k") def getK2() = + @NonEscaping def getK2() = // ERR: A @NonEscaping method must be private or final. k; // ERR: Cannot use 'k' because a GlobalRef[...](this) cannot be used in a field initializer, constructor, or methods called from a constructor. } class TestGlobalRefInheritanceSub extends TestGlobalRefInheritance { @@ -660,7 +696,7 @@ k = other.k; f = GlobalRef[TestGlobalRefRestriction](this); // ERR (this escaped) } - private def foo1() { + @NonEscaping private def foo1() { val z = (k as GlobalRef[TestGlobalRefRestriction]{home==here}); // ERR (because it is called from a ctor) z(); } @@ -690,7 +726,7 @@ val j = flag ? 3 : foo(); // ERR: reads from j before it is assigned. val k = foo(); var i:Int{self!=0}; - final def foo() { + @NonEscaping final def foo() { val z = j; i = 1; return 2; @@ -703,7 +739,7 @@ bla(); // ERR: bla() reads from layout before it is written to! layout = 1; } - private def bla() { + @NonEscaping private def bla() { Console.OUT.println(layout); // previously printed 0 } } @@ -713,7 +749,7 @@ def this(name:String{name != null}) { setName(name); } - public final def setName(name:String{name != null}) { + @NonEscaping public final def setName(name:String{name != null}) { this.name = name; } } @@ -724,7 +760,7 @@ setI(); // i1 is definitely-assigned now } - final def setI() { + @NonEscaping final def setI() { if (flag) { i1 = 2; } else { @@ -740,7 +776,7 @@ finish m2(); } //Read=[i1] SeqWrite=[i2] Write=[i1,i2] - final def m1() { + @NonEscaping final def m1() { val z1 = i1; if (flag) { async { i1 = 1; } @@ -752,7 +788,7 @@ } } //Read=[] SeqWrite=[i1] Write=[i1,i2] - private def m2() { + @NonEscaping private def m2() { if (flag) { finish async { i1 = 1; val z = i1; } async { i2 = 2; } @@ -775,17 +811,17 @@ m2(); } //Read=[] SeqWrite=[i1,i2,i3] Write=[i1,i2,i3] - final def m1() { + @NonEscaping final def m1() { i1 = 1; m2(); } //Read=[] SeqWrite=[i1,i2,i3] Write=[i1,i2,i3] - private def m2() { + @NonEscaping private def m2() { i2 = 2; m3(); } //Read=[] SeqWrite=[i1,i2,i3] Write=[i1,i2,i3] - private def m3() { + @NonEscaping private def m3() { i3 = 3; if (flag) { i1=1; i2=2; // stop the recursion. @@ -809,8 +845,8 @@ f2 = m1(); setV2(i); } - private def m1():Int = v1++; - public final def setV2(i:Int{self!=0}) { v2 = i; } + @NonEscaping private def m1():Int = v1++; + @NonEscaping public final def setV2(i:Int{self!=0}) { v2 = i; } } class IllegalExample { var f2:Int{self!=0}; @@ -822,7 +858,7 @@ def this(i:Int) { // ERR field is not initialized in this(Int) setV2(); } - final def setV2() { v2 = 3; } + @NonEscaping final def setV2() { v2 = 3; } } class IllegalExample2[T] { var t:T; // ERR (not initialized) @@ -832,13 +868,13 @@ def this() { foo(); } - final def foo() { + final def foo() { // ERR (warning) } } class SuperCallTest extends SuperTest22 { def this() { super(); - foo(); // ERR (cannot call super methods in a conprivate structor unless annotated with @NonEscaping) + foo(); // ERR (cannot call super methods in a private constructor unless annotated with @NonEscaping) } } @@ -875,7 +911,7 @@ var e:Inner = new Inner(); // ERR var e2:StaticInner = new StaticInner(); - private def foo(arg:TestFieldInitForwardRef):Int = 3; + @NonEscaping private def foo(arg:TestFieldInitForwardRef):Int = 3; } @@ -993,15 +1029,15 @@ } final operator this+(that:EscapingCtorTest):EscapingCtorTest = null; final operator (that:EscapingCtorTest)*this:EscapingCtorTest = null; - final def apply(that:EscapingCtorTest):EscapingCtorTest = null; + @NonEscaping final def apply(that:EscapingCtorTest):EscapingCtorTest = null; - final def m() { + @NonEscaping final def m() { g(); } - private def g() { + @NonEscaping private def g() { z(null); } - final def z(q:EscapingCtorTest) { + @NonEscaping final def z(q:EscapingCtorTest) { q.g(); g(); val inner1 = new Inner(); // ERR @@ -1022,15 +1058,15 @@ EscapingCtorTest.this.g(); z(EscapingCtorTest.this); // Inner "this" can NOT escape - f(null); // ERR - this.f(null); // ERR + f(null); + this.f(null); val z:Inner = null; z.f(z); z.f(this); // ERR bar(this); // ERR bar(z); } - def f(inner:Inner) {} + @NonEscaping private def f(inner:Inner) {} } } @@ -1046,15 +1082,15 @@ def this(i:Int) { m2(); } - final def m1() { + @NonEscaping final def m1() { i1 = 1; m2(); } - private def m2() { + @NonEscaping private def m2() { i2 = 2; m3(); } - private def m3() { + @NonEscaping private def m3() { i3 = 3; if (i3==4) { i1=1; i2=2; // stop the recursion. @@ -1105,4 +1141,5 @@ case 4: } } -} \ No newline at end of file +} + Modified: trunk/x10.tests/examples/Constructs/Init/InitFieldWithCall.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Init/InitFieldWithCall.x10 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.tests/examples/Constructs/Init/InitFieldWithCall.x10 2010-10-05 19:23:45 UTC (rev 17015) @@ -10,6 +10,7 @@ */ import harness.x10Test; +import x10.compiler.NonEscaping; @@ -19,7 +20,7 @@ public class InitFieldWithCall extends x10Test { - final def m()=1; + @NonEscaping final def m()=1; val a = m(); public def run() =true; Modified: trunk/x10.tests/examples/Issues/XTENLANG_1565.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_1565.x10 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.tests/examples/Issues/XTENLANG_1565.x10 2010-10-05 19:23:45 UTC (rev 17015) @@ -10,6 +10,7 @@ */ import harness.x10Test; +import x10.compiler.NonEscaping; /** * @author yoav @@ -66,7 +67,7 @@ // j:[1,2,1,2] f(j); } - final def f(i:Int):Int=i+1; + @NonEscaping final def f(i:Int):Int=i+1; public def run(): boolean { return true; Modified: trunk/x10.tests/examples/Issues/XTENLANG_198.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_198.x10 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.tests/examples/Issues/XTENLANG_198.x10 2010-10-05 19:23:45 UTC (rev 17015) @@ -10,6 +10,7 @@ */ import harness.x10Test; +import x10.compiler.NonEscaping; /** * @author bdlucas 12/2008 @@ -19,7 +20,7 @@ class XTENLANG_198 extends x10Test { static class A { - final def foo(): String = "A"; + @NonEscaping final def foo(): String = "A"; val x:String; def this() { x = foo(); Modified: trunk/x10.tests/examples/Issues/XTENLANG_52.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_52.x10 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.tests/examples/Issues/XTENLANG_52.x10 2010-10-05 19:23:45 UTC (rev 17015) @@ -10,6 +10,7 @@ */ import harness.x10Test; +import x10.compiler.NonEscaping; /** * @author bdlucas 10/2008 @@ -25,7 +26,7 @@ static type R(rank:int) = R{self.rank==rank}; - public final def get(): R(rank) { throw new RuntimeException(); } + @NonEscaping public final def get(): R(rank) { throw new RuntimeException(); } val rs = [get()]; Modified: trunk/x10.tests/examples/Misc/RecursiveConstraint.x10 =================================================================== --- trunk/x10.tests/examples/Misc/RecursiveConstraint.x10 2010-10-05 18:53:00 UTC (rev 17014) +++ trunk/x10.tests/examples/Misc/RecursiveConstraint.x10 2010-10-05 19:23:45 UTC (rev 17015) @@ -1,3 +1,4 @@ +// Yoav added: IGNORE_FILE /* * This file is part of the X10 project (http://x10-lang.org). * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-10-05 20:33:13
|
Revision: 17023 http://x10.svn.sourceforge.net/x10/?rev=17023&view=rev Author: yzibin Date: 2010-10-05 20:33:07 +0000 (Tue, 05 Oct 2010) Log Message: ----------- Fixed XTENLANG-823, and CheckEscapingThis now reports an error for creating an anonymous inner instance (even though the qualifier is null, so the AST doesn't really include "this") Modified Paths: -------------- trunk/x10.compiler/src/polyglot/visit/CFGBuilder.java trunk/x10.compiler/src/x10/ast/Async_c.java trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 Modified: trunk/x10.compiler/src/polyglot/visit/CFGBuilder.java =================================================================== --- trunk/x10.compiler/src/polyglot/visit/CFGBuilder.java 2010-10-05 20:27:52 UTC (rev 17022) +++ trunk/x10.compiler/src/polyglot/visit/CFGBuilder.java 2010-10-05 20:33:07 UTC (rev 17023) @@ -14,6 +14,7 @@ import polyglot.main.Report; import polyglot.types.*; import polyglot.util.*; +import x10.ast.Async; /** * Class used to construct a CFG. @@ -127,6 +128,8 @@ for (CFGBuilder v = this; v != null; v = v.outer) { Term c = v.innermostTarget; + if (c instanceof Async) break; // cannot break/continue in an Async + if (c instanceof Try) { Try tr = (Try) c; if (tr.finallyBlock() != null) { Modified: trunk/x10.compiler/src/x10/ast/Async_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Async_c.java 2010-10-05 20:27:52 UTC (rev 17022) +++ trunk/x10.compiler/src/x10/ast/Async_c.java 2010-10-05 20:33:07 UTC (rev 17023) @@ -253,10 +253,10 @@ */ public <S> List<S> acceptCFG(CFGBuilder v, List<S> succs) { if (clocks() == null || clocks().isEmpty()) { - v.visitCFG(body, this, EXIT); + v.push(this).visitCFG(body, this, EXIT); } else { v.visitCFGList(clocks, body, ENTRY); - v.visitCFG(body, this, EXIT); + v.push(this).visitCFG(body, this, EXIT); } v.edge(v,this,ENTRY,this,EXIT,FlowGraph.EDGE_KEY_FALSE); // a trick to make sure we treat Async like a conditional for the purpose of initialization. see InitChecker. Modified: trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java =================================================================== --- trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java 2010-10-05 20:27:52 UTC (rev 17022) +++ trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java 2010-10-05 20:33:07 UTC (rev 17023) @@ -727,6 +727,12 @@ @Override public Node visitEdgeNoOverride(Node parent, Node n) { checkGlobalRef(n); // check globalRef usage in ctors and methods called from ctors + if (n instanceof New) { + New aNew = (New) n; + if (aNew.qualifier()==null && aNew.body()!=null) { + reportError("'this' cannot escape via an anonymous class during construction", n.position()); + } + } // You can access "this" for field access and field assignment. // field assignment: if (n instanceof FieldAssign) { Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-05 20:27:52 UTC (rev 17022) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-05 20:33:07 UTC (rev 17023) @@ -619,16 +619,16 @@ } class TestAnonymousClass { static val anonymous1 = new Object() {}; - val anonymous2 = new Object() {}; // ERR: 'this' and 'super' cannot escape from a constructor or from methods called from a constructor - val anonymous3 = new TestAnonymousClass() {}; // ERR: 'this' and 'super' cannot escape from a constructor or from methods called from a constructor + val anonymous2 = new Object() {}; // ERR: 'this' cannot escape via an anonymous class during construction + val anonymous3 = new TestAnonymousClass() {}; // ERR: 'this' cannot escape via an anonymous class during construction def foo() { val x = new Object() {}; } @NonEscaping final def foo2() { - val x = new Object() {}; // ERR: 'this' and 'super' cannot escape from a constructor or from methods called from a constructor + val x = new Object() {}; // ERR: 'this' cannot escape via an anonymous class during construction } - val anonymous = new BlaInterface() { // ERR: 'this' and 'super' cannot escape from a constructor or from methods called from a constructor + val anonymous = new BlaInterface() { // ERR: 'this' cannot escape via an anonymous class during construction public def bla():Int{self!=0} { return k; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-10-06 15:09:02
|
Revision: 17104 http://x10.svn.sourceforge.net/x10/?rev=17104&view=rev Author: dgrove-oss Date: 2010-10-06 15:08:55 +0000 (Wed, 06 Oct 2010) Log Message: ----------- bump version numbers to 2.1 Modified Paths: -------------- trunk/x10.common/META-INF/MANIFEST.MF trunk/x10.compiler/META-INF/MANIFEST.MF trunk/x10.compiler/src/x10/Version.java trunk/x10.constraints/META-INF/MANIFEST.MF trunk/x10.doc/META-INF/MANIFEST.MF trunk/x10.runtime/META-INF/MANIFEST.MF Modified: trunk/x10.common/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.common/META-INF/MANIFEST.MF 2010-10-06 14:59:42 UTC (rev 17103) +++ trunk/x10.common/META-INF/MANIFEST.MF 2010-10-06 15:08:55 UTC (rev 17104) @@ -2,5 +2,5 @@ Bundle-ManifestVersion: 2 Bundle-Name: X10 Common components Bundle-SymbolicName: x10.common -Bundle-Version: 2.0.6.qualifier +Bundle-Version: 2.1.0.qualifier Export-Package: x10.config Modified: trunk/x10.compiler/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.compiler/META-INF/MANIFEST.MF 2010-10-06 14:59:42 UTC (rev 17103) +++ trunk/x10.compiler/META-INF/MANIFEST.MF 2010-10-06 15:08:55 UTC (rev 17104) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: X10 compiler Bundle-SymbolicName: x10.compiler -Bundle-Version: 2.0.6.qualifier +Bundle-Version: 2.1.0.qualifier Bundle-Localization: plugin Require-Bundle: x10.common, x10.constraints, Modified: trunk/x10.compiler/src/x10/Version.java =================================================================== --- trunk/x10.compiler/src/x10/Version.java 2010-10-06 14:59:42 UTC (rev 17103) +++ trunk/x10.compiler/src/x10/Version.java 2010-10-06 15:08:55 UTC (rev 17104) @@ -18,6 +18,6 @@ public String name() { return "x10"; } public int major() { return 2; } - public int minor() { return 0; } - public int patch_level() { return 6; } + public int minor() { return 1; } + public int patch_level() { return 0; } } Modified: trunk/x10.constraints/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.constraints/META-INF/MANIFEST.MF 2010-10-06 14:59:42 UTC (rev 17103) +++ trunk/x10.constraints/META-INF/MANIFEST.MF 2010-10-06 15:08:55 UTC (rev 17104) @@ -2,6 +2,6 @@ Bundle-ManifestVersion: 2 Bundle-Name: X10 Constraints Bundle-SymbolicName: x10.constraints -Bundle-Version: 2.0.6.qualifier +Bundle-Version: 2.1.0.qualifier Export-Package: x10.constraint Bundle-RequiredExecutionEnvironment: J2SE-1.5 Modified: trunk/x10.doc/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.doc/META-INF/MANIFEST.MF 2010-10-06 14:59:42 UTC (rev 17103) +++ trunk/x10.doc/META-INF/MANIFEST.MF 2010-10-06 15:08:55 UTC (rev 17104) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: x10.doc Bundle-SymbolicName: x10.doc -Bundle-Version: 0.1.0 +Bundle-Version: 2.1.0.qualifier Bundle-RequiredExecutionEnvironment: J2SE-1.5 Require-Bundle: x10.common, x10.compiler;visibility:=reexport, Modified: trunk/x10.runtime/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.runtime/META-INF/MANIFEST.MF 2010-10-06 14:59:42 UTC (rev 17103) +++ trunk/x10.runtime/META-INF/MANIFEST.MF 2010-10-06 15:08:55 UTC (rev 17104) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: X10 runtime Bundle-SymbolicName: x10.runtime -Bundle-Version: 2.0.6.qualifier +Bundle-Version: 2.1.0.qualifier Eclipse-AutoStart: true Bundle-Vendor: rf...@wa... Require-Bundle: x10.common This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-10-06 16:02:34
|
Revision: 17115 http://x10.svn.sourceforge.net/x10/?rev=17115&view=rev Author: yzibin Date: 2010-10-06 16:02:27 +0000 (Wed, 06 Oct 2010) Log Message: ----------- 1) Only the first dataflow analysis reports CFG errors now (which is ReachChecker). 2) better error message for break/continue in async, and if the CFG has errors then the dataflow doesn't report errors caused by that (like "unreachable statement"). 3) Fixed all region stuff in test suite, i.e., changed [(1..10),(1..10)] as Region(2) to (1..10)*(1..10) Modified Paths: -------------- trunk/x10.compiler/src/polyglot/frontend/JLScheduler.java trunk/x10.compiler/src/polyglot/visit/CFGBuilder.java trunk/x10.compiler/src/polyglot/visit/DataFlow.java trunk/x10.compiler/src/polyglot/visit/ReachChecker.java trunk/x10.compiler/src/x10/ExtensionInfo.java trunk/x10.dist/samples/tutorial/HeatTransfer_v3.x10 trunk/x10.tests/examples/Constructs/Array/ArrayFutureFlatten.x10 trunk/x10.tests/examples/Constructs/Array/ArrayInitializer1a.x10 trunk/x10.tests/examples/Constructs/Array/ArrayInitializer1b.x10 trunk/x10.tests/examples/Constructs/Closures/ClosureEnclosingScope6.x10 trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 trunk/x10.tests/examples/Constructs/DepType/DepTypeInMethodArgDependsOnArg.x10 trunk/x10.tests/examples/Constructs/DepType/DepTypeRef.x10 trunk/x10.tests/examples/Constructs/DepType/PropertyPropagationTest.x10 trunk/x10.tests/examples/Constructs/DepType/StaticReturn.x10 trunk/x10.tests/examples/Constructs/DepType/Transitive.x10 trunk/x10.tests/examples/Constructs/DepType/Transitivity.x10 trunk/x10.tests/examples/Samples/HeatTransferTest_v3.x10 Modified: trunk/x10.compiler/src/polyglot/frontend/JLScheduler.java =================================================================== --- trunk/x10.compiler/src/polyglot/frontend/JLScheduler.java 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.compiler/src/polyglot/frontend/JLScheduler.java 2010-10-06 16:02:27 UTC (rev 17115) @@ -50,7 +50,9 @@ goals.add(ReassembleAST(job)); goals.add(ConformanceChecked(job)); - goals.add(ReachabilityChecked(job)); + + // Data-flow analyses + goals.add(ReachabilityChecked(job)); // This must be the first dataflow analysis (see DataFlow.reportCFG_Errors) // goals.add(ExceptionsChecked(job)); goals.add(ExitPathsChecked(job)); goals.add(InitializationsChecked(job)); Modified: trunk/x10.compiler/src/polyglot/visit/CFGBuilder.java =================================================================== --- trunk/x10.compiler/src/polyglot/visit/CFGBuilder.java 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.compiler/src/polyglot/visit/CFGBuilder.java 2010-10-06 16:02:27 UTC (rev 17115) @@ -128,7 +128,9 @@ for (CFGBuilder v = this; v != null; v = v.outer) { Term c = v.innermostTarget; - if (c instanceof Async) break; // cannot break/continue in an Async + if (c instanceof Async) { + throw new CFGBuildError("Cannot "+b.kind()+" in an async", b.position()); + } if (c instanceof Try) { Try tr = (Try) c; Modified: trunk/x10.compiler/src/polyglot/visit/DataFlow.java =================================================================== --- trunk/x10.compiler/src/polyglot/visit/DataFlow.java 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.compiler/src/polyglot/visit/DataFlow.java 2010-10-06 16:02:27 UTC (rev 17115) @@ -50,6 +50,9 @@ * <code>dataflowOnEntry</code> is true. */ protected LinkedList<FlowGraphSource> flowgraphStack; + + protected boolean reportCFG_Errors = false; // only the first data-flow analysis should report CFG problems (like illegal break/continue) + protected boolean hadCFG_Error = false; protected static class FlowGraphSource { FlowGraphSource(FlowGraph g, CodeDecl s) { @@ -431,10 +434,12 @@ long t1 = System.currentTimeMillis(); try { + hadCFG_Error = false; v.visitGraph(); } catch (CFGBuildError e) { - reportError(e.message(), e.position()); + hadCFG_Error = true; + if (reportCFG_Errors) reportError(e.message(), e.position()); return; } Modified: trunk/x10.compiler/src/polyglot/visit/ReachChecker.java =================================================================== --- trunk/x10.compiler/src/polyglot/visit/ReachChecker.java 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.compiler/src/polyglot/visit/ReachChecker.java 2010-10-06 16:02:27 UTC (rev 17115) @@ -27,6 +27,7 @@ super(job, ts, nf, true /* forward analysis */, true /* perform dataflow on entry to CodeDecls */); + reportCFG_Errors = true; // this is always the first dataflow analysis } protected static class DataFlowItem extends Item { @@ -136,7 +137,7 @@ // check for reachability. if (n instanceof Term) { n = checkReachability((Term)n); - if (!((Term)n).reachable()) { + if (!hadCFG_Error && !((Term)n).reachable()) { // Do we throw an exception or not? // Compound statements are allowed to be unreachable Modified: trunk/x10.compiler/src/x10/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-10-06 16:02:27 UTC (rev 17115) @@ -396,7 +396,7 @@ goals.add(ConformanceChecked(job)); // Data-flow analyses - goals.add(ReachabilityChecked(job)); + goals.add(ReachabilityChecked(job)); // This must be the first dataflow analysis (see DataFlow.reportCFG_Errors) // goals.add(ExceptionsChecked(job)); goals.add(ExitPathsChecked(job)); goals.add(InitializationsChecked(job)); Modified: trunk/x10.dist/samples/tutorial/HeatTransfer_v3.x10 =================================================================== --- trunk/x10.dist/samples/tutorial/HeatTransfer_v3.x10 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.dist/samples/tutorial/HeatTransfer_v3.x10 2010-10-06 16:02:27 UTC (rev 17115) @@ -1,3 +1,4 @@ +// Yoav added: IGNORE_FILE /* * This file is part of the X10 project (http://x10-lang.org). * Modified: trunk/x10.tests/examples/Constructs/Array/ArrayFutureFlatten.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayFutureFlatten.x10 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.tests/examples/Constructs/Array/ArrayFutureFlatten.x10 2010-10-06 16:02:27 UTC (rev 17115) @@ -21,8 +21,8 @@ public class ArrayFutureFlatten extends x10Test { public def run(): boolean = { - val A = new Array[int]([1..10, 1..10], (Point)=>0); - val B = new Array[int]([1..10, 1..10], (Point)=>0); + val A = new Array[int]((1..10)*(1..10), (Point)=>0); + val B = new Array[int]((1..10)*(1..10), (Point)=>0); val b = (Future.make[int](()=>3))(); chk(0 == (Future.make[int](()=>B(1,1))())); return true; Modified: trunk/x10.tests/examples/Constructs/Array/ArrayInitializer1a.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayInitializer1a.x10 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.tests/examples/Constructs/Array/ArrayInitializer1a.x10 2010-10-06 16:02:27 UTC (rev 17115) @@ -20,7 +20,7 @@ public def run(): boolean = { val e = 0..9; - val r = [e, e, e] as Region; + val r = e*e*e; val ia = new Array[Int](r, ([i,j,k]: Point)=> i); for (val p[i,j,k] in ia.region) chk(ia(p) == i); // should infer p:Point(3) Modified: trunk/x10.tests/examples/Constructs/Array/ArrayInitializer1b.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayInitializer1b.x10 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.tests/examples/Constructs/Array/ArrayInitializer1b.x10 2010-10-06 16:02:27 UTC (rev 17115) @@ -20,7 +20,7 @@ public def run(): boolean = { val e = 0..9; - val r = [e, e, e] as Region(3); + val r = e*e*e; val ia = new Array[Int](r, ([i,j,k]:Point)=> i); for (val p[i,j,k]:Point(3) in ia.region) chk(ia(p) == i); Modified: trunk/x10.tests/examples/Constructs/Closures/ClosureEnclosingScope6.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Closures/ClosureEnclosingScope6.x10 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.tests/examples/Constructs/Closures/ClosureEnclosingScope6.x10 2010-10-06 16:02:27 UTC (rev 17115) @@ -10,8 +10,8 @@ */ import harness.x10Test; +import x10.compiler.NonEscaping; - /** * The closure body may refer to instances of enclosing classes using the * syntax C.this, where C is the name of the enclosing class. Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-06 16:02:27 UTC (rev 17115) @@ -1143,3 +1143,77 @@ } } + + + + + + +class TestBreaksInAsyncAt { + class Shyk_Flup { // XTENLANG-823 + public def test() { + + lesp_frobi: for (var i : Int = 0; i < 10; i++) { + if (i<3) break lesp_frobi; + finish async{ + break lesp_frobi; // ERR: Cannot break in an async + } + x10.io.Console.OUT.println("This must not happen!"); + } + } + } + + var flag:Boolean; + + def test1() { + while (flag) { + if (flag) continue; + if (flag) break; + } + } + def test2() { + while (flag) { + at (here) { + if (flag) continue; + if (flag) break; + } + } + } + + def test3() { + while (flag) { + async { + while (flag) { + if (flag) break; + } + } + } + } + + def failTestLabel() { + while (flag) { + if (flag) continue non_existing_label; // ERR: Target of branch statement not found. + } + } + def failTest1() { + while (flag) { + async { + if (flag) continue; // ERR: Cannot continue in an async + } + } + } + def failTest2() { + while (flag) { + async { + if (flag) break; // ERR: Cannot break in an async + } + } + } + def failTest3() { + while (flag) { + async { + if (flag) return; // ERR: Cannot return from an async. + } + } + } +} \ No newline at end of file Modified: trunk/x10.tests/examples/Constructs/DepType/DepTypeInMethodArgDependsOnArg.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/DepTypeInMethodArgDependsOnArg.x10 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.tests/examples/Constructs/DepType/DepTypeInMethodArgDependsOnArg.x10 2010-10-06 16:02:27 UTC (rev 17115) @@ -21,7 +21,7 @@ val a_src: Array[double]{rank==a_dest.rank}): void = { } public def run(): boolean = { - val buffDest: Array[double]{rank==2} = new Array[double]([1..10, 1..10]); + val buffDest: Array[double]{rank==2} = new Array[double]((1..10)*(1..10)); val buffSrc = buffDest; arraycopy(buffDest, buffSrc); return true; Modified: trunk/x10.tests/examples/Constructs/DepType/DepTypeRef.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/DepTypeRef.x10 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.tests/examples/Constructs/DepType/DepTypeRef.x10 2010-10-06 16:02:27 UTC (rev 17115) @@ -18,7 +18,7 @@ */ public class DepTypeRef extends x10Test { public def run(): boolean = { - var R: Region{rect} = [1..2, 1..2]; + var R: Region{rect} = (1..2)*(1..2); var a: Array[double]{rect} = new Array[double](R, (p: Point) => 1.0); return true; } Modified: trunk/x10.tests/examples/Constructs/DepType/PropertyPropagationTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/PropertyPropagationTest.x10 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.tests/examples/Constructs/DepType/PropertyPropagationTest.x10 2010-10-06 16:02:27 UTC (rev 17115) @@ -18,8 +18,8 @@ */ public class PropertyPropagationTest extends x10Test { public def run(): boolean = { - val R = [1..10, 1..10] as Region; - val R2 = [1..101, 1..101] as Region; + val R = (1..10)*(1..10); + val R2 = (1..101)*(1..101); val D = Dist.makeBlock(R); val E = Dist.makeBlock(R2); // val F = D || E; removed because || removed on Dist. Modified: trunk/x10.tests/examples/Constructs/DepType/StaticReturn.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/StaticReturn.x10 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.tests/examples/Constructs/DepType/StaticReturn.x10 2010-10-06 16:02:27 UTC (rev 17115) @@ -21,7 +21,7 @@ return true; } def starY(): Dist{rank==2} = { - var d: Dist{rank==2} = Dist.makeConstant([0..1, 0..1], here); + var d: Dist{rank==2} = Dist.makeConstant((0..1)*(0..1), here); return d; } public static def main(Array[String](1)) { Modified: trunk/x10.tests/examples/Constructs/DepType/Transitive.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/Transitive.x10 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.tests/examples/Constructs/DepType/Transitive.x10 2010-10-06 16:02:27 UTC (rev 17115) @@ -22,7 +22,7 @@ public class Transitive extends x10Test { public def run(): boolean = { - val a: Region{rank==2} = [0..10, 0..10]; + val a: Region{rank==2} = (0..10)*(0..10); val b: Region{rank==a.rank} = a; var c: Region{rank==2} = b; return true; Modified: trunk/x10.tests/examples/Constructs/DepType/Transitivity.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/Transitivity.x10 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.tests/examples/Constructs/DepType/Transitivity.x10 2010-10-06 16:02:27 UTC (rev 17115) @@ -30,8 +30,8 @@ public def run(): boolean = { - val buffDest: Array[double]{rank==2} = new Array[double]([1..10, 1..10]); - var buffSrc: Array[double]{rank==buffDest.rank} = new Array[double]([1..10, 1..10]); + val buffDest: Array[double]{rank==2} = new Array[double]((1..10)*(1..10)); + var buffSrc: Array[double]{rank==buffDest.rank} = new Array[double]((1..10)*(1..10)); return true; } Modified: trunk/x10.tests/examples/Samples/HeatTransferTest_v3.x10 =================================================================== --- trunk/x10.tests/examples/Samples/HeatTransferTest_v3.x10 2010-10-06 15:58:34 UTC (rev 17114) +++ trunk/x10.tests/examples/Samples/HeatTransferTest_v3.x10 2010-10-06 16:02:27 UTC (rev 17115) @@ -1,3 +1,4 @@ +// Yoav added: IGNORE_FILE /* * This file is part of the X10 project (http://x10-lang.org). * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-10-06 18:13:15
|
Revision: 17127 http://x10.svn.sourceforge.net/x10/?rev=17127&view=rev Author: yzibin Date: 2010-10-06 18:13:09 +0000 (Wed, 06 Oct 2010) Log Message: ----------- added more test for finish-async init, changed places(p) to place(p). Modified Paths: -------------- trunk/x10.compiler/src/polyglot/visit/InitChecker.java trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 trunk/x10.tests/tests/ScalableFinish/SimpleFinish3.x10 trunk/x10.tests/tests/ScalableFinish/SimpleFinish4.x10 trunk/x10.tests/tests/ScalableFinish/SimpleFinish5.x10 Modified: trunk/x10.compiler/src/polyglot/visit/InitChecker.java =================================================================== --- trunk/x10.compiler/src/polyglot/visit/InitChecker.java 2010-10-06 18:01:58 UTC (rev 17126) +++ trunk/x10.compiler/src/polyglot/visit/InitChecker.java 2010-10-06 18:13:09 UTC (rev 17127) @@ -48,7 +48,7 @@ * Yoav Zibin added: - Adding finish-async initialization of val (and shared vars): + Adding finish-async initialization of var/val: See XTENLANG-1565. I kept the CFG without changes. So, an Async_c exit has two incoming edges: from the exit of the body and @@ -91,7 +91,7 @@ // i=[1,1,1,1] Here is a more complicated example: - shared var i:Int, j:Int, k:Int; + var i:Int, j:Int, k:Int; val m:Int, n:Int, q:Int; i=1; Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-06 18:01:58 UTC (rev 17126) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-06 18:13:09 UTC (rev 17127) @@ -508,6 +508,112 @@ } val r3 = i; } + + static def use(a:Int) {} + + public static def main(Array[String]) { + var i:Int, j:Int, k:Int, x:Int, y:Int; + val m:Int, n:Int, q:Int; + + x=1; + async { use(x); x=4; use(x); } + use(x); + async { y=4; use(x); use(y); } + use(y); // ERR: "y" may not have been initialized + + i=1; + use(i); + // i:[1,1,1,1] + finish { + m=2; + use(m); + // m:[1,1,1,1] + if (true) { + async { + n=3; i=4; j=5; k=6; q=7; + use(n); use(i); use(j); use(k); use(q); use(m); + // n:[1,1,1,1] i:[2,2,2,2] j:[1,1,1,1] k:[1,1,1,1] q:[1,1,1,1] + } + use(n); // ERR: "n" may not have been initialized + use(i); + use(j); // ERR: "j" may not have been initialized + use(k); // ERR: "k" may not have been initialized + use(q); // ERR: "q" may not have been initialized + use(m); + // n:[0,0,1,1] i:[1,1,2,2] j:[0,0,1,1] k:[0,0,1,1] q:[0,0,1,1] + k=8; + use(k); + // k:[1,1,2,2] + } else { + // n:[0,0,0,0] m:[1,1,1,1] i:[1,1,1,1] j:[0,0,0,0] k:[0,0,0,0] q:[0,0,0,0] + n=9; + use(n); + m=10; // ERR: Final variable "m" might already have been initialized + use(m); + // n:[1,1,1,1] m:[2,2,2,2] + } + // k:[0,1,0,2] n:[0,1,1,1] m:[1,2,1,2] i:[1,1,1,2] j:[0,0,0,1] q:[0,0,0,1] + k=11; + use(k); + // k:[1,2,1,3] + } + // k:[1,3,1,3] n:[1,1,1,1] m:[1,2,1,2] i:[1,2,1,2] j:[0,1,0,1] q:[0,1,0,1] + j=12; + use(q); // ERR: "q" may not have been initialized + use(n); use(i); use(j); use(k); use(m); + // j:[1,2,1,2] + // all (except q) are definitely-assigned now. + + } + static def use2(loc:Int,expected:Int,a:Int) { if (expected!=a) throw new RuntimeException("ERROR! loc="+loc+" expected="+expected+" a="+a); } + + public static def main2(Array[String]) { + var i:Int, j:Int, k:Int, x:Int, y:Int; + val m:Int, n:Int, q:Int; + + x=1; + finish async { use2(101,1,x); x=4; use2(102,4,x); } + use2(103,4,x); + async { y=5; use2(104,4,x); use2(105,5,y); } + + i=1; + use2(106,1,i); + // i:[1,1,1,1] + finish { + m=2; + use2(107,2,m); + // m:[1,1,1,1] + if (true) { + async { + n=3; i=4; j=5; k=6; q=7; + use2(108,3,n); use2(109,4,i); use2(110,5,j); use2(111,6,k); use2(112,7,q); use2(113,2,m); + // n:[1,1,1,1] i:[2,2,2,2] j:[1,1,1,1] k:[1,1,1,1] q:[1,1,1,1] + } + use2(115,2,m); + // n:[0,0,1,1] i:[1,1,2,2] j:[0,0,1,1] k:[0,0,1,1] q:[0,0,1,1] + k=8; + use2(116,8,k); + // k:[1,1,2,2] + } else { + // n:[0,0,0,0] m:[1,1,1,1] i:[1,1,1,1] j:[0,0,0,0] k:[0,0,0,0] q:[0,0,0,0] + n=9; + use2(117,9,n); + use2(118,2,m); + // n:[1,1,1,1] m:[2,2,2,2] + } + // k:[0,1,0,2] n:[0,1,1,1] m:[1,2,1,2] i:[1,1,1,2] j:[0,0,0,1] q:[0,0,0,1] + k=11; + use2(119,11,k); + // k:[1,2,1,3] + } + // k:[1,3,1,3] n:[1,1,1,1] m:[1,2,1,2] i:[1,2,1,2] j:[0,1,0,1] q:[0,1,0,1] + j=12; + k=99; + use2(120,3,n); use2(121,4,i); use2(122,12,j); use2(123,99,k); use2(124,2,m); + // j:[1,2,1,2] + // all (except q) are definitely-assigned now. + + } } @@ -1216,4 +1322,15 @@ } } } +} + + + +class Possel811 { //XTENLANG-811 + interface I { + def i():void; // ERR: <anonymous class> should be declared abstract; it does not define i(): x10.lang.Void, which is declared in Possel811.I + } + def test() { + new I(){}; + } } \ No newline at end of file Modified: trunk/x10.tests/tests/ScalableFinish/SimpleFinish3.x10 =================================================================== --- trunk/x10.tests/tests/ScalableFinish/SimpleFinish3.x10 2010-10-06 18:01:58 UTC (rev 17126) +++ trunk/x10.tests/tests/ScalableFinish/SimpleFinish3.x10 2010-10-06 18:13:09 UTC (rev 17127) @@ -12,7 +12,7 @@ @FinishAsync(1,1,false,2) finish { for(var p:int = 0; p<Place.MAX_PLACES; p++){ - async at (Place.places(p)){} + async at (Place.place(p)){} } } } Modified: trunk/x10.tests/tests/ScalableFinish/SimpleFinish4.x10 =================================================================== --- trunk/x10.tests/tests/ScalableFinish/SimpleFinish4.x10 2010-10-06 18:01:58 UTC (rev 17126) +++ trunk/x10.tests/tests/ScalableFinish/SimpleFinish4.x10 2010-10-06 18:13:09 UTC (rev 17127) @@ -12,7 +12,7 @@ @FinishAsync(1,1,false,2) finish { for(var p:int = 0; p<Place.MAX_PLACES; p++){ - async at (Place.places(p)){ + async at (Place.place(p)){ for(var pp:int = 0; pp<Place.MAX_PLACES; pp++){ val i = pp; async{} Modified: trunk/x10.tests/tests/ScalableFinish/SimpleFinish5.x10 =================================================================== --- trunk/x10.tests/tests/ScalableFinish/SimpleFinish5.x10 2010-10-06 18:01:58 UTC (rev 17126) +++ trunk/x10.tests/tests/ScalableFinish/SimpleFinish5.x10 2010-10-06 18:13:09 UTC (rev 17127) @@ -15,14 +15,14 @@ async{} } for(var p:int = 0; p<Place.MAX_PLACES; p++){ - async at (Place.places(p)){ + async at (Place.place(p)){ for(var pp:int = 0; pp<50; pp++){ async{} } } } for(var p3:int = Place.MAX_PLACES-1; p3>=0;p3--){ - async at (Place.places(p3)){} + async at (Place.place(p3)){} } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-10-06 18:18:13
|
Revision: 17128 http://x10.svn.sourceforge.net/x10/?rev=17128&view=rev Author: yzibin Date: 2010-10-06 18:18:07 +0000 (Wed, 06 Oct 2010) Log Message: ----------- Fixed XTENLANG-1888. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10Local_c.java trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 Modified: trunk/x10.compiler/src/x10/ast/X10Local_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-10-06 18:13:09 UTC (rev 17127) +++ trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-10-06 18:18:07 UTC (rev 17128) @@ -68,15 +68,15 @@ } // if the local is defined in an outer class, then it must be final - // shared was removed from the language: you can access var in a closure (backends need to be fixed) -// if (!context.isLocal(li.name())) { -// // this local is defined in an outer class -// if (!li.flags().isFinal() && !X10Flags.toX10Flags(li.flags()).isShared()) { -// Errors.issue(tc.job(), new SemanticException("Local variable \"" + li.name() + -// "\" is accessed from an inner class or a closure, and must be declared final or shared.", -// this.position())); -// } -// } + // shared was removed from the language: you cannot access var in a closure + if (!context.isLocal(li.name())) { + // this local is defined in an outer class + if (!li.flags().isFinal() && !X10Flags.toX10Flags(li.flags()).isShared()) { + Errors.issue(tc.job(), new SemanticException("Local variable \"" + li.name() + + "\" is accessed from an inner class or a closure, and must be declared final.", + this.position())); + } + } X10Local_c result = (X10Local_c) localInstance(li).type(li.type()); Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-06 18:13:09 UTC (rev 17127) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-06 18:18:07 UTC (rev 17128) @@ -1333,4 +1333,22 @@ def test() { new I(){}; } +} + +class AccessOfVarIllegalFromClosure { // XTENLANG-1888 + val x:Int = 1; + var y:Int = 1; + + public def run() = { + + val a:Int = 1; + var b:Int = 1; + + val closure = + () => + x+ + y+ + a+ + b; // ERR: Local variable "b" is accessed from an inner class or a closure, and must be declared final. + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-10-06 18:31:35
|
Revision: 17129 http://x10.svn.sourceforge.net/x10/?rev=17129&view=rev Author: yzibin Date: 2010-10-06 18:31:29 +0000 (Wed, 06 Oct 2010) Log Message: ----------- I broke async-init because async are considered closures as well. Undid my changes. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10Local_c.java trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 Modified: trunk/x10.compiler/src/x10/ast/X10Local_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-10-06 18:18:07 UTC (rev 17128) +++ trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-10-06 18:31:29 UTC (rev 17129) @@ -69,14 +69,14 @@ // if the local is defined in an outer class, then it must be final // shared was removed from the language: you cannot access var in a closure - if (!context.isLocal(li.name())) { - // this local is defined in an outer class - if (!li.flags().isFinal() && !X10Flags.toX10Flags(li.flags()).isShared()) { - Errors.issue(tc.job(), new SemanticException("Local variable \"" + li.name() + - "\" is accessed from an inner class or a closure, and must be declared final.", - this.position())); - } - } +// if (!context.isLocal(li.name())) { +// // this local is defined in an outer class +// if (!li.flags().isFinal() && !X10Flags.toX10Flags(li.flags()).isShared()) { +// Errors.issue(tc.job(), new SemanticException("Local variable \"" + li.name() + +// "\" is accessed from an inner class or a closure, and must be declared final.", +// this.position())); +// } +// } X10Local_c result = (X10Local_c) localInstance(li).type(li.type()); Modified: trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java =================================================================== --- trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java 2010-10-06 18:18:07 UTC (rev 17128) +++ trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java 2010-10-06 18:31:29 UTC (rev 17129) @@ -337,6 +337,10 @@ final X10Flags flags = X10Flags.toX10Flags(((ProcedureDef_c)def).flags()); return flags.isProperty(); } + private boolean isPrivate(ProcedureDef def) { + final X10Flags flags = X10Flags.toX10Flags(((ProcedureDef_c)def).flags()); + return flags.isPrivate(); + } private boolean isPrivateOrFinal(ProcedureDef def) { if (isXlassFinal) return true; final X10Flags flags = X10Flags.toX10Flags(((ProcedureDef_c)def).flags()); @@ -775,7 +779,7 @@ if (allMethods.containsKey(pd)) { // we already analyzed this method (or it is an error method) } else { - if (!isNonEscaping) + if (!isNonEscaping && !isXlassFinal && !isPrivate(procDef)) job.compiler().errorQueue().enqueue(ErrorInfo.WARNING,"Method '"+procDef.signature()+"' is called during construction and therefore should be marked as @NonEscaping.", method.position()); final Block body = method.body(); if (body!=null) { Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-06 18:18:07 UTC (rev 17128) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-06 18:31:29 UTC (rev 17129) @@ -626,6 +626,24 @@ } } +class TestNonEscapingWarning { + final class FinalBar { + def this() { + f1(); + f2(); + } + private def f1() {} + final def f2() {} + } + class NonFinalBar { + def this() { + f1(); + f2(); + } + private def f1() {} + final def f2() {} // ERR: (warning) + } +} abstract class SuperClassTest { val a=1; val b=2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-10-06 18:34:22
|
Revision: 17130 http://x10.svn.sourceforge.net/x10/?rev=17130&view=rev Author: dgrove-oss Date: 2010-10-06 18:34:11 +0000 (Wed, 06 Oct 2010) Log Message: ----------- Normalize svn properties. No other changes. Modified Paths: -------------- trunk/x10.compiler/src/polyglot/util/CodedErrorInfo.java trunk/x10.compiler/src/x10/ast/ArrayLiteral.java trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java trunk/x10.compiler/src/x10/ast/Resume.java trunk/x10.compiler/src/x10/ast/Resume_c.java trunk/x10.compiler/src/x10/types/constraints/CTerms.java trunk/x10.compiler/src/x10/util/HierarchyUtils.java trunk/x10.compiler/src/x10/util/synthesizer/AsyncSynth.java trunk/x10.compiler/src/x10c/ast/BackingArrayNewArray.java trunk/x10.compiler/src/x10c/ast/X10CBackingArrayNewArray_c.java trunk/x10.compiler/src/x10c/types/X10CContext_c.java trunk/x10.compiler/src/x10c/visit/AsyncInitializer.java trunk/x10.compiler/src/x10c/visit/ExpressionFlattenerForAtExpr.java trunk/x10.compiler/src/x10c/visit/VarsBoxer.java trunk/x10.doc/src/x10doc/doc/X10ParamTag.java trunk/x10.doc/src/x10doc/doc/X10ThrowsTag.java trunk/x10.runtime/src-java/x10/runtime/impl/java/X10Throwable.java trunk/x10.runtime/src-java/x10/runtime/impl/java/X10WrappedThrowable.java trunk/x10.runtime/src-x10/x10/compiler/Det.x10 trunk/x10.runtime/src-x10/x10/compiler/Global.x10 trunk/x10.runtime/src-x10/x10/compiler/Incomplete.x10 trunk/x10.runtime/src-x10/x10/compiler/Pinned.x10 trunk/x10.runtime/src-x10/x10/compiler/TempNoInline_0.x10 trunk/x10.runtime/src-x10/x10/compiler/TempNoInline_1.x10 trunk/x10.runtime/src-x10/x10/compiler/TempNoInline_2.x10 trunk/x10.runtime/src-x10/x10/compiler/TempNoInline_3.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/AsyncFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/BoxedBoolean.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/FinishFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/Frame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/MainFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/RegularFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/BoxedBoolean.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/RootFinish.x10 trunk/x10.runtime/src-x10/x10/lang/Deque.x10 trunk/x10.runtime/src-x10/x10/lang/GlobalCell.x10 trunk/x10.runtime/src-x10/x10/lang/Latch.x10 trunk/x10.runtime/src-x10/x10/lang/Lock.x10 trunk/x10.runtime/src-x10/x10/lang/Monitor.x10 trunk/x10.runtime/src-x10/x10/lang/Reducible.x10 trunk/x10.runtime/src-x10/x10/lang/Semaphore.x10 trunk/x10.runtime/src-x10/x10/lang/Sequence.x10 trunk/x10.runtime/src-x10/x10/util/Future.x10 trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest.x10 trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1.x10 trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Array/UnboundedPolyRegionSize.x10 trunk/x10.tests/examples/Constructs/Atomic/Atomic1a.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAsyncInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAsyncInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAsyncInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAsyncInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAtEachInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAtEachInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAtEachInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAtEachInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureForceInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureForceInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureForceInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureForceInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureMakeInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureMakeInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureMakeInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureMakeInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoNextInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/NoNextInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoNextInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoNextInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoResumeInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/NoResumeInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoResumeInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoResumeInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoWhenInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/NoWhenInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoWhenInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoWhenInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/OKAtomicInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/OKAtomicInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/OKAtomicInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/OKAtomicInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Call/ConConstructor1Arg.x10 trunk/x10.tests/examples/Constructs/Call/ConConstructor2Arg_2_DYNAMIC_CALLS.x10 trunk/x10.tests/examples/Constructs/Call/ConConstructor2Arg_DYNAMIC_CALLS.x10 trunk/x10.tests/examples/Constructs/Call/ConInstance1Arg.x10 trunk/x10.tests/examples/Constructs/Call/ConInstance2Arg.x10 trunk/x10.tests/examples/Constructs/Call/ConInstance2Arg_2.x10 trunk/x10.tests/examples/Constructs/Call/ConInstanceHere_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Call/ConStatic1Arg.x10 trunk/x10.tests/examples/Constructs/Call/ConStatic2Arg.x10 trunk/x10.tests/examples/Constructs/Call/ConStatic2Arg_2.x10 trunk/x10.tests/examples/Constructs/Call/ConStructInstance1Arg.x10 trunk/x10.tests/examples/Constructs/Call/ConStructInstance2Arg.x10 trunk/x10.tests/examples/Constructs/Call/ConStructInstance2Arg_2.x10 trunk/x10.tests/examples/Constructs/Call/TestInterfaceParam_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Class/InnerClass.x10 trunk/x10.tests/examples/Constructs/Clock/ClockedAsync_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Clock/ClockedFinish.x10 trunk/x10.tests/examples/Constructs/Closures/ClosureCall3.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF1.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF1Generic.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF2.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF2Generic.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF3.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF3Generic.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF3Generic_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF3_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF4_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF5_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/EmptyType_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/NestedExpressions.x10 trunk/x10.tests/examples/Constructs/DepType/NestedExpressions1_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/NestedExpressions1a.x10 trunk/x10.tests/examples/Constructs/DepType/NestedExpressions1b.x10 trunk/x10.tests/examples/Constructs/DepType/NestedExpressions2.x10 trunk/x10.tests/examples/Constructs/DepType/NestedExpressions2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/NestedExpressions3_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Init/InitFieldWithCall.x10 trunk/x10.tests/examples/Constructs/Init/InitFieldWithInstanceClass.x10 trunk/x10.tests/examples/Constructs/Instanceof/NullableObjectToBoxConstrainedType2.x10 trunk/x10.tests/examples/Constructs/Instanceof/NullableObjectToBoxConstrainedType3.x10 trunk/x10.tests/examples/Constructs/Place/AtCheck3a_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Point/ImplicitCastFromArray.x10 trunk/x10.tests/examples/Constructs/Structs/NewForStruct_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Typedefs/RecursiveTypeDefs_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeClosure_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeConstructor.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeConstructor_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeField.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeField_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeMethod.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeMethod1_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeMethod_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeVarField_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeVar_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeVariable.x10 trunk/x10.tests/examples/Constructs/Types/HasType_MustFailCompile.x10 trunk/x10.tests/examples/Misc/RecursiveConstraint.x10 trunk/x10.tests/examples/Misc/RefA.x10 Property Changed: ---------------- trunk/x10.compiler/src/polyglot/types/UpcastTransform.java trunk/x10.compiler/src/polyglot/util/CodedErrorInfo.java trunk/x10.compiler/src/x10/ast/ArrayLiteral.java trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java trunk/x10.compiler/src/x10/ast/Resume.java trunk/x10.compiler/src/x10/ast/Resume_c.java trunk/x10.compiler/src/x10/compiler/ws/WSCodeGenerator.java trunk/x10.compiler/src/x10/compiler/ws/WSTransformState.java trunk/x10.compiler/src/x10/compiler/ws/codegen/AbstractWSClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSAsyncClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSFinishStmtClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSForLoopClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSMainMethodClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSMethodFrameClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSRegularFrameClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSSwitchClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSWhenFrameClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSWhileDoLoopClassGen.java trunk/x10.compiler/src/x10/compiler/ws/util/AddIndirectLocalDeclareVisitor.java trunk/x10.compiler/src/x10/compiler/ws/util/AdvLocalAccessToFieldAccessReplacer.java trunk/x10.compiler/src/x10/compiler/ws/util/ClosureDefReinstantiator.java trunk/x10.compiler/src/x10/compiler/ws/util/CodePatternDetector.java trunk/x10.compiler/src/x10/compiler/ws/util/ILocalToFieldContainerMap.java trunk/x10.compiler/src/x10/compiler/ws/util/LocalAccessToFieldAccessReplacer.java trunk/x10.compiler/src/x10/compiler/ws/util/ReferenceContainer.java trunk/x10.compiler/src/x10/compiler/ws/util/TransCodes.java trunk/x10.compiler/src/x10/compiler/ws/util/Triple.java trunk/x10.compiler/src/x10/compiler/ws/util/WSCallGraph.java trunk/x10.compiler/src/x10/compiler/ws/util/WSCallGraphNode.java trunk/x10.compiler/src/x10/compiler/ws/util/WSCodeGenUtility.java trunk/x10.compiler/src/x10/finish/table/CallTableAtVal.java trunk/x10.compiler/src/x10/finish/table/CallTableKey.java trunk/x10.compiler/src/x10/finish/table/CallTableMethodKey.java trunk/x10.compiler/src/x10/finish/table/CallTableMethodVal.java trunk/x10.compiler/src/x10/finish/table/CallTableScopeKey.java trunk/x10.compiler/src/x10/finish/table/CallTableUtil.java trunk/x10.compiler/src/x10/finish/table/CallTableVal.java trunk/x10.compiler/src/x10/finish/table/HprofParser.java trunk/x10.compiler/src/x10/finish/table/OutputUtil.java trunk/x10.compiler/src/x10/types/constraints/CTerms.java trunk/x10.compiler/src/x10/util/HierarchyUtils.java trunk/x10.compiler/src/x10/util/synthesizer/AsyncSynth.java trunk/x10.compiler/src/x10/visit/ExpressionFlattener.java trunk/x10.compiler/src/x10/visit/FinishAnnotationVisitor.java trunk/x10.compiler/src/x10/visit/FinishAsyncVisitor.java trunk/x10.compiler/src/x10/visit/MainMethodFinder.java trunk/x10.compiler/src/x10c/ast/BackingArrayNewArray.java trunk/x10.compiler/src/x10c/ast/X10CBackingArrayNewArray_c.java trunk/x10.compiler/src/x10c/types/X10CContext_c.java trunk/x10.compiler/src/x10c/visit/AsyncInitializer.java trunk/x10.compiler/src/x10c/visit/ExpressionFlattenerForAtExpr.java trunk/x10.compiler/src/x10c/visit/VarsBoxer.java trunk/x10.compiler/src/x10cpp/postcompiler/FreeBSD_CXXCommandBuilder.java trunk/x10.compiler/src/x10cuda/types/ConstMem.java trunk/x10.doc/src/x10doc/doc/X10ParamTag.java trunk/x10.doc/src/x10doc/doc/X10ThrowsTag.java trunk/x10.runtime/src-cpp/x10/lang/GlobalRef.struct_h trunk/x10.runtime/src-cpp/x10/lang/IBox.struct_h trunk/x10.runtime/src-cpp/x10/lang/PlaceLocalHandle_Impl.struct_h trunk/x10.runtime/src-cpp/x10/lang/Struct.struct_h trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.struct_h trunk/x10.runtime/src-cpp/x10aux/cuda_kernel.h trunk/x10.runtime/src-java/x10/runtime/impl/java/X10Throwable.java trunk/x10.runtime/src-java/x10/runtime/impl/java/X10WrappedThrowable.java trunk/x10.runtime/src-x10/x10/compiler/Det.x10 trunk/x10.runtime/src-x10/x10/compiler/Ephemeral.x10 trunk/x10.runtime/src-x10/x10/compiler/FinishAsync.x10 trunk/x10.runtime/src-x10/x10/compiler/Global.x10 trunk/x10.runtime/src-x10/x10/compiler/Incomplete.x10 trunk/x10.runtime/src-x10/x10/compiler/InlineOnly.x10 trunk/x10.runtime/src-x10/x10/compiler/NoSuperCall.x10 trunk/x10.runtime/src-x10/x10/compiler/Pinned.x10 trunk/x10.runtime/src-x10/x10/compiler/Ref.x10 trunk/x10.runtime/src-x10/x10/compiler/TempNoInline_0.x10 trunk/x10.runtime/src-x10/x10/compiler/TempNoInline_1.x10 trunk/x10.runtime/src-x10/x10/compiler/TempNoInline_2.x10 trunk/x10.runtime/src-x10/x10/compiler/TempNoInline_3.x10 trunk/x10.runtime/src-x10/x10/compiler/Uninitialized.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/AsyncFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/BoxedBoolean.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/FinishFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/Frame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/MainFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/RegularFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/RootFinish.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/RootFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/Stolen.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/Worker.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/AsyncFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/BoxedBoolean.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/FinishFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/Frame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/MainFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/RegularFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/RootFinish.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/RootFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/Stolen.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/Worker.x10 trunk/x10.runtime/src-x10/x10/lang/Deque.x10 trunk/x10.runtime/src-x10/x10/lang/GlobalCell.x10 trunk/x10.runtime/src-x10/x10/lang/Latch.x10 trunk/x10.runtime/src-x10/x10/lang/Lock.x10 trunk/x10.runtime/src-x10/x10/lang/Monitor.x10 trunk/x10.runtime/src-x10/x10/lang/Reducible.x10 trunk/x10.runtime/src-x10/x10/lang/Semaphore.x10 trunk/x10.runtime/src-x10/x10/lang/Sequence.x10 trunk/x10.runtime/src-x10/x10/util/CUDAUtilities.x10 trunk/x10.runtime/src-x10/x10/util/Future.x10 trunk/x10.runtime/src-x10/x10/util/Team.x10 trunk/x10.runtime/x10rt/common/x10rt_emu.cc trunk/x10.runtime/x10rt/common/x10rt_emu_coll.cc trunk/x10.runtime/x10rt/include/x10rt_cpp.h trunk/x10.runtime/x10rt/include/x10rt_ser.h trunk/x10.runtime/x10rt/sockets/Launcher.cc trunk/x10.runtime/x10rt/sockets/Launcher.h trunk/x10.runtime/x10rt/sockets/Launcher_Init.cc trunk/x10.runtime/x10rt/sockets/TCP.h trunk/x10.runtime/x10rt/sockets/tcp.cc trunk/x10.runtime/x10rt/sockets/x10rt_sockets.cc trunk/x10.runtime/x10rt/test/x10rt_coll.cc trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest.x10 trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1.x10 trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Array/UnboundedPolyRegionSize.x10 trunk/x10.tests/examples/Constructs/Atomic/Atomic1a.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAsyncInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAsyncInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAsyncInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAsyncInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAtEachInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAtEachInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAtEachInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoAtEachInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureForceInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureForceInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureForceInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureForceInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureMakeInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureMakeInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureMakeInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureMakeInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoNextInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/NoNextInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoNextInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoNextInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoResumeInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/NoResumeInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoResumeInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoResumeInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoWhenInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/NoWhenInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/NoWhenInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoWhenInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/OKAtomicInAtomic.x10 trunk/x10.tests/examples/Constructs/Atomic/OKAtomicInAtomicMethod.x10 trunk/x10.tests/examples/Constructs/Atomic/OKAtomicInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/OKAtomicInWhenMethod.x10 trunk/x10.tests/examples/Constructs/Call/ConConstructor1Arg.x10 trunk/x10.tests/examples/Constructs/Call/ConConstructor2Arg_2_DYNAMIC_CALLS.x10 trunk/x10.tests/examples/Constructs/Call/ConConstructor2Arg_DYNAMIC_CALLS.x10 trunk/x10.tests/examples/Constructs/Call/ConInstance1Arg.x10 trunk/x10.tests/examples/Constructs/Call/ConInstance2Arg.x10 trunk/x10.tests/examples/Constructs/Call/ConInstance2Arg_2.x10 trunk/x10.tests/examples/Constructs/Call/ConInstanceHere_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Call/ConStatic1Arg.x10 trunk/x10.tests/examples/Constructs/Call/ConStatic2Arg.x10 trunk/x10.tests/examples/Constructs/Call/ConStatic2Arg_2.x10 trunk/x10.tests/examples/Constructs/Call/ConStructInstance1Arg.x10 trunk/x10.tests/examples/Constructs/Call/ConStructInstance2Arg.x10 trunk/x10.tests/examples/Constructs/Call/ConStructInstance2Arg_2.x10 trunk/x10.tests/examples/Constructs/Call/TestInterfaceParam_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeClassTwo.x10 trunk/x10.tests/examples/Constructs/Class/ConstructorsWithInferredTypes.x10 trunk/x10.tests/examples/Constructs/Class/InnerClass.x10 trunk/x10.tests/examples/Constructs/Clock/ClockedAsync_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Clock/ClockedFinish.x10 trunk/x10.tests/examples/Constructs/Closures/ClosureCall3.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF1.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF10.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF1Generic.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF2.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF2Generic.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF3.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF3Generic.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF3Generic_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF3_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF4_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF5_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF6.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF7.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF8.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF9.x10 trunk/x10.tests/examples/Constructs/DepType/EmptyType_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/NestedExpressions.x10 trunk/x10.tests/examples/Constructs/DepType/NestedExpressions1_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/NestedExpressions1a.x10 trunk/x10.tests/examples/Constructs/DepType/NestedExpressions1b.x10 trunk/x10.tests/examples/Constructs/DepType/NestedExpressions2.x10 trunk/x10.tests/examples/Constructs/DepType/NestedExpressions2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/NestedExpressions3_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/ThisInConstructorReturn_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Distribution/BlockDist2.x10 trunk/x10.tests/examples/Constructs/If/DanglingElse.x10 trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10 trunk/x10.tests/examples/Constructs/Init/InitFieldWithCall.x10 trunk/x10.tests/examples/Constructs/Init/InitFieldWithInstanceClass.x10 trunk/x10.tests/examples/Constructs/Instanceof/NullableObjectToBoxConstrainedType2.x10 trunk/x10.tests/examples/Constructs/Instanceof/NullableObjectToBoxConstrainedType3.x10 trunk/x10.tests/examples/Constructs/Interface/InterfaceMethodCollision_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/AtCheck3a_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Point/ImplicitCastFromArray.x10 trunk/x10.tests/examples/Constructs/Rail/RailAlignment.x10 trunk/x10.tests/examples/Constructs/Structs/NewForStruct_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Typedefs/RecursiveTypeDefs_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeClosure_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeConstructor.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeConstructor_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeField.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeField_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeMethod.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeMethod1_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeMethod_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeVarField_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeVar_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeVariable.x10 trunk/x10.tests/examples/Constructs/Types/HasType_MustFailCompile.x10 trunk/x10.tests/examples/Misc/RecursiveConstraint.x10 trunk/x10.tests/examples/Misc/RefA.x10 trunk/x10.tests/tests/ScalableFinish/LocalFinish.x10 trunk/x10.tests/tests/ScalableFinish/ManyLocalFinish1.x10 trunk/x10.tests/tests/ScalableFinish/ManyLocalFinish2.x10 trunk/x10.tests/tests/ScalableFinish/SimpleFinish1.x10 trunk/x10.tests/tests/ScalableFinish/SimpleFinish2.x10 trunk/x10.tests/tests/ScalableFinish/SimpleFinish3.x10 trunk/x10.tests/tests/ScalableFinish/SimpleFinish4.x10 trunk/x10.tests/tests/ScalableFinish/SimpleFinish5.x10 Property changes on: trunk/x10.compiler/src/polyglot/types/UpcastTransform.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.compiler/src/polyglot/util/CodedErrorInfo.java =================================================================== --- trunk/x10.compiler/src/polyglot/util/CodedErrorInfo.java 2010-10-06 18:31:29 UTC (rev 17129) +++ trunk/x10.compiler/src/polyglot/util/CodedErrorInfo.java 2010-10-06 18:34:11 UTC (rev 17130) @@ -1,23 +1,23 @@ -package polyglot.util; - -import java.util.Map; - -public class CodedErrorInfo extends ErrorInfo { - int errorCode; - public static final String ERROR_CODE_KEY= "errorCode"; - Map<String, Object> attributes; - - public CodedErrorInfo(int kind, String message, Position position, - Map<String, Object> attributes) { - super(kind, message, position); - this.attributes = attributes; - } - - public int getErrorCode() { - return (Integer) attributes.get(ERROR_CODE_KEY); - } - - public Map<String, Object> getAttributes() { - return attributes; - } -} +package polyglot.util; + +import java.util.Map; + +public class CodedErrorInfo extends ErrorInfo { + int errorCode; + public static final String ERROR_CODE_KEY= "errorCode"; + Map<String, Object> attributes; + + public CodedErrorInfo(int kind, String message, Position position, + Map<String, Object> attributes) { + super(kind, message, position); + this.attributes = attributes; + } + + public int getErrorCode() { + return (Integer) attributes.get(ERROR_CODE_KEY); + } + + public Map<String, Object> getAttributes() { + return attributes; + } +} Property changes on: trunk/x10.compiler/src/polyglot/util/CodedErrorInfo.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/ast/ArrayLiteral.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ArrayLiteral.java 2010-10-06 18:31:29 UTC (rev 17129) +++ trunk/x10.compiler/src/x10/ast/ArrayLiteral.java 2010-10-06 18:34:11 UTC (rev 17130) @@ -1,16 +1,16 @@ -package x10.ast; - -import polyglot.ast.Expr; -import polyglot.ast.TypeNode; - -/** - * The interface implemented by an array literal. An array literal is simply a tuple with a - * user-specified return type. - * @author vj - * - */ -public interface ArrayLiteral extends Expr { - Tuple_c tuple(); - TypeNode indexType(); - -} +package x10.ast; + +import polyglot.ast.Expr; +import polyglot.ast.TypeNode; + +/** + * The interface implemented by an array literal. An array literal is simply a tuple with a + * user-specified return type. + * @author vj + * + */ +public interface ArrayLiteral extends Expr { + Tuple_c tuple(); + TypeNode indexType(); + +} Property changes on: trunk/x10.compiler/src/x10/ast/ArrayLiteral.java ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java 2010-10-06 18:31:29 UTC (rev 17129) +++ trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java 2010-10-06 18:34:11 UTC (rev 17130) @@ -1,134 +1,134 @@ -/** - * - */ -package x10.ast; - -import java.util.List; - -import polyglot.ast.Expr; -import polyglot.ast.Expr_c; -import polyglot.ast.Node; -import polyglot.ast.Term; -import polyglot.ast.TypeNode; -import polyglot.types.Context; -import polyglot.types.SemanticException; -import polyglot.types.Type; -import polyglot.types.TypeSystem; -import polyglot.util.CodeWriter; -import polyglot.util.Position; -import polyglot.visit.AscriptionVisitor; -import polyglot.visit.CFGBuilder; -import polyglot.visit.ContextVisitor; -import polyglot.visit.NodeVisitor; -import polyglot.visit.PrettyPrinter; -import x10.errors.Errors; -import x10.types.X10Context; -import x10.types.X10ParsedClassType; -import x10.types.X10TypeMixin; -import x10.types.X10TypeSystem; -import x10.types.checker.PlaceChecker; - -/** - * A representation of the syntactic form new Array[T]{ e1,..., en}. - * Each ei must be of type T. The type of this expression is Array[T](0..n-1). - * - * From an implementation point of view, an ArrayLiteral_c is simply a Tuple with - * a user-specified type. It is translated in the Desugarer into a Tuple, to be - * implemented by backends as appropriate. - * @author vj - * - */ -public class ArrayLiteral_c extends Expr_c implements ArrayLiteral { - - TypeNode array; - TypeNode indexType; - Tuple_c tuple; - /** - * @param pos - */ - public ArrayLiteral_c(Position pos, TypeNode array, TypeNode indexType, Tuple_c tuple) { - super(pos); - this.array=array; - this.indexType = indexType; - this.tuple = tuple; - } - - public Tuple_c tuple() { - return tuple; - } - /* (non-Javadoc) - * @see polyglot.ast.Term#firstChild() - */ - public Term firstChild() { - return indexType; - } - - public TypeNode indexType() { - return indexType; - } - - /* (non-Javadoc) - * @see polyglot.ast.Term_c#acceptCFG(polyglot.visit.CFGBuilder, java.util.List) - * Visit this term in evaluation order. - */ - @Override - public <S> List<S> acceptCFG(CFGBuilder v, List<S> succs) { - v.visitCFG(indexType, tuple, ENTRY); - v.visitCFG(tuple, this, EXIT); - return succs; - } - // TODO: Igor suggests hiding the fact that a Tuple is referenced - // and dealing with the tuple elements explicitly in the typechecker code. - public Node visitChildren( NodeVisitor v ) { - TypeNode atn = (TypeNode) visitChild(this.array, v); - TypeNode tn = (TypeNode) visitChild( this.indexType, v ); - Tuple_c t = (Tuple_c) visitChild(this.tuple, v); - if (atn != array || t != tuple || tn != indexType) { - ArrayLiteral_c n = (ArrayLiteral_c) copy(); - n.array = atn; - n.tuple = t; - n.indexType = tn; - return n; - } - return this; - } - public Node typeCheck(ContextVisitor tc) throws SemanticException { - ArrayLiteral_c n = (ArrayLiteral_c) super.typeCheck(tc); - Type type = tuple.type(); - Type iType = indexType.type(); - X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - - String arrayTypeName = array.type().toString(); - if (! (arrayTypeName.equals("x10.array.Array") || arrayTypeName.equals("Array"))) - Errors.issue(tc.job(), - new Errors.ArrayLiteralMustBeOfArrayType(array.type().toString(), n.position())); - - Type aType = X10TypeMixin.typeArg(type,0); - List<Expr> vals = tuple.arguments(); - for (Expr e : vals) { - Type t = e.type(); - if (! ts.isSubtype(t, iType, tc.context())) - Errors.issue(tc.job(), - new Errors.ArrayLiteralTypeMismatch(e, iType)); - } - Type resultType = X10TypeMixin.makeArrayRailOf(iType, n.tuple().arguments().size(), n.position()); - - return n.type(resultType); - } - - public String toString() { - return "new Array[" + indexType + "]{ " + tuple + "}"; - } - - /** Write the expression to an output file. */ - - public void prettyPrint(CodeWriter w, PrettyPrinter tr) { - w.write("new Array["); - printBlock(indexType, w, tr); - w.write("]"); - tuple.prettyPrint(w,tr); - - } - - -} +/** + * + */ +package x10.ast; + +import java.util.List; + +import polyglot.ast.Expr; +import polyglot.ast.Expr_c; +import polyglot.ast.Node; +import polyglot.ast.Term; +import polyglot.ast.TypeNode; +import polyglot.types.Context; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.TypeSystem; +import polyglot.util.CodeWriter; +import polyglot.util.Position; +import polyglot.visit.AscriptionVisitor; +import polyglot.visit.CFGBuilder; +import polyglot.visit.ContextVisitor; +import polyglot.visit.NodeVisitor; +import polyglot.visit.PrettyPrinter; +import x10.errors.Errors; +import x10.types.X10Context; +import x10.types.X10ParsedClassType; +import x10.types.X10TypeMixin; +import x10.types.X10TypeSystem; +import x10.types.checker.PlaceChecker; + +/** + * A representation of the syntactic form new Array[T]{ e1,..., en}. + * Each ei must be of type T. The type of this expression is Array[T](0..n-1). + * + * From an implementation point of view, an ArrayLiteral_c is simply a Tuple with + * a user-specified type. It is translated in the Desugarer into a Tuple, to be + * implemented by backends as appropriate. + * @author vj + * + */ +public class ArrayLiteral_c extends Expr_c implements ArrayLiteral { + + TypeNode array; + TypeNode indexType; + Tuple_c tuple; + /** + * @param pos + */ + public ArrayLiteral_c(Position pos, TypeNode array, TypeNode indexType, Tuple_c tuple) { + super(pos); + this.array=array; + this.indexType = indexType; + this.tuple = tuple; + } + + public Tuple_c tuple() { + return tuple; + } + /* (non-Javadoc) + * @see polyglot.ast.Term#firstChild() + */ + public Term firstChild() { + return indexType; + } + + public TypeNode indexType() { + return indexType; + } + + /* (non-Javadoc) + * @see polyglot.ast.Term_c#acceptCFG(polyglot.visit.CFGBuilder, java.util.List) + * Visit this term in evaluation order. + */ + @Override + public <S> List<S> acceptCFG(CFGBuilder v, List<S> succs) { + v.visitCFG(indexType, tuple, ENTRY); + v.visitCFG(tuple, this, EXIT); + return succs; + } + // TODO: Igor suggests hiding the fact that a Tuple is referenced + // and dealing with the tuple elements explicitly in the typechecker code. + public Node visitChildren( NodeVisitor v ) { + TypeNode atn = (TypeNode) visitChild(this.array, v); + TypeNode tn = (TypeNode) visitChild( this.indexType, v ); + Tuple_c t = (Tuple_c) visitChild(this.tuple, v); + if (atn != array || t != tuple || tn != indexType) { + ArrayLiteral_c n = (ArrayLiteral_c) copy(); + n.array = atn; + n.tuple = t; + n.indexType = tn; + return n; + } + return this; + } + public Node typeCheck(ContextVisitor tc) throws SemanticException { + ArrayLiteral_c n = (ArrayLiteral_c) super.typeCheck(tc); + Type type = tuple.type(); + Type iType = indexType.type(); + X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); + + String arrayTypeName = array.type().toString(); + if (! (arrayTypeName.equals("x10.array.Array") || arrayTypeName.equals("Array"))) + Errors.issue(tc.job(), + new Errors.ArrayLiteralMustBeOfArrayType(array.type().toString(), n.position())); + + Type aType = X10TypeMixin.typeArg(type,0); + List<Expr> vals = tuple.arguments(); + for (Expr e : vals) { + Type t = e.type(); + if (! ts.isSubtype(t, iType, tc.context())) + Errors.issue(tc.job(), + new Errors.ArrayLiteralTypeMismatch(e, iType)); + } + Type resultType = X10TypeMixin.makeArrayRailOf(iType, n.tuple().arguments().size(), n.position()); + + return n.type(resultType); + } + + public String toString() { + return "new Array[" + indexType + "]{ " + tuple + "}"; + } + + /** Write the expression to an output file. */ + + public void prettyPrint(CodeWriter w, PrettyPrinter tr) { + w.write("new Array["); + printBlock(indexType, w, tr); + w.write("]"); + tuple.prettyPrint(w,tr); + + } + + +} Property changes on: trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/ast/Resume.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Resume.java 2010-10-06 18:31:29 UTC (rev 17129) +++ trunk/x10.compiler/src/x10/ast/Resume.java 2010-10-06 18:34:11 UTC (rev 17130) @@ -1,22 +1,22 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -package x10.ast; - -import polyglot.ast.Stmt; - -/** The node constructed for the X10 construct resume; - * @author vj - */ -public interface Resume extends Stmt -{ - -} +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +package x10.ast; + +import polyglot.ast.Stmt; + +/** The node constructed for the X10 construct resume; + * @author vj + */ +public interface Resume extends Stmt +{ + +} Property changes on: trunk/x10.compiler/src/x10/ast/Resume.java ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/ast/Resume_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Resume_c.java 2010-10-06 18:31:29 UTC (rev 17129) +++ trunk/x10.compiler/src/x10/ast/Resume_c.java 2010-10-06 18:34:11 UTC (rev 17130) @@ -1,39 +1,39 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -package x10.ast; - -import java.util.List; - -import polyglot.ast.Node; -import polyglot.ast.Term; -import polyglot.ast.Stmt_c; -import polyglot.types.SemanticException; -import polyglot.types.TypeSystem; -import polyglot.util.Position; -import polyglot.visit.CFGBuilder; -import polyglot.visit.ContextVisitor; -import x10.types.X10Context; - -public class Resume_c extends Stmt_c implements Resume { - - public Resume_c(Position p) { - super(p); - } - - public Term firstChild() { - return null; - } - - public <S> List<S> acceptCFG(CFGBuilder v, List<S> succs) { - return succs; - } -} +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +package x10.ast; + +import java.util.List; + +import polyglot.ast.Node; +import polyglot.ast.Term; +import polyglot.ast.Stmt_c; +import polyglot.types.SemanticException; +import polyglot.types.TypeSystem; +import polyglot.util.Position; +import polyglot.visit.CFGBuilder; +import polyglot.visit.ContextVisitor; +import x10.types.X10Context; + +public class Resume_c extends Stmt_c implements Resume { + + public Resume_c(Position p) { + super(p); + } + + public Term firstChild() { + return null; + } + + public <S> List<S> acceptCFG(CFGBuilder v, List<S> succs) { + return succs; + } +} Property changes on: trunk/x10.compiler/src/x10/ast/Resume_c.java ___________________________________________________________________ Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/WSCodeGenerator.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/WSTransformState.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/codegen/AbstractWSClassGen.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/codegen/WSAsyncClassGen.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/codegen/WSFinishStmtClassGen.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/codegen/WSForLoopClassGen.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/codegen/WSMainMethodClassGen.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/codegen/WSMethodFrameClassGen.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/codegen/WSRegularFrameClassGen.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/codegen/WSSwitchClassGen.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/codegen/WSWhenFrameClassGen.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/codegen/WSWhileDoLoopClassGen.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/util/AddIndirectLocalDeclareVisitor.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/util/AdvLocalAccessToFieldAccessReplacer.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/util/ClosureDefReinstantiator.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/util/CodePatternDetector.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/util/ILocalToFieldContainerMap.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/util/LocalAccessToFieldAccessReplacer.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/util/ReferenceContainer.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/util/TransCodes.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/util/Triple.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/util/WSCallGraph.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/util/WSCallGraphNode.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/compiler/ws/util/WSCodeGenUtility.java ___________________________________________________________________ Deleted: svn:executable - * Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/finish/table/CallTableAtVal.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/finish/table/CallTableKey.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/finish/table/CallTableMethodKey.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/finish/table/CallTableMethodVal.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/finish/table/CallTableScopeKey.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/finish/table/CallTableUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/finish/table/CallTableVal.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/finish/table/HprofParser.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Property changes on: trunk/x10.compiler/src/x10/finish/table/OutputUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/types/constraints/CTerms.java =================================================================== --- trunk/x10.compiler/src/x10/types/constraints/CTerms.java 2010-10-06 18:31:29 UTC (rev 17129) +++ trunk/x10.compiler/src/x10/types/constraints/CTerms.java 2010-10-06 18:34:11 UTC (rev 17130) @@ -1,19 +1,19 @@ -package x10.types.constraints; - -import x10.constraint.XField; -import x10.constraint.XName; -import x10.constraint.XVar; - -public class CTerms { - - - /** - * Make and return <code>receiver.field</code>. - * @param receiver - * @param field - * @return - */ - public static final XField makeField(XVar receiver, XName field) { - return new XField(receiver, field); - } -} +package x10.types.constraints; + +import x10.constraint.XField; +import x10.constraint.XName; +import x10.constraint.XVar; + +public class CTerms { + + + /** + * Make and return <code>receiver.field</code>. + * @param receiver + * @param field + * @return + */ + public static final XField makeField(XVar receiver, XName field) { + return new XField(receiver, field); + } +} Property changes on: trunk/x10.compiler/src/x10/types/constraints/CTerms.java ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/util/HierarchyUtils.java =================================================================== --- trunk/x10.compiler/src/x10/util/HierarchyUtils.java 2010-10-06 18:31:29 UTC (rev 17129) +++ trunk/x10.compiler/src/x10/util/HierarchyUtils.java 2010-10-06 18:34:11 UTC (rev 17130) @@ -1,107 +1,107 @@ -package x10.util; - -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.Set; - -import polyglot.types.ClassType; -import polyglot.types.Flags; -import polyglot.types.MethodInstance; -import polyglot.types.Type; - -public class HierarchyUtils { - - public static Set<ClassType> getSuperTypes(ClassType startingClass) - { - Set<ClassType> superTypes = new LinkedHashSet<ClassType>(); - ClassType previousType = startingClass; - ClassType superType = (ClassType)startingClass.superClass(); - - while(superType != null) - { - superTypes.add(superType); - addInterfaces(previousType, superTypes); - previousType = superType; - superType = (ClassType)superType.superClass(); - } - - addInterfaces(previousType, superTypes); - - return superTypes; - } - - public static Set<ClassType> getSuperClasses(ClassType startingClass) - { - Set<ClassType> superTypes = new HashSet<ClassType>(); - ClassType superType = (ClassType)startingClass.superClass(); - - while(superType != null) - { - superTypes.add(superType); - superType = (ClassType)superType.superClass(); - } - - return superTypes; - } - - private static void addInterfaces(ClassType startingClass, Set<ClassType> interfaces) - { - for(Type type : startingClass.interfaces()) - { - interfaces.add((ClassType)type); - addInterfaces((ClassType)type, interfaces); - } - } - - public static Set<ClassType> getInterfaces(Set<ClassType> classes) - { - Set<ClassType> interfaces = new HashSet<ClassType>(); - for(ClassType ct : classes) - { - addInterfaces(ct, interfaces); - } - - return interfaces; - } - - public static Set<MethodInstance> getMethods(Set<ClassType> classes) - { - return getMethods(classes, Flags.NONE); - } - - public static Set<MethodInstance> getMethods(Set<ClassType> classes, Flags flags) - { - Set<MethodInstance> methods = new HashSet<MethodInstance>(); - for(ClassType ct : classes) - { - for(MethodInstance mi : ct.methods()) - { - if(mi.flags().contains(flags)) - { - methods.add(mi); - } - } - } - - return methods; - } - - public static Set<MethodInstance> getImplementedMethods(Set<ClassType> classes) - { - Set<MethodInstance> methods = new HashSet<MethodInstance>(); - for(ClassType ct : classes) - { - for(MethodInstance mi : ct.methods()) - { - if(!mi.flags().isAbstract()) - { - methods.add(mi); - } - } - } - - return methods; - } - - -} +package x10.util; + +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.Set; + +import polyglot.types.ClassType; +import polyglot.types.Flags; +import polyglot.types.MethodInstance; +import polyglot.types.Type; + +public class HierarchyUtils { + + public static Set<ClassType> getSuperTypes(ClassType startingClass) + { + Set<ClassType> superTypes = new LinkedHashSet<ClassType>(); + ClassType previousType = startingClass; + ClassType superType = (ClassType)startingClass.superClass(); + + while(superType != null) + { + superTypes.add(superType); + addInterfaces(previousType, superTypes); + previousType = superType; + superType = (ClassType)superType.superClass(); + } + + addInterfaces(previousType, superTypes); + + return superTypes; + } + + public static Set<ClassType> getSuperClasses(ClassType startingClass) + { + Set<ClassType> superTypes = new HashSet<ClassType>(); + ClassType superType = (ClassType)startingClass.superClass(); + + while(superType != null) + { + superTypes.add(superType); + superType = (ClassType)superType.superClass(); + } + + return superTypes; + } + + private static void addInterfaces(ClassType startingClass, Set<ClassType> interfaces) + { + for(Type type : startingClass.interfaces()) + { + interfaces.add((ClassType)type); + addInterfaces((ClassType)type, interfaces); + } + } + + public static Set<ClassType> getInterfaces(Set<ClassType> classes) + { + Set<ClassType> interfaces = new HashSet<ClassType>(); + for(ClassType ct : classes) + { + addInterfaces(ct, interfaces); + } + + return interfaces; + } + + public static Set<MethodInstance> getMethods(Set<ClassType> classes) + { + return getMethods(classes, Flags.NONE); + } + + public static Set<MethodInstance> getMethods(Set<ClassType> classes, Flags flags) + { + Set<MethodInstance> methods = new HashSet<MethodInstance>(); + for(ClassType ct : classes) + { + for(MethodInstance mi : ct.methods()) + { + if(mi.flags().contains(flags)) + { + methods.add(mi); + } + } + } + + return methods; + } + + public static Set<MethodInstance> getImplementedMethods(Set<ClassType> classes) + { + Set<MethodInstance> methods = new HashSet<MethodInstance>(); + for(ClassType ct : classes) + { + for(MethodInstance mi : ct.methods()) + { + if(!mi.flags().isAbstract()) + { + methods.add(mi); + } + } + } + + return methods; + } + + +} Property changes on: trunk/x10.compiler/src/x10/util/HierarchyUtils.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.compiler/src/x10/util/synthesizer/AsyncSynth.java =================================================================== --- trunk/x10.compiler/src/x10/util/synthesizer/AsyncSynth.java 2010-10-06 18:31:29 UTC (rev 17129) +++ trunk/x10.compiler/src/x10/util/synthesizer/AsyncSynth.java 2010-10-06 18:34:11 UTC (rev 17130) @@ -1,98 +1,98 @@ -package x10.util.synthesizer; - -import java.util.ArrayList; -import java.util.List; - -import polyglot.ast.Expr; -import polyglot.ast.Stmt; -import polyglot.types.Name; -import polyglot.types.SemanticException; -import polyglot.types.Type; -import polyglot.util.Position; -import x10.ast.Closure; -import x10.ast.Tuple; -import x10.ast.X10NodeFactory; -import x10.types.X10Context; - -/** - * Some codes based on desugar - */ -public class AsyncSynth extends AbstractStateSynth implements IStmtSynth { - - Stmt body; - List<Expr> clocks; - Expr place; - - public AsyncSynth(X10NodeFactory xnf, X10Context xct, Position pos, - Stmt body, List<Expr> clocks, Expr place) { - super(xnf, xct, pos); - this.body = body; - this.clocks = clocks; - this.place = place; - } - - public AsyncSynth(X10NodeFactory xnf, X10Context xct, Position pos, - Stmt body, Expr place) { - super(xnf, xct, pos); - this.body = body; - this.clocks = new ArrayList<Expr>(); - this.place = place; - } - - public AsyncSynth(X10NodeFactory xnf, X10Context xct, Position pos, - Stmt body, List<Expr> clocks) { - super(xnf, xct, pos); - this.body = body; - this.clocks = clocks; - } - - public AsyncSynth(X10NodeFactory xnf, X10Context xct, Position pos, - Stmt body) { - super(xnf, xct, pos); - this.body = body; - this.clocks = new ArrayList<Expr>(); - } - - - public Stmt genStmt() throws SemanticException { - - //different situations - List<Expr> exprs = new ArrayList<Expr>(); - List<Type> types = new ArrayList<Type>(); - - - if(place == null){ - if(clocks.size() > 0){ - Type clockRailType = xts.ValRail(xts.Clock()); - Tuple clockRail = (Tuple) xnf.Tuple(pos, clocks).type(clockRailType); - exprs.add(clockRail); - types.add(clockRailType); - } - } - else{ //place != null; - //process places - if (xts.isImplicitCastValid(place.type(), xts.Object(), xct)) { - place = synth.makeFieldAccess(pos,place, xts.homeName(), xct); - } - exprs.add(place); - types.add(xts.Place()); - - if(clocks.size() > 0){ - Type clockRailType = xts.ValRail(xts.Clock()); - Tuple clockRail = (Tuple) xnf.Tuple(pos, clocks).type(clockRailType); - exprs.add(clockRail); - types.add(clockRailType); - } - } - - System.out.println(xct.currentCode()); - Closure closure = synth.makeClosure(body.position(), xts.Void(), synth.toBlock(body), xct); - exprs.add(closure); - types.add(closure.closureDef().asType()); - Stmt result = xnf.Eval(pos, synth.makeStaticCall(pos, xts.Runtime(), Name.make("runAsync"), exprs, xts.Void(), - types, xct)); - - return result; - } - -} +package x10.util.synthesizer; + +import java.util.ArrayList; +import java.util.List; + +import polyglot.ast.Expr; +import polyglot.ast.Stmt; +import polyglot.types.Name; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.util.Position; +import x10.ast.Closure; +import x10.ast.Tuple; +import x10.ast.X10NodeFactory; +import x10.types.X10Context; + +/** + * Some codes based on desugar + */ +public class AsyncSynth extends AbstractStateSynth implements IStmtSynth { + + Stmt body; + List<Expr> clocks; + Expr place; + + public AsyncSynth(X10NodeFactory xnf, X10Context xct, Position pos, + Stmt body, List<Expr> clocks, Expr place) { + super(xnf, xct, pos); + this.body = body; + this.clocks = clocks; + this.place = place; + } + + public AsyncSynth(X10NodeFactory xnf, X10Context xct, Position pos, + Stmt body, Expr place) { + super(x... [truncated message content] |
From: <yz...@us...> - 2010-10-06 19:46:15
|
Revision: 17137 http://x10.svn.sourceforge.net/x10/?rev=17137&view=rev Author: yzibin Date: 2010-10-06 19:46:08 +0000 (Wed, 06 Oct 2010) Log Message: ----------- really fixed XTENLANG-1888 (before I forgot that an Async is translated to a dummy-closure) Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10Local_c.java trunk/x10.compiler/src/x10/ast/X10Return_c.java trunk/x10.compiler/src/x10/types/X10Context_c.java trunk/x10.tests/examples/Constructs/Closures/ClosureEnclosingScope1s.x10 trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 Modified: trunk/x10.compiler/src/x10/ast/X10Local_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-10-06 19:39:32 UTC (rev 17136) +++ trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-10-06 19:46:08 UTC (rev 17137) @@ -50,6 +50,7 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; +import x10.types.X10Context_c; import x10.types.checker.PlaceChecker; import x10.types.constraints.CConstraint; import x10.types.constraints.CConstraint; @@ -61,7 +62,7 @@ } public Node typeCheck(ContextVisitor tc) { - X10Context context = (X10Context) tc.context(); + X10Context_c context = (X10Context_c) tc.context(); LocalInstance li = localInstance(); if (!((X10LocalInstance) li).isValid()) { li = findAppropriateLocal(tc, name.id()); @@ -69,14 +70,14 @@ // if the local is defined in an outer class, then it must be final // shared was removed from the language: you cannot access var in a closure -// if (!context.isLocal(li.name())) { -// // this local is defined in an outer class -// if (!li.flags().isFinal() && !X10Flags.toX10Flags(li.flags()).isShared()) { -// Errors.issue(tc.job(), new SemanticException("Local variable \"" + li.name() + -// "\" is accessed from an inner class or a closure, and must be declared final.", -// this.position())); -// } -// } + if (!context.isLocalIncludingAsync(li.name())) { + // this local is defined in an outer class + if (!li.flags().isFinal() && !X10Flags.toX10Flags(li.flags()).isShared()) { + Errors.issue(tc.job(), new SemanticException("Local variable \"" + li.name() + + "\" is accessed from an inner class or a closure, and must be declared final.", + this.position())); + } + } X10Local_c result = (X10Local_c) localInstance(li).type(li.type()); Modified: trunk/x10.compiler/src/x10/ast/X10Return_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Return_c.java 2010-10-06 19:39:32 UTC (rev 17136) +++ trunk/x10.compiler/src/x10/ast/X10Return_c.java 2010-10-06 19:46:08 UTC (rev 17137) @@ -95,6 +95,12 @@ return removeLocals((X10Context) ctx.pop(), c, thisCode); } + public static boolean isAsyncCode(CodeDef ci) { + return (ci != null) + && (ci instanceof MethodDef) + && ((MethodDef) ci).name().toString().equals(X10TypeSystem_c.DUMMY_ASYNC); + } + @Override public Node typeCheck(ContextVisitor tc) { X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); @@ -102,9 +108,7 @@ CodeDef ci = c.currentCode(); - if ((ci != null) - && (ci instanceof MethodDef) - && ((MethodDef) ci).name().toString().equals(X10TypeSystem_c.DUMMY_ASYNC)) { + if (isAsyncCode(ci)) { Errors.issue(tc.job(), new SemanticException("Cannot return from an async."), this); return this; } Modified: trunk/x10.compiler/src/x10/types/X10Context_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10Context_c.java 2010-10-06 19:39:32 UTC (rev 17136) +++ trunk/x10.compiler/src/x10/types/X10Context_c.java 2010-10-06 19:46:08 UTC (rev 17137) @@ -96,6 +96,7 @@ import x10.types.constraints.CConstraint; import x10.types.constraints.TypeConstraint; import x10.types.constraints.XConstrainedTerm; +import x10.ast.X10Return_c; public class X10Context_c extends Context_c implements X10Context { @@ -389,6 +390,11 @@ public boolean isLocal(Name name) { return depType == null ? super.isLocal(name) : pop().isLocal(name); } + public boolean isLocalIncludingAsync(Name name) { + if (isLocal(name)) return true; + if (outer!=null && X10Return_c.isAsyncCode(currentCode())) return ((X10Context_c)outer).isLocalIncludingAsync(name); + return false; + } public boolean isValInScopeInClass(Name name) { Modified: trunk/x10.tests/examples/Constructs/Closures/ClosureEnclosingScope1s.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Closures/ClosureEnclosingScope1s.x10 2010-10-06 19:39:32 UTC (rev 17136) +++ trunk/x10.tests/examples/Constructs/Closures/ClosureEnclosingScope1s.x10 2010-10-06 19:46:08 UTC (rev 17137) @@ -14,8 +14,8 @@ /** * The body s in a function (x1: T1, . . ., xn: Tn) => { s } may access - * fields of enclosing classes and local variable declared in an outer - * scope. + * fields of enclosing classes and FINAL local variable declared in an outer + * scope (and of course var/val fields of the outer instances). * * @author bdlucas 8/2008 */ @@ -26,7 +26,7 @@ public def run(): boolean = { - var b:int = 1; + val b:int = 1; class C { val c = 1; Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-06 19:39:32 UTC (rev 17136) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-06 19:46:08 UTC (rev 17137) @@ -1044,6 +1044,8 @@ // generic parameter test var f2:T; // ERR + // includes: Int, Long, ULong, UInt, Float, Double, Boolean, Char + // excludes: Short,UShort,Byte,UByte // primitive private struct tests (when we'll add literals for Short,UShort,Byte,UByte, I should add more tests) var i1:Int; var i2:Int{self==0}; @@ -1074,7 +1076,7 @@ var ch1:Char; var ch2:Char{self=='\0'}; var ch3:Char{self!='\0'}; // ERR - // todo: do tests for Char, Byte, UByte, Short, UShort + // todo: do tests for Byte, UByte, Short, UShort // references (with or without null) var r0:Array[Int{self!=0}]; @@ -1346,10 +1348,10 @@ class Possel811 { //XTENLANG-811 interface I { - def i():void; // ERR: <anonymous class> should be declared abstract; it does not define i(): x10.lang.Void, which is declared in Possel811.I + def i():void; } def test() { - new I(){}; + new I(){}; // ERR: <anonymous class> should be declared abstract; it does not define i(): x10.lang.Void, which is declared in Possel811.I } } @@ -1357,7 +1359,7 @@ val x:Int = 1; var y:Int = 1; - public def run() = { + public def run() { val a:Int = 1; var b:Int = 1; @@ -1369,4 +1371,67 @@ a+ b; // ERR: Local variable "b" is accessed from an inner class or a closure, and must be declared final. } + + static def use(i:Any) {} + def test2() { + var q:Int = 1; + finish async q=2; + use(() => { + use(q); // ERR: Local variable "q" is accessed from an inner class or a closure, and must be declared final. + }); + use(() => { async + use(q); // ERR: Local variable "q" is accessed from an inner class or a closure, and must be declared final. + }); + use(() => { finish async async + use(q); // ERR: Local variable "q" is accessed from an inner class or a closure, and must be declared final. + }); + + use(() => { var q:Int = 1; + use(q); + }); + use(() => { var q:Int = 1; async + use(q); + }); + use(() => { finish async { var q:Int = 1; async + use(q); + }}); + use(() => { finish { var q:Int = 1; async { async + use(q); + }}}); + use(() => { finish { async { async {var q:Int = 1; + use(q); + }}}}); + use(() => { finish { async { async { + use(q); // ERR: Local variable "q" is accessed from an inner class or a closure, and must be declared final. + var q:Int = 1; + }}}}); + val w = q; + } +} +class TestVarAccessInClosures { + val a1:int = 1; + var a2:int = 1; + public def run() { + + val b1:int = 1; + var b2:int = 1; + + class C { + val c1:int = 1; + var c2:int = 1; + def foo() = { + val fun = () => { + val d1:int = 1; + var d2:int = 1; + (() => a1+b1+c1+d1+ + a2+ + b2+ // ERR: Local variable "b2" is accessed from an inner class or a closure, and must be declared final. + c2+ + d2 // ERR: Local variable "d2" is accessed from an inner class or a closure, and must be declared final. + )() + }; + fun() + } + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-10-06 21:44:28
|
Revision: 17146 http://x10.svn.sourceforge.net/x10/?rev=17146&view=rev Author: yzibin Date: 2010-10-06 21:44:20 +0000 (Wed, 06 Oct 2010) Log Message: ----------- Fixed XTENLANG-1884 (it exposed other errors in "ateach" and in the place term of LocalDef) Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/Here_c.java trunk/x10.compiler/src/x10/ast/X10Local_c.java trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 Modified: trunk/x10.compiler/src/x10/ast/Here_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Here_c.java 2010-10-06 20:39:43 UTC (rev 17145) +++ trunk/x10.compiler/src/x10/ast/Here_c.java 2010-10-06 21:44:20 UTC (rev 17146) @@ -82,7 +82,7 @@ if (h != null) { CConstraint cc = new CConstraint(); try { - cc.addSelfBinding(xc.currentPlaceTerm()); + cc.addSelfBinding(h); } catch (XFailure e) { throw new SemanticException("Constraint on here is inconsistent; " + e.getMessage(), position()); Modified: trunk/x10.compiler/src/x10/ast/X10Local_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-10-06 20:39:43 UTC (rev 17145) +++ trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-10-06 21:44:20 UTC (rev 17146) @@ -41,6 +41,7 @@ import x10.constraint.XLocal; import x10.constraint.XTerm; import x10.constraint.XVar; +import x10.constraint.XConstraint; import x10.errors.Errors; import x10.types.X10Context; import x10.types.X10FieldInstance; @@ -51,9 +52,11 @@ import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; import x10.types.X10Context_c; +import x10.types.X10LocalDef_c; import x10.types.checker.PlaceChecker; import x10.types.constraints.CConstraint; import x10.types.constraints.CConstraint; +import x10.types.constraints.XConstrainedTerm; public class X10Local_c extends Local_c { @@ -68,19 +71,44 @@ li = findAppropriateLocal(tc, name.id()); } - // if the local is defined in an outer class, then it must be final - // shared was removed from the language: you cannot access var in a closure - if (!context.isLocalIncludingAsync(li.name())) { - // this local is defined in an outer class - if (!li.flags().isFinal() && !X10Flags.toX10Flags(li.flags()).isShared()) { - Errors.issue(tc.job(), new SemanticException("Local variable \"" + li.name() + - "\" is accessed from an inner class or a closure, and must be declared final.", - this.position())); + if (!li.flags().isFinal() && !X10Flags.toX10Flags(li.flags()).isShared()) { + // if the local is defined in an outer class, then it must be final + // shared was removed from the language: you cannot access var in a closure + // Note that an async is similar to a closure (we create a dummy closure) + if (!context.isLocalIncludingAsync(li.name())) { + // this local is defined in an outer class + Errors.issue(tc.job(), new SemanticException("Local variable \"" + li.name() +"\" is accessed from an inner class or a closure, and must be declared final.",this.position())); } - } - X10Local_c result = (X10Local_c) localInstance(li).type(li.type()); + // we check that usages inside an "at" are at the origin place if it is a "var" (for "val" we're fine) + final X10LocalDef_c localDef_c = (X10LocalDef_c) li.def(); + XTerm origin = localDef_c.placeTerm(); + // todo: weird bug where origin was null for: + //C:\cygwin\home\Yoav\intellij\sourceforge\x10.runtime\src-x10\x10\compiler\ws\Worker.x10:86,18-22 + //Message: Semantic Error: Local variable "frame" is accessed at a different place, and must be declared final. + if (origin!=null) { // origin = PlaceChecker.here(); + final XConstrainedTerm placeTerm = context.currentPlaceTerm(); + final XTerm currentPlace = placeTerm.term(); + XConstraint constraint = new XConstraint(); + boolean isOk = false; + try { + constraint.addBinding(origin,currentPlace); + if (placeTerm.constraint().entails(constraint)) { + //ok origin == currentPlace + isOk = true; + } + } catch (XFailure xFailure) { + // how can it happen? in any case, we should report an error so isOk=false + } + if (!isOk) + Errors.issue(tc.job(), new SemanticException("Local variable \"" + li.name() +"\" is accessed at a different place, and must be declared final.",this.position())); + } + } + + + X10Local_c result = (X10Local_c) localInstance(li).type(li.type()); + try { VarDef dli = context.varWhoseTypeIsBeingElaborated(); if (context.inDepType()) { Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-06 20:39:43 UTC (rev 17145) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-06 21:44:20 UTC (rev 17146) @@ -1434,4 +1434,82 @@ } } } +} + + +class TestOnlyLocalVarAccess { + // for some reason, the origin of "frame" is null. I couldn't reproduce it... + //C:\cygwin\home\Yoav\intellij\sourceforge\x10.runtime\src-x10\x10\compiler\ws\Worker.x10:86,18-22 + //Message: Semantic Error: Local variable "frame" is accessed at a different place, and must be declared final. + var i:Int; + static def test0(var b:TestOnlyLocalVarAccess) { + b.i++; + } + + static def test0() { + var x:Int = 0; + at (here) x=20; + x=10; + at (here.next()) + x=1; // ERR: Local variable "x" is accessed at a different place, and must be declared final. + val place1 = here; + val place2 = place1; + at (here.next()) { + x=2; // ERR: Local variable "x" is accessed at a different place, and must be declared final. + at (place1) + x=3; + at (place2) + x=4; + at (place1) at (place2) + x=5; + } + Console.OUT.println(x); + } + def test1() { + var x:Int = 0; + at (here) x=20; + x=10; + at (here.next()) + x=1; // ERR: Local variable "x" is accessed at a different place, and must be declared final. + val place1 = here; + val place2 = place1; + at (here.next()) { + x=2; // ERR: Local variable "x" is accessed at a different place, and must be declared final. + at (place1) + x=3; + at (place2) + x=4; + at (place1) at (place2) + x=5; + } + Console.OUT.println(x); + } + def test2(var x:Int) { + at (here) x=20; + x=10; + at (here.next()) + x=1; // ERR: Local variable "x" is accessed at a different place, and must be declared final. + val place1 = here; + val place2 = place1; + at (here.next()) { + x=2; // ERR: Local variable "x" is accessed at a different place, and must be declared final. + at (place1) + x=3; + at (place2) + x=4; + at (place1) at (place2) + x=5; + } + Console.OUT.println(x); + } + + def test3(a: DistArray[double](1)) { + var n: int = 1; + at (here) n=2; + finish ateach ([i] in a.dist | + (0..n)) { // todo ERR: it shouldn't give an error! + n++; // ERR: Local variable "n" is accessed at a different place, and must be declared final. + } + } + } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-10-07 19:02:41
|
Revision: 17168 http://x10.svn.sourceforge.net/x10/?rev=17168&view=rev Author: yzibin Date: 2010-10-07 19:02:34 +0000 (Thu, 07 Oct 2010) Log Message: ----------- removed ArrayLiteral Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/Tuple_c.java trunk/x10.compiler/src/x10/ast/X10NodeFactory.java trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java trunk/x10.compiler/src/x10/parser/X10Parser.java trunk/x10.compiler/src/x10/parser/x10.g trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.compiler/src/x10/visit/ExpressionFlattener.java trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 Removed Paths: ------------- trunk/x10.compiler/src/x10/ast/ArrayLiteral.java trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java Deleted: trunk/x10.compiler/src/x10/ast/ArrayLiteral.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ArrayLiteral.java 2010-10-07 18:58:28 UTC (rev 17167) +++ trunk/x10.compiler/src/x10/ast/ArrayLiteral.java 2010-10-07 19:02:34 UTC (rev 17168) @@ -1,16 +0,0 @@ -package x10.ast; - -import polyglot.ast.Expr; -import polyglot.ast.TypeNode; - -/** - * The interface implemented by an array literal. An array literal is simply a tuple with a - * user-specified return type. - * @author vj - * - */ -public interface ArrayLiteral extends Expr { - Tuple_c tuple(); - TypeNode indexType(); - -} Deleted: trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java 2010-10-07 18:58:28 UTC (rev 17167) +++ trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java 2010-10-07 19:02:34 UTC (rev 17168) @@ -1,134 +0,0 @@ -/** - * - */ -package x10.ast; - -import java.util.List; - -import polyglot.ast.Expr; -import polyglot.ast.Expr_c; -import polyglot.ast.Node; -import polyglot.ast.Term; -import polyglot.ast.TypeNode; -import polyglot.types.Context; -import polyglot.types.SemanticException; -import polyglot.types.Type; -import polyglot.types.TypeSystem; -import polyglot.util.CodeWriter; -import polyglot.util.Position; -import polyglot.visit.AscriptionVisitor; -import polyglot.visit.CFGBuilder; -import polyglot.visit.ContextVisitor; -import polyglot.visit.NodeVisitor; -import polyglot.visit.PrettyPrinter; -import x10.errors.Errors; -import x10.types.X10Context; -import x10.types.X10ParsedClassType; -import x10.types.X10TypeMixin; -import x10.types.X10TypeSystem; -import x10.types.checker.PlaceChecker; - -/** - * A representation of the syntactic form new Array[T]{ e1,..., en}. - * Each ei must be of type T. The type of this expression is Array[T](0..n-1). - * - * From an implementation point of view, an ArrayLiteral_c is simply a Tuple with - * a user-specified type. It is translated in the Desugarer into a Tuple, to be - * implemented by backends as appropriate. - * @author vj - * - */ -public class ArrayLiteral_c extends Expr_c implements ArrayLiteral { - - TypeNode array; - TypeNode indexType; - Tuple_c tuple; - /** - * @param pos - */ - public ArrayLiteral_c(Position pos, TypeNode array, TypeNode indexType, Tuple_c tuple) { - super(pos); - this.array=array; - this.indexType = indexType; - this.tuple = tuple; - } - - public Tuple_c tuple() { - return tuple; - } - /* (non-Javadoc) - * @see polyglot.ast.Term#firstChild() - */ - public Term firstChild() { - return indexType; - } - - public TypeNode indexType() { - return indexType; - } - - /* (non-Javadoc) - * @see polyglot.ast.Term_c#acceptCFG(polyglot.visit.CFGBuilder, java.util.List) - * Visit this term in evaluation order. - */ - @Override - public <S> List<S> acceptCFG(CFGBuilder v, List<S> succs) { - v.visitCFG(indexType, tuple, ENTRY); - v.visitCFG(tuple, this, EXIT); - return succs; - } - // TODO: Igor suggests hiding the fact that a Tuple is referenced - // and dealing with the tuple elements explicitly in the typechecker code. - public Node visitChildren( NodeVisitor v ) { - TypeNode atn = (TypeNode) visitChild(this.array, v); - TypeNode tn = (TypeNode) visitChild( this.indexType, v ); - Tuple_c t = (Tuple_c) visitChild(this.tuple, v); - if (atn != array || t != tuple || tn != indexType) { - ArrayLiteral_c n = (ArrayLiteral_c) copy(); - n.array = atn; - n.tuple = t; - n.indexType = tn; - return n; - } - return this; - } - public Node typeCheck(ContextVisitor tc) throws SemanticException { - ArrayLiteral_c n = (ArrayLiteral_c) super.typeCheck(tc); - Type type = tuple.type(); - Type iType = indexType.type(); - X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); - - String arrayTypeName = array.type().toString(); - if (! (arrayTypeName.equals("x10.array.Array") || arrayTypeName.equals("Array"))) - Errors.issue(tc.job(), - new Errors.ArrayLiteralMustBeOfArrayType(array.type().toString(), n.position())); - - Type aType = X10TypeMixin.typeArg(type,0); - List<Expr> vals = tuple.arguments(); - for (Expr e : vals) { - Type t = e.type(); - if (! ts.isSubtype(t, iType, tc.context())) - Errors.issue(tc.job(), - new Errors.ArrayLiteralTypeMismatch(e, iType)); - } - Type resultType = X10TypeMixin.makeArrayRailOf(iType, n.tuple().arguments().size(), n.position()); - - return n.type(resultType); - } - - public String toString() { - return "new Array[" + indexType + "]{ " + tuple + "}"; - } - - /** Write the expression to an output file. */ - - public void prettyPrint(CodeWriter w, PrettyPrinter tr) { - w.write("new Array["); - printBlock(indexType, w, tr); - w.write("]"); - tuple.prettyPrint(w,tr); - - } - - -} Modified: trunk/x10.compiler/src/x10/ast/Tuple_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Tuple_c.java 2010-10-07 18:58:28 UTC (rev 17167) +++ trunk/x10.compiler/src/x10/ast/Tuple_c.java 2010-10-07 19:02:34 UTC (rev 17168) @@ -19,6 +19,7 @@ import polyglot.ast.Node; import polyglot.ast.Precedence; import polyglot.ast.Term; +import polyglot.ast.TypeNode; import polyglot.types.FieldInstance; import polyglot.types.Name; import polyglot.types.SemanticException; @@ -43,6 +44,7 @@ import x10.types.X10TypeSystem; import x10.types.constraints.CConstraint; import x10.types.constraints.CConstraint; +import x10.errors.Errors; /** * An immutable representation of the list of elements in an X10 array constructor @@ -53,10 +55,12 @@ public class Tuple_c extends Expr_c implements Tuple { protected List<Expr> elements; + protected TypeNode indexType; - public Tuple_c(Position pos, List<Expr> elements) { + public Tuple_c(Position pos, List<Expr> elements, TypeNode indexType) { super(pos); - assert(elements != null); + this.indexType = indexType; + assert(elements != null); this.elements = TypedList.copyAndCheck(elements, Expr.class, true); } @@ -99,9 +103,10 @@ } /** Reconstruct the initializer. */ - protected Tuple_c reconstruct(List<Expr> elements) { - if (! CollectionUtil.allEqual(elements, this.elements)) { + protected Tuple_c reconstruct(TypeNode tn, List<Expr> elements) { + if (tn!=indexType || ! CollectionUtil.allEqual(elements, this.elements)) { Tuple_c n = (Tuple_c) copy(); + n.indexType = tn; n.elements = TypedList.copyAndCheck(elements, Expr.class, true); return n; } @@ -111,8 +116,10 @@ /** Visit the children of the initializer. */ public Node visitChildren(NodeVisitor v) { + TypeNode tn = null; + if (indexType!=null) tn = (TypeNode) visitChild( this.indexType, v ); List<Expr> elements = visitList(this.elements, v); - return reconstruct(elements); + return reconstruct(tn,elements); } public Type childExpectedType(Expr child, AscriptionVisitor av) { @@ -146,11 +153,20 @@ return child.type(); } + public TypeNode indexType() { + return indexType; + } public Term firstChild() { - return listChild(elements, null); + return indexType!=null ? indexType : listChild(elements, null); } public <S> List<S> acceptCFG(CFGBuilder v, List<S> succs) { + if (indexType!=null) { + if (elements.size()>0) + v.visitCFG(indexType, elements.get(0), ENTRY); + else + v.visitCFG(indexType, this, EXIT); + } v.visitCFGList(elements, this, EXIT); return succs; } @@ -175,13 +191,28 @@ type = ts.Any(); // should be bottom type, not top } - Type t = X10TypeMixin.makeArrayRailOf(type, elements.size(), position()); - return type(t); + Type resultType = X10TypeMixin.makeArrayRailOf(type, elements.size(), position()); + + if (indexType!=null) { + Type iType = indexType.type(); + List<Expr> vals = arguments(); + for (Expr e : vals) { + Type t = e.type(); + if (! ts.isSubtype(t, iType, tc.context())) + Errors.issue(tc.job(), + new Errors.ArrayLiteralTypeMismatch(e, iType)); + } + resultType = X10TypeMixin.makeArrayRailOf(iType, arguments().size(), position()); + } + return type(resultType); } @Override public String toString() { StringBuilder sb = new StringBuilder(); + if (indexType!=null) { + sb.append("new Array[").append(indexType).append("]"); + } sb.append("["); for (Iterator<Expr> i = elements.iterator(); i.hasNext(); ) { Expr e = i.next(); @@ -198,6 +229,11 @@ @Override public void prettyPrint(CodeWriter w, PrettyPrinter tr) { + if (indexType!=null) { + w.write("new Array["); + printBlock(indexType, w, tr); + w.write("]"); + } w.write("{"); for (Iterator<Expr> i = elements.iterator(); i.hasNext(); ) { Modified: trunk/x10.compiler/src/x10/ast/X10NodeFactory.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10NodeFactory.java 2010-10-07 18:58:28 UTC (rev 17167) +++ trunk/x10.compiler/src/x10/ast/X10NodeFactory.java 2010-10-07 19:02:34 UTC (rev 17168) @@ -64,8 +64,6 @@ AtStmt AtStmt(Position pos, Expr place, Stmt body); AtExpr AtExpr(Position pos, Expr place, TypeNode returnType, Block body); - ArrayLiteral ArrayLiteral(Position pos, TypeNode array, TypeNode indexType, Tuple values); - ConstructorCall X10ConstructorCall(Position pos, ConstructorCall.Kind kind, Expr outer, List<TypeNode> typeArgs, List<Expr> args); ConstructorCall X10ThisCall(Position pos, Expr outer, List<TypeNode> typeArgs, List<Expr> args); ConstructorCall X10ThisCall(Position pos, List<TypeNode> typeArgs, List<Expr> args); @@ -138,6 +136,7 @@ SettableAssign SettableAssign(Position pos, Expr a, List<Expr> indices, Assign.Operator op, Expr rhs); Tuple Tuple(Position pos, List<Expr> args); + Tuple Tuple(Position pos, TypeNode indexType, List<Expr> args); Formal Formal(Position pos, FlagsNode flags, TypeNode type, Id name); X10Formal X10Formal(Position pos, FlagsNode flags, TypeNode type, Id name, List<Formal> vars, boolean unnamed); Modified: trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2010-10-07 18:58:28 UTC (rev 17167) +++ trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2010-10-07 19:02:34 UTC (rev 17168) @@ -411,12 +411,6 @@ return X10New(pos, qualifier, objectType, Collections.<TypeNode>emptyList(), arguments, body); } - public ArrayLiteral ArrayLiteral(Position pos, TypeNode arrayType, TypeNode argType, Tuple values) { - ArrayLiteral n = new ArrayLiteral_c(pos, arrayType, argType, (Tuple_c) values); - n = (ArrayLiteral) n.ext(extFactory().extExpr()); - return (ArrayLiteral) n.del(delFactory().delExpr()); - } - // Wrap the body in a block to facilitate code transformations public AtEach AtEach(Position pos, Formal formal, Expr domain, List<Expr> clocks, Stmt body) @@ -543,8 +537,12 @@ } public Tuple Tuple(Position pos, List<Expr> a) { + return Tuple(pos,null, a); + + } + public Tuple Tuple(Position pos, TypeNode indexType, List<Expr> a) { //Report.report(1, "X10NodeFactory_c making tuple " + p + " " + r + " " + a); - Tuple n = new Tuple_c(pos, a); + Tuple n = new Tuple_c(pos, a, indexType); n = (Tuple) n.ext(extFactory().extCall()); n = (Tuple) n.del(delFactory().delCall()); return n; Modified: trunk/x10.compiler/src/x10/parser/X10Parser.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-10-07 18:58:28 UTC (rev 17167) +++ trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-10-07 19:02:34 UTC (rev 17168) @@ -102,6 +102,7 @@ import polyglot.types.Flags; import x10.types.X10Flags; import x10.types.checker.Converter; +import x10.errors.Errors; import polyglot.types.TypeSystem; import polyglot.util.CollectionUtil; import polyglot.util.ErrorInfo; @@ -2361,8 +2362,10 @@ //#line 1689 "x10/parser/x10.g" List<Expr> ArgumentListopt = (List<Expr>) getRhsSym(7); //#line 1691 "lpg.generator/templates/java/btParserTemplateF.gi" - TypeNode array = TypeName.toType(); - setResult(nf.ArrayLiteral(pos(), TypeName.toType(), Type, nf.Tuple(pos(), ArgumentListopt))); + String arrayTypeName = TypeName.name.id().toString(); + if (! (arrayTypeName.equals("x10.array.Array") || arrayTypeName.equals("Array"))) + syntaxError(new Errors.ArrayLiteralMustBeOfArrayType(arrayTypeName, TypeName.pos).getMessage(),TypeName.pos); + setResult(nf.Tuple(pos(), Type, ArgumentListopt)); break; } Modified: trunk/x10.compiler/src/x10/parser/x10.g =================================================================== --- trunk/x10.compiler/src/x10/parser/x10.g 2010-10-07 18:58:28 UTC (rev 17167) +++ trunk/x10.compiler/src/x10/parser/x10.g 2010-10-07 19:02:34 UTC (rev 17168) @@ -1688,8 +1688,10 @@ ./ | new TypeName '[' Type ']' '[' ArgumentListopt ']' /.$BeginJava - TypeNode array = TypeName.toType(); - setResult(nf.ArrayLiteral(pos(), TypeName.toType(), Type, nf.Tuple(pos(), ArgumentListopt))); + String arrayTypeName = TypeName.name.id().toString(); + if (! (arrayTypeName.equals("x10.array.Array") || arrayTypeName.equals("Array"))) + syntaxError(new Errors.ArrayLiteralMustBeOfArrayType(arrayTypeName, TypeName.pos).getMessage(),TypeName.pos); + setResult(nf.Tuple(pos(), Type, ArgumentListopt)); $EndJava ./ | Primary . new Identifier TypeArgumentsopt ( ArgumentListopt ) ClassBodyopt Modified: trunk/x10.compiler/src/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Desugarer.java 2010-10-07 18:58:28 UTC (rev 17167) +++ trunk/x10.compiler/src/x10/visit/Desugarer.java 2010-10-07 19:02:34 UTC (rev 17168) @@ -69,7 +69,6 @@ import x10.Configuration; import x10.ExtensionInfo; import x10.ast.AnnotationNode; -import x10.ast.ArrayLiteral; import x10.ast.Async; import x10.ast.AtEach; import x10.ast.AtExpr; @@ -359,8 +358,6 @@ return visitLocalDecl((LocalDecl) n); if (n instanceof Resume) return visitResume((Resume) n); - if (n instanceof ArrayLiteral) - return visitArrayLiteral((ArrayLiteral) n); return n; } @@ -1485,11 +1482,6 @@ X10MethodInstance ci = c.closureDef().asType().applyMethod(); return xnf.ClosureCall(pos, c, Collections.singletonList(e)).closureInstance(ci).type(xts.Boolean()); } - - private Expr visitArrayLiteral(ArrayLiteral n) throws SemanticException { - Position pos = n.position(); - return n.tuple().type(n.type()); - } public static class Substitution<T extends Node> extends ErrorHandlingVisitor { protected final List<T> by; Modified: trunk/x10.compiler/src/x10/visit/ExpressionFlattener.java =================================================================== --- trunk/x10.compiler/src/x10/visit/ExpressionFlattener.java 2010-10-07 18:58:28 UTC (rev 17167) +++ trunk/x10.compiler/src/x10/visit/ExpressionFlattener.java 2010-10-07 19:02:34 UTC (rev 17168) @@ -62,7 +62,6 @@ import polyglot.util.Position; import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; -import x10.ast.ArrayLiteral; import x10.ast.AssignPropertyCall; import x10.ast.Async; import x10.ast.AtEach; @@ -152,9 +151,6 @@ * @return true if the node cannot be flattened, false otherwise */ public static boolean cannotFlatten(Node n) { - if (n instanceof ArrayLiteral) { // FIXME: when ArrayLiterals become tuples with explicit types, delete this clause and flattenArrayLiteral - return true; - } if (n instanceof ConstructorDecl) { // can't flatten constructors until local assignments can precede super() and this() return true; } @@ -248,7 +244,6 @@ else if (expr instanceof LocalAssign) return flattenLocalAssign((LocalAssign) expr); else if (expr instanceof Call) return flattenMethodCall((Call) expr); else if (expr instanceof New) return flattenNew((New) expr); - else if (expr instanceof ArrayLiteral) return flattenArrayLiteral((ArrayLiteral) expr); // FIXME: remove this case when array literals become Tuples with explicit types else if (expr instanceof Tuple) return flattenTuple((Tuple) expr); else if (expr instanceof Binary) return flattenBinary((Binary) expr); else if (expr instanceof Unary) return flattenUnary((Unary) expr); @@ -268,25 +263,6 @@ } /** - * Flatten an Array literal. - * <pre> - * new Array[X](({s1; e1}), ..., ({sk; ek})) -> new Array[X]({s1; val t1 = e1; ... sk; val tk = ek; new Array[x](t1, ..., tk)}) - * </pre> - * - * @param expr the New expression to be flattened - * @return a flat expression equivalent to expr - */ - private Expr flattenArrayLiteral(ArrayLiteral expr) { - assert false; - return null; - /* FIXME: delete this method when array literals become tuples with explicit types - List<Stmt> stmts = new ArrayList<Stmt>(); - Expr primary = getPrimaryAndStatements(expr.tuple(), stmts); - return toFlatExpr(expr.position(), stmts, expr.tuple(primary)); - */ - } - - /** * Flatten a primary expression. * (no-op: Primary expressions are already flat!) * Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-07 18:58:28 UTC (rev 17167) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-07 19:02:34 UTC (rev 17168) @@ -1438,10 +1438,11 @@ class TestOnlyLocalVarAccess { - // for some reason, the origin of "frame" is null. I couldn't reproduce it... + // for some reason, the origin of "frame" is null. I couldn't reproduce it... see XTENLANG-1902 //C:\cygwin\home\Yoav\intellij\sourceforge\x10.runtime\src-x10\x10\compiler\ws\Worker.x10:86,18-22 //Message: Semantic Error: Local variable "frame" is accessed at a different place, and must be declared final. var i:Int; + static def testInferReturnType()=test0(null); static def test0(var b:TestOnlyLocalVarAccess) { b.i++; } @@ -1562,4 +1563,13 @@ } } def use(x:Any) {} -} \ No newline at end of file +} + +class A[T,U] { + def foo(x:T,y:U, z:String):void {} +} +class B extends A[String,String] { + def foo(x:String,y:String, z:String):Int { return 1; } // ERR: foo(x: x10.lang.String, y: x10.lang.String, z: x10.lang.String): x10.lang.Int in B cannot override foo(x: x10.lang.String, y: x10.lang.String, z: x10.lang.String): x10.lang.Void in A[x10.lang.String, x10.lang.String]; attempting to use incompatible return type. + // B.foo(String,String,String) cannot override A.foo(T,U,String); attempting to use incompatible return type. found: int required: void +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-10-07 19:48:03
|
Revision: 17173 http://x10.svn.sourceforge.net/x10/?rev=17173&view=rev Author: yzibin Date: 2010-10-07 19:47:56 +0000 (Thu, 07 Oct 2010) Log Message: ----------- removed "!" from the grammar (still need to regenerate the parser. added some test cases for Array literals (with and without explicit type) Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10Local_c.java trunk/x10.compiler/src/x10/parser/x10.g trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 Modified: trunk/x10.compiler/src/x10/ast/X10Local_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-10-07 19:32:54 UTC (rev 17172) +++ trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-10-07 19:47:56 UTC (rev 17173) @@ -83,10 +83,8 @@ // we check that usages inside an "at" are at the origin place if it is a "var" (for "val" we're fine) final X10LocalDef_c localDef_c = (X10LocalDef_c) li.def(); XTerm origin = localDef_c.placeTerm(); - // todo: weird bug where origin was null for: - //C:\cygwin\home\Yoav\intellij\sourceforge\x10.runtime\src-x10\x10\compiler\ws\Worker.x10:86,18-22 - //Message: Semantic Error: Local variable "frame" is accessed at a different place, and must be declared final. - + // origin maybe null when typechecking a method to get the return type (see XTENLANG-1902) + // but we will type check that method again later (with correct placeTerm) if (origin!=null) { // origin = PlaceChecker.here(); final XConstrainedTerm placeTerm = context.currentPlaceTerm(); final XTerm currentPlace = placeTerm.term(); Modified: trunk/x10.compiler/src/x10/parser/x10.g =================================================================== --- trunk/x10.compiler/src/x10/parser/x10.g 2010-10-07 19:32:54 UTC (rev 17172) +++ trunk/x10.compiler/src/x10/parser/x10.g 2010-10-07 19:47:56 UTC (rev 17173) @@ -1846,30 +1846,6 @@ setResult(nf.DepParameterExpr(pos(), ExistentialListopt, Conjunctionopt)); $EndJava ./ - | ! PlaceType - /.$BeginJava - Expr placeClause = nf.Call(pos(), nf.Self(pos()), nf.Id(pos(), "at"), PlaceType); - setResult(nf.DepParameterExpr(pos(), null, Collections.singletonList(placeClause))); - $EndJava - ./ - | ! - /.$BeginJava - Expr placeClause = nf.Call(pos(), nf.Self(pos()), nf.Id(pos(), "at"), nf.AmbHereThis(pos())); - setResult(nf.DepParameterExpr(pos(), null, Collections.singletonList(placeClause))); - $EndJava - ./ - | ! PlaceType { ExistentialListopt Conjunction } - /.$BeginJava - Expr placeClause = nf.Call(pos(), nf.Self(pos()), nf.Id(pos(), "at"), PlaceType); - setResult(nf.DepParameterExpr(pos(), ExistentialListopt, CollectionUtil.append(Conjunction, Collections.singletonList(placeClause)))); - $EndJava - ./ - | ! { ExistentialListopt Conjunction } - /.$BeginJava - Expr placeClause = nf.Call(pos(), nf.Self(pos()), nf.Id(pos(), "at"), nf.AmbHereThis(pos())); - setResult(nf.DepParameterExpr(pos(), ExistentialListopt, CollectionUtil.append(Conjunction, Collections.singletonList(placeClause)))); - $EndJava - ./ TypeParamsWithVariance ::= '[' TypeParamWithVarianceList ']' Modified: trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1_MustFailCompile.x10 2010-10-07 19:32:54 UTC (rev 17172) +++ trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1_MustFailCompile.x10 2010-10-07 19:47:56 UTC (rev 17173) @@ -22,7 +22,7 @@ val e = 0..9; val r = [1, 2, 3]; val a = new Array[Int{self!=0}][ - 0, // this should give a compilation error. + 0, // ERR: The literal is not of the given type 1,2,3]; var sumr:int=0, suma:int=0; for (i in a.values()) suma += i; @@ -30,6 +30,37 @@ return suma==6 && sumr==6; } + + def test() { + // size&dimension is inferred correctly for: new Array[XX][YYY] + val a10 = new Array[Int][1,2,3]; + val a11:Array[Int] = new Array[Int][1,2,3]; + val a12:Array[Int](1) = new Array[Int][1,2,3]; + val a13:Array[Int](1){size==3} = new Array[Int][1,2,3]; + val a2:Array[A](1){size==3} = new Array[Int][1,2,3]; // ERR: Cannot assign expression to target. + val a3:Array[Int](2){size==3} = new Array[Int][1,2,3]; // ERR: Cannot assign expression to target. + val a4:Array[Int](1){size==4} = new Array[Int][1,2,3]; // ERR: Cannot assign expression to target. + + val b:Array[A] = new Array[A][new A()]; + val b1:Array[A](1){size==1} = new Array[A][new A()]; + } + def test2() { + // size&dimension is inferred correctly for: [YYY] + val a10 = [1,2,3]; + val a11:Array[Int] = [1,2,3]; + val a12:Array[Int](1) = [1,2,3]; + val a13:Array[Int](1){size==3} = [1,2,3]; + val a2:Array[A](1){size==3} = [1,2,3]; // ERR: Cannot assign expression to target. + val a3:Array[Int](2){size==3} = [1,2,3]; // ERR: Cannot assign expression to target. + val a4:Array[Int](1){size==4} = [1,2,3]; // ERR: Cannot assign expression to target. + + val b:Array[A] = [new A()]; + val b1:Array[A](1){size==1} = [new A()]; + } + + static class A {} + + public static def main(Array[String](1)): Void = { new ArrayLiteralTest1_MustFailCompile().execute(); } Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-07 19:32:54 UTC (rev 17172) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-07 19:47:56 UTC (rev 17173) @@ -1515,11 +1515,13 @@ } + class TestGlobalRefHomeAt { // see http://jira.codehaus.org/browse/XTENLANG-1905 - def test() { - val r = GlobalRef(this); - val r2 = r; - val r3 = GlobalRef(this); + def test() { + val p = here; + val r:GlobalRef[TestGlobalRefHomeAt]{home==p} = GlobalRef[TestGlobalRefHomeAt](this); + val r2:GlobalRef[TestGlobalRefHomeAt]{home==p} = r; + val r3:GlobalRef[TestGlobalRefHomeAt]{home==p} = GlobalRef[TestGlobalRefHomeAt](this); use(r()); use(r2()); @@ -1527,7 +1529,7 @@ at (r.home()) { use(r()); - use(r2()); + use(r2()); // todo ERR use(r3()); // todo ERR } at (r2.home()) { @@ -1547,7 +1549,7 @@ at (r.home()) { use(r()); - use(r2()); + use(r2()); // todo ERR use(r3()); // todo ERR } at (r2.home()) { @@ -1565,10 +1567,10 @@ def use(x:Any) {} } -class A[T,U] { +class A564[T,U] { def foo(x:T,y:U, z:String):void {} } -class B extends A[String,String] { +class B564 extends A564[String,String] { def foo(x:String,y:String, z:String):Int { return 1; } // ERR: foo(x: x10.lang.String, y: x10.lang.String, z: x10.lang.String): x10.lang.Int in B cannot override foo(x: x10.lang.String, y: x10.lang.String, z: x10.lang.String): x10.lang.Void in A[x10.lang.String, x10.lang.String]; attempting to use incompatible return type. // B.foo(String,String,String) cannot override A.foo(T,U,String); attempting to use incompatible return type. found: int required: void } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2010-10-08 09:23:16
|
Revision: 17188 http://x10.svn.sourceforge.net/x10/?rev=17188&view=rev Author: sparksparkspark Date: 2010-10-08 09:23:10 +0000 (Fri, 08 Oct 2010) Log Message: ----------- Add functionality to free a CUDA array Modified Paths: -------------- trunk/x10.dist/samples/CUDA/CUDABlackScholes.x10 trunk/x10.dist/samples/CUDA/KMeansCUDA.x10 trunk/x10.runtime/src-x10/x10/array/RemoteArray.x10 trunk/x10.runtime/src-x10/x10/util/CUDAUtilities.x10 Modified: trunk/x10.dist/samples/CUDA/CUDABlackScholes.x10 =================================================================== --- trunk/x10.dist/samples/CUDA/CUDABlackScholes.x10 2010-10-08 09:19:08 UTC (rev 17187) +++ trunk/x10.dist/samples/CUDA/CUDABlackScholes.x10 2010-10-08 09:23:10 UTC (rev 17188) @@ -136,6 +136,12 @@ Console.OUT.println("Effective memory bandwidth: " + (5 * OPT_N * 4) * 1.0e-9f / (gpuTime * 1.0E-9f) + " GB/s"); Console.OUT.println("Gigaoptions per second : " + ((2 * OPT_N) * 1.0e-9f) / (gpuTime * 1.0e-9f)); + CUDAUtilities.deleteRemoteArray(d_CallResult); + CUDAUtilities.deleteRemoteArray(d_PutResult); + CUDAUtilities.deleteRemoteArray(d_StockPrice); + CUDAUtilities.deleteRemoteArray(d_OptionStrike); + CUDAUtilities.deleteRemoteArray(d_OptionYears); + // Read back GPU results finish { Array.asyncCopy(d_CallResult, 0, h_CallResultGPU, 0, OPT_N); Modified: trunk/x10.dist/samples/CUDA/KMeansCUDA.x10 =================================================================== --- trunk/x10.dist/samples/CUDA/KMeansCUDA.x10 2010-10-08 09:19:08 UTC (rev 17187) +++ trunk/x10.dist/samples/CUDA/KMeansCUDA.x10 2010-10-08 09:23:10 UTC (rev 17188) @@ -231,6 +231,9 @@ Console.OUT.println("reduce: "+r_time/1E3); } + CUDAUtilities.deleteRemoteArray(gpu_points); + CUDAUtilities.deleteRemoteArray(gpu_nearest); + } // gpus } // hosts Modified: trunk/x10.runtime/src-x10/x10/array/RemoteArray.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/RemoteArray.x10 2010-10-08 09:19:08 UTC (rev 17187) +++ trunk/x10.runtime/src-x10/x10/array/RemoteArray.x10 2010-10-08 09:23:10 UTC (rev 17188) @@ -70,6 +70,8 @@ public def apply(p:Point{self.rank==this.rank}) {here==home} = array()(p); + public def apply() {here==home} = array(); + public def hashCode() = array.hashCode(); } Modified: trunk/x10.runtime/src-x10/x10/util/CUDAUtilities.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/CUDAUtilities.x10 2010-10-08 09:19:08 UTC (rev 17187) +++ trunk/x10.runtime/src-x10/x10/util/CUDAUtilities.x10 2010-10-08 09:23:10 UTC (rev 17188) @@ -53,7 +53,6 @@ @Native("c++", "x10_ulong addr = x10aux::remote_alloc(gpu.FMGL(id), ((size_t)numElements)*sizeof(FMGL(T)));\n"+ "IndexedMemoryChunk<FMGL(T)> imc(addr);\n"+ - // TODO: initialise "initCUDAArray<FMGL(T)>(gpu,init,imc,numElements);\n"+ "return x10::array::RemoteArray<FMGL(T)>::_make(gpu, reg, imc, numElements);\n" ) { } @@ -93,6 +92,17 @@ return at (place) new RemoteArray(new Array[T](numElements, (p:Int)=>init(p))); } } + + public static def deleteRemoteArray[T] (arr: RemoteArray[T]{self.rank==1}) : Void + { + val place = arr.home; + if (place.isCUDA()) { + @Native("c++", + "IndexedMemoryChunk<FMGL(T)> imc = arr->apply()->raw();\n"+ + "x10aux::remote_free(place.FMGL(id), (x10_ulong)(size_t)imc->raw());\n" + ) { } + } + } } // vim: shiftwidth=4:tabstop=4:expandtab This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-10-08 22:45:59
|
Revision: 17229 http://x10.svn.sourceforge.net/x10/?rev=17229&view=rev Author: yzibin Date: 2010-10-08 22:45:51 +0000 (Fri, 08 Oct 2010) Log Message: ----------- deleted ForEach fixed 1910. Modified Paths: -------------- trunk/x10.compiler/build-user.xml trunk/x10.compiler/build.xml trunk/x10.compiler/src/x10/ast/Async_c.java trunk/x10.compiler/src/x10/ast/AtStmt_c.java trunk/x10.compiler/src/x10/ast/Finish_c.java trunk/x10.compiler/src/x10/ast/X10ClockedLoop_c.java trunk/x10.compiler/src/x10/ast/X10Local_c.java trunk/x10.compiler/src/x10/ast/X10NodeFactory.java trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java trunk/x10.compiler/src/x10/ast/X10Return_c.java trunk/x10.compiler/src/x10/parser/X10Parser.java trunk/x10.compiler/src/x10/types/X10Context.java trunk/x10.compiler/src/x10/types/X10Context_c.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/util/RunTestSuite.java trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.compiler/src/x10/visit/ExpressionFlattener.java trunk/x10.compiler/src/x10/visit/X10DelegatingVisitor.java trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.tests/examples/Constructs/Await/ArgMustBeBoolean_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Call/ConConstructor2Arg_2_DYNAMIC_CALLS.x10 trunk/x10.tests/examples/Constructs/Call/ConConstructor2Arg_DYNAMIC_CALLS.x10 trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 trunk/x10.tests/examples/Constructs/Generics/Generics_ERR_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Typedefs/RecursiveTypeDefs_MustFailCompile.x10 trunk/x10.tests/examples/Misc/RefA_MustFailCompile.x10 trunk/x10.tests/tests/ScalableFinish/SimpleFinish3.x10 trunk/x10.tests/tests/ScalableFinish/SimpleFinish4.x10 trunk/x10.tests/tests/ScalableFinish/SimpleFinish5.x10 Removed Paths: ------------- trunk/x10.compiler/src/x10/ast/ForEach.java trunk/x10.compiler/src/x10/ast/ForEach_c.java Modified: trunk/x10.compiler/build-user.xml =================================================================== --- trunk/x10.compiler/build-user.xml 2010-10-08 22:10:30 UTC (rev 17228) +++ trunk/x10.compiler/build-user.xml 2010-10-08 22:45:51 UTC (rev 17229) @@ -1,3 +1,4 @@ <target name="help"> <echo message="Please run: $ ant -v -projecthelp"/> -</target> \ No newline at end of file +</target> +<property name="lpg.location" location="../../../lpg_parser/lpg.generator"/> \ No newline at end of file Modified: trunk/x10.compiler/build.xml =================================================================== --- trunk/x10.compiler/build.xml 2010-10-08 22:10:30 UTC (rev 17228) +++ trunk/x10.compiler/build.xml 2010-10-08 22:45:51 UTC (rev 17229) @@ -92,8 +92,14 @@ <condition property="platform" value="win32"><os family="windows"/></condition> <condition property="platform" value="linux"><os name="Linux"/></condition> <condition property="platform" value="macosx"><os name="Mac OS X"/></condition> - <!-- Work around Mac OS's Java reporting x86 as i386 --> - <condition property="arch" value="x86" else="${os.arch}"><equals arg1="${os.arch}" arg2="i386"/></condition> + <condition property="arch" value="x86" else="${os.arch}"> + <or> + <!-- Work around Mac OS's Java reporting x86 as i386 --> + <equals arg1="${os.arch}" arg2="i386"/> + <!-- Treat amd64 as x86 --> + <equals arg1="${os.arch}" arg2="amd64"/> + </or> + </condition> <property name="lpg.executable.location" location="${lpg.location}.${platform}_${arch}"/> <property name="lpg.executable" location="${lpg.executable.location}/lpgexe/lpg-${platform}_${arch}"/> <!-- Modified: trunk/x10.compiler/src/x10/ast/Async_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Async_c.java 2010-10-08 22:10:30 UTC (rev 17228) +++ trunk/x10.compiler/src/x10/ast/Async_c.java 2010-10-08 22:45:51 UTC (rev 17229) @@ -158,21 +158,10 @@ public Context enterChildScope(Node child, Context c) { if (Report.should_report(TOPICS, 5)) Report.report(5, "enter async scope"); - X10Context xc = (X10Context) c; if (child == this.body) { - X10TypeSystem ts = (X10TypeSystem) c.typeSystem(); - X10MethodDef asyncInstance = (X10MethodDef) ts.asyncCodeInstance(c.inStaticContext()); - if (xc.currentCode() instanceof X10MethodDef) { - X10MethodDef outer = (X10MethodDef) c.currentCode(); - List<ParameterType> capturedTypes = outer.typeParameters(); - if (!capturedTypes.isEmpty()) { - asyncInstance = ((X10MethodDef) asyncInstance.copy()); - asyncInstance.setTypeParameters(capturedTypes); - } - } - xc = (X10Context) xc.pushCode(asyncInstance); + return AtStmt_c.createDummyAsync(c, true); } - return xc; + return c; } public Node typeCheck(ContextVisitor tc) { Modified: trunk/x10.compiler/src/x10/ast/AtStmt_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AtStmt_c.java 2010-10-08 22:10:30 UTC (rev 17228) +++ trunk/x10.compiler/src/x10/ast/AtStmt_c.java 2010-10-08 22:45:51 UTC (rev 17229) @@ -52,6 +52,7 @@ import x10.types.X10MethodDef; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.types.X10Context_c; import x10.types.checker.PlaceChecker; import x10.types.constraints.CConstraint; import x10.types.constraints.XConstrainedTerm; @@ -174,10 +175,10 @@ return reconstruct(place, body); } - public Context enterScope(Context c) { + public static Context createDummyAsync(Context c, boolean isAsyncOrAt) { X10TypeSystem ts = (X10TypeSystem) c.typeSystem(); X10MethodDef asyncInstance = (X10MethodDef) ts.asyncCodeInstance(c.inStaticContext()); - + if (c.currentCode() instanceof X10MethodDef) { X10MethodDef outer = (X10MethodDef) c.currentCode(); XVar thisVar = outer.thisVar(); @@ -189,7 +190,11 @@ } } c = c.pushCode(asyncInstance); + ((X10Context_c)c).x10Kind = isAsyncOrAt ? X10Context_c.X10Kind.Async : X10Context_c.X10Kind.At; return c; + } + public Context enterScope(Context c) { + return createDummyAsync(c, false); } @Override Modified: trunk/x10.compiler/src/x10/ast/Finish_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Finish_c.java 2010-10-08 22:10:30 UTC (rev 17228) +++ trunk/x10.compiler/src/x10/ast/Finish_c.java 2010-10-08 22:45:51 UTC (rev 17229) @@ -68,8 +68,7 @@ @Override public Context enterChildScope(Node child, Context c) { c = super.enterChildScope(child,c); - if (clocked) - c=((X10Context) c).pushClockedFinishScope(); + c=((X10Context) c).pushFinishScope(clocked); addDecls(c); return c; } Deleted: trunk/x10.compiler/src/x10/ast/ForEach.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ForEach.java 2010-10-08 22:10:30 UTC (rev 17228) +++ trunk/x10.compiler/src/x10/ast/ForEach.java 2010-10-08 22:45:51 UTC (rev 17229) @@ -1,20 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -package x10.ast; - -/** - * @author vj Jan 5, 2005 - * @author igor Jan 19, 2006 - */ -public interface ForEach extends X10ClockedLoop { -} - Deleted: trunk/x10.compiler/src/x10/ast/ForEach_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ForEach_c.java 2010-10-08 22:10:30 UTC (rev 17228) +++ trunk/x10.compiler/src/x10/ast/ForEach_c.java 2010-10-08 22:45:51 UTC (rev 17229) @@ -1,73 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -package x10.ast; - -import java.util.Iterator; -import java.util.List; - -import polyglot.ast.Expr; -import polyglot.ast.Formal; -import polyglot.ast.Node; -import polyglot.ast.Stmt; -import polyglot.types.SemanticException; -import polyglot.types.Type; -import polyglot.util.CodeWriter; -import polyglot.util.Position; -import polyglot.visit.PrettyPrinter; -import polyglot.visit.TypeChecker; -import x10.types.X10Context; -import x10.types.X10TypeSystem; - -/** - * An immutable representation of the X10 statement: [clocked] foreach (i : D) S - * @author vj Dec 9, 2004 - * @author Christian Grothoff - */ -public class ForEach_c extends X10ClockedLoop_c implements ForEach, Clocked { - - /** - * @param pos - */ - public ForEach_c(Position pos) { - super(pos); - loopKind = LoopKind.FOREACH; - } - - /** - * @param pos - * @param formal - * @param domain - * @param clocks - * @param body - */ - public ForEach_c(Position pos, Formal formal, Expr domain, List<Expr> clocks, Stmt body) { - super(pos, formal, domain, clocks, body); - loopKind = LoopKind.FOREACH; - } - public ForEach_c(Position pos, Formal formal, Expr domain, Stmt body) { - super(pos, formal, domain, body); - loopKind = LoopKind.FOREACH; - } - - public String toString() { - return "foreach (" + formal + ":" + domain + ")" + body; - } - - public void prettyPrint(CodeWriter w, PrettyPrinter tr) { - w.write("foreach("); - printBlock(formal, w, tr); - w.write(" : "); - printBlock(domain, w, tr); - w.write(") "); - printSubStmt(body, w, tr); - } -} Modified: trunk/x10.compiler/src/x10/ast/X10ClockedLoop_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClockedLoop_c.java 2010-10-08 22:10:30 UTC (rev 17228) +++ trunk/x10.compiler/src/x10/ast/X10ClockedLoop_c.java 2010-10-08 22:45:51 UTC (rev 17229) @@ -91,21 +91,10 @@ } public Context enterChildScope(Node child, Context c) { - X10Context xc = (X10Context) c; if (child == this.body) { - X10TypeSystem ts = (X10TypeSystem) c.typeSystem(); - X10MethodDef asyncInstance = (X10MethodDef) ts.asyncCodeInstance(c.inStaticContext()); - if (xc.currentCode() instanceof X10MethodDef) { - X10MethodDef outer = (X10MethodDef) c.currentCode(); - List<ParameterType> capturedTypes = outer.typeParameters(); - if (!capturedTypes.isEmpty()) { - asyncInstance = ((X10MethodDef) asyncInstance.copy()); - asyncInstance.setTypeParameters(capturedTypes); - } - } - xc = (X10Context) xc.pushCode(asyncInstance); + return AtStmt_c.createDummyAsync(c,false); // only subclass is AtEach (so it is an at, not an async) } - return xc; + return c; } Modified: trunk/x10.compiler/src/x10/ast/X10Local_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-10-08 22:10:30 UTC (rev 17228) +++ trunk/x10.compiler/src/x10/ast/X10Local_c.java 2010-10-08 22:45:51 UTC (rev 17229) @@ -18,33 +18,25 @@ * * @author vj */ -import java.util.Set; import polyglot.ast.Id; import polyglot.ast.Local_c; import polyglot.ast.Node; import polyglot.types.CodeDef; -import polyglot.types.Context; -import polyglot.types.FieldInstance; -import polyglot.types.Flags; import polyglot.types.LocalInstance; import polyglot.types.Name; import polyglot.types.SemanticException; import polyglot.types.Type; import polyglot.types.Types; -import polyglot.types.UnknownType; import polyglot.types.VarDef; import polyglot.util.Position; import polyglot.visit.ContextVisitor; import x10.constraint.XFailure; -import x10.constraint.XLocal; import x10.constraint.XTerm; -import x10.constraint.XVar; import x10.constraint.XConstraint; import x10.errors.Errors; import x10.types.X10Context; -import x10.types.X10FieldInstance; import x10.types.X10Flags; import x10.types.X10LocalInstance; import x10.types.X10ProcedureDef; @@ -53,9 +45,7 @@ import x10.types.X10TypeSystem_c; import x10.types.X10Context_c; import x10.types.X10LocalDef_c; -import x10.types.checker.PlaceChecker; import x10.types.constraints.CConstraint; -import x10.types.constraints.CConstraint; import x10.types.constraints.XConstrainedTerm; public class X10Local_c extends Local_c { @@ -66,19 +56,29 @@ } public Node typeCheck(ContextVisitor tc) { X10Context_c context = (X10Context_c) tc.context(); + final Name liName = name.id(); LocalInstance li = localInstance(); if (!((X10LocalInstance) li).isValid()) { - li = findAppropriateLocal(tc, name.id()); + li = findAppropriateLocal(tc, liName); } if (!li.flags().isFinal() && !X10Flags.toX10Flags(li.flags()).isShared()) { // if the local is defined in an outer class, then it must be final // shared was removed from the language: you cannot access var in a closure // Note that an async is similar to a closure (we create a dummy closure) - if (!context.isLocalIncludingAsync(li.name())) { + if (context.isLocal(liName)) { + // ok + } else if (!context.isLocalIncludingAsyncAt(liName)) { // this local is defined in an outer class - Errors.issue(tc.job(), new SemanticException("Local variable \"" + li.name() +"\" is accessed from an inner class or a closure, and must be declared final.",this.position())); - } + Errors.issue(tc.job(), new SemanticException("Local variable \"" + liName +"\" is accessed from an inner class or a closure, and must be declared final.",this.position())); + } else { + // if the access is in an async and the local-var is not local, then we must ensure that the scoping looks like this: var ... (no async) ... finish ... async + // algorithm: we go up the context (going outwards) looking for a finish + // (setting flag foundFinish to true when we find a finish, and to false when we find an async) + // when we get to the var definition, then foundFinish must be true. + if (!context.isSequentialAccess(true,liName)) + Errors.issue(tc.job(), new SemanticException("Local variable \"" + liName +"\" cannot be captured in an async if there is no enclosing finish in the same scoping-level as \"" + liName +"\"; consider changing \"" + liName +"\" from var to val.",this.position())); + } // we check that usages inside an "at" are at the origin place if it is a "var" (for "val" we're fine) final X10LocalDef_c localDef_c = (X10LocalDef_c) li.def(); @@ -100,7 +100,7 @@ // how can it happen? in any case, we should report an error so isOk=false } if (!isOk) - Errors.issue(tc.job(), new SemanticException("Local variable \"" + li.name() +"\" is accessed at a different place, and must be declared final.",this.position())); + Errors.issue(tc.job(), new SemanticException("Local variable \"" + liName +"\" is accessed at a different place, and must be declared final.",this.position())); } } @@ -112,7 +112,7 @@ if (context.inDepType()) { li = result.localInstance(); if (! (li.def().equals(dli)) && ! li.flags().isFinal()) { - throw new SemanticError("A var local variable " + li.name() + throw new SemanticError("A var local variable " + liName + " is not allowed in a constraint.", position()); } Modified: trunk/x10.compiler/src/x10/ast/X10NodeFactory.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10NodeFactory.java 2010-10-08 22:10:30 UTC (rev 17228) +++ trunk/x10.compiler/src/x10/ast/X10NodeFactory.java 2010-10-08 22:45:51 UTC (rev 17229) @@ -116,9 +116,6 @@ Await Await(Position pos, Expr expr); X10Loop ForLoop(Position pos, Formal formal, Expr domain, Stmt body); - X10Loop ForEach(Position pos, Formal formal, Expr domain, List<Expr> clocks, - Stmt body); - X10Loop ForEach(Position pos, Formal formal, Expr domain, Stmt body); X10Loop AtEach(Position pos, Formal formal, Expr domain, List<Expr> clocks, Stmt body); X10Loop AtEach(Position pos, Formal formal, Expr domain, Stmt body); Modified: trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2010-10-08 22:10:30 UTC (rev 17228) +++ trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2010-10-08 22:45:51 UTC (rev 17229) @@ -451,28 +451,8 @@ return n; } -// Wrap the body in a block to facilitate code transformations - public ForEach ForEach(Position pos, Formal formal, Expr domain, - List<Expr> clocks, Stmt body) - { - ForEach n = new ForEach_c(pos, formal, domain, clocks, asBlock(body)); - X10ExtFactory_c ext_fac = (X10ExtFactory_c) extFactory(); - n = (ForEach) n.ext(ext_fac.extForEachImpl()); - X10DelFactory_c del_fac = (X10DelFactory_c) delFactory(); - n = (ForEach) n.del(del_fac.delForEachImpl()); - return n; - } - public ForEach ForEach(Position pos, Formal formal, Expr domain, - Stmt body) - { - ForEach n = new ForEach_c(pos, formal, domain, asBlock(body)); - X10ExtFactory_c ext_fac = (X10ExtFactory_c) extFactory(); - n = (ForEach) n.ext(ext_fac.extForEachImpl()); - X10DelFactory_c del_fac = (X10DelFactory_c) delFactory(); - n = (ForEach) n.del(del_fac.delForEachImpl()); - return n; - } + // Wrap the body in a block to facilitate code transformations public Finish Finish(Position pos, Stmt body, boolean clocked) { Finish n = new Finish_c(pos, asBlock(body), clocked); Modified: trunk/x10.compiler/src/x10/ast/X10Return_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Return_c.java 2010-10-08 22:10:30 UTC (rev 17228) +++ trunk/x10.compiler/src/x10/ast/X10Return_c.java 2010-10-08 22:45:51 UTC (rev 17229) @@ -11,10 +11,7 @@ package x10.ast; -import polyglot.ast.Assign; -import polyglot.ast.Call; import polyglot.ast.Expr; -import polyglot.ast.New; import polyglot.ast.Node; import polyglot.ast.NodeFactory; import polyglot.ast.Return_c; @@ -24,9 +21,7 @@ import polyglot.types.FunctionDef; import polyglot.types.InitializerDef; import polyglot.types.LocalDef; -import polyglot.types.LocalInstance; import polyglot.types.MethodDef; -import polyglot.types.Name; import polyglot.types.Ref; import polyglot.types.SemanticException; import polyglot.types.Type; @@ -34,7 +29,6 @@ import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.visit.ContextVisitor; -import x10.Configuration; import x10.constraint.XEQV; import x10.constraint.XFailure; import x10.constraint.XLocal; @@ -48,6 +42,7 @@ import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; +import x10.types.X10Context_c; import x10.types.checker.Converter; import x10.types.checker.PlaceChecker; import x10.types.constraints.CConstraint; @@ -95,12 +90,6 @@ return removeLocals((X10Context) ctx.pop(), c, thisCode); } - public static boolean isAsyncCode(CodeDef ci) { - return (ci != null) - && (ci instanceof MethodDef) - && ((MethodDef) ci).name().toString().equals(X10TypeSystem_c.DUMMY_ASYNC); - } - @Override public Node typeCheck(ContextVisitor tc) { X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); @@ -108,7 +97,7 @@ CodeDef ci = c.currentCode(); - if (isAsyncCode(ci)) { + if (((X10Context_c)c).inAsyncScope()) { // can return from an at but not from an async Errors.issue(tc.job(), new SemanticException("Cannot return from an async."), this); return this; } Modified: trunk/x10.compiler/src/x10/parser/X10Parser.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-10-08 22:10:30 UTC (rev 17228) +++ trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-10-08 22:45:51 UTC (rev 17229) @@ -1163,10 +1163,10 @@ // Rule 1: TypeName ::= TypeName . ErrorId // case 1: { - //#line 8 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 8 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 6 "x10/parser/MissingId.gi" ParsedName TypeName = (ParsedName) getRhsSym(1); - //#line 8 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 8 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1179,10 +1179,10 @@ // Rule 2: PackageName ::= PackageName . ErrorId // case 2: { - //#line 18 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 18 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 16 "x10/parser/MissingId.gi" ParsedName PackageName = (ParsedName) getRhsSym(1); - //#line 18 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 18 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1195,10 +1195,10 @@ // Rule 3: ExpressionName ::= AmbiguousName . ErrorId // case 3: { - //#line 28 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 28 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 26 "x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 28 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 28 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1211,10 +1211,10 @@ // Rule 4: MethodName ::= AmbiguousName . ErrorId // case 4: { - //#line 38 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 38 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 36 "x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 38 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 38 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1227,10 +1227,10 @@ // Rule 5: PackageOrTypeName ::= PackageOrTypeName . ErrorId // case 5: { - //#line 48 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 48 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 46 "x10/parser/MissingId.gi" ParsedName PackageOrTypeName = (ParsedName) getRhsSym(1); - //#line 48 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 48 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1243,10 +1243,10 @@ // Rule 6: AmbiguousName ::= AmbiguousName . ErrorId // case 6: { - //#line 58 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 58 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 56 "x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 58 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 58 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1259,10 +1259,10 @@ // Rule 7: FieldAccess ::= Primary . ErrorId // case 7: { - //#line 68 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 68 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 66 "x10/parser/MissingId.gi" Expr Primary = (Expr) getRhsSym(1); - //#line 68 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 68 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(), Primary, nf.Id(pos(getRightSpan()), "*"))); break; @@ -1272,9 +1272,9 @@ // Rule 8: FieldAccess ::= super . ErrorId // case 8: { - //#line 74 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 74 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 74 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 74 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(getRightSpan()), nf.Super(pos(getLeftSpan())), nf.Id(pos(getRightSpan()), "*"))); break; @@ -1284,12 +1284,12 @@ // Rule 9: FieldAccess ::= ClassName . super$sup . ErrorId // case 9: { - //#line 80 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 80 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 78 "x10/parser/MissingId.gi" ParsedName ClassName = (ParsedName) getRhsSym(1); //#line 78 "x10/parser/MissingId.gi" IToken sup = (IToken) getRhsIToken(3); - //#line 80 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 80 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(getRightSpan()), nf.Super(pos(getRhsFirstTokenIndex(3)), ClassName.toType()), nf.Id(pos(getRightSpan()), "*"))); break; @@ -1299,12 +1299,12 @@ // Rule 10: MethodInvocation ::= MethodPrimaryPrefix ( ArgumentListopt ) // case 10: { - //#line 87 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 87 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 85 "x10/parser/MissingId.gi" Object MethodPrimaryPrefix = (Object) getRhsSym(1); //#line 85 "x10/parser/MissingId.gi" List<Expr> ArgumentListopt = (List<Expr>) getRhsSym(3); - //#line 87 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 87 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" Expr Primary = (Expr) ((Object[]) MethodPrimaryPrefix)[0]; polyglot.lex.Identifier identifier = (polyglot.lex.Identifier) ((Object[]) MethodPrimaryPrefix)[1]; setResult(nf.Call(pos(), Primary, nf.Id(pos(), identifier.getIdentifier()), ArgumentListopt)); @@ -1315,12 +1315,12 @@ // Rule 11: MethodInvocation ::= MethodSuperPrefix ( ArgumentListopt ) // case 11: { - //#line 94 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 94 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 92 "x10/parser/MissingId.gi" polyglot.lex.Identifier MethodSuperPrefix = (polyglot.lex.Identifier) getRhsSym(1); //#line 92 "x10/parser/MissingId.gi" List<Expr> ArgumentListopt = (List<Expr>) getRhsSym(3); - //#line 94 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 94 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" polyglot.lex.Identifier identifier = MethodSuperPrefix; setResult(nf.Call(pos(), nf.Super(pos(getLeftSpan())), nf.Id(pos(), identifier.getIdentifier()), ArgumentListopt)); break; @@ -1330,12 +1330,12 @@ // Rule 12: MethodInvocation ::= MethodClassNameSuperPrefix ( ArgumentListopt ) // case 12: { - //#line 100 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 100 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 98 "x10/parser/MissingId.gi" Object MethodClassNameSuperPrefix = (Object) getRhsSym(1); //#line 98 "x10/parser/MissingId.gi" List<Expr> ArgumentListopt = (List<Expr>) getRhsSym(3); - //#line 100 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 100 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" ParsedName ClassName = (ParsedName) ((Object[]) MethodClassNameSuperPrefix)[0]; JPGPosition super_pos = (JPGPosition) ((Object[]) MethodClassNameSuperPrefix)[1]; polyglot.lex.Identifier identifier = (polyglot.lex.Identifier) ((Object[]) MethodClassNameSuperPrefix)[2]; @@ -1347,12 +1347,12 @@ // Rule 13: MethodPrimaryPrefix ::= Primary . ErrorId$ErrorId // case 13: { - //#line 109 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 109 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 107 "x10/parser/MissingId.gi" Expr Primary = (Expr) getRhsSym(1); //#line 107 "x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(3); - //#line 109 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 109 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" Object[] a = new Object[2]; a[0] = Primary; a[1] = id(getRhsFirstTokenIndex(3)); @@ -1364,10 +1364,10 @@ // Rule 14: MethodSuperPrefix ::= super . ErrorId$ErrorId // case 14: { - //#line 117 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 117 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 115 "x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(3); - //#line 117 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 117 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(id(getRhsFirstTokenIndex(3))); break; } @@ -1376,14 +1376,14 @@ // Rule 15: MethodClassNameSuperPrefix ::= ClassName . super$sup . ErrorId$ErrorId // case 15: { - //#line 122 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 122 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 120 "x10/parser/MissingId.gi" ParsedName ClassName = (ParsedName) getRhsSym(1); //#line 120 "x10/parser/MissingId.gi" IToken sup = (IToken) getRhsIToken(3); //#line 120 "x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(5); - //#line 122 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 122 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" Object[] a = new Object[3]; a[0] = ClassName; a[1] = pos(getRhsFirstTokenIndex(3)); @@ -1396,9 +1396,9 @@ // Rule 16: Modifiersopt ::= $Empty // case 16: { - //#line 1191 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1191 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1191 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1191 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new LinkedList<Modifier>()); break; } @@ -1407,12 +1407,12 @@ // Rule 17: Modifiersopt ::= Modifiersopt Modifier // case 17: { - //#line 1196 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1196 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1194 "x10/parser/x10.g" List<Modifier> Modifiersopt = (List<Modifier>) getRhsSym(1); //#line 1194 "x10/parser/x10.g" Modifier Modifier = (Modifier) getRhsSym(2); - //#line 1196 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1196 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" Modifiersopt.add(Modifier); break; } @@ -1421,9 +1421,9 @@ // Rule 18: Modifier ::= abstract // case 18: { - //#line 1202 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1202 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1202 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1202 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.ABSTRACT)); break; } @@ -1432,10 +1432,10 @@ // Rule 19: Modifier ::= Annotation // case 19: { - //#line 1207 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1207 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1205 "x10/parser/x10.g" AnnotationNode Annotation = (AnnotationNode) getRhsSym(1); - //#line 1207 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1207 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new AnnotationModifier(Annotation)); break; } @@ -1444,9 +1444,9 @@ // Rule 20: Modifier ::= atomic // case 20: { - //#line 1212 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1212 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1212 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1212 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.ATOMIC)); break; } @@ -1455,9 +1455,9 @@ // Rule 21: Modifier ::= final // case 21: { - //#line 1222 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1222 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1222 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1222 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.FINAL)); break; } @@ -1466,9 +1466,9 @@ // Rule 22: Modifier ::= native // case 22: { - //#line 1232 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1232 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1232 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1232 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.NATIVE)); break; } @@ -1477,9 +1477,9 @@ // Rule 23: Modifier ::= private // case 23: { - //#line 1237 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1237 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1237 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1237 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.PRIVATE)); break; } @@ -1488,9 +1488,9 @@ // Rule 24: Modifier ::= protected // case 24: { - //#line 1242 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1242 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1242 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1242 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.PROTECTED)); break; } @@ -1499,9 +1499,9 @@ // Rule 25: Modifier ::= public // case 25: { - //#line 1247 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1247 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1247 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1247 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.PUBLIC)); break; } @@ -1510,9 +1510,9 @@ // Rule 26: Modifier ::= static // case 26: { - //#line 1252 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1252 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1252 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1252 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.STATIC)); break; } @@ -1521,9 +1521,9 @@ // Rule 27: Modifier ::= transient // case 27: { - //#line 1257 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1257 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1257 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1257 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.TRANSIENT)); break; } @@ -1532,9 +1532,9 @@ // Rule 28: Modifier ::= clocked // case 28: { - //#line 1262 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1262 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1262 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1262 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.CLOCKED)); break; } @@ -1543,12 +1543,12 @@ // Rule 30: MethodModifiersopt ::= MethodModifiersopt property$property // case 30: { - //#line 1269 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1269 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1267 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); //#line 1267 "x10/parser/x10.g" IToken property = (IToken) getRhsIToken(2); - //#line 1269 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1269 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" MethodModifiersopt.add(new FlagModifier(pos(getRhsFirstTokenIndex(2)), FlagModifier.PROPERTY)); break; } @@ -1557,12 +1557,12 @@ // Rule 31: MethodModifiersopt ::= MethodModifiersopt Modifier // case 31: { - //#line 1274 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1274 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1272 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); //#line 1272 "x10/parser/x10.g" Modifier Modifier = (Modifier) getRhsSym(2); - //#line 1274 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1274 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" MethodModifiersopt.add(Modifier); break; } @@ -1571,7 +1571,7 @@ // Rule 32: TypeDefDeclaration ::= Modifiersopt type Identifier TypeParametersopt FormalParametersopt WhereClauseopt = Type ; // case 32: { - //#line 1280 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1280 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1278 "x10/parser/x10.g" List<Modifier> Modifiersopt = (List<Modifier>) getRhsSym(1); //#line 1278 "x10/parser/x10.g" @@ -1584,7 +1584,7 @@ DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); //#line 1278 "x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(8); - //#line 1280 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1280 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkTypeDefModifiers(Modifiersopt); FlagsNode f = extractFlags(modifiers); List<AnnotationNode> annotations = extractAnnotations(modifiers); @@ -1607,10 +1607,10 @@ // Rule 33: Properties ::= ( PropertyList ) // case 33: { - //#line 1300 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1300 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1298 "x10/parser/x10.g" List<PropertyDecl> PropertyList = (List<PropertyDecl>) getRhsSym(2); - //#line 1300 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1300 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" setResult(PropertyList); break; } @@ -1618,10 +1618,10 @@ // Rule 34: PropertyList ::= Property // case 34: { - //#line 1305 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1305 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1303 "x10/parser/x10.g" PropertyDecl Property = (PropertyDecl) getRhsSym(1); - //#line 1305 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1305 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" List<PropertyDecl> l = new TypedList<PropertyDecl>(new LinkedList<PropertyDecl>(), PropertyDecl.class, false); l.add(Property); setResult(l); @@ -1632,12 +1632,12 @@ // Rule 35: PropertyList ::= PropertyList , Property // case 35: { - //#line 1312 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1312 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1310 "x10/parser/x10.g" List<PropertyDecl> PropertyList = (List<PropertyDecl>) getRhsSym(1); //#line 1310 "x10/parser/x10.g" PropertyDecl Property = (PropertyDecl) getRhsSym(3); - //#line 1312 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1312 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" PropertyList.add(Property); break; } @@ -1646,14 +1646,14 @@ // Rule 36: Property ::= Annotationsopt Identifier ResultType // case 36: { - //#line 1319 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1319 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1317 "x10/parser/x10.g" List<AnnotationNode> Annotationsopt = (List<AnnotationNode>) getRhsSym(1); //#line 1317 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(2); //#line 1317 "x10/parser/x10.g" TypeNode ResultType = (TypeNode) getRhsSym(3); - //#line 1319 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1319 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" List<AnnotationNode> annotations = extractAnnotations(Annotationsopt); PropertyDecl cd = nf.PropertyDecl(pos(), nf.FlagsNode(pos(), Flags.PUBLIC.Final()), ResultType, Identifier); cd = (PropertyDecl) ((X10Ext) cd.ext()).annotations(annotations); @@ -1665,7 +1665,7 @@ // Rule 37: MethodDeclaration ::= MethodModifiersopt def Identifier TypeParametersopt FormalParameters WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 37: { - //#line 1328 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1328 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1326 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); //#line 1326 "x10/parser/x10.g" @@ -1682,7 +1682,7 @@ TypeNode Offersopt = (TypeNode) getRhsSym(8); //#line 1326 "x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(9); - //#line 1328 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1328 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); ProcedureDecl pd; if (Identifier.id().toString().equals("this")) { @@ -1719,7 +1719,7 @@ // Rule 38: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) BinOp ( FormalParameter$fp2 ) WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 38: { - //#line 1361 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1361 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1359 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); //#line 1359 "x10/parser/x10.g" @@ -1738,7 +1738,7 @@ TypeNode Offersopt = (TypeNode) getRhsSym(13); //#line 1359 "x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(14); - //#line 1361 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1361 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); Name opName = X10Binary_c.binaryMethodName(BinOp); if (opName == null) { @@ -1769,7 +1769,7 @@ // Rule 39: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt PrefixOp ( FormalParameter$fp2 ) WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 39: { - //#line 1388 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1388 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1386 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); //#line 1386 "x10/parser/x10.g" @@ -1786,7 +1786,7 @@ TypeNode Offersopt = (TypeNode) getRhsSym(10); //#line 1386 "x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(11); - //#line 1388 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1388 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); Name opName = X10Unary_c.unaryMethodName(PrefixOp); if (opName == null) { @@ -1817,7 +1817,7 @@ // Rule 40: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt this BinOp ( FormalParameter$fp2 ) WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 40: { - //#line 1415 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1415 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1413 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); //#line 1413 "x10/parser/x10.g" @@ -1834,7 +1834,7 @@ TypeNode Offersopt = (TypeNode) getRhsSym(11); //#line 1413 "x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(12); - //#line 1415 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1415 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); Name opName = X10Binary_c.binaryMethodName(BinOp); if (opName == null) { @@ -1865,7 +1865,7 @@ // Rule 41: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) BinOp this WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 41: { - //#line 1442 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1442 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1440 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); //#line 1440 "x10/parser/x10.g" @@ -1882,7 +1882,7 @@ TypeNode Offersopt = (TypeNode) getRhsSym(11); //#line 1440 "x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(12); - //#line 1442 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1442 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); Name opName = X10Binary_c.invBinaryMethodName(BinOp); if (opName == null) { @@ -1913,7 +1913,7 @@ // Rule 42: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt PrefixOp this WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 42: { - //#line 1469 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1469 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1467 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); //#line 1467 "x10/parser/x10.g" @@ -1928,7 +1928,7 @@ TypeNode Offersopt = (TypeNode) getRhsSym(8); //#line 1467 "x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(9); - //#line 1469 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1469 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); Name opName = X10Unary_c.unaryMethodName(PrefixOp); if (opName == null) { @@ -1959,7 +1959,7 @@ // Rule 43: MethodDeclaration ::= MethodModifiersopt operator this TypeParametersopt FormalParameters WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 43: { - //#line 1496 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1496 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1494 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); //#line 1494 "x10/parser/x10.g" @@ -1974,7 +1974,7 @@ TypeNode Offersopt = (TypeNode) getRhsSym(8); //#line 1494 "x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(9); - //#line 1496 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1496 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); MethodDecl md = nf.X10MethodDecl(pos(), extractFlags(modifiers), @@ -2000,7 +2000,7 @@ // Rule 44: MethodDeclaration ::= MethodModifiersopt operator this TypeParametersopt FormalParameters = ( FormalParameter$fp2 ) WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 44: { - //#line 1518 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1518 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1516 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); //#line 1516 "x10/parser/x10.g" @@ -2017,7 +2017,7 @@ TypeNode Offersopt = (TypeNode) getRhsSym(12); //#line 1516 "x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(13); - //#line 1518 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1518 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); MethodDecl md = nf.X10MethodDecl(pos(), extractFlags(modifiers), @@ -2043,7 +2043,7 @@ // Rule 45: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) as Type WhereClauseopt Offersopt MethodBody // case 45: { - //#line 1540 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1540 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1538 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); //#line 1538 "x10/parser/x10.g" @@ -2058,7 +2058,7 @@ TypeNode Offersopt = (TypeNode) getRhsSym(10); //#line 1538 "x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(11); - //#line 1540 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1540 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); MethodDecl md = nf.X10MethodDecl(pos(), extractFlags(modifiers), @@ -2084,7 +2084,7 @@ // Rule 46: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) as ? WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 46: { - //#line 1562 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1562 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1560 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); //#line 1560 "x10/parser/x10.g" @@ -2099,7 +2099,7 @@ TypeNode Offersopt = (TypeNode) getRhsSym(11); //#line 1560 "x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(12); - //#line 1562 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1562 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); MethodDecl md = nf.X10MethodDecl(pos(), extractFlags(modifiers), @@ -2125,7 +2125,7 @@ // Rule 47: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 47: { - //#line 1584 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1584 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1582 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); //#line 1582 "x10/parser/x10.g" @@ -2140,7 +2140,7 @@ TypeNode Offersopt = (TypeNode) getRhsSym(9); //#line 1582 "x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(10); - //#line 1584 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1584 "lpg_parser/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); MethodDecl md = nf.X10MethodDecl(pos(), ... [truncated message content] |
From: <vj...@us...> - 2010-10-11 11:27:01
|
Revision: 17236 http://x10.svn.sourceforge.net/x10/?rev=17236&view=rev Author: vj0 Date: 2010-10-11 11:26:53 +0000 (Mon, 11 Oct 2010) Log Message: ----------- Fix regressions in tests due to r17235. (change e+ string to "" + e + string.) Modified Paths: -------------- trunk/x10.compiler/src/x10/types/X10TypeMixin.java trunk/x10.compiler/src/x10/types/constraints/TypeConstraint.java trunk/x10.dist/samples/FRASimpleDist.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 trunk/x10.tests/examples/Constructs/Array/ArrayAccessWithMismatchingPointRank_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Array/ArrayMap.x10 trunk/x10.tests/examples/Constructs/Array/ArrayReduce.x10 trunk/x10.tests/examples/Constructs/Array/ArrayScan.x10 trunk/x10.tests/examples/Constructs/Array/TestArray.x10 trunk/x10.tests/examples/Constructs/At/AtFieldAccess.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest10a.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest12.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest13.x10 trunk/x10.tests/examples/Constructs/DepType/CovariantReturnFromAnonymousClass.x10 trunk/x10.tests/examples/Constructs/Future/FutureTest4_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Generics/GenericInference1_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Init/InitNonNullable_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Point/ArrayPointBinding_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Point/PointComparison1.x10 Modified: trunk/x10.compiler/src/x10/types/X10TypeMixin.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2010-10-11 11:26:53 UTC (rev 17236) @@ -1266,6 +1266,26 @@ return null; } + /** + * Determine if xp1 is more specific than xp2 given some (unknown) current call c to a method m or a constructor + * for a class or interface Q (in the given context). (Note that xp1 and xp2 may not be function definitions since + * no method resolution is not necessary for function definitions.) + * + * <p> We may assume that xp1 and xp2 are instantiations of underlying (possibly generic) procedure definitions, + * pd1 and pd2 (respectively) that lie in the applicable and available method call set for c. + * + * <p> The determination is done as follows. First, if xp1 is an instance of a static method on a class C1, and xp2 + * is an instance of a static method on a class C2, and C1 is distinct from C2 but descends from it, + * Otherwise we examine pd1 and pd2 -- the underlying possibly generic method definitions. Now pd1 is more + * specific than pd2 if a call can be made to pd2 with the information available about pd1's arguments. As usual, + * type parameters of pd2 (if any) are permitted to be instantiated during this process. + * @param ct -- represents the container on which both xp1 and xp2 are available. Ignored now. TODO: Remove the machinery + * introduced to permit ct to be available in this call to moreSpecificImpl. + * @param xp1 -- the instantiated procedure definition. + * @param xp2 + * @param context + * @return + */ public static boolean moreSpecificImpl(Type ct, ProcedureInstance<?> xp1, ProcedureInstance<?> xp2, Context context) { X10TypeSystem ts = (X10TypeSystem) xp1.typeSystem(); Type ct1 = xp2 instanceof MemberInstance<?> ? ((MemberInstance<?>) xp1).container() : null; @@ -1288,18 +1308,28 @@ if (descends && ! ts.hasSameClassDef(t1, t2) && flags1.isStatic() && flags2.isStatic()) { return true; } - boolean java = javaStyleMoreSpecificMethod(xp1, xp2, (X10Context) context, ts, ct1, t1, t2,descends); + // For now (10/10/10) we check using both styles and mark the cases in which results are different + // as a diagnostic output for the compiler. + boolean java = javaStyleMoreSpecificMethod(xp1, xp2, (X10Context) context, ct1, t1, t2,descends); boolean old = oldStyleMoreSpecificMethod(xp1, xp2, (X10Context) context, ts, ct1, t1, t2, descends); if (java != old) { - System.out.println("Discrepency in moreSpecific computation for:" + System.out.println("(Warning) Please check definitions p1 and p2." + + ((java && ! old) ? "p1 is now more specific than p2; it was not in 2.0.6." + : "p1 is now not more specific than p2; it was in 2.0.6.") + "\n\t: p1: " + xp1 + "\n\t: at " + xp1.position() + "\n\t: p2: " + xp2 - + "\n\t: at " + xp2.position() - + "\n\t: java/old=" + java + "/" + old); + + "\n\t: at " + xp2.position()); } + // Change this to return old to re-enable 2.0.6 style computation. return java; } + // This is taken from the 2.0.6 implementation. + // This contains logic for pre-generic Java. One determines + // that a method MI1 is more specific than MI2 if each argument of + // MI1 is a subtype of the corresponding argument of MI2. That is, + // MI2 is taken as the instance of the method definition for the given + // call. Hence no type inference is done. private static boolean oldStyleMoreSpecificMethod( ProcedureInstance<?> xp1, ProcedureInstance<?> xp2, Context context, X10TypeSystem ts, Type ct1, Type t1, Type t2, @@ -1343,69 +1373,83 @@ return true; } + /** + * + * @param xp1 -- the first procedure instance + * @param xp2 -- the second procedure instance + * @param context -- the context for the original call + * @param ts + * @param ct1 + * @param t1 -- base type of ct1 + * @param t2 -- base type of the container of xp2. + * @param descends -- does t1 descend from t2? + * @return + */ private static boolean javaStyleMoreSpecificMethod( ProcedureInstance<?> xp1, ProcedureInstance<?> xp2, - X10Context context, X10TypeSystem ts, Type ct1, Type t1, Type t2, + X10Context context, Type ct1, Type t1, Type t2, boolean descends) { assert xp1 != null; assert xp2 != null; + assert context != null; + X10TypeSystem ts = (X10TypeSystem) context.typeSystem(); List<Type> typeArgs = Collections.<Type>emptyList(); try { if (xp2 instanceof X10MethodInstance) { - // For X10 2.1, instance generic methods - // are not supported. Hence ThisMI is the same as MI. - - // Static methods cannot refer to class type parameters, hence - // the only type instantiations introduced in MI are for - // method type parameters. Also, static methods cannot refer to this - // hence there are no this constraints to transfer over. - // Therefore ThisMI is the same as OrigMI. + // Both xp1 and xp2 should be X10MethodInstance's X10MethodInstance xmi2 = (X10MethodInstance) xp2; + X10MethodInstance origMI2 = (X10MethodInstance) xmi2.origMI(); + assert origMI2 != null; - X10MethodInstance thisMI2 = // xmi2.flags().isStatic() ? - (X10MethodInstance) xmi2.origMI(); - //: xmi2; - assert thisMI2 != null; - if (! (xp1 instanceof X10MethodInstance)) return false; X10MethodInstance xmi1 = (X10MethodInstance) xp1; - X10MethodInstance thisMI1 = // xmi1.flags().isStatic() ? - (X10MethodInstance)xmi1.origMI(); - //: xmi1; - if (thisMI1 == null) - assert thisMI1 != null; - //typeArgs = thisMI1.typeParameters(); - List<Type> argTypes = new ArrayList<Type>(thisMI1.formalTypes()); + X10MethodInstance origMI1 = (X10MethodInstance)xmi1.origMI(); + assert origMI1 != null; + + // Now determine that a call can be made to thisMI2 using the + // argument list obtained from thisMI1. If not, return false. + List<Type> argTypes = new ArrayList<Type>(origMI1.formalTypes()); if (xp2.formalTypes().size() != argTypes.size()) return false; + // TODO: Establish that the current context is aware of the method + // guard for xmi1. + if (typeArgs.isEmpty() || typeArgs.size() == xmi2.typeParameters().size()) { MethodInstance r = Matcher.inferAndCheckAndInstantiate(context, - thisMI2, ct1, typeArgs, argTypes, xp2.position()); + origMI2, ct1, typeArgs, argTypes, xp2.position()); if (r == null) return false; } } else if (xp2 instanceof X10ConstructorInstance) { + // Both xp1 and xp2 should be X10ConstructorInstance's X10ConstructorInstance xmi2 = (X10ConstructorInstance) xp2; + X10ConstructorInstance origMI2 = (X10ConstructorInstance) xmi2.origMI(); + assert origMI2 != null; + if (! (xp1 instanceof X10ConstructorInstance)) return false; - X10ConstructorInstance origMI1 = (X10ConstructorInstance) ((X10ConstructorInstance) xp1).origMI(); + X10ConstructorInstance xmi1 = (X10ConstructorInstance) xp1; + X10ConstructorInstance origMI1 = (X10ConstructorInstance) xmi1.origMI(); + assert origMI1 != null; List<Type> argTypes = new ArrayList<Type>(origMI1.formalTypes()); if (xp2.formalTypes().size() != argTypes.size()) return false; - X10ConstructorInstance origMI2 = (X10ConstructorInstance) xmi2.origMI(); + // TODO: Figure out how to do type inference. X10ConstructorInstance r = Matcher.inferAndCheckAndInstantiate( context, origMI2, ct1, typeArgs, argTypes, xp2.position()); if (r == null) return false; } else { - System.out.println("Unhandled MoreSpecificMatcher case: " + xp2 + " class " + xp2.getClass()); - assert false; + // Should not happen. + System.out.println("Diagnostic. Unhandled MoreSpecificMatcher case: " + xp2 + " class " + xp2.getClass()); + assert false; } } catch (SemanticException z) { return false; } - + // I have kept the logic below from 2.0.6 for now. + // TODO: Determine whether this should stay or not. // If the formal types are all equal, check the containers; otherwise p1 is more specific. for (int i = 0; i < xp1.formalTypes().size(); i++) { Type f1 = xp1.formalTypes().get(i); Modified: trunk/x10.compiler/src/x10/types/constraints/TypeConstraint.java =================================================================== --- trunk/x10.compiler/src/x10/types/constraints/TypeConstraint.java 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.compiler/src/x10/types/constraints/TypeConstraint.java 2010-10-11 11:26:53 UTC (rev 17236) @@ -489,7 +489,7 @@ } } - public static <PI extends X10ProcedureInstance<?>> void inferTypeArguments(X10Context context, PI me, TypeConstraint tenv, + private static <PI extends X10ProcedureInstance<?>> void inferTypeArguments(X10Context context, PI me, TypeConstraint tenv, ParameterType[] X, Type[] Y, Type[] Z, XVar[] x, XVar[] y, XVar ythis, XVar xthis) throws SemanticException { X10TypeSystem xts = (X10TypeSystem) me.typeSystem(); @@ -579,7 +579,7 @@ else if (lowerBound != null) Y[i] = lowerBound; else { - System.err.println("Diagnostic: No constraint on type parameters. " + System.err.println("(Diagnostic) No constraint on type parameters. " + "Returning Any instead of throwing an exception." + (X[i] != null ? "\n\t: Position: " + X[i].position().toString() : "")); Modified: trunk/x10.dist/samples/FRASimpleDist.x10 =================================================================== --- trunk/x10.dist/samples/FRASimpleDist.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.dist/samples/FRASimpleDist.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -114,7 +114,7 @@ // print statistics val GUPs = (cpuTime > 0.0 ? 1.0 / cpuTime : -1.0) * num_updates / 1e9; Console.OUT.println("CPU time used = "+cpuTime+" seconds"); - Console.OUT.println(GUPs+" Billion(10^9) Updates per second (GUP/s)"); + Console.OUT.println("" + GUPs+" Billion(10^9) Updates per second (GUP/s)"); // repeat for testing. randomAccessUpdate(num_updates, logLocalTableSize, tables); Modified: trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 =================================================================== --- trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -54,14 +54,14 @@ // Needs to be done properly and integrated into the Dist/Region/DistArray // class library in x10.array. static def blockIt(d:Dist(2), numProcs:int):Rail[Iterable[Point(2)]] { - val blocks = Rail.make[x10.util.ArrayList[Point{self.rank==d.rank}]](numProcs, - (int) => new x10.util.ArrayList[Point{self.rank==d.rank}]()); + val blocks = Rail.make(numProcs, // + (int) => new x10.util.ArrayList[Point{self.rank==2}]()); var modulo:int = 0; for (p in d) { blocks(modulo).add(p); modulo = (modulo + 1) % numProcs; } - val ans = Rail.make[Iterable[Point(2)]](numProcs, (i:Int) => blocks(i)); + val ans = Rail.make[Iterable[Point(2)]](numProcs, (i:Int) => blocks(i)); // [Iterable[Point(2)]] return ans; } Modified: trunk/x10.tests/examples/Constructs/Array/ArrayAccessWithMismatchingPointRank_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayAccessWithMismatchingPointRank_MustFailCompile.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/Array/ArrayAccessWithMismatchingPointRank_MustFailCompile.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -26,8 +26,8 @@ val ia = new Array[int](e, (Point)=>0); // will infer ia:Array[int](1) val p = [1,1] as Point; // will infer p:Point(2) - val p1 = [1] as Point; - a(ia(p1)); // ok + val p1 = [1] as Point; + a(ia(p1)); // ok a(ia(p)); // ERR should fail at compile time because of mismatching rank. return true; Modified: trunk/x10.tests/examples/Constructs/Array/ArrayMap.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayMap.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/Array/ArrayMap.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -28,7 +28,7 @@ val a: DistArray[double](dist) = DistArray.make[double](dist, (p:Point)=>p(0) as double); for (pt:Point(1) in a) { val x = (at (a.dist(pt)) Future.make[double](()=>a(pt)))(); - out.print(x + " "); + out.print("" + x + " "); } out.println(); @@ -36,7 +36,7 @@ val b = a.map((a:double)=>1.5*a) as DistArray[double](dist); for (pt:Point(1) in b) { val x = (at (b.dist(pt)) Future.make[double](()=>b(pt)))(); - out.print(x + " "); + out.print("" + x + " "); } out.println(); Modified: trunk/x10.tests/examples/Constructs/Array/ArrayReduce.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayReduce.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/Array/ArrayReduce.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -31,7 +31,7 @@ val a = DistArray.make[double](dist, (p:Point)=>p(0) as double); for (pt:Point(1) in a) { val x = (at (a.dist(pt)) Future.make[double](()=>a(pt)))(); - out.print(x + " "); + out.print("" + x + " "); } out.println(); Modified: trunk/x10.tests/examples/Constructs/Array/ArrayScan.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayScan.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/Array/ArrayScan.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -44,7 +44,7 @@ val aa = a as Array[double](1); out.println("--- " + msg); for (pt:Point(1) in aa) - out.print(aa(pt) + " "); + out.print("" + aa(pt) + " "); out.println(); } Modified: trunk/x10.tests/examples/Constructs/Array/TestArray.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/TestArray.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/Array/TestArray.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -114,7 +114,7 @@ (o as Grid).pr(rank-1); } else { val d = (o as Box[double]).value; - out.print((d as int)+""); + out.print("" + (d as int)); } if (rank==1) Modified: trunk/x10.tests/examples/Constructs/At/AtFieldAccess.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/At/AtFieldAccess.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/At/AtFieldAccess.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -18,10 +18,10 @@ var t: T; public def run():boolean { - var Second:Place = Place.FIRST_PLACE.next(); - var r: Region = 0..0; + val Second = Place.FIRST_PLACE.next(); + val r = 0..0; val D = r->Second; - for (p: Point in D.region) { + for (p in D.region) { t = at (D(p)) new T(); } val tt = this.t; Modified: trunk/x10.tests/examples/Constructs/Clock/ClockTest10a.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockTest10a.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/Clock/ClockTest10a.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -59,28 +59,28 @@ def taskA(val a: Clock): void = { for ([k]:Point(1) in 1..N) { varA(ph(k)) = k; - x10.io.Console.OUT.println(k + " A producing " + varA(ph(k))); + x10.io.Console.OUT.println("" + k + " A producing " + varA(ph(k))); next; } } def taskB(val a: Clock, val b: Clock): void = { for ([k]:Point(1) in 1..N) { varB(ph(k)) = varA(ph(k-1))+varA(ph(k-1)); - x10.io.Console.OUT.println(k + " B consuming oldA producing " + varB(ph(k))); + x10.io.Console.OUT.println("" + k + " B consuming oldA producing " + varB(ph(k))); next; } } def taskC(val a: Clock, val c: Clock): void = { for ([k]:Point(1) in 1..N) { varC(ph(k)) = varA(ph(k-1))*varA(ph(k-1)); - x10.io.Console.OUT.println(k+" C consuming oldA producing "+ varC(ph(k))); + x10.io.Console.OUT.println("" + k+" C consuming oldA producing "+ varC(ph(k))); next; } } def taskD(val b: Clock, val c: Clock): void = { for ([k]:Point(1) in 1..N) { varD(ph(k)) = varB(ph(k-1))+varC(ph(k-1))+10; - x10.io.Console.OUT.println(k+" D consuming oldC producing "+varD(ph(k))); + x10.io.Console.OUT.println("" + k+" D consuming oldC producing "+varD(ph(k))); var n: int = k-pipeDepth; chk(!(k>pipeDepth) || varD(ph(k)) == n+n+n*n+10); next; @@ -89,7 +89,7 @@ def taskE(val c: Clock): void = { for ([k]:Point(1) in 1..N) { varE(ph(k)) = varC(ph(k-1))*7; - x10.io.Console.OUT.println(k+" E consuming oldC producing "+varE(ph(k))); + x10.io.Console.OUT.println("" + k+" E consuming oldC producing "+varE(ph(k))); var n: int = k-pipeDepth; chk(!(k>pipeDepth) || varE(ph(k)) == n*n*7); next; Modified: trunk/x10.tests/examples/Constructs/Clock/ClockTest12.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockTest12.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/Clock/ClockTest12.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -37,13 +37,13 @@ var tmp: int; Activity.sleep(1000); atomic tmp = phase; - x10.io.Console.OUT.println(id+" observed current phase = "+tmp); + x10.io.Console.OUT.println(""+id+" observed current phase = "+tmp); chk(tmp == 0); c.resume(); // 1st next advances in activity #2 Activity.sleep(1000); c.resume(); // not an error, still in phase 0 when (phase > 0) { - x10.io.Console.OUT.println(id+" observed future phase = "+phase); + x10.io.Console.OUT.println(""+id+" observed future phase = "+phase); chk(phase == 1); Activity.sleep(5000); chk(phase == 1); // cannot go beyond next phase @@ -51,13 +51,13 @@ next; Activity.sleep(1000); atomic tmp = phase; - x10.io.Console.OUT.println(id+" observed current phase = "+tmp); + x10.io.Console.OUT.println(""+id+" observed current phase = "+tmp); chk(tmp == 1); c.resume(); // 2nd next advances in activity #2 c.resume(); // not an error still in phase 1 c.resume(); when (phase>1) { - x10.io.Console.OUT.println(id+" observed future phase = "+phase); + x10.io.Console.OUT.println(""+id+" observed future phase = "+phase); chk(phase == 2); Activity.sleep(5000); chk(phase == 2); // cannot go beyond next phase Modified: trunk/x10.tests/examples/Constructs/Clock/ClockTest13.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockTest13.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/Clock/ClockTest13.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -101,17 +101,17 @@ def taskA(val a: Clock): void = { for ([k] in 1..N) { - x10.io.Console.OUT.println(k+" A new phase"); + x10.io.Console.OUT.println(""+k+" A new phase"); atomic phaseA++; - x10.io.Console.OUT.println(k+" A resuming a"); + x10.io.Console.OUT.println(""+k+" A resuming a"); a.resume(); if (k <= M-chainLength) { - x10.io.Console.OUT.println(k+" Waiting for forward phase shift"); + x10.io.Console.OUT.println(""+k+" Waiting for forward phase shift"); when (phaseB == phaseA+1 && phaseC == phaseB+1 && phaseD == phaseC+1) { - x10.io.Console.OUT.println(k+" Max forward phase shift reached"); + x10.io.Console.OUT.println(""+k+" Max forward phase shift reached"); } } next; @@ -119,44 +119,44 @@ } def taskB(val a: Clock, val b: Clock): void = { for ([k] in 1..N) { - x10.io.Console.OUT.println(k+" B new phase"); + x10.io.Console.OUT.println(""+k+" B new phase"); atomic phaseB++; - x10.io.Console.OUT.println(k+" B resuming a"); + x10.io.Console.OUT.println(""+k+" B resuming a"); a.resume(); - x10.io.Console.OUT.println(k+" B resuming b"); + x10.io.Console.OUT.println(""+k+" B resuming b"); b.resume(); - x10.io.Console.OUT.println(k+" B before next"); + x10.io.Console.OUT.println(""+k+" B before next"); next; } } def taskC(val b: Clock, val c: Clock): void = { for ([k] in 1..N) { - x10.io.Console.OUT.println(k+" C new phase"); + x10.io.Console.OUT.println(""+k+" C new phase"); atomic phaseC++; - x10.io.Console.OUT.println(k+" C resuming b"); + x10.io.Console.OUT.println(""+k+" C resuming b"); b.resume(); - x10.io.Console.OUT.println(k+" C resuming c"); + x10.io.Console.OUT.println(""+k+" C resuming c"); c.resume(); - x10.io.Console.OUT.println(k+" C before next"); + x10.io.Console.OUT.println(""+k+" C before next"); next; } } def taskD(val c: Clock): void = { for ([k] in 1..N) { - x10.io.Console.OUT.println(k+" D new phase"); + x10.io.Console.OUT.println(""+k+" D new phase"); atomic phaseD++; - x10.io.Console.OUT.println(k+" D resuming c"); + x10.io.Console.OUT.println(""+k+" D resuming c"); c.resume(); if (k >= M && k <= N-chainLength) { - x10.io.Console.OUT.println(k+" Waiting for reverse phase shift"); + x10.io.Console.OUT.println(""+k+" Waiting for reverse phase shift"); when (phaseC == phaseD+1 && phaseB == phaseC+1 && phaseA == phaseB+1) { - x10.io.Console.OUT.println(k+" Max reverse phase shift reached"); + x10.io.Console.OUT.println(""+k+" Max reverse phase shift reached"); } } - x10.io.Console.OUT.println(k+" D before next"); + x10.io.Console.OUT.println(""+k+" D before next"); next; } } Modified: trunk/x10.tests/examples/Constructs/DepType/CovariantReturnFromAnonymousClass.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/CovariantReturnFromAnonymousClass.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/DepType/CovariantReturnFromAnonymousClass.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -30,7 +30,7 @@ } public def run(): boolean = { - x10.io.Console.OUT.println((new I() { + x10.io.Console.OUT.println("" + (new I() { public def test(): void = { x10.io.Console.OUT.println("Inner Class test invoked."); } Modified: trunk/x10.tests/examples/Constructs/Future/FutureTest4_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Future/FutureTest4_MustFailCompile.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/Future/FutureTest4_MustFailCompile.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -28,7 +28,7 @@ * testing free variables in future expression */ public def run(): boolean = { - val A = DistArray.make[int](Dist.makeBlock([0..N-1, 0..N-1]), + val A = DistArray.make[int](Dist.makeBlock((0..N-1)*(0..N-1)), ([i,j]: Point): int => N*i+j); var x: int=0; var s: int=0; Modified: trunk/x10.tests/examples/Constructs/Generics/GenericInference1_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Generics/GenericInference1_MustFailCompile.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/Generics/GenericInference1_MustFailCompile.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -13,7 +13,7 @@ /** - * A call to a polymorphic method, closure, or constructor may omit + * A call to a polymorphic method, closure, or staticructor may omit * the explicit type arguments. If the method has a type parameter T, * the type argument corresponding to T is inferred to be the least * common ancestor of the types of any formal parameters of type T. @@ -23,11 +23,11 @@ public class GenericInference1_MustFailCompile extends GenericTest { - class V {const name = "V";}; - class W extends V {const name = "W";} - class X extends V {const name = "X";}; - class Y extends X {const name = "Y";}; - class Z extends X {const name = "Z";}; + class V {static name = "V";}; + class W extends V {static name = "W";} + class X extends V {static name = "X";}; + class Y extends X {static name = "Y";}; + class Z extends X {static name = "Z";}; def m[T](){T<:X} = T.name; Modified: trunk/x10.tests/examples/Constructs/Init/InitNonNullable_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Init/InitNonNullable_MustFailCompile.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/Init/InitNonNullable_MustFailCompile.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -49,10 +49,10 @@ chk(bna.val(9).data == 19); var tmp7: Node = (bna.val(9).next) as Node; chk(bna.val(9).next.data == 19); - val A: Array[Node] = new Array[Node]([0..9]->here) as Array[Node]; - var tmp8: Node = (A(2)) as Node; + val A <: Array[Node] = new Array[Node](0..9, (p:Point(1))=>new Node()); + var tmp8 = A(2); chk(A(2).data == 19); - var tmp9: Node = (A(2).next) as Node; + var tmp9 = A(2).next; chk(A(2).next.data == 19); return true; } @@ -74,6 +74,6 @@ } static class BoxedNodeArray { - public var val: Array[Node]; + public var val: Array[Node](1); } } Modified: trunk/x10.tests/examples/Constructs/Point/ArrayPointBinding_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Point/ArrayPointBinding_MustFailCompile.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/Point/ArrayPointBinding_MustFailCompile.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -21,7 +21,7 @@ public def run(): boolean = { - p[i,j]: Rail[Point] = new Rail[Point](1); + p[i,j]: Array[Point] = new Array[Point](1); p(0) = [1,2]; return (i == 1 && j == 2); Modified: trunk/x10.tests/examples/Constructs/Point/PointComparison1.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Point/PointComparison1.x10 2010-10-11 02:44:54 UTC (rev 17235) +++ trunk/x10.tests/examples/Constructs/Point/PointComparison1.x10 2010-10-11 11:26:53 UTC (rev 17236) @@ -20,11 +20,11 @@ class PointComparison1 extends TestPoint { def comp(a: Point, b: Point) {a.rank==b.rank} { - pr(a + "> " + b + " " + (a > b)); - pr(a + "< " + b + " " + (a < b)); - pr(a + ">=" + b + " " + (a >= b)); - pr(a + "<=" + b + " " + (a <= b)); - pr(a + ".equals" + b + " " + (a.equals(b))); + pr(""+ a+ "> " + b + " " + (a > b)); + pr(""+ a+ "< " + b + " " + (a < b)); + pr(""+ a+ ">=" + b + " " + (a >= b)); + pr(""+ a+ "<=" + b + " " + (a <= b)); + pr(""+ a+ ".equals" + b + " " + (a.equals(b))); } public def run() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-10-12 17:12:12
|
Revision: 17306 http://x10.svn.sourceforge.net/x10/?rev=17306&view=rev Author: ipeshansky Date: 2010-10-12 17:12:05 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Fix XTENLANG-1908. Avoid synthesizing expressions for "hidden" XFields. Rename fake "here" field to "$$here". Change Synthesizer.makeExpr(*) methods to handle null gracefully (allows returning null to bail out of a clause). Make XField.hidden private and add an accessor. Fix XPromise_c.dump() to propagate the "hidden" bit on XFields (patch from Vijay). Add abstract equals() and hashCode() to XTerm to ensure the subclasses override them. Remove unused XTypeTranslator.transClassType(). Various minor cleanup and whitespace changes. Modified Paths: -------------- trunk/x10.compiler/src/x10/types/XTypeTranslator.java trunk/x10.compiler/src/x10/types/checker/PlaceChecker.java trunk/x10.compiler/src/x10/util/Synthesizer.java trunk/x10.constraints/src/x10/constraint/XField.java trunk/x10.constraints/src/x10/constraint/XPromise_c.java trunk/x10.constraints/src/x10/constraint/XTerm.java Modified: trunk/x10.compiler/src/x10/types/XTypeTranslator.java =================================================================== --- trunk/x10.compiler/src/x10/types/XTypeTranslator.java 2010-10-12 16:59:28 UTC (rev 17305) +++ trunk/x10.compiler/src/x10/types/XTypeTranslator.java 2010-10-12 17:12:05 UTC (rev 17306) @@ -139,10 +139,10 @@ return trans(new CConstraint(), target, fi, t); } - Object fakeKey = new Object(); + public static final Object FAKE_KEY = new Object(); public XTerm transFakeField(CConstraint c, XTerm target, String name) { //XName field = XTerms.makeName(fi.def(), Types.get(fi.def().container()) + "#" + fi.name().toString()); - XName field = XTerms.makeName(fakeKey, name); + XName field = XTerms.makeName(FAKE_KEY, name); return XTerms.makeFakeField((XVar) target, field); } public XTerm trans(CConstraint c, XTerm target, FieldInstance fi, Type t) throws SemanticException { @@ -293,31 +293,6 @@ return Subst.subst(t, y, x); } - private XTerm transClassType(X10ClassType t) { - X10ClassDef def = t.x10Def(); - - int n = def.typeParameters().size(); - if (n == 0) - return XTerms.makeLit(def); - - List<XTerm> terms = new ArrayList<XTerm>(); - - if (t.isIdentityInstantiation()) { - for (int i = 0; i < n; i++) { - XTerm ti = trans(def.typeParameters().get(i)); - terms.add(ti); - } - return XTerms.makeAtom(XTerms.makeName(def), terms); - } - - List<Type> args = t.typeArguments(); - for (int i = 0; i < n; i++) { - XTerm ti = trans(args.get(i)); - terms.add(ti); - } - return XTerms.makeAtom(XTerms.makeName(def), terms); - } - public XLit trans(int t) { return XTerms.makeLit(t); } Modified: trunk/x10.compiler/src/x10/types/checker/PlaceChecker.java =================================================================== --- trunk/x10.compiler/src/x10/types/checker/PlaceChecker.java 2010-10-12 16:59:28 UTC (rev 17305) +++ trunk/x10.compiler/src/x10/types/checker/PlaceChecker.java 2010-10-12 17:12:05 UTC (rev 17306) @@ -120,7 +120,7 @@ * @return */ static XTerm homeVar(XTerm target, X10TypeSystem xts) { - return xts.xtypeTranslator().transFakeField(new CConstraint(), target, "here"); + return xts.xtypeTranslator().transFakeField(new CConstraint(), target, "$$here"); } static XTerm globalRefHomeVar(XTerm target, X10TypeSystem xts) { return xts.xtypeTranslator().trans(new CConstraint(), target, GlobalRefHome(xts)); Modified: trunk/x10.compiler/src/x10/util/Synthesizer.java =================================================================== --- trunk/x10.compiler/src/x10/util/Synthesizer.java 2010-10-12 16:59:28 UTC (rev 17305) +++ trunk/x10.compiler/src/x10/util/Synthesizer.java 2010-10-12 17:12:05 UTC (rev 17306) @@ -1292,9 +1292,8 @@ */ public X10ClassDecl createClassWithConstructor(Position p, X10ClassDef cDef, - X10Context context) throws SemanticException { - - + X10Context context) throws SemanticException + { X10ClassDecl cDecl = createClass(p, cDef, context); //add default constructor @@ -1317,7 +1316,6 @@ cDef.addConstructor(xDef); return (X10ClassDecl) cDecl.body(cb.members(cm)); - } /** @@ -1329,9 +1327,7 @@ * @param tc * @return * @throws SemanticException - * */ - // TODO: This has to be made to work with nested types. public X10CanonicalTypeNode makeCanonicalTypeNodeWithDepExpr(Position pos, Type type, ContextVisitor tc) { X10NodeFactory nf = ((X10NodeFactory) tc.nodeFactory()); @@ -1373,173 +1369,201 @@ if (! (tn instanceof X10CanonicalTypeNode)) assert tn instanceof X10CanonicalTypeNode; return (X10CanonicalTypeNode) tn; - } - /** + + /** * Return a synthesized AST for a constraint. Used when generating code from implicit casts. - * @param c -- the constraint - * @return -- the expr corresponding to the constraint - * @seeAlso -- X10TypeTransltor.constraint(...): it generates a constraint from an AST. + * @param c the constraint + * @return the expression corresponding to the constraint + * @seeAlso X10TypeTranslator.constraint(...): it generates a constraint from an AST. */ - Expr makeExpr(XTerm t, Position pos) { - if (t instanceof XField) - return makeExpr((XField) t, pos); - if (t instanceof XLit) - return makeExpr((XLit) t, pos); - if (t instanceof XEquals) - return makeExpr((XEquals) t, pos); - if (t instanceof XDisEquals) - return makeExpr((XDisEquals) t, pos); - if (t instanceof XEQV) - return makeExpr((XEQV) t, pos); // this must occur before XLocal_c - if (t instanceof XLocal) - return makeExpr((XLocal) t, pos); - if (t instanceof XNot) - return makeExpr((XNot) t, pos); - if (t instanceof XFormula) - return makeExpr((XFormula) t, pos); - return null; - } - Expr makeExpr(XField t, Position pos) { - Receiver r = makeExpr(t.receiver(), pos); - if (r == null && t.receiver() instanceof XLit) { - Object val = ((XLit) t.receiver()).val(); - if (val instanceof QName) { - r = xnf.TypeNodeFromQualifiedName(pos, (QName) val); - } - } - String str = t.field().toString(); - int i = str.indexOf("#"); - //TypeNode tn = null; - if (i > 0) { - // FIXME: should we create a type node and cast? Can we ever access fields of a superclass? - //String typeName = str.substring(0, i); - //tn = xnf.TypeNodeFromQualifiedName(pos, QName.make(typeName)); - str = str.substring(i+1); - if (str.endsWith("()")) - str = str.substring(0, str.length()-2); - } - return xnf.Field(pos, r, xnf.Id(pos, Name.make(str))); - } - Expr makeExpr(XEQV t, Position pos) { - String str = t.toString(); - //if (str.startsWith("_place")) - // assert ! str.startsWith("_place") : "Place var: "+str; - int i = str.indexOf("#"); - TypeNode tn = null; - if (i > 0) { - String typeName = str.substring(0, i); - tn = xnf.TypeNodeFromQualifiedName(pos, QName.make(typeName)); - str = str.substring(i+1); - } - if (str.equals("self")) - return tn == null ? xnf.Special(pos, X10Special.SELF) : xnf.Special(pos, X10Special.SELF, tn); - if (str.equals("this")) - return tn == null ? xnf.Special(pos, X10Special.THIS) : xnf.Special(pos, X10Special.THIS, tn); - - return xnf.AmbExpr(pos, xnf.Id(pos,Name.make(str))); - } - Expr makeExpr(XLocal t, Position pos) { - String str = t.name().toString(); - //if (str.startsWith("_place")) - // assert ! str.startsWith("_place") : "Place var: "+str; - if (str.equals("here")) - return xnf.Here(pos); - int i = str.indexOf("#"); - TypeNode tn = null; - if (i > 0) { - String typeName = str.substring(0, i); - tn = xnf.TypeNodeFromQualifiedName(pos, QName.make(typeName)); - str = str.substring(i+1); - } - if (str.equals("self")) - return tn == null ? xnf.Special(pos, X10Special.SELF) : xnf.Special(pos, X10Special.SELF, tn); - if (str.equals("this")) - return tn == null ? xnf.Special(pos, X10Special.THIS) : xnf.Special(pos, X10Special.THIS, tn); - return xnf.AmbExpr(pos, xnf.Id(pos,Name.make(str))); - } - - Expr makeExpr(XNot t, Position pos) { - return xnf.Unary(pos, makeExpr(t.arguments().get(0), pos), Unary.NOT); - } - - Expr makeExpr(XLit t, Position pos) { - Object val = t.val(); - if (val== null) - return xnf.NullLit(pos); - if (val instanceof String) - return xnf.StringLit(pos, (String) val); - if (val instanceof Integer) - return xnf.IntLit(pos, IntLit.INT, ((Integer) val).intValue()); - if (val instanceof Long) - return xnf.IntLit(pos, IntLit.LONG, ((Long) val).longValue()); - if (val instanceof Boolean) - return xnf.BooleanLit(pos, ((Boolean) val).booleanValue()); - if (val instanceof Character) - return xnf.CharLit(pos, ((Character) val).charValue()); - if (val instanceof Float) - return xnf.FloatLit(pos, FloatLit.FLOAT, ((Float) val).doubleValue()); - if (val instanceof Double) - return xnf.FloatLit(pos, FloatLit.DOUBLE, ((Double) val).doubleValue()); - return null; - } - Expr makeExpr(XEquals t, Position pos) { - Expr left = makeExpr(t.arguments().get(0), pos); - Expr right = makeExpr(t.arguments().get(1), pos); - if (left == null) - assert left != null; - if (right == null) - assert right != null; - return xnf.Binary(pos, left, Binary.EQ, right); - } - Expr makeExpr(XDisEquals t, Position pos) { - Expr left = makeExpr(t.arguments().get(0), pos); - Expr right = makeExpr(t.arguments().get(1), pos); - return xnf.Binary(pos, left, Binary.NE, right); - } - Expr makeExpr(XFormula t, Position pos) { - List<Expr> args = new ArrayList<Expr>(); - for (XTerm a : t.arguments()) { - args.add(makeExpr(a, pos)); - } - String op = t.asExprOperator().toString(); - if (op.equals(XTerms.asExprAndName.toString())) { - return xnf.Binary(pos, args.get(0), Binary.COND_AND, args.get(1)); - } - if (op.equals(XTerms.asExprEqualsName.toString())) { - return xnf.Binary(pos, args.get(0), Binary.EQ, args.get(1)); - } - if (op.equals(XTerms.asExprDisEqualsName.toString())) { - return xnf.Binary(pos, args.get(0), Binary.NE, args.get(1)); - } - if (op.equals(XTerms.asExprNotName.toString())) { - return xnf.Unary(pos, Unary.NOT, args.get(0)); - } - - // FIXME: [IP] Hack to handle the "at" atom added by XTypeTranslator for structs - //if (n.toString().equals("at")) { - // Receiver r = args.remove(0); - // return xnf.Call(pos, r, xnf.Id(pos, n), args); - //} else { - return xnf.Call(pos, xnf.Id(pos, Name.make(op)), args); - //} - } - - + Expr makeExpr(XTerm t, Position pos) { + if (t instanceof XField) + return makeExpr((XField) t, pos); + if (t instanceof XLit) + return makeExpr((XLit) t, pos); + if (t instanceof XEquals) + return makeExpr((XEquals) t, pos); + if (t instanceof XDisEquals) + return makeExpr((XDisEquals) t, pos); + if (t instanceof XEQV) + return makeExpr((XEQV) t, pos); // this must occur before XLocal_c + if (t instanceof XLocal) + return makeExpr((XLocal) t, pos); + if (t instanceof XNot) + return makeExpr((XNot) t, pos); + if (t instanceof XFormula) + return makeExpr((XFormula) t, pos); + // FIXME: warn about being unable to translate the term + return null; + } + + TypeNode makeTypeNode(XVar receiver, Position pos) { + if (!(receiver instanceof XLit)) + return null; + Object val = ((XLit) receiver).val(); + if (!(val instanceof QName)) + return null; + return xnf.TypeNodeFromQualifiedName(pos, (QName) val); + } + + Expr makeExpr(XField t, Position pos) { + if (t.isHidden()) + return null; + Receiver r = makeExpr(t.receiver(), pos); + if (r == null) { + r = makeTypeNode(t.receiver(), pos); + } + if (r == null) + return null; + String str = t.field().toString(); + int i = str.indexOf("#"); + //TypeNode tn = null; + if (i > 0) { + // FIXME: should we create a type node and cast? Can we ever access fields of a superclass? + //String typeName = str.substring(0, i); + //tn = xnf.TypeNodeFromQualifiedName(pos, QName.make(typeName)); + str = str.substring(i+1); + if (str.endsWith("()")) + str = str.substring(0, str.length()-2); + } + return xnf.Field(pos, r, xnf.Id(pos, Name.make(str))); + } + + // FIXME: merge with makeExpr(XLocal, Position) + Expr makeExpr(XEQV t, Position pos) { + String str = t.toString(); + //if (str.startsWith("_place")) + // assert ! str.startsWith("_place") : "Place var: "+str; + int i = str.indexOf("#"); + TypeNode tn = null; + if (i > 0) { + String typeName = str.substring(0, i); + tn = xnf.TypeNodeFromQualifiedName(pos, QName.make(typeName)); + str = str.substring(i+1); + } + if (str.equals("self") || str.equals("this")) { + X10Special.Kind kind = str.equals("self") ? X10Special.SELF : X10Special.THIS; + return tn == null ? xnf.Special(pos, kind) : xnf.Special(pos, kind, tn); + } + return xnf.AmbExpr(pos, xnf.Id(pos,Name.make(str))); + } + + // FIXME: merge with makeExpr(XEQV, Position) + Expr makeExpr(XLocal t, Position pos) { + String str = t.name().toString(); + //if (str.startsWith("_place")) + // assert ! str.startsWith("_place") : "Place var: "+str; + if (str.equals("here")) + return xnf.Here(pos); + int i = str.indexOf("#"); + TypeNode tn = null; + if (i > 0) { + String typeName = str.substring(0, i); + tn = xnf.TypeNodeFromQualifiedName(pos, QName.make(typeName)); + str = str.substring(i+1); + } + if (str.equals("self") || str.equals("this")) { + X10Special.Kind kind = str.equals("self") ? X10Special.SELF : X10Special.THIS; + return tn == null ? xnf.Special(pos, kind) : xnf.Special(pos, kind, tn); + } + return xnf.AmbExpr(pos, xnf.Id(pos,Name.make(str))); + } + + Expr makeExpr(XNot t, Position pos) { + Expr expr = makeExpr(t.arguments().get(0), pos); + if (expr == null) + return null; + return xnf.Unary(pos, expr, Unary.NOT); + } + + Expr makeExpr(XLit t, Position pos) { + Object val = t.val(); + if (val == null) + return xnf.NullLit(pos); + if (val instanceof String) + return xnf.StringLit(pos, (String) val); + if (val instanceof Integer) + return xnf.IntLit(pos, IntLit.INT, ((Integer) val).intValue()); + if (val instanceof Long) + return xnf.IntLit(pos, IntLit.LONG, ((Long) val).longValue()); + if (val instanceof Boolean) + return xnf.BooleanLit(pos, ((Boolean) val).booleanValue()); + if (val instanceof Character) + return xnf.CharLit(pos, ((Character) val).charValue()); + if (val instanceof Float) + return xnf.FloatLit(pos, FloatLit.FLOAT, ((Float) val).doubleValue()); + if (val instanceof Double) + return xnf.FloatLit(pos, FloatLit.DOUBLE, ((Double) val).doubleValue()); + if (val instanceof QName) // will get picked up later + return null; + // FIXME: warn about being unable to translate the literal + return null; + } + + Expr makeExpr(XEquals t, Position pos) { + Expr left = makeExpr(t.arguments().get(0), pos); + Expr right = makeExpr(t.arguments().get(1), pos); + if (left == null || right == null) + return null; + return xnf.Binary(pos, left, Binary.EQ, right); + } + + Expr makeExpr(XDisEquals t, Position pos) { + Expr left = makeExpr(t.arguments().get(0), pos); + Expr right = makeExpr(t.arguments().get(1), pos); + if (left == null || right == null) + return null; + return xnf.Binary(pos, left, Binary.NE, right); + } + + Expr makeExpr(XFormula t, Position pos) { + List<Expr> args = new ArrayList<Expr>(); + for (XTerm a : t.arguments()) { + Expr e = makeExpr(a, pos); + if (e == null) + return null; + args.add(e); + } + String op = t.asExprOperator().toString(); + if (op.equals(XTerms.asExprAndName.toString())) { + return xnf.Binary(pos, args.get(0), Binary.COND_AND, args.get(1)); + } + if (op.equals(XTerms.asExprEqualsName.toString())) { + return xnf.Binary(pos, args.get(0), Binary.EQ, args.get(1)); + } + if (op.equals(XTerms.asExprDisEqualsName.toString())) { + return xnf.Binary(pos, args.get(0), Binary.NE, args.get(1)); + } + if (op.equals(XTerms.asExprNotName.toString())) { + return xnf.Unary(pos, Unary.NOT, args.get(0)); + } + + // FIXME: [IP] Hack to handle the "at" atom added by XTypeTranslator for structs + //if (n.toString().equals("at")) { + // Receiver r = args.remove(0); + // return xnf.Call(pos, r, xnf.Id(pos, n), args); + //} else { + return xnf.Call(pos, xnf.Id(pos, Name.make(op)), args); + //} + } + public List<Expr> makeExpr(CConstraint c, Position pos) { - List<Expr> es = new ArrayList<Expr>(); - if (c==null) - return es; - List<XTerm> terms = c.extConstraints(); - - for (XTerm term : terms) { - es.add(makeExpr(term, pos)); - } - return es; + List<Expr> es = new ArrayList<Expr>(); + if (c==null) + return es; + List<XTerm> terms = c.extConstraints(); + + for (XTerm term : terms) { + Expr e = makeExpr(term, pos); + if (e != null) + es.add(e); + } + return es; } - + //Some - + /** * Get an int value expression * @param value Modified: trunk/x10.constraints/src/x10/constraint/XField.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XField.java 2010-10-12 16:59:28 UTC (rev 17305) +++ trunk/x10.constraints/src/x10/constraint/XField.java 2010-10-12 17:12:05 UTC (rev 17306) @@ -20,129 +20,129 @@ */ public class XField extends XVar { - public XVar receiver; - public XName field; - // used by XPromise_c to determine if this field should occur in the output - // representation of a constraint or not. - boolean hidden; + public XVar receiver; + public XName field; + // used by XPromise_c to determine if this field should occur in the output + // representation of a constraint or not. + private boolean hidden; - public XField(XVar receiver, XName field) { - super(); - this.receiver = receiver; - this.field = field; - this.hidden=false; - } - public XField(XVar receiver, XName field, boolean hidden) { - super(); - this.receiver = receiver; - this.field = field; - this.hidden=hidden; - } + public XField(XVar receiver, XName field) { + this(receiver, field, false); + } - public XTermKind kind() { return XTermKind.FIELD_ACCESS;} - @Override - public XTerm subst(XTerm y, XVar x, boolean propagate) { - XTerm r = super.subst(y, x, propagate); - if (! equals(r)) - return r; - XVar newReceiver = (XVar) receiver.subst(y, x); - if (newReceiver == receiver) { - return this; - } - XField result = clone(); - result.receiver = newReceiver; - return result; - } - - public List<XEQV> eqvs() { - return receiver().eqvs(); - } + public XField(XVar receiver, XName field, boolean hidden) { + super(); + this.receiver = receiver; + this.field = field; + this.hidden = hidden; + } - public XName field() { - return field; - } + public boolean isHidden() { return hidden; } - public String name() { - return field.toString(); - } - - public boolean hasVar(XVar v) { - return equals(v) || receiver.hasVar(v); - } + public XTermKind kind() { return XTermKind.FIELD_ACCESS; } - public XVar receiver() { - return receiver; - } + @Override + public XTerm subst(XTerm y, XVar x, boolean propagate) { + XTerm r = super.subst(y, x, propagate); + if (! equals(r)) + return r; + XVar newReceiver = (XVar) receiver.subst(y, x); + if (newReceiver == receiver) { + return this; + } + XField result = clone(); + result.receiver = newReceiver; + return result; + } - public int hashCode() { - return receiver.hashCode() + field.hashCode(); - } + public List<XEQV> eqvs() { + return receiver().eqvs(); + } - public boolean equals(Object o) { - if (o instanceof XField) { - XField other = (XField) o; - return receiver.equals(other.receiver) && field.equals(other.field); - } - return false; - } + public XName field() { + return field; + } - public String toString() { - return (receiver == null ? "" : receiver.toString() + ".") + field; - } + public String name() { + return field.toString(); + } - public boolean hasEQV() { - if (receiver() == null) - assert false; - return receiver().hasEQV(); - } - + public boolean hasVar(XVar v) { + return equals(v) || receiver.hasVar(v); + } - @Override - public XField clone() { - XField n = (XField) super.clone(); - n.vars = null; - return n; - } - - // memoize rootVar and path. - protected XVar[] vars; + public XVar receiver() { + return receiver; + } - public XVar[] vars() { - if (vars == null) - initVars(); - return vars; - } + public int hashCode() { + return receiver.hashCode() + field.hashCode(); + } - public XVar rootVar() { - if (vars == null) - initVars(); - return vars[0]; - } + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof XField) { + XField other = (XField) o; + return receiver.equals(other.receiver) && field.equals(other.field); + } + return false; + } - public boolean prefixes(XTerm t) { - if (equals(t)) - return true; - if (!(t instanceof XVar)) - return false; - XVar[] vars = ((XVar) t).vars(); - boolean result = false; - for (int i = 0; (!result) && i < vars.length; i++) { - result = equals(vars[i]); - } - return result; - } + public String toString() { + return (receiver == null ? "" : receiver.toString() + ".") + field; + } - protected void initVars() { - int count = 0; - for (XVar source = this; source instanceof XField; source = ((XField) source).receiver()) - count++; - vars = new XVar[count + 1]; - XVar f = this; - for (int i = count; i >= 0; i--) { - vars[i] = f; - if (i > 0) - f = ((XField) f).receiver(); - } + public boolean hasEQV() { + if (receiver() == null) + assert false; + return receiver().hasEQV(); + } - } + @Override + public XField clone() { + XField n = (XField) super.clone(); + n.vars = null; + return n; + } + + // memoize rootVar and path. + protected XVar[] vars; + + public XVar[] vars() { + if (vars == null) + initVars(); + return vars; + } + + public XVar rootVar() { + if (vars == null) + initVars(); + return vars[0]; + } + + public boolean prefixes(XTerm t) { + if (equals(t)) + return true; + if (!(t instanceof XVar)) + return false; + XVar[] vars = ((XVar) t).vars(); + boolean result = false; + for (int i = 0; (!result) && i < vars.length; i++) { + result = equals(vars[i]); + } + return result; + } + + protected void initVars() { + int count = 0; + for (XVar source = this; source instanceof XField; source = ((XField) source).receiver()) + count++; + vars = new XVar[count + 1]; + XVar f = this; + for (int i = count; i >= 0; i--) { + vars[i] = f; + if (i > 0) + f = ((XField) f).receiver(); + } + } } Modified: trunk/x10.constraints/src/x10/constraint/XPromise_c.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XPromise_c.java 2010-10-12 16:59:28 UTC (rev 17305) +++ trunk/x10.constraints/src/x10/constraint/XPromise_c.java 2010-10-12 17:12:05 UTC (rev 17306) @@ -377,9 +377,9 @@ if (value != null) { if (dumpEQV || ! t1.hasEQV()) { XTerm t2 = lookup().var(); - if (hideFake && t1 instanceof XField && ((XField) t1).hidden) + if (hideFake && t1 instanceof XField && ((XField) t1).isHidden()) return; - if (hideFake && t2 instanceof XField && ((XField) t2).hidden) + if (hideFake && t2 instanceof XField && ((XField) t2).isHidden()) return; result.add( XTerms.makeEquals(t1, t2)); } @@ -394,7 +394,16 @@ for (Map.Entry<XName,XPromise> m : fields.entrySet()) { XName name = m.getKey(); XPromise p = m.getValue(); - XVar path2 = v==null? null : XTerms.makeField(v, name); + XTerm t = p.term(); + XVar path2 = null; + if (v != null && !(t instanceof XField) && !((XField) t).receiver().equals(v)) { + assert false; +// path2 = XTerms.makeField(v, name); + } +// path2 = v == null ? null : (XVar) t; + boolean hidden = t instanceof XField ? ((XField) t).isHidden() : false; + path2 = v == null ? null : + (hidden ? XTerms.makeFakeField(v, name) : XTerms.makeField(v, name)); p.dump(path2, result, dumpEQV, hideFake); } } Modified: trunk/x10.constraints/src/x10/constraint/XTerm.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XTerm.java 2010-10-12 16:59:28 UTC (rev 17305) +++ trunk/x10.constraints/src/x10/constraint/XTerm.java 2010-10-12 17:12:05 UTC (rev 17306) @@ -24,7 +24,6 @@ */ public abstract class XTerm implements Serializable, Cloneable { - public XTerm() { super(); } @@ -147,4 +146,7 @@ abstract XPromise internIntoConstraint(XConstraint constraint, XPromise last) throws XFailure; + public abstract int hashCode(); + public abstract boolean equals(Object o); + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-10-12 18:38:33
|
Revision: 17317 http://x10.svn.sourceforge.net/x10/?rev=17317&view=rev Author: dgrove-oss Date: 2010-10-12 18:38:26 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Restructure header files so that struct_equals can be pulled back into basic_functions.h (where we have more capability to call methods of Reference and IBox). Pre-condition for fixing struct_equals between boxed and non-boxed struct instances to acually be computed correctly. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10/lang/GlobalRef.h trunk/x10.runtime/src-cpp/x10/lang/GlobalRef.struct_h trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.h trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.struct_h trunk/x10.runtime/src-cpp/x10aux/basic_functions.h Removed Paths: ------------- trunk/x10.runtime/src-cpp/x10aux/struct_equals.h Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-10-12 18:29:23 UTC (rev 17316) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-10-12 18:38:26 UTC (rev 17317) @@ -715,7 +715,6 @@ sh.writeln("#include <x10aux/ref.h>"); sh.writeln("#include <x10aux/RTT.h>"); sh.writeln("#include <x10aux/serialization.h>"); - sh.writeln("#include <x10aux/struct_equals.h>"); sh.forceNewline(0); } Modified: trunk/x10.runtime/src-cpp/x10/lang/GlobalRef.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/GlobalRef.h 2010-10-12 18:29:23 UTC (rev 17316) +++ trunk/x10.runtime/src-cpp/x10/lang/GlobalRef.h 2010-10-12 18:38:26 UTC (rev 17317) @@ -96,6 +96,10 @@ return _struct_equals(x10aux::class_cast<x10::lang::GlobalRef<T> >(that)); } +template<class T> x10_boolean x10::lang::GlobalRef<T>::_struct_equals(x10::lang::GlobalRef<T> that) { + return (location == that->location) && x10aux::struct_equals(value, that->value); +} + template<class T> x10aux::ref<x10::lang::String> x10::lang::GlobalRef<T>::toString() { char* tmp = x10aux::alloc_printf("x10.lang.GlobalRef<%s>", x10aux::getRTT<T>()->name()); return x10::lang::String::Steal(tmp); Modified: trunk/x10.runtime/src-cpp/x10/lang/GlobalRef.struct_h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/GlobalRef.struct_h 2010-10-12 18:29:23 UTC (rev 17316) +++ trunk/x10.runtime/src-cpp/x10/lang/GlobalRef.struct_h 2010-10-12 18:38:26 UTC (rev 17317) @@ -5,7 +5,6 @@ #include <x10aux/ref.h> #include <x10aux/RTT.h> #include <x10aux/serialization.h> -#include <x10aux/struct_equals.h> namespace x10 { namespace lang { @@ -50,9 +49,7 @@ x10_boolean _struct_equals(x10aux::ref<x10::lang::Any>); - x10_boolean _struct_equals(GlobalRef<T> that) { - return (location == that->location) && x10aux::struct_equals(value, that->value); - } + x10_boolean _struct_equals(GlobalRef<T> that); x10aux::ref<x10::lang::String> toString(); Modified: trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.h 2010-10-12 18:29:23 UTC (rev 17316) +++ trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.h 2010-10-12 18:38:26 UTC (rev 17317) @@ -121,6 +121,10 @@ return _struct_equals(x10aux::class_cast<x10::util::IndexedMemoryChunk<T> >(that)); } +template<class T> x10_boolean x10::util::IndexedMemoryChunk<T>::_struct_equals(x10::util::IndexedMemoryChunk<T> that) { + return x10aux::struct_equals(data, that->data); +} + template<class T> x10aux::ref<x10::lang::String> x10::util::IndexedMemoryChunk<T>::toString() { char* tmp = x10aux::alloc_printf("x10.util.IndexedMemoryChunk<%s>(%llx)", x10aux::getRTT<T>()->name(), data); return x10::lang::String::Steal(tmp); Modified: trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.struct_h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.struct_h 2010-10-12 18:29:23 UTC (rev 17316) +++ trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.struct_h 2010-10-12 18:38:26 UTC (rev 17317) @@ -5,7 +5,6 @@ #include <x10aux/ref.h> #include <x10aux/RTT.h> #include <x10aux/serialization.h> -#include <x10aux/struct_equals.h> #include <assert.h> @@ -71,9 +70,7 @@ x10_boolean _struct_equals(x10aux::ref<x10::lang::Any>); - x10_boolean _struct_equals(x10::util::IndexedMemoryChunk<T> that) { - return x10aux::struct_equals(data, that->data); - } + x10_boolean _struct_equals(x10::util::IndexedMemoryChunk<T> that); x10aux::ref<x10::lang::String> toString(); Modified: trunk/x10.runtime/src-cpp/x10aux/basic_functions.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/basic_functions.h 2010-10-12 18:29:23 UTC (rev 17316) +++ trunk/x10.runtime/src-cpp/x10aux/basic_functions.h 2010-10-12 18:38:26 UTC (rev 17317) @@ -16,7 +16,6 @@ #include <x10aux/ref.h> #include <x10aux/hash.h> #include <x10aux/string_utils.h> -#include <x10aux/struct_equals.h> #include <x10/lang/IBox.struct_h> @@ -46,6 +45,80 @@ return string_utils::lit(getRTT<T>()->name()); } + + /******* struct_equals ********/ + + extern GPUSAFE x10_boolean compare_references_slow(ref<x10::lang::Reference> x, ref<x10::lang::Reference> y); + inline GPUSAFE x10_boolean compare_references(ref<x10::lang::Reference> x, ref<x10::lang::Reference> y) { + if (x == y) return true; + if (x.isNull()) return y.isNull(); + return compare_references_slow(x, y); + } + + /* + * Inner level of dispatching to cover combinations of: + * ref + * user-defined structs + * built-in C types + */ + + template<class T, class U> struct StructEquals { static inline GPUSAFE x10_boolean _(T x, U y) { + return x._struct_equals(y); // two structs + } }; + + template<class T, class U> struct StructEquals<ref<T>,U> { static inline GPUSAFE x10_boolean _(ref<T> x, U y) { + return false; // a ref and a struct + } }; + + template<class T, class U> struct StructEquals<T,ref<U> > { static inline GPUSAFE x10_boolean _(T x, ref<U> y) { + return false; // a struct and a ref + } }; + + template<class T, class U> struct StructEquals<ref<T>,ref<U> > { static inline GPUSAFE x10_boolean _(ref<T> x, ref<U> y) { + return compare_references(x, y); // two refs + } }; + + + /* + * Outer level of dispatching to cannonicalize to only rval types + * and bound the explosion of possible combinations + */ + + inline x10_boolean struct_equals(const x10_double x, const x10_double y) { return x==y; } + inline x10_boolean struct_equals(const x10_float x, const x10_float y) { return x==y; } + inline x10_boolean struct_equals(const x10_long x, const x10_long y) { return x==y; } + inline x10_boolean struct_equals(const x10_int x, const x10_int y) { return x==y; } + inline x10_boolean struct_equals(const x10_short x, const x10_short y) { return x==y; } + inline x10_boolean struct_equals(const x10_byte x, const x10_byte y) { return x==y; } + inline x10_boolean struct_equals(const x10_ulong x, const x10_ulong y) { return x==y; } + inline x10_boolean struct_equals(const x10_uint x, const x10_uint y) { return x==y; } + inline x10_boolean struct_equals(const x10_ushort x, const x10_ushort y) { return x==y; } + inline x10_boolean struct_equals(const x10_ubyte x, const x10_ubyte y) { return x==y; } + inline x10_boolean struct_equals(const x10_char x, const x10_char y) { return x.v==y.v; } + inline x10_boolean struct_equals(const x10_boolean x, const x10_boolean y) { return x==y; } + + template<class T, class U> inline x10_boolean struct_equals(T x, U y) { + return StructEquals<T,U>::_(x, y); + } + template<class T, class U> inline x10_boolean struct_equals(captured_ref_lval<T> x, U y) { + return StructEquals<ref<T>,U>::_(ref<T>(*x), y); + } + template<class T, class U> inline x10_boolean struct_equals(T x, captured_ref_lval<U> y) { + return StructEquals<T,ref<U> >::_(x, ref<U>(*y)); + } + template<class T, class U> inline x10_boolean struct_equals(captured_ref_lval<T> x, captured_ref_lval<U> y) { + return StructEquals<ref<T>,ref<U> >::_(ref<T>(*x), ref<U>(*y)); + } + template<class T, class U> inline x10_boolean struct_equals(captured_struct_lval<T> x, U y) { + return struct_equals(*x, y); + } + template<class T, class U> inline x10_boolean struct_equals(T x, captured_struct_lval<U> y) { + return struct_equals(x, *y); + } + template<class T, class U> inline x10_boolean struct_equals(captured_struct_lval<T> x, captured_struct_lval<U> y) { + return struct_equals(*x, *y); + } + /******* equals ********/ // covers all heap-allocated values (Objects, Functions, Structs boxes to interface types) Deleted: trunk/x10.runtime/src-cpp/x10aux/struct_equals.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/struct_equals.h 2010-10-12 18:29:23 UTC (rev 17316) +++ trunk/x10.runtime/src-cpp/x10aux/struct_equals.h 2010-10-12 18:38:26 UTC (rev 17317) @@ -1,93 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -#ifndef X10AUX_STRUCT_EQUALS_H -#define X10AUX_STRUCT_EQUALS_H - -#include <x10aux/config.h> -#include <x10aux/ref.h> -#include <x10aux/captured_lval.h> - -namespace x10aux { - - extern GPUSAFE x10_boolean compare_references_slow(ref<x10::lang::Reference> x, ref<x10::lang::Reference> y); - inline GPUSAFE x10_boolean compare_references(ref<x10::lang::Reference> x, ref<x10::lang::Reference> y) { - if (x == y) return true; - if (x.isNull()) return y.isNull(); - return compare_references_slow(x, y); - } - - /* - * Inner level of dispatching to cover combinations of: - * ref - * user-defined structs - * built-in C types - */ - - template<class T, class U> struct StructEquals { static inline GPUSAFE x10_boolean _(T x, U y) { - return x._struct_equals(y); // two structs - } }; - - template<class T, class U> struct StructEquals<ref<T>,U> { static inline GPUSAFE x10_boolean _(ref<T> x, U y) { - return false; // a ref and a struct - } }; - - template<class T, class U> struct StructEquals<T,ref<U> > { static inline GPUSAFE x10_boolean _(T x, ref<U> y) { - return false; // a struct and a ref - } }; - - template<class T, class U> struct StructEquals<ref<T>,ref<U> > { static inline GPUSAFE x10_boolean _(ref<T> x, ref<U> y) { - return compare_references(x, y); // two refs - } }; - - - /* - * Outer level of dispatching to cannonicalize to only rval types - * and bound the explosion of possible combinations - */ - - inline x10_boolean struct_equals(const x10_double x, const x10_double y) { return x==y; } - inline x10_boolean struct_equals(const x10_float x, const x10_float y) { return x==y; } - inline x10_boolean struct_equals(const x10_long x, const x10_long y) { return x==y; } - inline x10_boolean struct_equals(const x10_int x, const x10_int y) { return x==y; } - inline x10_boolean struct_equals(const x10_short x, const x10_short y) { return x==y; } - inline x10_boolean struct_equals(const x10_byte x, const x10_byte y) { return x==y; } - inline x10_boolean struct_equals(const x10_ulong x, const x10_ulong y) { return x==y; } - inline x10_boolean struct_equals(const x10_uint x, const x10_uint y) { return x==y; } - inline x10_boolean struct_equals(const x10_ushort x, const x10_ushort y) { return x==y; } - inline x10_boolean struct_equals(const x10_ubyte x, const x10_ubyte y) { return x==y; } - inline x10_boolean struct_equals(const x10_char x, const x10_char y) { return x.v==y.v; } - inline x10_boolean struct_equals(const x10_boolean x, const x10_boolean y) { return x==y; } - - template<class T, class U> inline x10_boolean struct_equals(T x, U y) { - return StructEquals<T,U>::_(x, y); - } - template<class T, class U> inline x10_boolean struct_equals(captured_ref_lval<T> x, U y) { - return StructEquals<ref<T>,U>::_(ref<T>(*x), y); - } - template<class T, class U> inline x10_boolean struct_equals(T x, captured_ref_lval<U> y) { - return StructEquals<T,ref<U> >::_(x, ref<U>(*y)); - } - template<class T, class U> inline x10_boolean struct_equals(captured_ref_lval<T> x, captured_ref_lval<U> y) { - return StructEquals<ref<T>,ref<U> >::_(ref<T>(*x), ref<U>(*y)); - } - template<class T, class U> inline x10_boolean struct_equals(captured_struct_lval<T> x, U y) { - return struct_equals(*x, y); - } - template<class T, class U> inline x10_boolean struct_equals(T x, captured_struct_lval<U> y) { - return struct_equals(x, *y); - } - template<class T, class U> inline x10_boolean struct_equals(captured_struct_lval<T> x, captured_struct_lval<U> y) { - return struct_equals(*x, *y); - } -} - -#endif /* X10AUX_STRUCT_EQUALS_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bh...@us...> - 2010-10-12 18:41:47
|
Revision: 17319 http://x10.svn.sourceforge.net/x10/?rev=17319&view=rev Author: bherta Date: 2010-10-12 18:41:41 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Added x10.lang.point to debug mapping types Added reference map to the larger debug mapping table Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java trunk/x10.runtime/src-cpp/x10aux/debug.h Modified: trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java =================================================================== --- trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java 2010-10-12 18:39:16 UTC (rev 17318) +++ trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java 2010-10-12 18:41:41 UTC (rev 17319) @@ -340,6 +340,8 @@ return 206; if (type.startsWith("x10.lang.ValRail")) return 207; + if (type.startsWith("x10.array.Point")) + return 208; if (type.startsWith("x10.array.Region")) return 300; return 101; // generic class @@ -945,6 +947,10 @@ w.writeln("sizeof(_X10ArrayMapList),"); else w.writeln("0, // no array mappings"); + if (!refMap.isEmpty()) + w.writeln("sizeof(_X10RefMapList),"); + else + w.writeln("0, // no reference mappings"); w.writeln("_X10strings,"); if (!m.isEmpty()) { @@ -985,7 +991,11 @@ if (!arrayMap.isEmpty()) w.write("_X10ArrayMapList"); else - w.write("NULL"); + w.write("NULL"); + if (!refMap.isEmpty()) + w.write("_X10RefMapList"); + else + w.write("NULL"); w.end(); w.newline(); w.writeln("};"); Modified: trunk/x10.runtime/src-cpp/x10aux/debug.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/debug.h 2010-10-12 18:39:16 UTC (rev 17318) +++ trunk/x10.runtime/src-cpp/x10aux/debug.h 2010-10-12 18:41:41 UTC (rev 17319) @@ -176,6 +176,7 @@ unsigned x10classMapListSize; // the size in bytes of the X10 class mapping list unsigned x10closureMapListSize; // the size in bytes of the X10 async closure mapping list unsigned x10arrayMapListSize; // the size in bytes of the X10 array mapping list + unsigned x10refMapListSize; // the size in bytes of the X10 reference mapping list const char* x10strings; // The string table const struct _X10sourceFile* x10sourceList; // The list of X10 source files @@ -186,6 +187,7 @@ const struct _X10ClassMap* x10classMapList; // The class mapping list const struct _X10ClosureMap* x10closureMapList; // The async closure mapping list const struct _X10ArrayMap* x10arrayMapList; // The array mapping list + const struct _X10RefMap* x10refMapList; // The reference mapping list }; //extern void _X10_Entry_Hook(); // A hook at the start of every X10 method. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |