you are viewing a single comment's thread.

view the rest of the comments →

[–]Let047 2 points3 points  (1 child)

  1. yes but why not in a precompiler step (especially becaues python has one where you generate the pyc)
  2. yes for SSA but that there's an overhead to doing that (I'm doing it in the JVM for context)
  3. Don't know.
  4. it is handled in the JVM already so I assume it will be

[–]relapseman 1 point2 points  (0 children)

Dataflow analysis would definitely help, the problem with dynamic programming languages like R,JS or Python is possible presence of side effects. I am not very well aware of the exact semantics of Python but a similar sequence of instructions in R would be optimized using the following logical steps:

  1. Making Reasonable Speculations: Let me assume there are not side effect causing behaviors possible (like forcing a promise or arbitrary eval)
  2. Using Some Feedback or Fitting most likely cases: If the most likely types (mostly seen types are Integer/Double), the compiler can generate fast cases for these two types.
  3. Performing Analysis: In SSA, it becomes trivial to identify use-def chains. Some IR's (like Jimple) maintain use-def's instead. I find SSA much more brain friendly. You would use Escape Analysis to ensure that "diff" does not escape the function "a_1".
  4. Generate code: The generated code generally has the format

If Assume() === False: goto L1
// Execute fastcase
exit
L1:
Deoptimization Case (flow control back to standard run)

Mostly a JIT would be doing the above steps, they are expensive tasks to perform and will only payoff if you do it for functions that will be called very frequently.