diff options
| author | Simon Marlow <marlowsd@gmail.com> | 2018-01-05 16:12:49 +0000 |
|---|---|---|
| committer | Simon Marlow <marlowsd@gmail.com> | 2018-01-08 08:41:35 +0000 |
| commit | a1a689dda48113f3735834350fb562bb1927a633 (patch) | |
| tree | 0931516152cc40f0481bb2fad35274f225bcd76c /compiler | |
| parent | 303106d55d75a9c796e58867cb541ad136bb217f (diff) | |
| download | haskell-a1a689dda48113f3735834350fb562bb1927a633.tar.gz | |
Improve accuracy of get/setAllocationCounter
Summary:
get/setAllocationCounter didn't take into account allocations in the
current block. This was known at the time, but it turns out to be
important to have more accuracy when using these in a fine-grained
way.
Test Plan:
New unit test to test incrementally larger allocaitons. Before I got
results like this:
```
+0
+0
+0
+0
+0
+4096
+0
+0
+0
+0
+0
+4064
+0
+0
+4088
+4056
+0
+0
+0
+4088
+4096
+4056
+4096
```
Notice how the results aren't always monotonically increasing. After
this patch:
```
+344
+416
+488
+560
+632
+704
+776
+848
+920
+992
+1064
+1136
+1208
+1280
+1352
+1424
+1496
+1568
+1640
+1712
+1784
+1856
+1928
+2000
+2072
+2144
```
Reviewers: niteria, bgamari, hvr, erikd
Subscribers: rwbarton, thomie, carter
Differential Revision: https://phabricator.haskell.org/D4288
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/codeGen/StgCmmForeign.hs | 4 | ||||
| -rw-r--r-- | compiler/prelude/primops.txt.pp | 14 |
2 files changed, 16 insertions, 2 deletions
diff --git a/compiler/codeGen/StgCmmForeign.hs b/compiler/codeGen/StgCmmForeign.hs index fc3d42aa8b..3473307423 100644 --- a/compiler/codeGen/StgCmmForeign.hs +++ b/compiler/codeGen/StgCmmForeign.hs @@ -408,8 +408,8 @@ Opening the nursery corresponds to the following code: @ tso = CurrentTSO; cn = CurrentNursery; - bdfree = CurrentNuresry->free; - bdstart = CurrentNuresry->start; + bdfree = CurrentNursery->free; + bdstart = CurrentNursery->start; // We *add* the currently occupied portion of the nursery block to // the allocation limit, because we will subtract it again in diff --git a/compiler/prelude/primops.txt.pp b/compiler/prelude/primops.txt.pp index 333694d0d2..e958baf0e4 100644 --- a/compiler/prelude/primops.txt.pp +++ b/compiler/prelude/primops.txt.pp @@ -2921,6 +2921,20 @@ primop TraceMarkerOp "traceMarker#" GenPrimOp has_side_effects = True out_of_line = True +primop GetThreadAllocationCounter "getThreadAllocationCounter#" GenPrimOp + State# RealWorld -> (# State# RealWorld, INT64 #) + { Retrieves the allocation counter for the current thread. } + with + has_side_effects = True + out_of_line = True + +primop SetThreadAllocationCounter "setThreadAllocationCounter#" GenPrimOp + INT64 -> State# RealWorld -> State# RealWorld + { Sets the allocation counter for the current thread to the given value. } + with + has_side_effects = True + out_of_line = True + ------------------------------------------------------------------------ section "Safe coercions" ------------------------------------------------------------------------ |
