소스 검색

+ Added a comment on tcgprocinfo.generate_exceptfilter operation.

git-svn-id: trunk@21111 -
sergei 13 년 전
부모
커밋
7f96fee752
1개의 변경된 파일17개의 추가작업 그리고 0개의 파일을 삭제
  1. 17 0
      compiler/psub.pas

+ 17 - 0
compiler/psub.pas

@@ -910,6 +910,23 @@ implementation
         resetprocdef;
       end;
 
+    { For SEH, the code from 'finally' blocks must be put into a separate procedures,
+      which can be called by OS during stack unwind. This resembles nested procedures,
+      but finalizer procedures do not have their own local variables and work directly
+      with the stack frame of parent. In particular, the tempgen must be shared, so
+      1) finalizer procedure is able to finalize temps of the parent,
+      2) if the finalizer procedure is complex enough to need its own temps, they are
+         allocated in stack frame of parent, so second-level finalizer procedures are
+         not needed.
+
+      Due to requirement of shared tempgen we cannot process finalizer as a regular nested
+      procedure (after the parent) and have to do it inline.
+      This is called by platform-specific tryfinallynodes during pass2.
+      Here we put away the codegen (which carries the register allocator state), process
+      the 'nested' procedure, then restore previous cg and continue processing the parent
+      procedure. generate_code() will create another cg, but not another tempgen because
+      setup_tempgen() is not called for potype_exceptfilter procedures. }
+
     procedure tcgprocinfo.generate_exceptfilter(nestedpi: tcgprocinfo);
       var
         saved_cg: tcg;