1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-26 03:51:32 +00:00

Delete code related to NATIVETRAN feature. (#232)

* Delete code related to NATIVETRAN feature.

This was obsolete work that had been done for generating
native code from the bytecode.

Closes Interlisp/medley#89.

* Remove unused SaveD6.
This commit is contained in:
Bruce Mitchener
2021-01-20 08:57:53 +07:00
committed by GitHub
parent c89b6fd611
commit 0a057dec6b
17 changed files with 19 additions and 1415 deletions

View File

@@ -131,27 +131,6 @@ done: ! else done;
nop
.end
/*
***************************************************************
Special Native Code Jump Routine.
***************************************************************
*/
.inline _asmgoto,4
jmp %o0
nop
.end
/* THIS IS WRONG! asmcall(label) is supposed to do a direct call there... this is just a jump. Used by emulator<->native interface */
.inline _asmcall,4
jmp %o0
nop
.end
/*
***************************************************************
Arithmetic Opcode Helpers

View File

@@ -1,210 +0,0 @@
/* $Id: loader.c,v 1.2 1999/01/03 02:07:16 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved
*/
/************************************************************************/
/* */
/* (C) Copyright 1989-95 Venue. All Rights Reserved. */
/* Manufactured in the United States of America. */
/* */
/************************************************************************/
#include "version.h"
#include "sys/exec.h" /* choose one you like */
#include <stdio.h>
#include "lispemul.h"
#include "adr68k.h"
#include "lsptypes.h"
#include "lispmap.h"
#include "lspglob.h"
#include "arith.h"
char *sbrk();
unsigned getpagesize(), getpid();
char *malloc();
#define roundup(a, b) ((((unsigned)(a) + (b)-1) / (b)) * (b))
/* A macro to convert a Lisp String to a C string */
#define LispStringToCString(Lisp, C) \
{ \
LispPTR *naddress; \
char *base; \
int length; \
int offset; \
naddress = (LispPTR *)(Addr68k_from_LADDR(Lisp)); \
base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); \
offset = (int)(((OneDArray *)naddress)->offset); \
length = ((OneDArray *)naddress)->totalsize; \
strncpy(C, base + offset, length); \
C[length] = '\0'; \
}
int dynamic_load_code(LispPTR *args)
/* args[0]: LispPTR to file name.
args[1]: native addr of where to load the code
returns: List(load_addr, entry_point, length)
*/
{
char file_name[512];
int load_address;
int entry_point;
LispStringToCString(args[0], file_name);
N_GETNUMBER(args[1], load_address, return_error);
return (load_native_object(load_address, file_name));
return_error:
printf("error in dynamic load: 0x%x\n", args[1]);
return (NIL_PTR);
}
load_native_object(unsigned load_address, char *dynamic_file)
{
int load_length, entry_point;
typedef char *charstrptr;
typedef charstrptr charstrlist[2];
charstrlist p;
int fd, asize, i;
struct exec hdr;
fd = open(dynamic_file, 0);
if (fd == -1) return (0);
if (read(fd, &hdr, sizeof hdr) == -1) return (0);
load_length = hdr.a_text + hdr.a_data;
#ifdef DEBUG
printf("Load Size: %x, Header Rec Size %x\n", load_length, sizeof hdr);
printf("Data Size: %x, Text Size %x\n", hdr.a_data, hdr.a_text);
#endif
if (read(fd, load_address, load_length) == -1) return (0);
entry_point = (int)((CFuncPTR)asmcall(load_address));
{
register int r0, r1, r2;
ARITH_SWITCH((int)load_address, r0);
ARITH_SWITCH((int)entry_point, r1);
ARITH_SWITCH(load_length, r2);
return (N_OP_cons(r0, N_OP_cons(r1, N_OP_cons(r2, NIL_PTR))));
}
}
/* **** system call subr, living in sb_OLD_COMPILE_LOAD_NATIVE slot *** */
int do_system_call(LispPTR arg)
{
char cmd_str[512];
register int result;
register int lisp_result;
LispStringToCString(arg, cmd_str);
#ifdef DEBUG
printf(":: %s \n", cmd_str);
#endif
int_block();
result = system(cmd_str);
int_unblock();
ARITH_SWITCH(result, lisp_result);
return (lisp_result);
}
/* ****** stuff below is old & should be removed when the subr is *** */
int dynamic_load(char *host_file, char *dynamic_file, unsigned load_address, unsigned needs_compile, unsigned needs_link,
unsigned do_load)
{
int result = 0;
char fnamec[80], fnameo[80], fnameil[80], cc_str[255], ld_str[255];
unsigned pagsiz = getpagesize();
host_file = "lisp"; /* TEMPORARY ********** */
printf("loading: %s into %s \n", dynamic_file, host_file);
if (load_address == 0) load_address = roundup(sbrk(0), pagsiz);
sprintf(fnamec, "%s.c", dynamic_file);
sprintf(fnameo, "%s.o", dynamic_file);
sprintf(fnameil, "%s.il", dynamic_file);
sprintf(cc_str,
"/bin/cc -pipe -c %s -o %s %s -O -I/users/krivacic/maiko/inc "
"/users/krivacic/maiko/src/disp68K.il",
fnamec, fnameo, fnameil);
sprintf(ld_str, "/bin/ld -N -s -Ttext %x -A /users/krivacic/maiko/bin/%s -o %s %s -lc",
load_address, host_file, dynamic_file, fnameo);
if (needs_compile) {
result = exec_command(cc_str);
if (result) return (0);
}
if (needs_link) {
result = exec_command(ld_str);
if (result) return (0);
}
if (do_load) {
char rm_str[200];
result = load_object(load_address, dynamic_file);
sprintf(rm_str, "/bin/rm %s %s %s %s", fnamec, fnameil, fnameo, dynamic_file);
/* *** exec_command(rm_str); *** */
}
TopOfStack = result;
return (result);
} /*dynamic_load */
int exec_command(char *cmd_str)
{
typedef char *charstrptr;
typedef charstrptr charstrlist[21];
charstrlist p;
char ws[21][80];
int i, ii, cmd_length;
int_block();
i = system(cmd_str);
int_unblock();
return (i);
} /*exec_command */
int load_object(unsigned load_address, char *dynamic_file)
{
int load_length, entry_point;
typedef char *charstrptr;
typedef charstrptr charstrlist[2];
charstrlist p;
int fd, asize, i;
struct exec hdr;
char *addr2;
unsigned pagsiz = getpagesize();
fd = open(dynamic_file, 0);
if (fd == -1) return (0);
if (read(fd, &hdr, sizeof hdr) == -1) return (0);
asize = roundup(hdr.a_text + hdr.a_data + hdr.a_bss, pagsiz) + pagsiz;
#ifdef DEBUG
printf("Load Size: %x, Header Rec Size %x\n", asize, sizeof hdr);
printf("Data Size: %x, Text Size %x\n", hdr.a_data, hdr.a_text);
#endif
addr2 = sbrk(asize);
addr2 = (char *)roundup(addr2, pagsiz);
if (load_address != (unsigned)addr2) { return (NIL_PTR); }
load_length = hdr.a_text + hdr.a_data;
read(fd, addr2, load_length);
entry_point = (int)((CFuncPTR)asmcall(addr2));
{
register int r0, r1, r2;
#ifdef DEBUG
printf("Values 0x%x & 0x%x\n", entry_point, load_length);
#endif
ARITH_SWITCH((int)addr2, r0);
ARITH_SWITCH((int)entry_point, r1);
ARITH_SWITCH(load_length, r2);
#ifdef DEBUG
printf("Returning 0x%x & 0x%x\n", r1, r2);
#endif
return (N_OP_cons(r0, N_OP_cons(r1, N_OP_cons(r2))));
}
}

View File

@@ -77,10 +77,6 @@ extern LispPTR *PENDINGINTERRUPT68k;
*/
/***********************************************************/
#ifdef NATIVETRAN
extern int *c_ret_to_dispatch;
extern int *ret_to_dispatch;
#endif
extern LispPTR Uraid_mess;
LispPTR subr_lisperror(); /* 0377 */
@@ -429,19 +425,8 @@ void OP_subrcall(int subr_no, int argnum) {
break;
}
#ifdef NATIVETRAN
case 02: /* get an emulator address */
{
register UNSIGNED iarg;
if (argnum != 2) goto ret_nil;
switch (args[1] & 0xffff) {
case 00: iarg = (UNSIGNED)&c_ret_to_dispatch; break;
case 01: iarg = (UNSIGNED)&ret_to_dispatch; break;
}
ARITH_SWITCH(iarg, TopOfStack);
break;
}
#endif
/* case 02: Used to be get an emulator address for
* defunct NATIVETRAN feature. */
}
break;
@@ -449,15 +434,6 @@ void OP_subrcall(int subr_no, int argnum) {
TopOfStack = NIL_PTR;
break;
#ifdef NATIVETRAN
/* old load native (should be superseded) */
case sb_OLD_COMPILE_LOAD_NATIVE:
POP_SUBR_ARGS;
{
TopOfStack = do_system_call(args[0]);
break;
};
#endif
case sb_DISABLEGC:
POP_SUBR_ARGS;
disablegc1(NIL);
@@ -482,16 +458,6 @@ void OP_subrcall(int subr_no, int argnum) {
break;
};
#ifdef NATIVETRAN
case sb_LOAD_NATIVE_FILE:
POP_SUBR_ARGS;
/* to become OBSOLETE */
{
TopOfStack = dynamic_load_code(args);
break;
}
#endif
case sb_DSK_GETFILENAME:
POP_SUBR_ARGS;
TopOfStack = DSK_getfilename(args);

View File

@@ -1196,7 +1196,6 @@ void all_stack_dump(DLword start, DLword end, DLword silent)
print(get_framename((struct frameex1 *)stkptr));
printf(" [");
if (((FX *)stkptr)->fast) printf("fast,");
if (((FX *)stkptr)->native) printf("native,");
if (((FX *)stkptr)->incall) printf("incall,");
if (((FX *)stkptr)->validnametable) printf("V,");
if (((FX *)stkptr)->nopush) printf("nopush,");

138
src/xc.c
View File

@@ -211,16 +211,6 @@ void dispatch(void) {
register struct state *stateptrcache = MState;
#undef MState
#define MState stateptrcache
#endif
#if (defined(I386) || defined(ISC))
int SaveD6;
#else
#ifdef OPDISP
#ifndef DOS
register int SaveD6;
#endif
#endif
#endif
/* OP_FN_COMMON arguments */
@@ -264,7 +254,6 @@ void dispatch(void) {
asm volatile("fldcw WORD PTR CODE32:FP_noint"); /* Turn off FP interrupts */
goto nextopcode;
#else
SaveD6 = 0;
goto setup_table;
#endif /* ISC */
@@ -345,66 +334,24 @@ nextopcode:
case 007:
CASE007:
UNWIND(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2);
#ifdef NATIVETRAN
ret_to_fn0:
asm("_ret_to_fn0:");
asm(" .globl _ret_to_fn0");
RET_FROM_NATIVE;
#endif
case 010:
CASE010:
FN0;
#ifdef NATIVETRAN
ret_to_fn1:
asm("_ret_to_fn1:");
asm(" .globl _ret_to_fn1");
RET_FROM_NATIVE;
#endif
case 011:
CASE011:
FN1;
#ifdef NATIVETRAN
ret_to_fn2:
asm("_ret_to_fn2:");
asm(" .globl _ret_to_fn2");
RET_FROM_NATIVE;
#endif
case 012:
CASE012:
FN2;
#ifdef NATIVETRAN
ret_to_fn3:
asm("_ret_to_fn3:");
asm(" .globl _ret_to_fn3");
RET_FROM_NATIVE;
#endif
case 013:
CASE013:
FN3;
#ifdef NATIVETRAN
ret_to_fn4:
asm("_ret_to_fn4:");
asm(" .globl _ret_to_fn4");
RET_FROM_NATIVE;
#endif
case 014:
CASE014:
FN4;
#ifdef NATIVETRAN
ret_to_fnx:
asm("_ret_to_fnx:");
asm(" .globl _ret_to_fnx");
RET_FROM_NATIVE;
#endif
case 015:
CASE015:
FNX;
#ifdef NATIVETRAN
ret_to_apply:
asm("_ret_to_apply:");
asm(" .globl _ret_to_apply");
RET_FROM_NATIVE;
#endif
case 016:
CASE016:
APPLY;
@@ -494,12 +441,6 @@ nextopcode:
case 054:
CASE054:
EVAL;
#ifdef NATIVETRAN
ret_to_envcall:
asm("_ret_to_envcall:");
asm(" .globl _ret_to_envcall");
RET_FROM_NATIVE;
#endif
case 055:
CASE055:
ENVCALL;
@@ -752,7 +693,7 @@ nextopcode:
EXT;
OP_subrcall(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2);
RET;
NATIVE_NEXTOP0;
nextop0;
};
case 0176:
CASE176 : { CONTEXTSWITCH; }
@@ -1027,7 +968,9 @@ nextopcode:
case 0327:
CASE327:
QUOTIENT /* QUOTIENT */
case 0330 : CASE330 : IPLUS2; /* IPLUS2 only while PLUS has no float */
case 0330:
CASE330:
IPLUS2; /* IPLUS2 only while PLUS has no float */
case 0331:
CASE331:
IDIFFERENCE; /* IDIFFERENCE only while no float */
@@ -1183,83 +1126,14 @@ nextopcode:
} /* switch */
#ifdef NATIVETRAN
/************************************************************************/
/* NATIVE CODE INTERFACE */
/************************************************************************/
/* FORIEGN -> DISPATCH */
/* Return to current frame ext */
c_ret_to_dispatch:
asm(" .globl _c_ret_to_dispatch");
asm("_c_ret_to_dispatch:");
PCMACL = (ByteCode *)FuncObj + BCE_CURRENTFX->pc;
goto ret_to_dispatch; /* assume optimizer will remove */
/* NATIVE -> DISPATCH */
/* Return to current frame ext */
ret_to_dispatch:
asm(" .globl _ret_to_dispatch");
asm("_ret_to_dispatch:");
RET_FROM_NATIVE;
nextop0;
/* NATIVE -> DISPATCH */
/* Execute opcode in current frame ext */
ret_to_unimpl:
asm(" .globl _ret_to_unimpl");
asm("_ret_to_unimpl:");
SaveD6 = 0x100;
/* HACK. Reg. d6 is set to dispatch to native_check */
/* so need to do switch instead of dispatch! */
RET_FROM_NATIVE;
goto nextopcode;
/* NATIVE -> UFN(PC) */
ret_to_ufn:
asm(" .globl _ret_to_ufn");
asm("_ret_to_ufn:");
RET_FROM_NATIVE;
goto op_ufn;
/* DISPATCH -> NATIVE? */
/* Return to current frame ext? */
native_check:
SaveD6 = 0;
NATIVE_NEXTOP0;
/* NATIVE -> TIMER */
/* Return to Execute timer interrupt */
ret_to_timer:
asm("_ret_to_timer:");
asm(" .globl _ret_to_timer");
SaveD6 = 0x100;
RET_FROM_NATIVE;
goto check_interrupt; /* assume optimizer will remove */
#else
native_check:
#ifndef DOS
#ifdef OPDISP
SaveD6 = 0x000;
#endif
#endif /* DOS */
goto nextopcode;
#endif
/************************************************************************/
/* TIMER INTERRUPT CHECK ROUTINE */
/************************************************************************/
check_interrupt:
#if (defined(NATIVETRAN) || defined(SUN3_OS3_OR_OS4_IL) || defined(I386) || defined(ISC))
#if (defined(SUN3_OS3_OR_OS4_IL) || defined(I386) || defined(ISC))
asm_label_check_interrupt();
#endif
@@ -1456,8 +1330,6 @@ PopNextop2:
#ifdef OPDISP
setup_table:
#ifndef ISC
SaveD6 = 0;
{
int i;
for (i = 0; i < 256; i++) { table[i] = (InstPtr)op_ufn; };