Closed Bug 432487 Opened 16 years ago Closed 16 years ago

IL should be shared between multiple MethodEnv's of the same Function

Categories

(Tamarin Graveyard :: Tracing Virtual Machine, defect, P1)

x86
macOS
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: edwsmith, Assigned: stejohns)

References

Details

Attachments

(2 files, 1 obsolete file)

Each MethodEnv captures a scope chain for an underlying function.  IL is currently (wrongly) associated with MethodEnv rather than the underlying code, so we end up duplicating IL for the function.

This is unbounded duplication.  Tracing magnifies the problem because if the functions call a hot subroutine, the many closures look like many call sites, causing much inlining, or if the subroutine has a loop, high fan-out on the path exiting the loop back to the caller.

ESC on TT demonstrates this problem with Hashtable.read() calling eqfn() to compare strings
Blocks: 431541
Priority: -- → P1
Assignee: nobody → edwsmith
Status: NEW → ASSIGNED
What if we could have multiple instances of the same MethodEnv-with-different-scope just share pointers to the same IL? If they all refer to the same underlying code then it should be identical code (and if not then they need different IL chunks anyway)

I guess the issue is how to do that sharing; if we are always verified at least once before MethodEnv::cloneWithNewScope is called then it should be easy-peasy... but I don't think that is the case. 
Stealing this, I see a simple way to deal with it
Assignee: edwsmith → stejohns
Status: ASSIGNED → NEW
Attached patch fixes this and other misc stuff (obsolete) — Splinter Review
This code is stale, but addresses this bug.  highlights:

* lots of int->int32_t noise
* optimize emit_LIT to use DUP or OVER when possible
* specializations of get/set/findprop
* got rid of the "gmi" entry point, everything is in ckargs
* ops that take a nameid take a nameoff instead (offset into abc), one less thing to do at runtime
* get rid of everCalled()
* added OP_getouterscope
Attachment #326604 - Flags: review?(stejohns)
Attachment #326604 - Flags: review?(stejohns)
Attached patch Updated PatchSplinter Review
This encompasses part of your patch, but not all. 

Included:
* The basic IL-sharing fix, improved a bit to remove two more pointers from MethodEnv (storing 'em in AbcEnv is better since they won't ever be replicated, IMHO)
* optimize emit_LIT to use DUP or OVER when possible
* got rid of the "gmi" entry point, everything is in ckargs
* get rid of everCalled()

Not included:
* lots of int->int32_t noise
* specializations of get/set/findprop
* ops that take a nameid take a nameoff instead (offset into abc), one less
thing to do at runtime
* added OP_getouterscope

This gives a modest but measurable speed improvement on sunspider tests, probably due to increased efficiency of closures with this code.
Attachment #326604 - Attachment is obsolete: true
Attachment #326828 - Flags: review?(edwsmith)
Attachment #326828 - Attachment is patch: true
Here's another patch (additive to previous one) to adapt the pending-const-speedup as well. This uses a new-and-improved technique different from the one in Edwin's initial patch.
Attachment #326975 - Flags: review?(edwsmith)
Attachment #326975 - Flags: review?(edwsmith) → review+
Attachment #326828 - Flags: review?(edwsmith) → review+
pushed as changeset:   442:0e2c25c2537a
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: