Closed Bug 61571 Opened 25 years ago Closed 25 years ago

improve speculative RTTI heuristics

Categories

(Core :: XPCOM, defect, P3)

x86
Linux
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: waterson, Assigned: waterson)

Details

Attachments

(5 files)

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...
+ // 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
Cleaned up the comments a bit. beard, jband: could you sr=?
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.
What platforms don't align vtables on int (unsigned) boundaries? /be
It's not the vtable, it's the code itself. Enclosing a patch that does what I'm talking about.
sr=beard, either way.
Sure, beard's is prettier. I'll use it.
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
Nah, leaving that in is fine. Saves us from slamming the signal handler if `ip' points to 0x1, for example.
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
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.
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
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Bah. I'm shippin' it.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: