むむ
荷が重い、とヒメイをあげつつ掘り進めております。ざくざく掘っていく内に vm 云々なソレが普通に出てくる世界に到達。いつもの如く自分メモを。
今確認中なソレが Scm_VMGetStackLite() なんですが vm な構造体と ContFrame な構造体の base とか pc 等のメンバのソレをチェックする必要あり。
まず ScmContFrameRec 構造体が以下
typedef struct ScmContFrameRec { struct ScmContFrameRec *prev; /* previous frame */ ScmEnvFrame *env; /* saved environment */ ScmObj *argp; /* saved argument pointer */ int size; /* size of argument frame */ SCM_PCTYPE pc; /* next PC */ ScmCompiledCode *base; /* base register value */ } ScmContFrame;
コメントには
継続は ScmContFrame の chain として表わされる。
argp == NULL かつ size >= 0 なら、frame は C の継続である
って何だこれは。意味的には微妙訳なのでアレとして、Scm_VmStackLite で使われているメンバは base と pc になっている。まず base の型定義ですが以下
/* * Compiled code packet */ struct ScmCompiledCodeRec { SCM_HEADER; ScmWord *code; /* Code vector (*1). This is allocated as atomic, to prevent GC from scanning it. (*2) */ ScmObj *constants; /* Constant vector. this isn't used during execution, but kept here so that the constants in the code vector won't be GC-ed. (*2) */ int codeSize; /* size of code vector */ int constantSize; /* size of constant vector (*2) */ int maxstack; /* maximum runtime stack depth */ u_short requiredArgs; /* # of required args, if this code is the body of a closure. Otherwise 0. */ u_short optionalArgs; /* 1 if this code is the body of a closure. that takes rest arg. Otherwise 0. */ ScmObj name; /* If this is the body of a closure, holds its name. Otherwise #f. */ ScmObj info; /* debug info. alist of instruction offset and info. */ ScmObj argInfo; /* If this code is the body of the closure, keeps a list of args. #f otherwise. (*3) */ ScmObj parent; /* ScmCompiledCode if this code is compiled within other code chunk. #f otherwise. */ ScmObj intermediateForm; /* A packed IForm of the body (see compile.scm for the details of IForm). It is used to inline this procedure. Only set if the procedure is defined with define-inline. #f otherwise. (*4) */ void *builder; /* An opaque data used during consturcting the code vector. Usually NULL. */ };
これ、コメント読んだだけでは理解不能だな (当たり前
compile.scm とか 3imp なソレをざっくりで良いから理解しておいた方が良さげ。ズルして3imp.pdfを読むとか読もうか、とも思ったのですが、compile.scm の方が良いのでしょうか。確か compile.scm なコメントが Reading Gauche にもあったはず。