-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unsafe operations for array uninitialization and raw arrays #207
Commits on Oct 7, 2017
-
Configuration menu - View commit details
-
Copy full SHA for 612eede - Browse repository at this point
Copy the full SHA 612eedeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 898d3a6 - Browse repository at this point
Copy the full SHA 898d3a6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8663034 - Browse repository at this point
Copy the full SHA 8663034View commit details -
Configuration menu - View commit details
-
Copy full SHA for eec191d - Browse repository at this point
Copy the full SHA eec191dView commit details -
Configuration menu - View commit details
-
Copy full SHA for ee9d072 - Browse repository at this point
Copy the full SHA ee9d072View commit details -
Configuration menu - View commit details
-
Copy full SHA for 884d7ef - Browse repository at this point
Copy the full SHA 884d7efView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1c0b24e - Browse repository at this point
Copy the full SHA 1c0b24eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5e4b00d - Browse repository at this point
Copy the full SHA 5e4b00dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 37c73d7 - Browse repository at this point
Copy the full SHA 37c73d7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2ab5d9e - Browse repository at this point
Copy the full SHA 2ab5d9eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 52d266c - Browse repository at this point
Copy the full SHA 52d266cView commit details -
Configuration menu - View commit details
-
Copy full SHA for d3569db - Browse repository at this point
Copy the full SHA d3569dbView commit details
Commits on Oct 10, 2017
-
Add
Array_uninit: 'a array * SeqInt.int -> unit
primitiveThe Array_uninit primitive sets all objptrs in the element at the given index to a bogus non-objptr value (0wx1). One motivation for this primitive is to support space-efficient polymorphic resizeable arrays. When shrinking a resizeable array, we would like to "NULL" out the elements that are no longer part of the logical array, in order to avoid a (logical) space leak.
Configuration menu - View commit details
-
Copy full SHA for 946385f - Browse repository at this point
Copy the full SHA 946385fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1672c55 - Browse repository at this point
Copy the full SHA 1672c55View commit details
Commits on Oct 11, 2017
-
Configuration menu - View commit details
-
Copy full SHA for 1b87b4b - Browse repository at this point
Copy the full SHA 1b87b4bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 098d606 - Browse repository at this point
Copy the full SHA 098d606View commit details
Commits on Oct 12, 2017
-
Configuration menu - View commit details
-
Copy full SHA for 51fc022 - Browse repository at this point
Copy the full SHA 51fc022View commit details
Commits on Oct 16, 2017
-
Update Useless optimization to handle Array_uninit primitive
It is correct to not special case the Array_uninit primitive, but doing so inhibits the Useless optimization.
Configuration menu - View commit details
-
Copy full SHA for 295f9cd - Browse repository at this point
Copy the full SHA 295f9cdView commit details -
Add
Array_uninitIsNop: 'a array -> bool
primitiveThe Array_uninitIsNop primitive answers if the Array_uninit primitive applied to the same array would be a nop (i.e., if the array has no objptrs in the elements). This can be used to skip a bulk-Array_uninit loop when it is known that the Array_uninit operations would be nops. The primitive is translated to a constant by toRssa. It would be possible to introduce SSA and SSA2 optimizations that simplified Array_uninitIsNop and Array_uninit when it is clear that the array will never have objptrs in the elements. In particular, while an `(int64 * int64) array` (in SSA) might become an `int64 array` (due to Useless), the reverse can never happen. Similarly, while an `((int64 * int64)) array` (in SSA2) might become an `(int64 * int64) array` (due to DeepFlatten), the reverse can never happen. Also, RSSA shrink does not seem to simplify the switch {test = 0x0: Word32, default = None, cases = ((0x0, L_1277), (0x1, L_1276))} that results from replacing Array_uninitIsNop with a constant.
Configuration menu - View commit details
-
Copy full SHA for 426baa1 - Browse repository at this point
Copy the full SHA 426baa1View commit details -
Configuration menu - View commit details
-
Copy full SHA for af42741 - Browse repository at this point
Copy the full SHA af42741View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1f08772 - Browse repository at this point
Copy the full SHA 1f08772View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9853172 - Browse repository at this point
Copy the full SHA 9853172View commit details -
Add
Array_allocRaw: SeqIndex.int -> 'a array
primitiveThe `Array_allocRaw` primitive allocates an array, but with a header that indicates that the array has no objptrs. A related `Array_toArray` primitive updates the header of an `Array_allocRaw` primitive to reveal the objptrs. Between the allocation and the cast, all elements of the array must be uninitialized (setting all objptrs in elements to a bogus non-objptr value (0wx1)). One motiviation for this primitive is that, in a parallel setting, the uninitialization of an array can be a sequential bottleneck. The `Array_allocRaw` is a constant time operation and the subsequent `Array_uninit` operations can be performed in parallel. Note that it is not safe to write non-bogus objptrs into a raw array. Because the raw array's header indicates that the array has no objptrs, non-bogus objptrs written to the array will not be traced or updated during a garbage collection. In the future, we may consider eliminating `Array_alloc` (the non-raw array allocation) and moving the uninitialization loop from the runtime to SML. To do so, though, we should ensure that arrays that do not need uninitialization are optimized early in the optimization pipeline.
Configuration menu - View commit details
-
Copy full SHA for 580da00 - Browse repository at this point
Copy the full SHA 580da00View commit details
Commits on Oct 20, 2017
-
Configuration menu - View commit details
-
Copy full SHA for e5206bb - Browse repository at this point
Copy the full SHA e5206bbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 81bb827 - Browse repository at this point
Copy the full SHA 81bb827View commit details
Commits on Oct 21, 2017
-
Fix latent bugs in ConstantProgagation with Array_allocRaw
Currently, no arrays are globalized; see MLton#206. However, if "small" arrays were globalized, then an `Array_allocRaw[t] (l)` would be globalized as `Array_alloc[t] (l)` and the `Array_toArray` (that casts the raw array to a normal array) would be dropped. Now, the `Array` abstract value tracks whether the array is raw or normal, which is used to generate either `Array_allocRaw` or `Array_alloc` if the array is globalized. Also, `Array_toArray` creates the destination `Array` abstract value with `Birth.unknown()`, which prohibits globalization.
Configuration menu - View commit details
-
Copy full SHA for 5c747df - Browse repository at this point
Copy the full SHA 5c747dfView commit details -
Merge branch 'master' of github.com:MLton/mlton into array-uninit
ShareZeroVec only optimizes val a: t array = Array_alloc[t] (l) ... val v: t vector = Array_toVector[t] (a) not val r: t array = Array_allocRaw[t] (l) ... val a: t vector = Array_toArray[t] (r) ... val v: t vector = Array_toVector[t] (a) The latter is possibly, just requires a more sophisticated analysis to connect Array_alloc/Array_allocRaw with Array_toVector.
Configuration menu - View commit details
-
Copy full SHA for c8c4ef6 - Browse repository at this point
Copy the full SHA c8c4ef6View commit details