Raymond Toy pushed to branch issue-97-define-ud2-inst at cmucl / cmucl
Commits:
73e864e8 by Raymond Toy at 2021-03-20T09:09:29-07:00
Fix disassembly of break inst
The code field for the break instruction had the wrong byte position.
It was (byte 8 8), but it should be (byte 8 16).
`(disassemble 'lisp::halt)` works now.
- - - - -
1 changed file:
- src/compiler/x86/insts.lisp
Changes:
=====================================
src/compiler/x86/insts.lisp
=====================================
@@ -2064,7 +2064,7 @@
(disassem:define-instruction-format (break 24 :default-printer '(:name :tab code))
(op :fields (list (byte 8 0) (byte 8 8)) :value '(#xb00001111 #b00001011))
- (code :field (byte 8 8)))
+ (code :field (byte 8 16)))
(define-emitter emit-break-inst 24
(byte 8 0) (byte 8 8) (byte 8 16))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/73e864e8ddcef408af202f9…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/73e864e8ddcef408af202f9…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch native-image at cmucl / cmucl
Commits:
62f09401 by Raymond Toy at 2021-02-14T10:07:00-08:00
Make all labels global and assign a section name.
Every label is now a global symbol.
Prepend each output file with a .section to name the section we're
creating.
- - - - -
916ccc3a by Raymond Toy at 2021-02-14T11:47:16-08:00
Emit addresses of assembler routines to internals.h
Create an array that contains the addresses of all the lisp assembler
routines so that when writing out the assembly code, we can create
symbols for the lisp assembler routines.
- - - - -
c6791370 by Raymond Toy at 2021-02-14T11:59:02-08:00
Dump the lisp assembly routines.
For now, we just write out .equ pseudo op for the address of each lisp
assembler routine so that the linker doesn't have any unresolved
values.
This is a workaround for now. Ideally, these would be real
relocatable symbols at the right address in the read-only space so
that everything can be relocated.
- - - - -
9f3243f4 by Raymond Toy at 2021-02-14T12:39:18-08:00
Print out the initial function addr for reference.
- - - - -
2 changed files:
- src/compiler/generic/new-genesis.lisp
- src/lisp/save.c
Changes:
=====================================
src/compiler/generic/new-genesis.lisp
=====================================
@@ -2448,7 +2448,7 @@
(and (>= (length string) (length head))
(string= string head :end1 (length head))))
-(defun emit-c-header-aux ()
+(defun emit-c-header-aux (assembler-routines)
(format t "/*~% * Machine generated header file. Do not edit.~% */~2%")
(format t "#ifndef _INTERNALS_H_~%#define _INTERNALS_H_~2%")
;; Write out various constants
@@ -2602,6 +2602,17 @@
(remove-if #'(lambda (char)
(member char '(#\% #\* #\.)))
(symbol-name feature))))))
+
+ (format t "~2%#if defined(DEFINE_ASM)~%")
+ (format t "/* Assembly routines */~%")
+ (format t "unsigned long lisp_asm_routines[] = {~%")
+ (dolist (routine (sort (copy-list *cold-assembler-routines*)
+ #'< :key #'cdr))
+ (format t " 0x~8,'0x, /* ~S */~%"
+ (cdr routine) (car routine)))
+ (format t " 0x~8,'0x, /* End marker */~%" 0)
+ (format t "};~%")
+ (format t "#endif~%")
;;
(format t "~%#endif~%"))
@@ -2622,14 +2633,14 @@
(string/= line1 line2))
(return t)))))))
-(defun emit-c-header (name)
+(defun emit-c-header (name assembler-routines)
(let* ((new-name (concatenate 'string (namestring name) ".NEW"))
(unix-newname (unix-namestring new-name nil)))
(with-open-file
(*standard-output* new-name
:direction :output
:if-exists :supersede)
- (emit-c-header-aux))
+ (emit-c-header-aux assembler-routines))
(cond ((not (probe-file name))
(unix:unix-chmod unix-newname #o444)
(rename-file new-name name)
@@ -2755,13 +2766,15 @@
:if-exists :supersede)
(write-map-file)))
(when header-name
+ (format t "cold-assembler ~S~%" *cold-assembler-routines*)
(emit-c-header
(merge-pathnames (if (eq header-name t)
"internals.h"
(merge-pathnames
header-name
(make-pathname :type "h")))
- core-name))
+ core-name)
+ *cold-assembler-routines*)
(emit-makefile-header
(merge-pathnames (if (eq header-name t)
"internals.inc"
=====================================
src/lisp/save.c
=====================================
@@ -13,6 +13,8 @@
#include <limits.h>
#include <math.h>
+/* Get the lisp assembly routines because we need them */
+#define DEFINE_ASM
#include "lisp.h"
#include "os.h"
#include "internals.h"
@@ -394,6 +396,8 @@ save_executable(char *filename, lispobj init_function)
fflush(stdout);
printf("Linking executable...\n");
+ printf(" init_function 0x%08lx\n", init_function);
+
fflush(stdout);
rc = obj_run_linker(init_function, filename);
printf("done.\n");
@@ -415,7 +419,8 @@ static char* asmtab_types[256];
void
asm_label(lispobj* ptr, lispobj object, FILE* f)
{
- fprintf(f, "L%lx:\n", (unsigned long) ptr);
+ fprintf(f, "\t.global\tL%08lx\n", (unsigned long) ptr);
+ fprintf(f, "L%08lx:\n", (unsigned long) ptr);
}
void
@@ -1356,6 +1361,7 @@ write_asm_object(const char *dir, int id, os_vm_address_t start, os_vm_address_t
{
char asm_file[PATH_MAX];
FILE* f;
+ int k;
printf("write_asm_object space %d start %p end %p\n",
id, start, end);
@@ -1365,14 +1371,25 @@ write_asm_object(const char *dir, int id, os_vm_address_t start, os_vm_address_t
lispobj* ptr = (lispobj*) start;
lispobj* end_ptr = (lispobj*) end;
+
+ /* Set the section name */
+ fprintf(f, "\t.section\t\"space%d\", \"wx\"\n", id);
+ /* Print the assembly routines */
+ k = 0;
+ while (lisp_asm_routines[k] != 0) {
+ fprintf(f, "\t.set\tL%08lx, 0x%08lx\n",
+ lisp_asm_routines[k],
+ lisp_asm_routines[k]);
+ ++k;
+ }
+
/*
* If the id is the static space, we need special handling for
* beginning which has NIL in a funny way to make NIL a symbol and
* list.
*/
if (id == STATIC_SPACE_ID) {
- int k;
/* Output the first word */
asm_header_word(ptr, *ptr, f, NULL);
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/6072cf3f9f6d5431f24153…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/6072cf3f9f6d5431f24153…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch master at cmucl / cmucl
Commits:
b6a38aa0 by Raymond Toy at 2021-02-13T09:56:15-08:00
Fix #103: Remove random-mt19937-update
We don't use the MT19937 RNG anymore, so we can remove this assembly
routine. But since the code still exists for mt19937, just use
reader-conditionals to disable this.
- - - - -
9b1abca5 by Raymond Toy at 2021-02-13T18:20:36+00:00
Merge branch 'issue-103-remove-random-mt19937-update' into 'master'
Fix #103: Remove random-mt19937-update
Closes #103
See merge request cmucl/cmucl!71
- - - - -
1 changed file:
- src/assembly/x86/arith.lisp
Changes:
=====================================
src/assembly/x86/arith.lisp
=====================================
@@ -313,7 +313,7 @@
;;; the state vector with new random numbers. The state vector is
;;; passed in the EAX register.
;;;
-#+assembler ; we don't want a vop for this one.
+#+(and random-mt19937 assembler) ; we don't want a vop for this one.
(define-assembly-routine
(random-mt19937-update)
((:temp state unsigned-reg eax-offset)
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/f99321c7080b723a0d0f4f…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/f99321c7080b723a0d0f4f…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch native-image at cmucl / cmucl
Commits:
93c256ba by Raymond Toy at 2021-02-08T16:37:40-08:00
Handle case of code header with no entry points.
We were just skipping that case, incorrectly. Makes the read-only
space print out the instructions for the assembly routines.
While we're at it, dump out the dynamic space too.
- - - - -
1 changed file:
- src/lisp/save.c
Changes:
=====================================
src/lisp/save.c
=====================================
@@ -27,6 +27,16 @@
#include "gencgc.h"
#endif
+/*
+ * Aargh! Why is SPARC so different here? What is the advantage of
+ * making it different from all the other ports?
+ */
+#if defined(sparc) || (defined(DARWIN) && defined(__ppc__))
+#define RAW_ADDR_OFFSET 0
+#else
+#define RAW_ADDR_OFFSET (6 * sizeof(lispobj) - type_FunctionPointer)
+#endif
+
/* Like (ceiling x y), but y is constrained to be a power of two */
#define CEILING(x,y) (((x) + ((y) - 1)) & (~((y) - 1)))
@@ -371,9 +381,13 @@ save_executable(char *filename, lispobj init_function)
#ifdef reg_ALLOC
write_space_object(dir_name, DYNAMIC_SPACE_ID, (os_vm_address_t)current_dynamic_space,
(os_vm_address_t)current_dynamic_space_free_pointer);
+ write_asm_object(dir_name, DYNAMIC_SPACE_ID, (os_vm_address_t)current_dynamic_space,
+ (os_vm_address_t)current_dynamic_space_free_pointer);
#else
write_space_object(dir_name, DYNAMIC_SPACE_ID, (os_vm_address_t)current_dynamic_space,
(os_vm_address_t)SymbolValue(ALLOCATION_POINTER));
+ write_asm_object(dir_name, DYNAMIC_SPACE_ID, (os_vm_address_t)current_dynamic_space,
+ (os_vm_address_t)SymbolValue(ALLOCATION_POINTER));
#endif
printf("\tdone]\n");
@@ -530,6 +544,14 @@ asm_fdefn(lispobj* ptr, lispobj object, FILE* f)
asm_lispobj(ptr + 1, ptr[1], f);
asm_lispobj(ptr + 2, ptr[2], f);
+#if 0
+ struct fdefn* fdefn = (struct fdefn*) ptr;
+
+ if (((char *) (fdefn->function + RAW_ADDR_OFFSET) != fdefn->raw_addr)) {
+ fprintf(f, "# Different!\n");
+ }
+#endif
+
fprintf(f, "\t.4byte\tL%lx\t# raw_addr\n", (unsigned long) ptr[3]);
return 4;
@@ -678,6 +700,15 @@ asm_code_header(lispobj* ptr, lispobj object, FILE* f)
fheaderl = fheaderp->next;
}
+ {
+ uint32_t* code_data = (uint32_t*) fheaderp->code;
+
+ for (k = 0; k < ncode_words; ++k) {
+ fprintf(f, "\t.4byte\t0x%08x\t# %p\n", code_data[k],
+ fheaderp->code + 4*k);
+ }
+ }
+
asm_align(f);
return nwords;
}
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/93c256baa6e0b526f3875e7…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/93c256baa6e0b526f3875e7…
You're receiving this email because of your account on gitlab.common-lisp.net.