Commit e7a5095f authored by Erick Gallesio's avatar Erick Gallesio

.

parent 96852676
......@@ -21,7 +21,7 @@
;;;;
;;;; Author: Erick Gallesio [eg@unice.fr]
;;;; Creation date: 14-Mar-2001 13:49 (eg)
;;;; Last file update: 14-Sep-2006 14:44 (eg)
;;;; Last file update: 15-Sep-2006 16:28 (eg)
;;;;
;;;
......@@ -179,28 +179,33 @@
(UGREF-TAIL-INVOKE 2) ;; Never produced by the compiler
(PUSH-PREPARE-CALL 0) ;; PUSH + PREPARE-CALL
(PUSH-GLOBAL-REF 1) ;; peephole: PUSH + GLOBAL-REF
(PUSH-UGLOBAL-REF 1) ;; Never produced by the compiler
(PUSH-GREF-INVOKE 2) ;; PUSH + GLOBAL-REF +INVOKE
(PUSH-UGREF-INVOKE 2) ;; PUSH + GLOBAL-REF +INVOKE
(UNUSED-16 0)
(UNUSED-15 0)
(UNUSED-14 0)
(UNUSED-13 0)
(UNUSED-12 0)
(UNUSED-11 0)
(UNUSED-10 0)
(UNUSED-9 0)
(UNUSED-8 0)
(UNUSED-7 0)
(UNUSED-6 0)
(UNUSED-5 0)
(UNUSED-4 0)
(UNUSED-3 0)
;; INLINED FUNCTIONS (again)
(IN-SINT-ADD2 1)
(IN-SINT-SUB2 1)
(IN-SINT-MUL2 1)
(IN-SINT-DIV2 1)
;; To allow easy evolution without recompiling everything,
;; we declare fake instructions.
(UNUSED-3 0)
(UNUSED-4 0)
(UNUSED-5 0)
(UNUSED-6 0)
(UNUSED-7 0)
(UNUSED-8 0)
(UNUSED-9 0)
(UNUSED-10 0)
(UNUSED-11 0)
(UNUSED-12 0)
))))
......
......@@ -21,7 +21,7 @@
;;;;
;;;; Author: Erick Gallesio [eg@unice.fr]
;;;; Creation date: 26-Feb-2000 10:47 (eg)
;;;; Last file update: 15-Sep-2006 11:18 (eg)
;;;; Last file update: 15-Sep-2006 16:05 (eg)
;;;;
;;(define-module new-compiler
......
......@@ -21,7 +21,7 @@
;;;;
;;;; Author: Erick Gallesio [eg@unice.fr]
;;;; Creation date: 17-Mar-2001 20:32 (eg)
;;;; Last file update: 14-Sep-2006 14:41 (eg)
;;;; Last file update: 15-Sep-2006 16:32 (eg)
;;;;
; ======================================================================
......@@ -157,7 +157,30 @@
((IN-EQUAL) 'JUMP-NOT-EQUAL)
((IN-NOT) 'JUMP-TRUE))
(next-arg1 code))))
;; [GLOBAL-REF, PUSH] => GLOBAL-REF-PUSH
((and (eq? i1 'GLOBAL-REF) (eq? i2 'PUSH))
(replace-2-instr code (list 'GLOBAL-REF-PUSH
(this-arg1 code))))
;; [PUSH GLOBAL-REF] => PUSH-GLOBAL-REF
((and (eq? i1 'PUSH) (eq? i2 'GLOBAL-REF))
(replace-2-instr code (list 'PUSH-GLOBAL-REF
(next-arg1 code))))
;; [PUSH-GLOBAL-REF, INVOKE] => PUSH-GREF-INVOKE
((and (eq? i1 'PUSH-GLOBAL-REF) (eq? i2 'INVOKE))
(replace-2-instr code (list 'PUSH-GREF-INVOKE
(this-arg1 code)
(next-arg1 code))))
;; [PUSH, PREPARE-CALL] => PUSH-PREPARE-CALL
((and (eq? i1 'PUSH) (eq? i2 'PREPARE-CALL))
(replace-2-instr code (list 'PUSH-PREPARE-CALL)))
;; [GLOBAL-REF, INVOKE] => GREF-INVOKE
((and (eq? i1 'GLOBAL-REF) (eq? i2 'INVOKE))
(replace-2-instr code (list 'GREF-INVOKE
......@@ -182,15 +205,6 @@
((LOCAL-REF3) 'LOCAL-REF3-PUSH)
((LOCAL-REF4) 'LOCAL-REF4-PUSH)))))
;; [GLOBAL-REF, PUSH] => GLOBAL-REF-PUSH
((and (eq? i1 'GLOBAL-REF) (eq? i2 'PUSH))
(replace-2-instr code (list 'GLOBAL-REF-PUSH
(this-arg1 code))))
;; [PUSH, PREPARE-CALL] => PUSH-PREPARE-CALL
((and (eq? i1 'PUSH) (eq? i2 'PREPARE-CALL))
(replace-2-instr code (list 'PUSH-PREPARE-CALL)))
(else ;; No optimization; goto next instruction
(set! code (cdr code))))))
;; Loop again on the same instruction
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -113,22 +113,30 @@
# define GREF_TAIL_INVOKE 108
# define UGREF_TAIL_INVOKE 109
# define PUSH_PREPARE_CALL 110
# define IN_SINT_ADD2 111
# define IN_SINT_SUB2 112
# define IN_SINT_MUL2 113
# define IN_SINT_DIV2 114
# define UNUSED_3 115
# define UNUSED_4 116
# define UNUSED_5 117
# define UNUSED_6 118
# define UNUSED_7 119
# define UNUSED_8 120
# define UNUSED_9 121
# define UNUSED_10 122
# define UNUSED_11 123
# define UNUSED_12 124
# define PUSH_GLOBAL_REF 111
# define PUSH_UGLOBAL_REF 112
# define PUSH_GREF_INVOKE 113
# define PUSH_UGREF_INVOKE 114
# define UNUSED_16 115
# define UNUSED_15 116
# define UNUSED_14 117
# define UNUSED_13 118
# define UNUSED_12 119
# define UNUSED_11 120
# define UNUSED_10 121
# define UNUSED_9 122
# define UNUSED_8 123
# define UNUSED_7 124
# define UNUSED_6 125
# define UNUSED_5 126
# define UNUSED_4 127
# define UNUSED_3 128
# define IN_SINT_ADD2 129
# define IN_SINT_SUB2 130
# define IN_SINT_MUL2 131
# define IN_SINT_DIV2 132
# define NB_VM_INSTR (UNUSED_12 +1)
# define NB_VM_INSTR (IN_SINT_DIV2 +1)
#endif
......@@ -246,20 +254,28 @@ static void *jump_table[] = {
&&lab_GREF_TAIL_INVOKE ,
&&lab_UGREF_TAIL_INVOKE ,
&&lab_PUSH_PREPARE_CALL ,
&&lab_PUSH_GLOBAL_REF ,
&&lab_PUSH_UGLOBAL_REF ,
&&lab_PUSH_GREF_INVOKE ,
&&lab_PUSH_UGREF_INVOKE ,
&&lab_UNUSED_16 ,
&&lab_UNUSED_15 ,
&&lab_UNUSED_14 ,
&&lab_UNUSED_13 ,
&&lab_UNUSED_12 ,
&&lab_UNUSED_11 ,
&&lab_UNUSED_10 ,
&&lab_UNUSED_9 ,
&&lab_UNUSED_8 ,
&&lab_UNUSED_7 ,
&&lab_UNUSED_6 ,
&&lab_UNUSED_5 ,
&&lab_UNUSED_4 ,
&&lab_UNUSED_3 ,
&&lab_IN_SINT_ADD2 ,
&&lab_IN_SINT_SUB2 ,
&&lab_IN_SINT_MUL2 ,
&&lab_IN_SINT_DIV2 ,
&&lab_UNUSED_3 ,
&&lab_UNUSED_4 ,
&&lab_UNUSED_5 ,
&&lab_UNUSED_6 ,
&&lab_UNUSED_7 ,
&&lab_UNUSED_8 ,
&&lab_UNUSED_9 ,
&&lab_UNUSED_10 ,
&&lab_UNUSED_11 ,
&&lab_UNUSED_12 ,
NULL};
#endif
#undef DEFINE_JUMP_TABLE
......@@ -379,20 +395,28 @@ static char *name_table[] = {
"GREF_TAIL_INVOKE ",
"UGREF_TAIL_INVOKE ",
"PUSH_PREPARE_CALL ",
"PUSH_GLOBAL_REF ",
"PUSH_UGLOBAL_REF ",
"PUSH_GREF_INVOKE ",
"PUSH_UGREF_INVOKE ",
"UNUSED_16 ",
"UNUSED_15 ",
"UNUSED_14 ",
"UNUSED_13 ",
"UNUSED_12 ",
"UNUSED_11 ",
"UNUSED_10 ",
"UNUSED_9 ",
"UNUSED_8 ",
"UNUSED_7 ",
"UNUSED_6 ",
"UNUSED_5 ",
"UNUSED_4 ",
"UNUSED_3 ",
"IN_SINT_ADD2 ",
"IN_SINT_SUB2 ",
"IN_SINT_MUL2 ",
"IN_SINT_DIV2 ",
"UNUSED_3 ",
"UNUSED_4 ",
"UNUSED_5 ",
"UNUSED_6 ",
"UNUSED_7 ",
"UNUSED_8 ",
"UNUSED_9 ",
"UNUSED_10 ",
"UNUSED_11 ",
"UNUSED_12 ",
NULL};
#endif
#undef DEFINE_NAME_TABLE
......@@ -21,7 +21,7 @@
*
* Author: Erick Gallesio [eg@unice.fr]
* Creation date: 1-Mar-2000 19:51 (eg)
* Last file update: 15-Sep-2006 11:19 (eg)
* Last file update: 15-Sep-2006 16:31 (eg)
*/
// INLINER values
......@@ -814,15 +814,20 @@ CASE(INT_PUSH) { push(MAKE_INT(fetch_next())) ; NEXT; }
CASE(CONSTANT_PUSH) { push(fetch_const()); NEXT; }
CASE(PUSH_GLOBAL_REF)
push(vm->val); /* Fall through */
CASE(GLOBAL_REF) {
SCM ref;
vm->val = STk_lookup(fetch_const(), vm->env, &ref, TRUE);
/* patch the code for optimize next accesses */
vm->pc[-2] = UGLOBAL_REF;
vm->pc[-2] = (vm->pc[-2] == GLOBAL_REF) ? UGLOBAL_REF: PUSH_UGLOBAL_REF;
vm->pc[-1] = add_global(&CDR(ref));
NEXT1;
}
CASE(PUSH_UGLOBAL_REF)
push(vm->val); /* Fall through */
CASE(UGLOBAL_REF) {
/* Never produced by compiler */
vm->val = fetch_global();
......@@ -845,19 +850,24 @@ CASE(UGLOBAL_REF_PUSH) {
}
CASE(PUSH_GREF_INVOKE)
push(vm->val); /* Fall through */
CASE(GREF_INVOKE) {
SCM ref;
vm->val = STk_lookup(fetch_const(), vm->env, &ref, TRUE);
nargs = fetch_next();
/* patch the code for optimize next accesses (pc[-1] is already equal to nargs)*/
vm->pc[-3] = UGREF_INVOKE;
vm->pc[-3] = (vm->pc[-3] == GREF_INVOKE)? UGREF_INVOKE : PUSH_UGREF_INVOKE;
vm->pc[-2] = add_global(&CDR(ref));
/*and now invoke */
tailp=FALSE; goto FUNCALL;
}
CASE(PUSH_UGREF_INVOKE)
push(vm->val); /* Fall through */
CASE(UGREF_INVOKE) { /* Never produced by compiler */
vm->val = fetch_global();
nargs = fetch_next();
......@@ -1167,8 +1177,17 @@ CASE(UNUSED_8)
CASE(UNUSED_9)
CASE(UNUSED_10)
CASE(UNUSED_11)
CASE(UNUSED_12) {
CASE(UNUSED_12)
CASE(UNUSED_13)
CASE(UNUSED_14)
CASE(UNUSED_15)
CASE(UNUSED_16)
CASE(UNUSED_17)
CASE(UNUSED_18)
CASE(UNUSED_19)
CASE(UNUSED_20)
{
;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment