(define-rule statement
(ASSIGN (REGISTER (? target)) (ENTRY:CONTINUATION (? label)))
- (load-pc-relative-address (target-register-reference target) label 8))
+ (let* ((target (target-register-reference target))
+ (get-pc (generate-label 'GET-PC)))
+ (LAP (CALL (@PCR ,get-pc))
+ (JMP (@PCRO ,label 8))
+ (LABEL ,get-pc)
+ (POP Q ,target))))
(define-rule statement
;; This is an intermediate rule -- not intended to produce code.
(CONS-POINTER (MACHINE-CONSTANT (? type))
(ENTRY:CONTINUATION (? label))))
(assert (= type type-code:compiled-return))
- (load-pc-relative-address/typed (target-register-reference target)
- type label 8))
+ (let* ((target (target-register-reference target))
+ (temp (temporary-register-reference))
+ (pushed (generate-label 'PUSHED)))
+ (LAP (CALL (@PCR ,pushed))
+ (JMP (@PCRO ,label 8))
+ (LABEL ,pushed)
+ (POP Q ,target)
+ (MOV Q ,temp (&U ,(make-non-pointer-literal type 0)))
+ (OR Q ,target ,temp))))
+
+(define-rule statement
+ (ASSIGN (PRE-INCREMENT (REGISTER 4) -1)
+ (CONS-POINTER (MACHINE-CONSTANT (? type))
+ (ENTRY:CONTINUATION (? label))))
+ (assert (= type type-code:compiled-return))
+ (let* ((temp (temporary-register-reference))
+ (pushed (generate-label 'PUSHED)))
+ (LAP (CALL (@PCR ,pushed))
+ (JMP (@PCRO ,label 8))
+ (LABEL ,pushed)
+ (MOV Q ,temp (&U ,(make-non-pointer-literal type 0)))
+ (OR Q (@R 4) ,temp))))
(define-rule statement
(ASSIGN (REGISTER (? target)) (VARIABLE-CACHE (? name)))
(cond ((null? checks)
(current-bblock-continue!
(make-new-sblock
- (LAP (POP Q (R ,rax)) ; continuation
- (AND Q (R ,rax) (R ,regnum:datum-mask)) ; clear type
- (JMP (R ,rax))))))
+ (LAP (AND Q (@R ,rsp) (R ,regnum:datum-mask))
+ (RET)))))
((block-association 'POP-RETURN)
=> current-bblock-continue!)
(else
(let ((interrupt-label (generate-label 'INTERRUPT)))
(LAP (CMP Q (R ,regnum:free-pointer) ,reg:compiled-memtop)
(JGE (@PCR ,interrupt-label))
- (POP Q (R ,rax)) ; continuation
- (AND Q (R ,rax) (R ,regnum:datum-mask)) ; clear type
- (JMP (R ,rax))
+ (AND Q (@R ,rsp) (R ,regnum:datum-mask))
+ (RET)
(LABEL ,interrupt-label)
,@(invoke-hook
entry:compiler-interrupt-continuation-2))))))
= (((ceo->offset) << 1) | ((ceo->continued_p) ? 1 : 0));
return (false);
}
+
+insn_t *
+cc_return_address_to_entry_address (insn_t * pc)
+{
+ if ((pc[0]) == 0xeb) /* JMP rel8 */
+ return ((pc + 2) + (* ((int8_t *) &pc[1])) - 8);
+ else if ((pc[0]) == 0xe9) /* JMP rel32 */
+ return ((pc + 5) + (* ((int32_t *) &pc[1])) - 8);
+ else
+ return (pc - 8);
+}
\f
/* Compiled closures */
#define CC_RETURN_ADDRESS_PTR(r) 0
#define CC_RETURN_ADDRESS_PC(r) (r)
-#define CC_RETURN_ADDRESS_TO_ENTRY_ADDRESS(r) (((insn_t *) (r)) - 8)
+insn_t * cc_return_address_to_entry_address (insn_t *);
+
+#define CC_RETURN_ADDRESS_TO_ENTRY_ADDRESS cc_return_address_to_entry_address
\f
#define EMBEDDED_CLOSURE_ADDRS_P 1