Closed
Bug 444598
Opened 18 years ago
Closed 17 years ago
Need a better approach to abc->IL conversion
Categories
(Tamarin Graveyard :: Tracing Virtual Machine, defect)
Tamarin Graveyard
Tracing Virtual Machine
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: treilly, Unassigned)
Details
Attachments
(1 file, 2 obsolete files)
|
43.77 KB,
patch
|
stejohns
:
review+
|
Details | Diff | Splinter Review |
There's a lot of potential for optimizing the VM by doing clever things in the abc->IL conversion step. The approach we have today is to just have highlevel EXTERN's for all abc opcodes is nice and simple but less than ideal. Nothing the Verifier knows about the code (types) or the code emitter knows about our IL can be utilized. A trivial example is comparing a String to null (ie OP_pushnull/OP_ifstrictne) resulting in:
global/flash.internal::checkNull()+11 OP_pushnull
global/flash.internal::checkNull()+12 OP_ifstrictne
code_pool+4305 BR -3485=k_code_pool+821
code_pool+821 op__2boxtype_plus_0000
code_pool+822 CASE
code_pool+7522 CASE
code_pool+7818 op_DROP_DROP_LIT0
code_pool+7819 EXIT
Where a simple "0 =" would have been faster and made for smaller IL. So how do we translate abc into IL more optimally. superwording and x86 IL are great but I think a smarter translator are needed. Any improvements in the IL will result in better traced code as well.
Goals are:
1) small IL, we want to approach 1 on the abc::IL ratio
2) fast IL, all Verifier knowledge and IL capability should be taken advantage of to produce optimal IL.
3) fast translation, ideally we translate entire methods in the Verifier pass very quickly just like today only much better code comes out, although if a more expensive system results in a net win for performance its okay.
This is a big feature/bug, mostly creating it to track commentary/ideas.
Comment 1•18 years ago
|
||
we can attack this in increments:
- peephole: works pretty good, but the patterns we'd check for start adding up so there should be a good way to organize the code
- since stack machine bytecode is serialized expression trees, you can get pretty far with a greedy matcher automaton (like a regex matcher). google for DBURG for an example where bytecode tree patterns are matched by an automaton built from a tree grammer
- crib from MIR: two passes, build expression trees and perform copy/constant propagation and cse in one pass, then emit code in two passes. the cost of this is it destroys the stack-nature of the code... emitting register-based code is straightforward, just like MIR's second pass. emitting stack code is doable but would require a redesigned second pass -- CSE and copy propagation makes the expression trees into expression dags which complicates emitting stack machine code
| Reporter | ||
Comment 2•17 years ago
|
||
Attachment #329511 -
Flags: review?(edwsmith)
| Reporter | ||
Comment 3•17 years ago
|
||
Instead of more peephole optimizations like this I think a good next step would be to use GlobalOptimizer's data structures to analyze expression trees in a large flex app. Are there a few very common things we should optimize or is there a ton of variabilty that wants something more sophisticated than peephole.
| Reporter | ||
Updated•17 years ago
|
Attachment #329511 -
Flags: review?(stejohns)
Comment 4•17 years ago
|
||
Comment on attachment 329511 [details] [diff] [review]
some optimizations that proved affective for a large Flex app
Looks good to me, but you should probably get Edwin to review+ it too -- he know the details of IL better than I
Attachment #329511 -
Flags: review?(stejohns) → review+
Comment 5•17 years ago
|
||
in Verifier.cpp is "delete mi2" safe? does buildMethodInfoFor(env) always return a new object?
in vm.fs OP_callstatic_only, it's a good idea to factor out shared code even if it will be inlined back together either by fc.py or the tracer.
is dump_prim_use() leaving any scalpels in the patient? not at first glance, just want to be sure.
Updated•17 years ago
|
Attachment #329511 -
Flags: review?(edwsmith) → review+
| Reporter | ||
Comment 6•17 years ago
|
||
Optimized prereap to mark only active part of stack
Refactored how we deal with MethodInfo's so they are always stack allocated.
Refactored code for needs arg coersion
Attachment #329511 -
Attachment is obsolete: true
Attachment #329684 -
Flags: review?(edwsmith)
Comment 7•17 years ago
|
||
Comment on attachment 329684 [details] [diff] [review]
abc->IL peephole opts and some misc others
state.sp and state.rp tell you where the current top of stack is, why not just use those?
| Reporter | ||
Comment 8•17 years ago
|
||
Tried that and things got really crashy. Does the tracer really update state.sp? I thought we'd need to push it out beyond max_local/max_scope b/c the tracer just writes to the stack and doesn't keep it up to date, remember DRC can happen at any object allocation.
Comment 9•17 years ago
|
||
oic, no the trace doesn't keep currentState.sp/rp up to date. it doesn't keep currentState.f fresh either, afaik. it could if we knew which calls could invoke the gc, however.
trying to estimate where the active part of the stack top is, however, won't work either -- you don't know how far deep the call is, that triggered the gc run. could be several stack frames deep.
Comment 10•17 years ago
|
||
one solution could be to insert gc safe points on the trace, where we flush out
currentState and let the gc do its thing, if it wants to.
| Reporter | ||
Comment 11•17 years ago
|
||
Now just looking for review of MethodInfo changes...
Attachment #329684 -
Attachment is obsolete: true
Attachment #329695 -
Flags: review?(stejohns)
Attachment #329684 -
Flags: review?(edwsmith)
Comment 12•17 years ago
|
||
Comment on attachment 329695 [details] [diff] [review]
Scratch prereap optimizations, now just abc->IL and MethodInfo refactoring
(1) could we add a comment to prereap indicating why the code is commented out?
(2) it looks like some (but not all) of my TraitsData-leak-fix is included in this (the m_tdref stuff in TraitsEnv), did you mean to include it?
Attachment #329695 -
Flags: review?(stejohns) → review+
| Reporter | ||
Comment 13•17 years ago
|
||
The comented out code is gone, I made a bug for fixing prereap, I'll regenerate the patch on top of your traits fix when it lands.
Comment 14•17 years ago
|
||
traits fix landed this afternoon
| Reporter | ||
Comment 15•17 years ago
|
||
pushed in 505:57e806aa856d
| Reporter | ||
Comment 16•17 years ago
|
||
the wordcode stuff addresses this need nicely.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•