|
|
|
[
Permlink
| « Hide
]
JIRA Migration Admin - [06/04/07 12:35 PM ]
Move from BugDB issue number 161818
Milestone ID = 905
Milestone = Flash 9.0 - Deferred Bugs Build ID = 17275 Build = AVMPLUS_1_0_0_d538 Fix Build ID = null Fix Build = null [wsharp 3/6/06] Entered Bug.
[dansmith 3/7/06] Deferring for this release. Good optimization for following release. [edwsmith 3/8/06] implementation notes: there are two suggestions here, comments for each 1. speed up early binding to static functions. Math.abs() becomes findproperty<Math> early-bind-to abs() The findproperty is slow, it requires a HT lookup. fix 1 (asc): at compile time, recognize that the result of findproperty can't vary from call to call in the same scope, so only call it once and keep re-using the result. this requires no vm changes and would give the 2x speedup fix 2 (avm): the findproperty call is necessary because we dont have a vm-wide int-indexed table of the toplevel symbols. but we could. Domain & DomainENV could be updated to assign every toplevel symbol an integer slot in a single table. at verify time, we would look for Math and find it in the Domain and get the integer slot_id. at run time, we'd use the id to index into a DomainENV based table. The two tables would have parallel structure, just like method_id's work (traits has a table of AbstractFunction* pointers) and VTable has a table organized the same way, with MethodENV pointers. 2. inline math functions like abs() and sqrt(), to use FPU instructions. first, create some opcodes for these functions, like OP_abs and OP_sqrt. then there are two approaches, as before. fix 1 (asc) use the new opcodes fix 2 (avm) recognize Math.abs at VT and call MIR to emit OP_abs (etc) like we do for other ops. either way, implement OP_abs/sqrt, etc, in MIR as follows. in pass 1 (verify pass) if we know we have an FPU with the right operation, generate MIR_abs, MIR_sqrt, etc. (new floating point MIR operations). If we don't, then emit MIR_cs to call some static helper function. in the second pass, generate MD code for MIR_abs, sqrt, etc, using the cpu instructions that make sense. note that if the CPU/FPU doesn't have the operation, then the MIR code will already have a static call to a helper. We don't want to have a MIR opcode that calls a static helper. if a helper is required, it should be invoked with the appropriate MIR call opcode. for example, x87 has sin/cos/tan, but SSE and PPC don't. but all three FPU's have sqrt support. Ed The Math binding in the global object is mutable and the function properties on the Math object are mutable and deletable in ES3 and ES4. Thus Ed's fix 1.1 fails (if we want to be standards-compliant). Fix 1.2 is better but we'd still have to dynamically look up the function property in the Math object, and then call it. Inlining has similar issues.
Another fix might be to do guarded inlining, ie, recognize Math.foo on the source level and effectively rewrite it to code like this: $theMathObjectIsDirty ? Math.foo(x) : OP_foo(x) which checks a bit in some data structure (the Domain?) that is set whenever the Math object is modified or whenever the global object's Math binding is modified. Effectively, it pushes the complexity into the Math object and into the global object. Even with that fix, "with" and "eval" get in the way, as they can introduce new bindings for "Math", so the optimization is not available in a scope affected by any of those constructs. Alternatively I suppose it's possible to inline if some incantation can turn on early-binding. Is there such an incantation already? back to internal review for reprioritization
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||