Skip to content

Commit 80fb8e0

Browse files
committed
Merge remote-tracking branch 'upstream/master' into stable
2 parents 8203e3c + 8f6609e commit 80fb8e0

34 files changed

+838
-654
lines changed

articles/code_coverage.dd

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ $(LI It can be used to track down why a particular section of code
3434

3535
$(LI Since execution counts are given for each line, it is possible
3636
to use the coverage analysis to reorder the basic blocks in
37-
a function to minimize jmps in the most used path, thus
38-
optimizing it.)
39-
)
37+
a function to minimize branches in the most used path, reducing stress
38+
on the processor's pipeline (a run-of-the-mill X86 processor can usually handle 48 branches in its pipeline). This technique
39+
is a special case of $(LINK2 https://en.wikipedia.org/wiki/Profile-guided_optimization, profile-guided optimization), which can
40+
be performed automatically if either the `LLVM` or `GCC` backend is utilized.
41+
))
4042

4143
$(P Experience with code coverage analyzers show that they dramatically
4244
reduce the number of bugs in shipping code.
43-
But it isn't a panacea, a code coverage analyzer won't help with:)
45+
But it isn't a panacea, a code coverage analyzer won't help (unlike Valgrind or the sanitizers available in GCC and LLVM) with:)
4446

4547
$(OL
4648
$(LI Identifying race conditions.)
@@ -51,18 +53,18 @@ $(LI Verifying that the program got the correct result.)
5153

5254
$(P Code coverage analysers are available for many popular languages,
5355
but they are often third party products that integrate
54-
poorly with the compiler, and are often very expensive.
56+
poorly with the compiler.
5557
A big problem with third party products is, in order to instrument
56-
the source code, they must include what is essentially a full blown
58+
the source code, they must include what is essentially a full-blown
5759
compiler front end for the same language. Not only is this an expensive
5860
proposition, it often winds up out of step with the various compiler
5961
vendors as their implementations change and as they evolve various extensions.
6062
($(LINK2 http://gcc.gnu.org/onlinedocs/gcc-3.0/gcc_8.html, gcov),
61-
the Gnu coverage analyzer, is an exception as it is both free
63+
the Gnu coverage analyzer is an exception as it is both free
6264
and is integrated into gcc.)
6365
)
6466

65-
$(P The D code coverage analyser is built in as part of the D compiler.
67+
$(P The D code coverage analyser is part of the D compiler.
6668
Therefore, it is always in perfect synchronization with the language
6769
implementation. It's implemented by establishing a counter for each
6870
line in each module compiled with the $(DDSUBLINK dmd,switch-cov, $(B -cov)) switch.
@@ -78,7 +80,7 @@ $(P For example, consider the Sieve program:)
7880

7981
import std.stdio;
8082

81-
bool flags[8191];
83+
bool[8191] flags;
8284

8385
int main()
8486
{
@@ -124,7 +126,7 @@ $(CONSOLE
124126
|
125127
|import std.stdio;
126128
|
127-
|bool flags[8191];
129+
|bool[8191] flags;
128130
|
129131
|int main()
130132
|{
@@ -163,13 +165,13 @@ as the execution count.
163165
At the end of the .lst file, the percent coverage is given.
164166
)
165167

166-
$(P There are 3 lines with an exection count
168+
$(P There are 3 lines with an execution count
167169
of 1, these were each executed once. The declaration line for $(D i, prime),
168170
etc., has 5 because there are 5 declarations, and the initialization of
169171
each declaration counts as one statement.)
170172

171173
$(P The first $(D for) loop shows 22. This is the sum of the 3 parts
172-
of the for header. If the for header is broken up into 3 lines, the
174+
of the for-header. If the for-header is broken up into 3 lines, the
173175
data is similarly divided:)
174176

175177
$(CONSOLE
@@ -263,7 +265,7 @@ sieve --DRT-covopt="merge:1 dstpath:reports"
263265

264266
$(H3 References)
265267

266-
$(LINK2 https://en.wikipedia.org/wiki/Code_coverage, Wikipedia)
268+
$(LINK2 https://en.wikipedia.org/wiki/Code_coverage, Wikipedia: "Code Coverage")
267269

268270
)
269271

articles/variadic-function-templates.dd

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,33 +124,32 @@ $(H2 $(LNAME2 d-solutions, D Programming Language Solutions))
124124

125125
$(H3 The D Look Ma No Templates Solution)
126126

127-
$(P It is not practical to solve this problem in C++ without
128-
using templates. In D, one can because D supports typesafe
129-
variadic function parameters.
127+
$(P The current best practice, e.g. as espoused by the standard library, favours
128+
the variadic template solution. However, if the template solution is not practical, D provides a runtime solution
129+
utilizing the $(D TypeInfo) system (An example is shown below). There is a lexical similarity with the
130+
non-template variadic functions provided by C and C++ ($(D va_list)), however the solution D provides is
131+
typesafe whereas the aforementioned alternative is not.
130132
)
131133

132134
------
133135
import core.vararg;
134136
import core.stdc.stdio;
135-
import std.format;
136-
137+
/*
138+
This function was part of D1.0, but does not exist anymore, it has been
139+
resurrected here to give a realistic example of how this feature could be used.
140+
*/
141+
void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr);
137142
void print(...)
138143
{
139144
void putc(dchar c)
140145
{
141146
fputc(c, stdout);
142147
}
143148

144-
std.format.doFormat(&putc, _arguments, _argptr);
149+
doFormat(&putc, _arguments, _argptr);
145150
}
146151
------
147152

148-
$(P It isn't elegant or the most efficient,
149-
but it does work. However it is not the recommended way to write variadic functions.
150-
(It relies on the parameters `_argptr` and `_arguments` imported from `core.vararg`
151-
which give a pointer to the values and their types, respectively.)
152-
)
153-
154153
$(H3 Translating the Variadic C++ Solution into D)
155154

156155
$(P Variadic templates in D enable a straightforward translation
@@ -195,7 +194,7 @@ $(H3 The Static If Solution)
195194

196195
$(P It would be nice to encapsulate all the logic into a
197196
single function. One way to do that is by using
198-
$D(static if)s, which provide for conditional compilation:
197+
$(D static if)s, which provide for conditional compilation:
199198
)
200199

201200
---

changelog/2.096.0.dd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $(LI $(RELATIVE_LINK2 dtoh-improvements,Improvements for the C++ header generati
2222
$(LI $(RELATIVE_LINK2 dwarf-switch,Add `-gdwarf=<version>` switch for the DMD compiler.))
2323
$(LI $(RELATIVE_LINK2 getVisibility,Introduced `__traits(getVisibility, Sym)` as an alias to `getProtection`))
2424
$(LI $(RELATIVE_LINK2 runtime-synchronized,Plain `synchronized` statements now use run-time allocated mutexes.))
25-
$(LI $(RELATIVE_LINK2 shortfunctions,Allow shortened function implementations for single-expresssion functions.))
25+
$(LI $(RELATIVE_LINK2 shortfunctions,Allow shortened function implementations for single-expression functions.))
2626

2727
)
2828

@@ -375,7 +375,7 @@ $(BUGSTITLE_BUGZILLA DMD Compiler regression fixes,
375375

376376
$(LI $(BUGZILLA 20661): opEquals not recognized for AA key $(LPAREN)take two$(RPAREN))
377377
$(LI $(BUGZILLA 21319): DMD crashes on immutable circular reference)
378-
$(LI $(BUGZILLA 21547): Oder of constructor declaration affects struct initializer)
378+
$(LI $(BUGZILLA 21547): Order of constructor declaration affects struct initializer)
379379
$(LI $(BUGZILLA 21678): "_d_arraysetlengthT is not callable using argument types" on chained array length assignment)
380380
$(LI $(BUGZILLA 21696): DMD 2.095.1 Compilation Crash)
381381
)

comparison.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ $(ITEMIZE
6767
$(A spec/template-mixin.html, Mixins),
6868
$(A spec/version.html#staticif, static if),
6969
$(A spec/expression.html#IsExpression, expressions),
70-
$(A spec/declaration.html#Typeof, typeof),
70+
$(A spec/type.html#Typeof, typeof),
7171
$(A spec/statement.html#ForeachStatement, foreach),
7272
$(A spec/declaration.html#AutoDeclaration, Implicit Type Inference)
7373
),

deprecate.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $(SPEC_S Deprecated Features,
1818
$(TROW $(DEPLINK Using the result of a comma expression), 2.072, 2.072, 2.079, &nbsp;)
1919
$(TROW $(DEPLINK delete), &nbsp;, 2.079, &nbsp;, &nbsp;)
2020
$(TROW $(DEPLINK scope as a type constraint), &nbsp;, 2.087, &nbsp;, &nbsp;)
21-
$(TROW $(DEPLINK Imaginary and complex types), future, &nbsp;, &nbsp;, &nbsp;)
21+
$(TROW $(DEPLINK Imaginary and complex types), future, 2.097, &nbsp;, &nbsp;)
2222
$(TROW $(DEPLINK Implicit catch statement), 2.072, 2.072, 2.081, &nbsp; )
2323
$(TROW $(DEPLINK .sort and .reverse properties for arrays), ?, 2.072, &nbsp;, 2.075)
2424
$(TROW $(DEPLINK C-style array pointers), ?, 2.072, 2.082, &nbsp;)

foundation/sponsors.dd

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,36 @@ $(LINK2 mailto:social@dlang.org, social@dlang.org). We're eager to add you to it
5252
)
5353

5454
$(UL
55-
$(LI Andrei Alexandrescu)
56-
$(LI Etienne Cimon)
55+
$(LI Vijay Nayar)
56+
$(LI George Toutoungis)
5757
$(LI John Hall)
5858
$(LI Gerhardus Jansen)
5959
$(LI Radu Racariu)
60-
$(LI Vijay Nayar)
61-
$(LI George Toutoungis)
6260
$(LI Bastiaan Veelo)
61+
$(LI Jared Hanson)
62+
$(LI C. Piker)
6363
$(LI Sepany)
64+
$(LI JR)
6465
$(LI Ali Çehreli)
6566
$(LI Longinus Ulyanovsky)
6667
$(LI Jack Applegame)
6768
$(LI Emil Nicolaie Perhinschi)
68-
$(LI JR)
69+
$(LI Alex Semenikhine)
6970
$(LI Georges Robert)
70-
$(LI C. Piker)
71+
$(LI Ross Lonstein)
7172
$(LI D. Gilliland)
7273
$(LI Alexander Bothe)
7374
$(LI Unity Technologies ApS)
74-
$(LI Jared Hanson)
7575
$(LI Zhang Zongren)
7676
$(LI Dag)
77+
$(LI Jeffrey Buhr)
78+
$(LI Matthew Strawbridge)
7779
$(LI Paul)
78-
$(LI Alex Semenikhine)
80+
$(LI Andrii Bazylevych)
81+
$(LI Aaron Disibio)
7982
$(LI Sebastian Wilzbach)
83+
$(LI Andrei Alexandrescu)
84+
$(LI Etienne Cimon)
8085
)
8186
)
8287

glossary.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ $(DL
5656
$(DD Refers to the ability to instantiate a template function
5757
without having to explicitly pass in the types to the template.
5858
Instead, the types are inferred automatically from the types of the
59-
runtime arguments.)
59+
runtime arguments. See $(LINK2 spec/template.html#ifti, spec) for details.)
6060

6161
$(DT Illegal)
6262
$(DD A code construct is illegal if it does not conform to the

index.dd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,16 @@ $(EXTRA_EXAMPLE_RUNNABLE Sort an Array at Compile-Time,
103103
----
104104
void main()
105105
{
106-
import std.algorithm, std.conv, std.stdio;
106+
import std.algorithm, std.stdio;
107107

108108
"Starting program".writeln;
109109

110-
// Sort a constant declaration at Compile-Time
111110
enum a = [ 3, 1, 2, 4, 0 ];
111+
// Sort data at compile-time
112112
static immutable b = sort(a);
113113

114114
// Print the result _during_ compilation
115-
pragma(msg, text("Finished compilation: ", b));
115+
pragma(msg, "Finished compilation: ", b);
116116
}
117117
----
118118
)

spec/abi.dd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ $(GNAME Value):
284284
$(GLINK CharWidth) $(GLINK Number) $(B _) $(GLINK HexDigits)
285285
$(B A) $(GLINK Number) $(GLINK Value)...
286286
$(B S) $(GLINK Number) $(GLINK Value)...
287+
$(B f) $(GLINK MangledName)
287288

288289
$(GNAME HexFloat):
289290
$(B NAN)

spec/arrays.dd

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,14 +666,15 @@ array.length = i;
666666
---------
667667
)
668668

669-
$(P Picking a good initial guess is an art, but you usually can
670-
pick a value covering 99% of the cases.
669+
$(P Base selection of the initial size on expected common
670+
use cases, which can be determined by instrumenting the code,
671+
or simply using good judgement.
671672
For example, when gathering user
672673
input from the console - it's unlikely to be longer than 80.
673674
)
674675

675-
$(P Also, you may wish to utilize the $(D reserve)
676-
function to pre-allocate array data to use with the append operator.)
676+
$(P The $(D reserve)
677+
function expands an array's capacity for use by the append operator.)
677678

678679
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
679680
---------

0 commit comments

Comments
 (0)