javascript - Why transformed the bytecode in the SpiderMonkey & JSC? -


The JavaScript engine is usually used to change the bytecode from the source code. Then, the byte code converts the native code.

1) Why turned the bytecode ?? Is the source code poorly converting the original code into bad performance? 2) If the source code is very simple (formerly A + b function), the source code that converts the original code is good?

complexity and portability .

Transforming source code and object code, whether it is bytecode for virtual machine or machine code for actual machine, a complex process Bytecode mimics the closest machines, and it is easy to work : To customize the code to run faster, it is also better to change the code or to convert it to other formats to make the machine larger, if the situation says for it.

For this reason, it is usually easier to write an front end whose source is to convert the work into bytes (or some other intermediate language < / Em>), and then an back end that works on intermediate language: it optimizes, produces machine code, and for all languages ​​like Jazz C More traditional compilers have done this for a long time. Java can be considered as an unusual application of this principle: its manufacturing process usually stops with intermediate representation (i.e. Java bytecode), and then developers send it out so that when the user runs it, then JVM "Can finish work"

There are two major advantages of working in this way, working on simplifying the code on one side The first big advantage is that you can use the backend to work with other languages. This does not matter to Javascript (which is not a standardized backend), but projects like LLVM and GCC eventually increase to cover so many different languages. Writing the frontend is difficult, but we say that I have made, for example, a luwa frontend for Mozilla's JavaScript backend. Then I can tap into all customization tasks that Mozilla has put in the backend. It saves me a lot of work.

The second big advantage is that you can reuse the frontend to work with more machines for this one does The practical effect is Javascript if I want to write a Javascript translator, maybe I will write my first backend - for x86 - use most architecture - because at that point I was probably doing development work. But most cell phones do not use x86-based architecture-ARM is more common these days - so if I want to run fast on cell phones, then I have to add an ARM backend. But I could have done this without having to rewrite the whole frontend, so once again, I have saved myself a lot of work if I wanted to run on Wii U (or the previous generation of game console, or older Mac) I'll need a power backend, but again, I can do this without having to type the frontend again.

The bottom line is that when it seems more complex to make two changes, in the long run it becomes really easy from those strange and uncontrollable things One that is sometimes fashioned in software design, but the benefits are real.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -