Skip to content

Commit 1601229

Browse files
authored
Merge branch 'master' into type-links
2 parents 5287b69 + 4e1e8de commit 1601229

File tree

6 files changed

+27
-23
lines changed

6 files changed

+27
-23
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

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
),

spec/expression.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ $(GNAME PrimaryExpression):
13771377
$(GLINK2 declaration, FundamentalType) $(D $(LPAREN)) $(GLINK ArgumentList)$(OPT) $(D $(RPAREN))
13781378
$(GLINK2 type, TypeCtor) $(D $(LPAREN)) $(GLINK Type) $(D $(RPAREN)) $(D .) $(IDENTIFIER)
13791379
$(GLINK2 type, TypeCtor) $(D $(LPAREN)) $(GLINK Type) $(D $(RPAREN)) $(D $(LPAREN)) $(GLINK ArgumentList)$(OPT) $(D $(RPAREN))
1380-
$(GLINK2 declaration, Typeof)
1380+
$(GLINK2 type, Typeof)
13811381
$(GLINK TypeidExpression)
13821382
$(GLINK IsExpression)
13831383
$(D $(LPAREN)) $(GLINK Expression) $(D $(RPAREN))

spec/lex.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ $(MULTICOLS 4,
10161016
$(LINK2 type.html, $(D true))
10171017
$(LINK2 statement.html#TryStatement, $(D try))
10181018
$(LINK2 expression.html#TypeidExpression, $(D typeid))
1019-
$(LINK2 declaration.html#Typeof, $(D typeof))
1019+
$(LINK2 type.html#Typeof, $(D typeof))
10201020

10211021
$(LINK2 type.html, $(D ubyte))
10221022
$(LINK2 type.html, $(D ucent))

spec/template-mixin.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $(GNAME TemplateMixin):
1818
$(GNAME MixinTemplateName):
1919
$(D .) $(GLINK MixinQualifiedIdentifier)
2020
$(GLINK MixinQualifiedIdentifier)
21-
$(GLINK2 declaration, Typeof) $(D .) $(GLINK MixinQualifiedIdentifier)
21+
$(GLINK2 type, Typeof) $(D .) $(GLINK MixinQualifiedIdentifier)
2222

2323
$(GNAME MixinQualifiedIdentifier):
2424
$(GLINK_LEX Identifier)

spec/type.dd

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ $(GNAME BasicType):
2626
$(GLINK FundamentalType)
2727
$(D .) $(GLINK QualifiedIdentifier)
2828
$(GLINK QualifiedIdentifier)
29-
$(GLINK2 declaration, Typeof)
30-
$(GLINK declaration, Typeof) $(D .) $(GLINK QualifiedIdentifier)
29+
$(GLINK Typeof)
30+
$(GLINK Typeof) $(D .) $(GLINK QualifiedIdentifier)
3131
$(GLINK TypeCtor) $(D $(LPAREN)) $(GLINK Type) $(D $(RPAREN))
3232
$(GLINK Vector)
3333
$(GLINK2 grammar, Traits)
@@ -540,18 +540,20 @@ $(GNAME MixinType):
540540
---
541541

542542

543-
$(H2 $(LNAME2 size_t, $(D size_t)))
543+
$(H2 $(LNAME2 aliased-types, Aliased Types))
544+
545+
$(H3 $(LNAME2 size_t, $(D size_t)))
544546

545547
$(P $(D size_t) is an alias to one of the unsigned integral basic types,
546548
and represents a type that is large enough to represent an offset into
547549
all addressable memory.)
548550

549-
$(H2 $(LNAME2 ptrdiff_t, $(D ptrdiff_t)))
551+
$(H3 $(LNAME2 ptrdiff_t, $(D ptrdiff_t)))
550552
$(P $(D ptrdiff_t) is an alias to the signed integral basic type the same size as $(D size_t).)
551553

552-
$(H2 $(LNAME2 string, $(D string)))
554+
$(H3 $(LNAME2 string, $(D string)))
553555

554-
$(P A $(DDSUBLINK spec/arrays, strings, $(I string) is a special case of an arrays.))
556+
$(P A $(DDSUBLINK spec/arrays, strings, $(I string) is a special case of an array.))
555557

556558
$(SPEC_SUBNAV_PREV_NEXT declaration, Declarations, property, Properties)
557559
)

0 commit comments

Comments
 (0)