Difference between bytecode processed instruction and machine language?

"A bytecode program is usually executed by parsing instructions one at a time. Such a bytecode interpreter is very portable. Some systems, called dynamic translators or just-in-time (JIT) compilers, translate the bytecode into machine language as needed during execution: this makes the virtual machine impossible. "

The question about this paragraph is this: after processing the bytecode, what is the difference between the analyzed instruction and the machine language (or machine code)?

+3
source share
4 answers

JIT .

C-:

int sum() {
   return 5 + 6;
}

. x86 ARM .

-, :

for(;;) {
   switch(*currentInstruction++) {
   case OP_PUSHINT:
      *stack++ = nextInt(currentInstruction);
      break;
   case OP_ADD:
      --stack;
      stack[-1].add(*stack);
      break;
   case OP_RETURN:
      return stack[-1];
   }
}

:

OP_PUSHINT (5)
OP_PUSHINT (6)
OP_ADD
OP_RETURN

x86, ARM, , .

JIT, ( ) , ++, .

+7

- JIT- - , .

+2

- "" . , "" ( "" ) , , . - .

JIT , . , JIT . , - . - , &mdash, . ( - , JITted , .)

+2

.

  • Native App - , .
  • JIT App - - .
  • Translated application - byte code is translated by a virtual machine, which is the Native App.

As you can say, with No. 1 you have the least cost, and with No. 3 you have the most overhead. Thus, performance should be the fastest at # 1 and just as fast at # 2 after the initial compilation overhead.

+1
source

Source: https://habr.com/ru/post/1708632/


All Articles