deer-develop / study

2 stars 0 forks source link

8장 요약 #32

Open swimmingone opened 2 months ago

swimmingone commented 2 months ago
image

8장에서는 VM translator 를 완성한다. 7장에서 push/pop, arithmetic-logic.. 이런 것들을 했고, 남아있는건 branching commands 와 function commands 에 대한 처리.


‘the VM translator will not only translate the VM commands (push, pop, add, and so on) into assembly instructions—it will also generate assembly code that realizes an envelope in which the program runs.’

사실 우리 프로젝트에서 VM translator 는 번역만 하는게 아니라, (프로그램의 실행 환경을 제공하는) 어셈블리 코드를 생성 하기도 한다.

branching

‘high-level control structures like if and while can be easily realized using nothing more than goto and if-goto commands.’

functions

‘subroutines, procedures, methods, or functions.’

얘네들은 다 같은 말이다.

built-in 이나 programmer-defined 나 동일하게 동작한다. (해야한다.)

‘the calling function (the caller) passes arguments to the called function (the callee) and suspends its execution until the latter completes its execution. The callee uses the passed arguments to execute or compute something and then returns a value (which may be void) to the caller. The caller then snaps back into action, resuming its execution.’

이 과정이 당연하다고 생각했는데 사실 고려해야 하는 것들이 많다. bullet 으로 나열됨

VM 구현체가 이런 일들을 처리해준다!

‘the function calling chain may be arbitrarily deep as well as recursive, at any given point in time only one function executes at the chain’s end, while all the other functions up the calling chain are waiting for it to return. This Last-In-First-Out processing model lends itself perfectly to the stack data structure, which is also LIFO’

‘we now use the same data structure to hold both the working stacks as well as the frames of all the functions up the calling chain’ ... ‘we’ll refer to this hard-working data structure as the global stack’

image