* Pragma inline results in duplicate strings?
@ 1997-06-04 0:00 Dale Stanbrough
1997-06-04 0:00 ` Samuel Tardieu
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Dale Stanbrough @ 1997-06-04 0:00 UTC (permalink / raw)
You'll probably say "implementation dependent", but i am wondering what the
normal thing for compilers to do is in the following situation.
procedure Break is
begin
Put ("<br>");
end;
pragma Inline (Break);
Is the string duplicated for each inline call?
Dale
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Pragma inline results in duplicate strings?
1997-06-04 0:00 Pragma inline results in duplicate strings? Dale Stanbrough
@ 1997-06-04 0:00 ` Samuel Tardieu
1997-06-07 0:00 ` Robert Dewar
1997-06-09 0:00 ` Tucker Taft
2 siblings, 0 replies; 5+ messages in thread
From: Samuel Tardieu @ 1997-06-04 0:00 UTC (permalink / raw)
To: Dale Stanbrough
>>>>> "Dale" == Dale Stanbrough <dale@goanna.cs.rmit.edu.au> writes:
Dale> Is the string duplicated for each inline call?
Not with GNAT.
See the following piece of code:
with Ada.Text_IO; use Ada.Text_IO;
procedure T is
procedure Break;
pragma Inline (Break);
procedure Break is
begin
Put_Line ("<br>");
end Break;
begin
Break;
Break;
end T;
It generates the following on a i386 with GNAT:
.file "t.adb"
.version "01.01"
gcc2_compiled.:
.section .rodata
.LC0:
.string "<br>"
.align 4
.LC1:
.long 1
.long 4
(the .text section has been omitted)
So it appears that GNAT is sharing strings literal, at least for
several instances of the same string in the same package. I haven't
tested how it behaves with external calls to Break.
Sam
--
Samuel Tardieu -- sam@ada.eu.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Pragma inline results in duplicate strings?
1997-06-04 0:00 Pragma inline results in duplicate strings? Dale Stanbrough
1997-06-04 0:00 ` Samuel Tardieu
@ 1997-06-07 0:00 ` Robert Dewar
1997-06-09 0:00 ` Tucker Taft
2 siblings, 0 replies; 5+ messages in thread
From: Robert Dewar @ 1997-06-07 0:00 UTC (permalink / raw)
Dale asks
<< procedure Break is
begin
Put ("<br>");
end;
pragma Inline (Break);
Is the string duplicated for each inline call?
>>
Right, this is ID, but most likely one would not want it duplicated, but in some
environments you might get at least one copy per unit that does inlining.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Pragma inline results in duplicate strings?
1997-06-04 0:00 Pragma inline results in duplicate strings? Dale Stanbrough
1997-06-04 0:00 ` Samuel Tardieu
1997-06-07 0:00 ` Robert Dewar
@ 1997-06-09 0:00 ` Tucker Taft
1997-06-11 0:00 ` Tucker Taft
2 siblings, 1 reply; 5+ messages in thread
From: Tucker Taft @ 1997-06-09 0:00 UTC (permalink / raw)
Dale Stanbrough (dale@goanna.cs.rmit.edu.au) wrote:
: You'll probably say "implementation dependent", but i am wondering what the
: normal thing for compilers to do is in the following situation.
Implementation dependent ;-). Some compilers "pool" strings, and
others don't. There is no reason *not* to pool strings in Ada,
since they are constants (unlike in C, where a string literal might
be updated through a pointer). It probably makes no difference
whether the string appears in an inline, I suspect. If the
same string is used multiple times in a single source file,
it is straightforward for the compiler to share a single
copy of the string.
: procedure Break is
: begin
: Put ("<br>");
: end;
: pragma Inline (Break);
: Is the string duplicated for each inline call?
: Dale
--
-Tucker Taft stt@inmet.com http://www.inmet.com/~stt/
Intermetrics, Inc. Burlington, MA USA
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Pragma inline results in duplicate strings?
1997-06-09 0:00 ` Tucker Taft
@ 1997-06-11 0:00 ` Tucker Taft
0 siblings, 0 replies; 5+ messages in thread
From: Tucker Taft @ 1997-06-11 0:00 UTC (permalink / raw)
Tucker Taft (stt@houdini.camb.inmet.com) wrote:
: ... Some compilers "pool" strings, and
: others don't. There is no reason *not* to pool strings in Ada,
: since they are constants (unlike in C, where a string literal might
: be updated through a pointer).
I was reminded that ISO/ANSI C does *not* permit updating the characters
of a string literal. Old "classic" C allowed this sort of thing, but
ISO/ANSI C frowns on it, and I suspect most modern C compilers pool
all duplicate string literals appearing in a single source file.
-Tucker Taft stt@inmet.com http://www.inmet.com/~stt/
Intermetrics, Inc. Burlington, MA USA
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1997-06-11 0:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-04 0:00 Pragma inline results in duplicate strings? Dale Stanbrough
1997-06-04 0:00 ` Samuel Tardieu
1997-06-07 0:00 ` Robert Dewar
1997-06-09 0:00 ` Tucker Taft
1997-06-11 0:00 ` Tucker Taft
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox