[GSoC] 'Replace Runtime Hooks with Templates' progress and update thread

Dan Printzell xwildn00bx at gmail.com
Tue Jul 23 22:02:36 UTC 2019


On Tuesday, 28 May 2019 at 10:47:03 UTC, Dan Printzell wrote:
> [...]

Week 30
=======

This week
~~~~~~~~~
The translation of _d_arraysetlengthT is fully merged!

Worked on getting the _d_arrayappend{T,cTX} and 
_d_array{,set}ctor dmd
PRs into a mergeable state, currently stuck at getting it to pass 
the
testcases. More information in Blockers.

I never finished the _d_arrayliteralTX PRs as I wanted to get the 
other
PR working first, but I never thought they would take this long 
time to
fix.

Next week
~~~~~~~~~
Pretty much same as last week:
- Finish port of `_d_arrayliteralTX`
- Start working on the `_d_delarray_t*`, `_d_arrayassign*`, and
   `_d_arraysetassign` translations.
- Work on getting the previous PRs merged.
   - The PR for _d_arrayappendcTX need to more logic on how to 
lower the
     appending, and more logic on how to interpret the lowered
     expressions.
   - _d_array{,set}ctor need to implements some fixes to get the 
CTFE to
     work correctly.
   - _d_arraycatnTX need fixes related to the CTFE interpretion. 
Also
     need to fix the code based on the received feedback.


Blockers
~~~~~~~~
This passed week I've been fighting with the optimizer to always 
be able
to detect the lowered code inside dinterpret.

With _d_arrayappendcTX I've (so far?) identified four different
expression groups that I need be able to detect and rewrite back 
so the
CTFE interpretion works correctly. They are:

```
//Case 1: left is the _d_arrayappendcTX call, right is the 
assignment onto the array.
trs ~= fork(t, next, t.counter); // =>
_d_arrayappendcTX(trs, 1LU) , trs[__dollar - 1LU] = fork(t, next, 
t.counter);

//Case 2: left is the _d_arrayappendcTX call, right is the 
construction onto the array.
arr ~= T(nanF, '\xff').this(0); // =>
_d_arrayappendcTX(arr, 1LU) , (arr[__dollar - 1LU] = T , 
arr[__dollar - 1LU].this(0));

//Case 3: left is the _d_arrayappendcTX call, right is a postblit 
and the assignment onto the array.
this.data ~= ((T __copytmp = (__copytmp = 
val).__fieldPostblit();) , __copytmp); // =>
_d_arrayappendcTX(this.data, 1LU) , ((T __copytmp = (__copytmp = 
val).__fieldPostblit();) , this.data[__dollar - 1LU] = __copytmp);

//Case 4: left is __appendtmp var, right is case 1
op ~= cast(immutable(char))this.x; // =>
(immutable ref immutable(char) __appendtmp115 = this.x;) , 
(_d_arrayappendcTX(op, 1LU) , op[__dollar - 1LU] = 
__appendtmp115);
```

Related to the _d_array{,set}ctor PR, it currently fails at 
object.d
line 3636, 'assert(postblitRecurseOrder =' order);=. This is 
because
order is equal to:
```
copy inner #1
copy inner #1
copy inner #1
copy outer
copy inner #1
copy inner #2
destroy inner #1
```
Verses what is expected:
```
copy inner #1
copy inner #1
copy inner #1
copy outer
copy inner #1
copy inner #2
destroy inner #1
destroy outer
destroy inner #1
destroy inner #1
destroy inner #1
```

It has something to do with optimizations, and probably 
exceptions. I
have not been able to find the cause of it yet. But what happens 
is that
it never calls the destructor for 'arrCopy[0]'.

Related to _d_arraycatnTX it currently broken two place so far 
which I
need to find a real fix to before it is done. The first one is 
that
implicit cast to 'const(char)*' does not work anymore of a string
concatenations. The second problem I've found is that:
`void badOp(int x, int y = 1 ~ "string") {}` prints the error:
`Error: cannot implicitly convert expression ['\x01', 's', 't', 
'r', 'i', 'n', 'g'] of type string to int`
Instead of: `Error: cannot implicitly convert expression 
"\x01string" of type string to int`

I'm not sure why it prints the string as a 'char[]', but it needs 
to be
fixed before it can be merged.


Thoughts after the second milestone
===================================
 From my point of view I would classify this milestone as less 
productive
compared to the first one, but from the sense that I got a hook 
fully
into dmd and druntime you could classify that this was more 
successful
milestone.

I need to figure out what is most important to get done for the 
final
milestone and prioritize that. I don't think I will be able to 
finish
everything 100% as the dmd PR are getting more difficult for
optimization, and each edge-case. But I do think I will be able to
finish all the druntime PRs.


More information about the Digitalmars-d mailing list