Closed
Bug 61571
Opened 25 years ago
Closed 25 years ago
improve speculative RTTI heuristics
Categories
(Core :: XPCOM, defect, P3)
Tracking
()
RESOLVED
FIXED
People
(Reporter: waterson, Assigned: waterson)
Details
Attachments
(5 files)
|
2.02 KB,
patch
|
Details | Diff | Splinter Review | |
|
2.45 KB,
patch
|
Details | Diff | Splinter Review | |
|
3.91 KB,
patch
|
Details | Diff | Splinter Review | |
|
1.35 KB,
patch
|
Details | Diff | Splinter Review | |
|
4.03 KB,
patch
|
Details | Diff | Splinter Review |
Turns out that we can improve the speculative RTTI heuristics for c86 gcc: each
typeinfo() routine appears to have as its standard prologue either:
55 push %ebp
89e5 mov %esp,%ebp
53 push %ebx
or:
55 push %ebp
89e5 mov %esp,%ebp
56 push %esi
Previously, I was just looking for the first two instructions. Adding the third
makes us a bit more robust without having to go add a lot of ``special'' entry
points (some of which ended up being declared ``static'' in NSPR anyway.) Patch
soon...
| Assignee | ||
Comment 1•25 years ago
|
||
| Assignee | ||
Comment 2•25 years ago
|
||
Comment 3•25 years ago
|
||
+ // by egcs, plus a ``signature'' instruction that appears
+ // in the ).
+ unsigned** fp1 = reinterpret_cast<unsigned**>(vt) + 1;
Missing comment words after "in the " and before ")." ?
Otherwise looks good. r=brendan@mozilla.org.
/be
| Assignee | ||
Comment 4•25 years ago
|
||
| Assignee | ||
Comment 5•25 years ago
|
||
Cleaned up the comments a bit. beard, jband: could you sr=?
Comment 6•25 years ago
|
||
I'd prefer to see this code use byte comparisons, rather than comparing using an
unsigned pointers. This could have alignment implications and the resulting code
would probably be clearer.
Comment 7•25 years ago
|
||
What platforms don't align vtables on int (unsigned) boundaries?
/be
Comment 8•25 years ago
|
||
It's not the vtable, it's the code itself. Enclosing a patch that does what I'm
talking about.
Comment 9•25 years ago
|
||
Comment 10•25 years ago
|
||
sr=beard, either way.
| Assignee | ||
Comment 11•25 years ago
|
||
Sure, beard's is prettier. I'll use it.
Comment 12•25 years ago
|
||
beard, don't you want to axe the if-not-0-mod-4-aligned-then-return here?
+ unsigned char* ip = *fp1;
+ if ((unsigned(ip) & 3) != 0)
+ return 0;
/be
| Assignee | ||
Comment 13•25 years ago
|
||
Nah, leaving that in is fine. Saves us from slamming the signal handler if `ip'
points to 0x1, for example.
| Assignee | ||
Comment 14•25 years ago
|
||
Comment 15•25 years ago
|
||
waterson: I'm confused. That test dates from when ip was unsigned*, which could
be misaligned when reinterpret_cast'd from a bona fide instruction pointer. If
you care about nearly-null pointers, do a range test, but (ip & 3) != 0 then
return means the code may as well have used an unsigned* rather than unsigned
char* after all. Right?
/be
| Assignee | ||
Comment 16•25 years ago
|
||
Ah, I see what you're saying: the function's entry point need not be word
aligned.
As it turns out, on egcs-1.1.2, with ld-2.9.5, on x86, the typeinfo() entry
points *are* word aligned. Since this code is specific to the above magic
concoction of tools, the alignment test doesn't trigger any ``false negatives''.
And there's a small performance benefit: it reduces the probability that we'll
trip the SIGSEGV signal handler if it turns out we're looking at a random word
that's not a pointer.
Comment 17•25 years ago
|
||
Ah, good to know there won't be false negatives -- that was my concern, beyond
any generality in using a byte pointer rather than a word pointer.
>And there's a small performance benefit: it reduces the probability that we'll
>trip the SIGSEGV signal handler if it turns out we're looking at a random word
>that's not a pointer.
Good one -- "performance benefit"!
Seriously, if you want to sanity-check the pointer, why not bounds-check it in
relation to known text sections?
/be
| Assignee | ||
Updated•25 years ago
|
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
| Assignee | ||
Comment 18•25 years ago
|
||
Bah. I'm shippin' it.
You need to log in
before you can comment on or make changes to this bug.
Description
•