1 /* src/vm/jit/inline/inline.c - code inliner
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Edwin Steiner
31 $Id: inline.c 4734 2006-04-05 09:57:55Z edwin $
44 #include "mm/memory.h"
45 #include "toolbox/logging.h"
46 #include "vm/global.h"
47 #include "vm/options.h"
48 #include "vm/statistics.h"
49 #include "vm/jit/jit.h"
50 #include "vm/jit/parse.h"
51 #include "vm/jit/inline/inline.h"
52 #include "vm/jit/loop/loop.h"
55 #include "vm/initialize.h"
56 #include "vm/method.h"
57 #include "vm/jit/jit.h"
59 #include "vm/jit/reg.h"
60 #include "vm/jit/stack.h"
62 #include "vm/jit/verify/typecheck.h"
64 #if defined(USE_THREADS)
65 # if defined(NATIVE_THREADS)
66 # include "threads/native/threads.h"
68 # include "threads/green/threads.h"
73 bool inline_debug_log = 0;
74 bool inline_debug_log_names = 0;
75 int inline_debug_start_counter = 0;
76 int inline_debug_max_size = INT_MAX;
77 int inline_debug_min_size = 0;
78 int inline_debug_end_counter = INT_MAX;
79 int inline_count_methods = 0;
80 #define DOLOG(code) do{ if (inline_debug_log) { code; } }while(0)
85 typedef struct inline_node inline_node;
86 typedef struct inline_target_ref inline_target_ref;
87 typedef struct inline_context inline_context;
88 typedef struct inline_stack_translation inline_stack_translation;
89 typedef struct inline_block_map inline_block_map;
95 inline_node *children;
100 /* info about the call site (if depth > 0)*/
102 basicblock *callerblock;
103 instruction *callerins;
105 stackptr n_callerstack;
106 int n_callerstackdepth;
107 stackptr o_callerstack;
108 exceptiontable **o_handlers;
110 /* info about the callee */
112 int prolog_instructioncount;
113 int epilog_instructioncount;
114 int extra_instructioncount;
115 int instructioncount;
118 basicblock *handler_monitorexit;
120 /* cumulative values */
121 int cumul_instructioncount;
122 int cumul_stackcount;
123 int cumul_basicblockcount;
126 int cumul_exceptiontablelength;
129 instruction *inlined_iinstr;
130 instruction *inlined_iinstr_cursor;
131 stackptr n_inlined_stack;
132 stackptr n_inlined_stack_cursor;
133 basicblock *inlined_basicblocks;
134 basicblock *inlined_basicblocks_cursor;
137 registerdata *regdata;
140 inline_target_ref *refs;
141 instruction *inline_start_instruction;
144 struct inline_target_ref {
145 inline_target_ref *next;
150 struct inline_stack_translation {
155 struct inline_block_map {
161 struct inline_context {
164 int next_block_number;
165 inline_block_map *blockmap;
170 stackptr o_translationlimit; /* if a stackptr is smaller than this, look it up in the table */
171 stackptr n_debug_stackbase;
172 inline_stack_translation *stacktranslationstart;
174 inline_stack_translation stacktranslation[1]; /* XXX VARIABLE LENGTH! */
177 static int stack_depth(stackptr sp)
188 #include "inline_debug.c"
190 void inline_print_stats()
192 printf("inlined callers: %d\n",inline_count_methods);
196 static bool inline_jit_compile_intern(jitdata *jd)
202 /* XXX initialize the static function's class */
205 m->isleafmethod = true;
207 /* call the compiler passes ***********************************************/
209 /* call parse pass */
211 DOLOG( log_message_class("Parsing ", m->class) );
216 /* call stack analysis pass */
218 if (!stack_analyse(jd)) {
225 static bool inline_jit_compile(inline_node *iln)
236 #if defined(USE_THREADS)
237 /* enter a monitor on the method */
238 builtin_monitorenter((java_objectheader *) m);
241 /* XXX dont parse these a second time because parse is not idempotent */
242 for (i=0; i<m->jcodelength; ++i) {
243 if (m->jcode[i] == JAVA_TABLESWITCH || m->jcode[i] == JAVA_LOOKUPSWITCH) {
249 /* allocate jitdata structure and fill it */
254 jd->cd = DNEW(codegendata);
255 jd->rd = DNEW(registerdata);
256 #if defined(ENABLE_LOOP)
257 jd->ld = DNEW(loopdata);
261 /* Allocate codeinfo memory from the heap as we need to keep them. */
263 jd->code = code_codeinfo_new(m); /* XXX check allocation */
265 #if defined(ENABLE_JIT)
266 # if defined(ENABLE_INTRP)
269 /* initialize the register allocator */
273 /* setup the codegendata memory */
277 /* now call internal compile function */
279 r = inline_jit_compile_intern(jd);
282 iln->regdata = jd->rd;
285 /* free some memory */
289 #if defined(ENABLE_JIT)
290 # if defined(ENABLE_INTRP)
299 #if defined(USE_THREADS)
300 /* leave the monitor */
301 builtin_monitorexit((java_objectheader *) m );
305 stack_show_method(jd);
311 static void insert_inline_node(inline_node *parent,inline_node *child)
316 assert(parent && child);
318 child->parent = parent;
320 first = parent->children;
322 /* insert as only node */
323 parent->children = child;
329 /* {there is at least one child already there} */
332 while (succ->callerpc < child->callerpc) {
335 /* insert as last node */
336 child->prev = first->prev;
338 child->prev->next = child;
339 child->next->prev = child;
344 assert(succ->callerpc > child->callerpc);
346 /* insert before succ */
348 child->prev = succ->prev;
350 child->prev->next = child;
351 child->next->prev = child;
354 static stackptr relocate_stack_ptr_intern(inline_node *iln,stackptr o_link,ptrint curreloc)
356 inline_stack_translation *tr;
359 /* XXX should limit range in both directions */
360 if (o_link < iln->ctx->o_translationlimit) {
361 /* this stack slot is from an earlier chunk, we must look it up */
362 tr = iln->ctx->stacktranslationstart;
363 while (tr >= iln->ctx->stacktranslation) {
364 if (o_link == tr->o_sp) {
365 DOLOG(printf("\t\t\ttable lookup %p -> %d\n",(void*)o_link,DEBUG_SLOT(tr->n_sp)));
370 DOLOG(debug_dump_inline_context(iln));
371 DOLOG(printf("\t\tFAILED TO TRANSLATE: %p\n",(void*)o_link));
375 /* this stack slot it in the most recent chunk */
377 DOLOG( printf("\t\t\toffset %d\n",(int)curreloc) );
378 return (stackptr) ((u1*)o_link + curreloc);
381 return iln->n_callerstack;
384 /* XXX for debugging */
385 static stackptr relocate_stack_ptr(inline_node *iln,stackptr o_link,ptrint curreloc)
389 new = relocate_stack_ptr_intern(iln,o_link,curreloc);
391 printf("\t\treloc %p -> %d (%p)\t(translimit=%p)\n",
392 (void*)o_link,DEBUG_SLOT(new),(void*)new,(void*)iln->ctx->o_translationlimit)
397 static void emit_instruction(inline_node *iln,instruction *ins,ptrint curreloc,stackptr o_curstack)
402 inline_target_ref *ref;
406 for (i=0; i<iln->depth; ++i)
410 n_ins = (iln->inlined_iinstr_cursor++);
411 assert((n_ins - iln->inlined_iinstr) < iln->cumul_instructioncount);
415 switch (n_ins[0].opc) {
416 /****************************************/
417 /* VARIABLE ACCESS */
431 n_ins[0].op1 += iln->localsoffset;
464 ref = DNEW(inline_target_ref);
465 ref->ref = (basicblock **) &(n_ins[0].target);
466 ref->next = iln->refs;
470 /****************************************/
475 n_ins[0].opc = ICMD_GOTO;
487 n_ins[0].opc = ICMD_INLINE_GOTO;
488 n_ins[0].dst = o_curstack;
490 n_ins[0].target = (void *) (ptrint) (iln->depth + 0x333); /* XXX */
491 ref = DNEW(inline_target_ref);
492 ref->ref = (basicblock **) &(n_ins[0].target);
493 ref->next = iln->refs;
499 n_ins[0].dst = relocate_stack_ptr(iln,n_ins[0].dst,curreloc);
502 static stackptr inline_new_stackslot(inline_node *iln,stackptr n_curstack,s4 type)
506 n_sp = iln->n_inlined_stack_cursor++;
507 assert((n_sp - iln->n_inlined_stack) < iln->cumul_stackcount);
509 n_sp->prev = n_curstack;
511 n_sp->varkind = TEMPVAR;
512 n_sp->varnum = stack_depth(n_curstack); /* XXX inefficient */
515 n_sp->regoff = (IS_FLT_DBL_TYPE(type)) ? -1 : INT_ARG_CNT;
521 static stackptr emit_inlining_prolog(inline_node *iln,inline_node *callee,stackptr n_curstack,instruction *o_iptr)
531 insinfo_inline *insinfo;
533 assert(iln && callee && o_iptr);
536 md = calleem->parseddesc;
537 isstatic = (calleem->flags & ACC_STATIC);
539 localindex = callee->localsoffset + md->paramslots;
540 depth = stack_depth(n_curstack) - 1; /* XXX inefficient */
541 for (i=md->paramcount-1; i>=0; --i) {
544 n_ins = (iln->inlined_iinstr_cursor++);
545 assert((n_ins - iln->inlined_iinstr) < iln->cumul_instructioncount);
547 type = md->paramtypes[i].type;
549 localindex -= IS_2_WORD_TYPE(type) ? 2 : 1;
550 assert(callee->regdata);
552 DOLOG( printf("prologlocal %d type=%d lofs=%d in ",
553 localindex - callee->localsoffset,
554 callee->regdata->locals[localindex - callee->localsoffset][type].type,callee->localsoffset);
555 method_println(callee->m); );
557 if ((callee->regdata->locals[localindex - callee->localsoffset][type].type >= 0)
559 (i==0 && callee->synchronize && !isstatic))
561 n_ins->opc = ICMD_ISTORE + type;
562 n_ins->op1 = localindex;
565 n_ins->opc = IS_2_WORD_TYPE(type) ? ICMD_POP2 : ICMD_POP; /* XXX is POP2 correct? */
567 n_ins->line = o_iptr->line;
569 if (n_curstack->varkind == ARGVAR) {
570 n_curstack->varkind = TEMPVAR;
571 n_curstack->varnum = depth;
572 n_curstack->flags &= ~INMEMORY;
574 n_curstack = n_curstack->prev;
575 n_ins->dst = n_curstack;
579 /* INLINE_START instruction */
581 n_ins = (iln->inlined_iinstr_cursor++);
582 assert((n_ins - iln->inlined_iinstr) < iln->cumul_instructioncount);
584 insinfo = DNEW(insinfo_inline);
585 insinfo->method = callee->m;
586 insinfo->outer = iln->m;
587 /* XXX using local 0 only works if it is read-only!! */
588 insinfo->synclocal = callee->localsoffset;
589 insinfo->synchronize = callee->synchronize;
591 n_ins->opc = ICMD_INLINE_START;
592 n_ins->dst = n_curstack;
593 n_ins->target = insinfo;
594 n_ins->line = o_iptr->line;
595 iln->inline_start_instruction = n_ins;
600 static void emit_inlining_epilog(inline_node *iln,inline_node *callee,stackptr n_curstack,instruction *o_iptr)
604 assert(iln && callee && o_iptr);
605 assert(iln->inline_start_instruction);
607 n_ins = (iln->inlined_iinstr_cursor++);
608 assert((n_ins - iln->inlined_iinstr) < iln->cumul_instructioncount);
610 n_ins->opc = ICMD_INLINE_END;
611 n_ins->dst = n_curstack;
612 n_ins->target = iln->inline_start_instruction->target; /* insinfo_inline * */
613 n_ins->line = o_iptr->line;
616 static void rewrite_stack(inline_node *iln,stackptr o_first,stackptr o_last,ptrint curreloc)
626 DOLOG(printf("rewrite_stack: no stack slots\n"));
632 assert(o_first <= o_last);
634 n = o_last - o_first + 1;
638 n_sp = iln->n_inlined_stack_cursor;
641 printf("rewrite_stack: rewriting %d stack slots (%p,%p) -> (%d,%d)\n",
642 n,(void*)o_first,(void*)o_last,DEBUG_SLOT(n_sp),
643 DEBUG_SLOT(n_sp+n-1))
646 DOLOG( printf("o_first = "); debug_dump_stack(o_first); printf("\n") );
647 DOLOG( printf("o_last = "); debug_dump_stack(o_last); printf("\n") );
649 while (o_sp <= o_last) {
652 n_sp->prev = relocate_stack_ptr(iln,n_sp->prev,curreloc);
653 switch (n_sp->varkind) {
654 case STACKVAR: n_sp->varnum += iln->n_callerstackdepth; break;
655 case LOCALVAR: n_sp->varnum += iln->localsoffset; break;
661 DOLOG( printf("n_sp = "); debug_dump_stack(n_sp-1); printf("\n") );
663 iln->n_inlined_stack_cursor = n_sp;
664 assert((n_sp - iln->n_inlined_stack) <= iln->cumul_stackcount);
667 static void inline_resolve_block_refs(inline_target_ref **refs,basicblock *o_bptr,basicblock *n_bptr)
669 inline_target_ref *ref;
670 inline_target_ref *prev;
675 if (*(ref->ref) == o_bptr) {
677 if ((ptrint) o_bptr < (0x333+100)) { /* XXX */
678 printf("resolving RETURN block reference %p -> new L%03d (%p)\n",
679 (void*)o_bptr,n_bptr->debug_nr,(void*)n_bptr);
682 printf("resolving block reference old L%03d (%p) -> new L%03d (%p)\n",
683 o_bptr->debug_nr,(void*)o_bptr,n_bptr->debug_nr,(void*)n_bptr);
687 *(ref->ref) = n_bptr;
689 prev->next = ref->next;
702 static basicblock * create_block(inline_node *iln,basicblock *o_bptr,inline_target_ref **refs,int indepth)
710 n_bptr = iln->inlined_basicblocks_cursor++;
712 assert((n_bptr - iln->inlined_basicblocks) < iln->cumul_basicblockcount);
714 memset(n_bptr,0,sizeof(basicblock));
717 n_bptr->type = BBTYPE_STD; /* XXX not necessary */
718 n_bptr->iinstr = iln->inlined_iinstr_cursor;
719 n_bptr->next = n_bptr+1;
720 n_bptr->debug_nr = iln->ctx->next_block_number++;
721 n_bptr->indepth = indepth;
724 /* allocate stackslots */
725 iln->n_inlined_stack_cursor += indepth;
726 n_sp = iln->n_inlined_stack_cursor - 1;
727 n_bptr->instack = n_sp;
729 assert((n_sp - iln->n_inlined_stack) < iln->cumul_stackcount);
731 /* link the stack elements */
732 for (i=indepth-1; i>=0; --i) {
733 n_sp->varkind = STACKVAR;
735 n_sp->prev = (i) ? n_sp-1 : NULL;
736 n_sp->flags = 0; /* XXX */
743 inline_resolve_block_refs(refs,o_bptr,n_bptr);
749 static void fill_translation_table(inline_node *iln,stackptr o_sp,stackptr n_sp,int n_depth)
754 printf("fill_translation_table (newdepth=%d):\n",n_depth);
755 printf("\tos_sp = "); debug_dump_stack(o_sp); printf("\n");
756 printf("\tns_sp = "); debug_dump_stack(n_sp); printf("\n");
759 /* we must translate all stack slots that were present before the call XXX */
760 /* and the instack of the block */
761 iln->ctx->stacktranslationstart = iln->ctx->stacktranslation + (n_depth - 1);
763 /* fill the translation table */
770 iln->ctx->stacktranslation[i].o_sp = o_sp;
771 iln->ctx->stacktranslation[i].n_sp = n_sp;
772 n_sp->flags |= (o_sp->flags & SAVEDVAR); /* XXX correct? */
773 n_sp->type = o_sp->type; /* XXX we overwrite this anyway with STACKVAR, right? */
781 assert(iln->ctx->stacktranslation[i].o_sp);
782 iln->ctx->stacktranslation[i].n_sp = n_sp;
783 n_sp->flags |= SAVEDVAR; /* XXX this is too conservative */
792 static void rewrite_method(inline_node *iln)
802 stackptr o_nexttorewrite;
803 stackptr o_lasttorewrite;
804 inline_node *nextcall;
807 inline_block_map *bm;
814 nextcall = iln->children;
816 /* set memory cursors */
817 iln->inlined_iinstr_cursor = iln->inlined_iinstr;
818 iln->n_inlined_stack_cursor = iln->n_inlined_stack;
819 iln->inlined_basicblocks_cursor = iln->inlined_basicblocks;
821 /* loop over basic blocks */
822 o_bptr = iln->m->basicblocks;
823 for (; o_bptr; o_bptr = o_bptr->next) {
825 if (o_bptr->flags < BBREACHED) {
827 printf("skipping old L%03d (flags=%d,type=%d,os=%p,oid=%d,ois=%p,cursor=%d,callerstack=%d) of ",
828 o_bptr->debug_nr,o_bptr->flags,o_bptr->type,
829 (void*)o_bptr->stack,o_bptr->indepth,(void*)o_bptr->instack,
830 DEBUG_SLOT(iln->n_inlined_stack_cursor),
831 DEBUG_SLOT(iln->n_callerstack));
832 method_println(iln->m);
835 n_bptr = create_block(iln,o_bptr,&(iln->refs),o_bptr->indepth + iln->n_callerstackdepth);
836 n_bptr->type = o_bptr->type;
837 /* enter it in the blockmap */
838 iln->ctx->blockmap[iln->ctx->blockmap_index].iln = iln;
839 iln->ctx->blockmap[iln->ctx->blockmap_index].o_block = o_bptr;
840 iln->ctx->blockmap[iln->ctx->blockmap_index++].n_block = n_bptr;
841 n_bptr->flags = o_bptr->flags;
845 assert(o_bptr->stack);
847 len = o_bptr->icount;
848 o_iptr = o_bptr->iinstr;
851 printf("rewriting old L%03d (flags=%d,type=%d,os=%p,oid=%d,ois=%p,cursor=%d,callerstack=%d) of ",
852 o_bptr->debug_nr,o_bptr->flags,o_bptr->type,
853 (void*)o_bptr->stack,o_bptr->indepth,(void*)o_bptr->instack,
854 DEBUG_SLOT(iln->n_inlined_stack_cursor),
855 DEBUG_SLOT(iln->n_callerstack));
856 method_println(iln->m);
857 printf("o_instack: ");debug_dump_stack(o_bptr->instack);printf("\n");
858 printf("o_callerstack: ");debug_dump_stack(iln->o_callerstack);printf("\n");
861 o_curstack = o_bptr->instack;
863 /* create an inlined clone of this block */
864 n_bptr = create_block(iln,o_bptr,&(iln->refs),o_bptr->indepth + iln->n_callerstackdepth);
865 n_bptr->type = o_bptr->type;
866 n_bptr->flags = o_bptr->flags;
868 /* enter it in the blockmap */
869 iln->ctx->blockmap[iln->ctx->blockmap_index].iln = iln;
870 iln->ctx->blockmap[iln->ctx->blockmap_index].o_block = o_bptr;
871 iln->ctx->blockmap[iln->ctx->blockmap_index++].n_block = n_bptr;
873 DOLOG( debug_dump_inline_context(iln) );
875 if (iln->n_callerstackdepth)
876 iln->n_callerstack = n_bptr->instack-o_bptr->indepth;
878 iln->n_callerstack = NULL;
879 fill_translation_table(iln,iln->o_callerstack,iln->n_callerstack,iln->n_callerstackdepth);
880 fill_translation_table(iln,o_bptr->instack,n_bptr->instack,n_bptr->indepth);
881 iln->ctx->o_translationlimit = o_bptr->stack;
883 DOLOG( debug_dump_inline_context(iln) );
885 /* calculate the stack element relocation */
886 curreloc = (u1*)iln->n_inlined_stack_cursor - (u1*)o_bptr->stack;
887 DOLOG( printf("curreloc <- %d = %p - %p\n",(int)curreloc,(void*)iln->n_inlined_stack_cursor,(void*)(u1*)o_bptr->stack) );
889 o_nexttorewrite = o_bptr->stack;
890 o_lasttorewrite = o_bptr->stack-1;
891 assert(o_nexttorewrite);
898 DOLOG( printf("o_curstack = "); debug_dump_stack(o_curstack); stack_show_icmd(o_iptr,false); printf(", dst = "); debug_dump_stack(o_dst); printf("\n") );
900 if (nextcall && o_iptr == nextcall->callerins) {
902 /* rewrite stack elements produced so far in this block */
903 if (o_nexttorewrite <= o_lasttorewrite) {
904 rewrite_stack(iln, o_nexttorewrite, o_lasttorewrite, curreloc);
907 /* write the inlining prolog */
908 n_sp = emit_inlining_prolog(iln,nextcall,relocate_stack_ptr(iln,o_curstack,curreloc),o_iptr);
909 icount += nextcall->m->parseddesc->paramcount + 1; /* XXX prolog instructions */
911 /* find the first stack slot under the arguments of the invocation */
913 for (i=0; i < nextcall->m->parseddesc->paramcount; ++i) {
917 nextcall->o_callerstack = o_sp;
919 /* see how deep the new stack is after the arguments have been removed */
920 i = stack_depth(n_sp);
921 assert(i == stack_depth(nextcall->o_callerstack) + iln->n_callerstackdepth);
923 /* end current block */
924 n_bptr->icount = icount;
925 n_bptr->outstack = n_sp;
926 n_bptr->outdepth = i;
928 /* caller stack depth for the callee */
929 assert(nextcall->n_callerstackdepth == i);
931 /* set memory pointers in the callee */
932 nextcall->inlined_iinstr = iln->inlined_iinstr_cursor;
933 nextcall->n_inlined_stack = iln->n_inlined_stack_cursor;
934 nextcall->inlined_basicblocks = iln->inlined_basicblocks_cursor;
937 DOLOG( printf("entering inline "); stack_show_icmd(o_iptr,false); printf("\n") );
938 rewrite_method(nextcall);
939 DOLOG( printf("leaving inline "); stack_show_icmd(o_iptr,false); printf("\n") );
941 /* skip stack slots used by the inlined callee */
942 curreloc += (u1*)nextcall->n_inlined_stack_cursor - (u1*)iln->n_inlined_stack_cursor;
944 /* update memory cursors */
945 assert(nextcall->inlined_iinstr_cursor == iln->inlined_iinstr_cursor + nextcall->cumul_instructioncount);
946 /* XXX m->stackcount seems to be a conservative estimate */
947 assert(nextcall->n_inlined_stack_cursor <= iln->n_inlined_stack_cursor + nextcall->cumul_stackcount);
948 assert(nextcall->inlined_basicblocks_cursor == iln->inlined_basicblocks_cursor + nextcall->cumul_basicblockcount);
949 iln->inlined_iinstr_cursor = nextcall->inlined_iinstr_cursor;
950 iln->n_inlined_stack_cursor = nextcall->n_inlined_stack_cursor;
951 iln->inlined_basicblocks_cursor = nextcall->inlined_basicblocks_cursor;
953 /* start new block */
954 i = (nextcall->m->parseddesc->returntype.type == TYPE_VOID) ? 0 : 1; /* number of return slots */
955 assert(i == 0 || i == 1);
956 n_bptr = create_block(iln,(void*) (ptrint) (nextcall->depth + 0x333) /*XXX*/,
957 &(nextcall->refs),nextcall->n_callerstackdepth + i);
958 n_bptr->flags = o_bptr->flags;
961 /* skip allocated stack slots */
962 curreloc += sizeof(stackelement) * (n_bptr->indepth - i);
964 /* fill the translation table for the slots present before the call */
965 n_sp = n_bptr->instack;
966 fill_translation_table(iln,nextcall->o_callerstack,(i) ? n_sp->prev : n_sp,nextcall->n_callerstackdepth);
968 /* the return slot */
972 fill_translation_table(iln,o_dst,n_sp,nextcall->n_callerstackdepth + 1);
974 o_nexttorewrite = o_dst + 1;
975 o_lasttorewrite = o_dst;
978 /* the next chunk of stack slots start with (including) the slots produced */
979 /* by the invocation */
980 o_nexttorewrite = o_lasttorewrite + 1;
981 o_lasttorewrite = o_nexttorewrite - 1;
984 DOLOG( debug_dump_inline_context(iln) );
985 iln->ctx->o_translationlimit = o_nexttorewrite;
987 /* emit inlining epilog */
988 emit_inlining_epilog(iln,nextcall,n_sp,o_iptr);
989 icount++; /* XXX epilog instructions */
991 /* proceed to next call */
992 nextcall = nextcall->next;
995 printf("resuming old L%03d (flags=%d,type=%d,os=%p,oid=%d,ois=%p,cursor=%d,curreloc=%d,callerstack=%d) of ",
996 o_bptr->debug_nr,o_bptr->flags,o_bptr->type,
997 (void*)o_bptr->stack,o_bptr->indepth,(void*)o_bptr->instack,
998 DEBUG_SLOT(iln->n_inlined_stack_cursor),(int)curreloc,
999 DEBUG_SLOT(iln->n_callerstack));
1000 method_println(iln->m);
1004 emit_instruction(iln,o_iptr,curreloc,o_curstack);
1007 if (o_dst > o_lasttorewrite)
1008 o_lasttorewrite = o_dst;
1011 DOLOG( printf("o_dst = %p\n",(void*)o_dst) );
1016 /* end of basic block */
1017 /* rewrite stack after last call */
1018 if (o_nexttorewrite <= o_lasttorewrite) {
1019 rewrite_stack(iln,o_nexttorewrite,o_lasttorewrite,curreloc);
1021 n_bptr->outstack = relocate_stack_ptr(iln,o_bptr->outstack,curreloc);
1022 n_bptr->outdepth = iln->n_callerstackdepth + o_bptr->outdepth;
1023 assert(n_bptr->outdepth == stack_depth(n_bptr->outstack));
1025 if (n_bptr->outstack) {
1027 n_bptr->outstack += curreloc;
1030 n_bptr->icount = icount;
1032 n_iptr = iln->inlined_iinstr_cursor - 1;
1033 if (n_iptr->opc == ICMD_INLINE_GOTO) {
1034 DOLOG( printf("creating stack slot for ICMD_INLINE_GOTO\n") );
1035 n_sp = iln->n_inlined_stack_cursor++;
1036 assert(n_iptr->dst);
1037 *n_sp = *n_iptr->dst;
1038 n_sp->prev = iln->n_callerstack;
1041 n_bptr->outdepth = iln->n_callerstackdepth + 1;
1042 n_bptr->outstack = n_sp;
1046 bm = iln->ctx->blockmap;
1047 for (i=0; i<iln->ctx->blockmap_index; ++i, ++bm) {
1048 assert(bm->iln && bm->o_block && bm->n_block);
1051 inline_resolve_block_refs(&(iln->refs),iln->ctx->blockmap[i].o_block,iln->ctx->blockmap[i].n_block);
1056 inline_target_ref *ref;
1059 if (!iln->depth || *(ref->ref) != (void*) (ptrint) (0x333 + iln->depth) /* XXX */) {
1060 DOLOG( printf("XXX REMAINING REF at depth %d: %p\n",iln->depth,(void*)*(ref->ref)) );
1069 static basicblock * inline_map_block(inline_node *iln,basicblock *o_block,inline_node *targetiln)
1071 inline_block_map *bm;
1072 inline_block_map *bmend;
1080 bm = iln->ctx->blockmap;
1081 bmend = bm + iln->ctx->blockmap_index;
1083 while (bm < bmend) {
1084 assert(bm->iln && bm->o_block && bm->n_block);
1085 if (bm->o_block == o_block && bm->iln == targetiln)
1091 return NULL; /* not reached */
1094 static exceptiontable * inline_exception_tables(inline_node *iln,exceptiontable *n_extable,exceptiontable **prevextable)
1102 assert(prevextable);
1104 child = iln->children;
1107 n_extable = inline_exception_tables(child,n_extable,prevextable);
1108 child = child->next;
1109 } while (child != iln->children);
1112 et = iln->m->exceptiontable;
1113 for (i=0; i<iln->m->exceptiontablelength; ++i) {
1115 memset(n_extable,0,sizeof(exceptiontable));
1116 n_extable->startpc = et->startpc;
1117 n_extable->endpc = et->endpc;
1118 n_extable->handlerpc = et->handlerpc;
1119 n_extable->start = inline_map_block(iln,et->start,iln);
1120 n_extable->end = inline_map_block(iln,et->end,iln);
1121 n_extable->handler = inline_map_block(iln,et->handler,iln);
1122 n_extable->catchtype = et->catchtype;
1125 (*prevextable)->down = n_extable;
1127 *prevextable = n_extable;
1133 if (iln->handler_monitorexit) {
1134 exceptiontable **activehandlers;
1136 memset(n_extable,0,sizeof(exceptiontable));
1137 n_extable->startpc = 0; /* XXX */
1138 n_extable->endpc = 0; /* XXX */
1139 n_extable->handlerpc = 0; /* XXX */
1140 n_extable->start = iln->inlined_basicblocks;
1141 n_extable->end = iln->inlined_basicblocks_cursor;
1142 n_extable->handler = iln->handler_monitorexit;
1143 n_extable->catchtype.any = NULL; /* finally */
1146 (*prevextable)->down = n_extable;
1148 *prevextable = n_extable;
1152 activehandlers = iln->o_handlers;
1153 while (*activehandlers) {
1155 assert(iln->parent);
1157 memset(n_extable,0,sizeof(exceptiontable));
1158 n_extable->startpc = 0; /* XXX */
1159 n_extable->endpc = 0; /* XXX */
1160 n_extable->handlerpc = 0; /* XXX */
1161 n_extable->start = iln->handler_monitorexit;
1162 n_extable->end = iln->handler_monitorexit + 1;
1163 n_extable->handler = inline_map_block(iln->parent,(*activehandlers)->handler,iln->parent);
1164 n_extable->catchtype = (*activehandlers)->catchtype;
1167 (*prevextable)->down = n_extable;
1169 *prevextable = n_extable;
1180 static void inline_locals(inline_node *iln,registerdata *rd)
1189 child = iln->children;
1192 inline_locals(child,rd);
1193 child = child->next;
1194 } while (child != iln->children);
1197 assert(iln->regdata);
1199 for (i=0; i<iln->m->maxlocals; ++i) {
1200 for (t=TYPE_INT; t<=TYPE_ADR; ++t) {
1201 DOLOG( printf("local %d type=%d in ",i,iln->regdata->locals[i][t].type); method_println(iln->m); );
1202 if (iln->regdata->locals[i][t].type >= 0) {
1203 rd->locals[iln->localsoffset + i][t].type = iln->regdata->locals[i][t].type;
1204 rd->locals[iln->localsoffset + i][t].flags |= iln->regdata->locals[i][t].flags;
1209 if (iln->regdata->memuse > rd->memuse)
1210 rd->memuse = iln->regdata->memuse;
1211 if (iln->regdata->argintreguse > rd->argintreguse)
1212 rd->argintreguse = iln->regdata->argintreguse;
1213 if (iln->regdata->argfltreguse > rd->argfltreguse)
1214 rd->argfltreguse = iln->regdata->argfltreguse;
1217 static void inline_stack_interfaces(inline_node *iln,registerdata *rd)
1226 assert(rd->interfaces);
1228 bptr = iln->inlined_basicblocks;
1229 for (i=0; i<iln->cumul_basicblockcount; ++i, ++bptr) {
1230 DOLOG( printf("INLINE STACK INTERFACE block L%03d\n",bptr->debug_nr) );
1231 DOLOG( printf("\toutstack = ");debug_dump_stack(bptr->outstack);printf("\n") );
1232 DOLOG( printf("\tinstack = ");debug_dump_stack(bptr->outstack);printf("\n") );
1234 assert(bptr->outdepth == stack_depth(bptr->outstack));
1235 assert(bptr->indepth == stack_depth(bptr->instack));
1237 sp = bptr->outstack;
1238 d = bptr->outdepth - 1;
1240 if ((sp->varkind == STACKVAR) && (sp->varnum > d)) {
1241 sp->varkind = TEMPVAR;
1244 sp->varkind = STACKVAR;
1247 DOLOG( printf("INLINE STACK INTERFACE L%03d outstack d=%d varkind=%d varnum=%d type=%d flags=%01x\n",
1248 bptr->debug_nr,d,sp->varkind,sp->varnum,sp->type,sp->flags) );
1249 rd->interfaces[d][sp->type].type = sp->type;
1250 rd->interfaces[d][sp->type].flags |= sp->flags;
1256 d = bptr->indepth - 1;
1258 rd->interfaces[d][sp->type].type = sp->type;
1259 if (sp->varkind == STACKVAR && (sp->flags & SAVEDVAR)) {
1260 rd->interfaces[d][sp->type].flags |= SAVEDVAR;
1262 DOLOG( printf("INLINE STACK INTERFACE L%03d instack d=%d varkind=%d varnum=%d type=%d flags=%01x\n",
1263 bptr->debug_nr,d,sp->varkind,sp->varnum,sp->type,sp->flags) );
1270 static bool inline_inline_intern(methodinfo *m,jitdata *jd, inline_node *iln)
1276 stackptr o_curstack;
1277 int opcode; /* invocation opcode */
1279 inline_node *calleenode;
1280 inline_node *active;
1284 exceptiontable **handlers;
1290 /* initialize cumulative counters */
1292 iln->cumul_maxstack = iln->n_callerstackdepth + m->maxstack + 1 /* XXX builtins */;
1293 iln->cumul_maxlocals = iln->localsoffset + m->maxlocals;
1294 iln->cumul_exceptiontablelength += m->exceptiontablelength;
1296 /* iterate over basic blocks */
1298 bptr = m->basicblocks;
1299 for (; bptr; bptr = bptr->next) {
1301 iln->cumul_basicblockcount++;
1303 /* extra stackslots */
1304 iln->cumul_stackcount += iln->n_callerstackdepth;
1306 if (bptr->flags < BBREACHED)
1309 /* allocate the buffer of active exception handlers */
1310 /* XXX this wastes some memory, but probably it does not matter */
1312 handlers = DMNEW(exceptiontable*, m->exceptiontablelength + 1);
1314 /* determine the active exception handlers for this block */
1315 /* XXX maybe the handlers of a block should be part of our IR */
1317 for (i = 0; i < m->exceptiontablelength; ++i) {
1318 if ((m->exceptiontable[i].start <= bptr) && (m->exceptiontable[i].end > bptr)) {
1319 handlers[nhandlers++] = m->exceptiontable + i;
1322 handlers[nhandlers] = NULL;
1324 assert(bptr->stack);
1327 iptr = bptr->iinstr;
1328 o_curstack = bptr->instack;
1330 iln->instructioncount += len;
1331 iln->cumul_instructioncount += len;
1334 printf("ADD INSTRUCTIONS [%d]: %d, count=%d, cumulcount=%d\n",
1335 iln->depth,len,iln->instructioncount,iln->cumul_instructioncount);
1338 while (--len >= 0) {
1345 /* XXX we cannot deal with IINC's stack hacking */
1348 case ICMD_LOOKUPSWITCH:
1349 case ICMD_TABLESWITCH:
1350 /* XXX these are not implemented, yet. */
1353 /****************************************/
1356 case ICMD_INVOKEVIRTUAL:
1357 case ICMD_INVOKESPECIAL:
1358 case ICMD_INVOKESTATIC:
1359 case ICMD_INVOKEINTERFACE:
1360 callee = (methodinfo *) iptr[0].val.a;
1363 if ((callee->flags & (ACC_STATIC | ACC_FINAL | ACC_PRIVATE) || opcode == ICMD_INVOKESPECIAL)
1364 && !(callee->flags & (ACC_NATIVE)))
1366 if (iln->depth < 3) {
1367 for (active = iln; active; active = active->parent) {
1368 if (callee == active->m) {
1369 DOLOG( printf("RECURSIVE!\n") );
1374 calleenode = DNEW(inline_node);
1375 memset(calleenode,0,sizeof(inline_node));
1377 calleenode->ctx = iln->ctx;
1378 calleenode->m = callee;
1379 calleenode->synchronize = (callee->flags & ACC_SYNCHRONIZED);
1380 isstatic = (callee->flags & ACC_STATIC);
1382 if (!inline_jit_compile(calleenode))
1385 /* info about the call site */
1386 calleenode->depth = iln->depth+1;
1387 calleenode->callerblock = bptr;
1388 calleenode->callerins = iptr;
1389 calleenode->callerpc = iptr - m->basicblocks->iinstr;
1390 calleenode->o_handlers = handlers;
1392 /* info about the callee */
1393 calleenode->localsoffset = iln->localsoffset + m->maxlocals;
1394 calleenode->prolog_instructioncount = callee->parseddesc->paramcount;
1395 calleenode->epilog_instructioncount = 0;
1396 calleenode->extra_instructioncount = 0;
1398 if (calleenode->synchronize) {
1400 builtintable_entry *bte;
1402 /* and exception handler */
1403 /* ALOAD, builtin_monitorexit, ATHROW */
1404 calleenode->extra_instructioncount += 3;
1405 /* stack elements used in handler */
1406 iln->cumul_stackcount += 2;
1408 /* exception table entries */
1409 iln->cumul_exceptiontablelength += 1 + nhandlers;
1411 bte = builtintable_get_internal(BUILTIN_monitorenter);
1413 if (md->memuse > calleenode->regdata->memuse)
1414 calleenode->regdata->memuse = md->memuse;
1415 if (md->argintreguse > calleenode->regdata->argintreguse)
1416 calleenode->regdata->argintreguse = md->argintreguse;
1419 bte = builtintable_get_internal(BUILTIN_staticmonitorenter);
1421 if (md->memuse > calleenode->regdata->memuse)
1422 calleenode->regdata->memuse = md->memuse;
1423 if (md->argintreguse > calleenode->regdata->argintreguse)
1424 calleenode->regdata->argintreguse = md->argintreguse;
1427 bte = builtintable_get_internal(BUILTIN_monitorexit);
1429 if (md->memuse > calleenode->regdata->memuse)
1430 calleenode->regdata->memuse = md->memuse;
1431 if (md->argintreguse > calleenode->regdata->argintreguse)
1432 calleenode->regdata->argintreguse = md->argintreguse;
1434 iln->ctx->calls_others = true;
1437 calleenode->stackcount = callee->stackcount;
1438 calleenode->cumul_stackcount = callee->stackcount;
1440 /* see how deep the stack is below the arguments */
1442 for (i=0; sp; sp = sp->prev)
1444 calleenode->n_callerstackdepth = iln->n_callerstackdepth + i - callee->parseddesc->paramcount;
1446 insert_inline_node(iln,calleenode);
1448 if (!inline_inline_intern(callee,jd,calleenode))
1451 if (calleenode->synchronize) {
1452 /* add exception handler block */
1453 iln->ctx->master->cumul_basicblockcount++;
1456 iln->cumul_instructioncount += calleenode->prolog_instructioncount;
1457 iln->cumul_instructioncount += calleenode->epilog_instructioncount;
1458 iln->cumul_instructioncount += calleenode->extra_instructioncount;
1459 iln->cumul_instructioncount += calleenode->cumul_instructioncount - 1/*invoke*/ + 2 /*INLINE_START|END*/;
1460 iln->cumul_stackcount += calleenode->cumul_stackcount;
1462 /* XXX extra block after inlined call */
1463 iln->cumul_stackcount += calleenode->n_callerstackdepth;
1464 iln->cumul_basicblockcount += 1;
1466 iln->cumul_basicblockcount += calleenode->cumul_basicblockcount;
1467 iln->cumul_exceptiontablelength += calleenode->cumul_exceptiontablelength;
1468 if (calleenode->cumul_maxstack > iln->cumul_maxstack)
1469 iln->cumul_maxstack = calleenode->cumul_maxstack;
1470 if (calleenode->cumul_maxlocals > iln->cumul_maxlocals)
1471 iln->cumul_maxlocals = calleenode->cumul_maxlocals;
1484 /* end of basic block */
1490 static void inline_write_exception_handlers(inline_node *master,inline_node *iln)
1493 stackptr n_curstack;
1496 builtintable_entry *bte;
1498 child = iln->children;
1501 inline_write_exception_handlers(master,child);
1502 child = child->next;
1503 } while (child != iln->children);
1506 if (iln->synchronize) {
1507 /* create the monitorexit handler */
1508 n_bptr = create_block(master,NULL,NULL,1 /*XXX*/);
1509 n_bptr->type = BBTYPE_EXH;
1510 n_bptr->flags = BBFINISHED;
1512 iln->handler_monitorexit = n_bptr;
1514 n_curstack = n_bptr->instack;
1516 /* ACONST / ALOAD */
1518 n_curstack = inline_new_stackslot(master,n_curstack,TYPE_ADR);
1520 n_ins = master->inlined_iinstr_cursor++;
1521 if (iln->m->flags & ACC_STATIC) {
1522 n_ins->opc = ICMD_ACONST;
1523 n_ins->val.a = iln->m->class;
1524 n_ins->target = class_get_self_classref(iln->m->class);
1527 n_ins->opc = ICMD_ALOAD;
1528 n_ins->op1 = iln->localsoffset; /* XXX */
1530 n_ins->dst = n_curstack;
1535 n_curstack = n_curstack->prev;
1537 bte = builtintable_get_internal(BUILTIN_monitorexit);
1539 n_ins = master->inlined_iinstr_cursor++;
1540 n_ins->opc = ICMD_BUILTIN;
1542 n_ins->dst = n_curstack;
1547 n_curstack = n_curstack->prev;
1549 n_ins = master->inlined_iinstr_cursor++;
1550 n_ins->opc = ICMD_ATHROW;
1551 n_ins->dst = n_curstack;
1554 /* close basic block */
1556 n_bptr->outstack = n_curstack;
1557 n_bptr->outdepth = stack_depth(n_curstack); /* XXX */
1562 static bool test_inlining(inline_node *iln,jitdata *jd,
1563 methodinfo **resultmethod, jitdata **resultjd)
1568 methodinfo *n_method;
1569 exceptiontable *n_ext;
1570 exceptiontable *prevext;
1576 static int debug_verify_inlined_code = 1;
1578 static int debug_compile_inlined_code_counter = 0;
1581 assert(iln && jd && resultmethod && resultjd);
1583 *resultmethod = iln->m;
1587 if (debug_compile_inlined_code_counter >5)
1591 n_ins = DMNEW(instruction,iln->cumul_instructioncount);
1592 iln->inlined_iinstr = n_ins;
1594 n_stack = DMNEW(stackelement,iln->cumul_stackcount);
1595 iln->n_inlined_stack = n_stack;
1596 iln->ctx->n_debug_stackbase = n_stack;
1598 n_bb = DMNEW(basicblock,iln->cumul_basicblockcount);
1599 iln->inlined_basicblocks = n_bb;
1601 iln->ctx->blockmap = DMNEW(inline_block_map,iln->cumul_basicblockcount);
1603 rewrite_method(iln);
1604 inline_write_exception_handlers(iln,iln);
1606 /* end of basic blocks */
1607 if (iln->inlined_basicblocks_cursor > iln->inlined_basicblocks) {
1608 iln->inlined_basicblocks_cursor[-1].next = NULL;
1611 if (iln->cumul_exceptiontablelength) {
1612 exceptiontable *tableend;
1614 n_ext = DMNEW(exceptiontable,iln->cumul_exceptiontablelength);
1616 tableend = inline_exception_tables(iln,n_ext,&prevext);
1617 assert(tableend == n_ext + iln->cumul_exceptiontablelength);
1619 prevext->down = NULL;
1625 /*******************************************************************************/
1627 n_method = NEW(methodinfo);
1628 memcpy(n_method,iln->m,sizeof(methodinfo));
1629 n_method->maxstack = iln->cumul_maxstack; /* XXX put into cd,rd */
1630 n_method->maxlocals = iln->cumul_maxlocals;
1631 n_method->basicblockcount = iln->cumul_basicblockcount;
1632 n_method->basicblocks = iln->inlined_basicblocks;
1633 n_method->basicblockindex = NULL;
1634 n_method->instructioncount = iln->cumul_instructioncount;
1635 n_method->instructions = iln->inlined_iinstr;
1636 n_method->stackcount = iln->cumul_stackcount;
1637 n_method->stack = iln->n_inlined_stack;
1639 n_method->exceptiontablelength = iln->cumul_exceptiontablelength;
1640 n_method->exceptiontable = n_ext;
1641 n_method->linenumbercount = 0;
1643 n_jd = DNEW(jitdata);
1647 if (iln->ctx->calls_others) {
1648 n_method->isleafmethod = false;
1651 n_jd->code = code_codeinfo_new(n_method);
1653 n_cd = DNEW(codegendata);
1655 memcpy(n_cd,jd->cd,sizeof(codegendata));
1656 n_cd->method = n_method;
1657 n_cd->maxstack = n_method->maxstack;
1658 n_cd->maxlocals = n_method->maxlocals;
1659 n_cd->exceptiontablelength = n_method->exceptiontablelength;
1660 n_cd->exceptiontable = n_method->exceptiontable;
1662 n_rd = DNEW(registerdata);
1666 iln->regdata = jd->rd;
1667 inline_locals(iln,n_rd);
1668 DOLOG( printf("INLINING STACK INTERFACES FOR "); method_println(iln->m) );
1669 inline_stack_interfaces(iln,n_rd);
1671 if (debug_verify_inlined_code) {
1672 debug_verify_inlined_code = 0;
1673 DOLOG( printf("VERIFYING INLINED RESULT...\n") );
1674 if (!typecheck(n_jd)) {
1675 *exceptionptr = NULL;
1676 DOLOG( printf("XXX INLINED RESULT DID NOT PASS VERIFIER XXX\n") );
1680 DOLOG( printf("VERIFICATION PASSED.\n") );
1682 debug_verify_inlined_code = 1;
1687 if (n_method->instructioncount >= inline_debug_min_size && n_method->instructioncount <= inline_debug_max_size) {
1688 if (debug_compile_inlined_code_counter >= inline_debug_start_counter
1689 && debug_compile_inlined_code_counter <= inline_debug_end_counter)
1692 (strcmp(n_method->class->name->text,"java/lang/reflect/Array") == 0 &&
1693 strcmp(n_method->name->text,"<clinit>") == 0 &&
1694 strcmp(n_method->descriptor->text,"()V") == 0)
1696 (strcmp(n_method->class->name->text,"java/lang/VMClassLoader") == 0 &&
1697 strcmp(n_method->name->text,"getSystemClassLoader") == 0 &&
1698 strcmp(n_method->descriptor->text,"()Ljava/lang/ClassLoader;") == 0)
1705 *resultmethod = n_method;
1709 inline_count_methods++;
1710 if (inline_debug_log_names)
1711 method_println(n_method);
1714 printf("==== %d.INLINE ==================================================================\n",debug_compile_inlined_code_counter);
1715 method_println(n_method);
1716 stack_show_method(jd);
1717 dump_inline_tree(iln);
1718 stack_show_method(n_jd);
1719 debug_dump_inlined_code(iln,n_method,n_cd,n_rd);
1720 printf("-------- DONE -----------------------------------------------------------\n");
1727 debug_compile_inlined_code_counter++;
1733 bool inline_inline(jitdata *jd, methodinfo **resultmethod,
1745 printf("==== INLINE ==================================================================\n");
1747 stack_show_method(jd);
1750 iln = DNEW(inline_node);
1751 memset(iln,0,sizeof(inline_node));
1753 iln->ctx = (inline_context *) DMNEW(u1,sizeof(inline_context) + sizeof(inline_stack_translation) * 1000 /* XXX */);
1754 memset(iln->ctx,0,sizeof(inline_context));
1755 iln->ctx->master = iln;
1756 iln->ctx->stacktranslationstart = iln->ctx->stacktranslation - 1;
1757 iln->ctx->calls_others = false;
1760 /* we cannot use m->instructioncount because it may be greater than
1761 * the actual number of instructions in the basic blocks. */
1762 iln->instructioncount = 0;
1763 iln->cumul_instructioncount = 0;
1765 iln->stackcount = m->stackcount;
1766 iln->cumul_stackcount = m->stackcount;
1768 if (inline_inline_intern(m,jd,iln)) {
1771 printf("==== TEST INLINE =============================================================\n");
1776 test_inlining(iln,jd,resultmethod,resultjd);
1780 printf("-------- DONE -----------------------------------------------------------\n");
1788 * These are local overrides for various environment variables in Emacs.
1789 * Please do not remove this and leave it at the end of the file, where
1790 * Emacs will automagically detect them.
1791 * ---------------------------------------------------------------------
1794 * indent-tabs-mode: t
1798 * vim:noexpandtab:sw=4:ts=4: