Closed
Bug 226597
Opened 21 years ago
Closed 21 years ago
nsObjectFrame.cpp Warning: String literal converted to char* in initialization.
Categories
(Core Graveyard :: Plug-ins, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: timeless, Assigned: timeless)
Details
Attachments
(1 file)
889 bytes,
patch
|
roc
:
review+
roc
:
superreview+
|
Details | Diff | Splinter Review |
"/export/home/timeless/mozilla/layout/html/base/src/nsObjectFrame.cpp", line
2664: Warning: String literal converted to char* in initialization.
once for each line.
Attachment #136193 -
Flags: superreview?(roc)
Attachment #136193 -
Flags: review?(roc)
Why do we want to do it this way? Does the warning go away if we change the
structure member types to "const char*"?
yes it goes away, but drepper indicates that we get a penalty because the data
has to be copied in at runtime.
Comment 4•21 years ago
|
||
With the proposed patch the total amount of data, size of read-writable data,
and code goes down.
So far each array entry needs two pointers and two (relative) relocations. And
the array itself is in read-writable memory. Accessing a string requires a
memory load.
With the new code the array is in read-only memory, no relocations are needed,
and accesses compute the strings address relative to the array address (no
additional memory access). The memory overhead caused by using the maximum
string length for each field is more than compensated by the pointer (4 or 8
byte) plus the relocation (8 - 24 bytes, depending on the platform). And the
program starts up faster since no runtime relocations are needed.
Using this new format is 100% the right way. For more info, see
http://people.redhat.com/drepper/dsohowto.pdf.
Intriguing. Thanks Ulrich. I don't suppose you know how well your analysis
applies to Windows DLLs too?
A few comments:
Section 1.5.4: Topological sort can usually be done in linear time.
I assume prelinking would avoid executing the two relocations? Would it also
avoid having to load the two relocations into memory?
Two other questions for my curiosity, if you don't mind:
Have you considered using tries to store symbol tables, instead of hashtables?
Suppose prelinking is really effective. Would it make sense to abandon PIC code
and hope that prelinking avoids most copy-on-writes?
Attachment #136193 -
Flags: superreview?(roc)
Attachment #136193 -
Flags: superreview+
Attachment #136193 -
Flags: review?(roc)
Attachment #136193 -
Flags: review+
Comment 7•21 years ago
|
||
First, I know not much about windows. The proposed code cannot hurt, though.
Maybe the benefits are not that big.
Re prelinking: yes, prelinking can avoid the relative relocations. But only if
the DSOs can really be prelinked. There are a few conditions (I think moz's
DSOs are fine). But importantly, the relocations are still present in the
binary. I.e., the address space consumption is still there. And probably even
memory consumption, since the conflict relocations always have to be processed
and this causes the pages with the relocations to be paged in. And in fact on
ia32, due to the nature of the used Elf32_Rel relocation, it might be that all
relocations get duplicated and there are additional Elf32_Rela relocations.
> Suppose prelinking is really effective. Would it make sense to abandon PIC
> code and hope that prelinking avoids most copy-on-writes?
You want to write DSOs without PIC? Prelinking won't help there much. You'll
end up with all kinds of text relocations. Every access to an external symbol
(like virtual function tables, variables) will cause a text relocation which is
not resolved at prelink time.
Okay, I see. Thanks for that! Couldn't you extend prelinking to speculatively
resolve external references, though?
Comment 9•21 years ago
|
||
> Couldn't you extend prelinking to speculatively resolve external references,
> though?
This is done, of course, but the lookup scope depends on the context. The DSO
paper cited above explains the lookup scope. A DSO used in different context
will have different scopes and the results of the lookups might be different.
The will cause text relocations, possibly many of them.
> the results of the lookups might be different.
They might, but if they're normally not different, then few text relocations
would need to be applied and non-PIC code might make sense. Right? Especially on
64-bit architectures where there's lots more virtual address space and it's much
easier to avoid collisions. I guess I should look at ld.so statistics and see
for myself. Thanks!!
Assignee | ||
Comment 11•21 years ago
|
||
checked in
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Updated•3 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•