From c8617f57d0413beb2890e94dabe227cef9c5ddad Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Sun, 2 Jun 2013 20:33:54 +0400 Subject: [PATCH] Better initialization of ir2-component-constants on x86-64. x86 uses the first constant for the fixup vector, x86-64 doesn't. Don't leave empty space in ir2-component-constants. On the C side, call gencgc_apply_code_fixups only on x86, and not on x86_64 as well, since its body is conditionalized for x86_64 anyway. --- NEWS | 2 +- src/compiler/x86-64/call.lisp | 12 +----------- src/runtime/gc-common.c | 2 +- src/runtime/gencgc-internal.h | 3 ++- src/runtime/gencgc.c | 12 ++++++------ 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/NEWS b/NEWS index 4c4f372..9b52416 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ ;;;; -*- coding: utf-8; fill-column: 78 -*- changes relative to sbcl-1.1.8: * enchancement: disassemble now annotates some previously missing static - function, like LENGTH. + functions, like LENGTH. changes in sbcl-1.1.8 relative to sbcl-1.1.7: * notice: The implementation of MAP-ALLOCATED-OBJECTS (the heart of diff --git a/src/compiler/x86-64/call.lisp b/src/compiler/x86-64/call.lisp index efa3b5d..58538fe 100644 --- a/src/compiler/x86-64/call.lisp +++ b/src/compiler/x86-64/call.lisp @@ -89,17 +89,7 @@ ;;; additional noise in the code object header. (!def-vm-support-routine select-component-format (component) (declare (type component component)) - ;; The 1+ here is because for the x86 the first constant is a - ;; pointer to a list of fixups, or NIL if the code object has none. - ;; (If I understand correctly, the fixups are needed at GC copy - ;; time because the X86 code isn't relocatable.) - ;; - ;; KLUDGE: It'd be cleaner to have the fixups entry be a named - ;; element of the CODE (aka component) primitive object. However, - ;; it's currently a large, tricky, error-prone chore to change - ;; the layout of any primitive object, so for the foreseeable future - ;; we'll just live with this ugliness. -- WHN 2002-01-02 - (dotimes (i (1+ code-constants-offset)) + (dotimes (i code-constants-offset) (vector-push-extend nil (ir2-component-constants (component-info component)))) (values)) diff --git a/src/runtime/gc-common.c b/src/runtime/gc-common.c index b601c9e..227021b 100644 --- a/src/runtime/gc-common.c +++ b/src/runtime/gc-common.c @@ -322,7 +322,7 @@ trans_code(struct code *code) #endif -#if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64) +#ifdef LISP_FEATURE_X86 gencgc_apply_code_fixups(code, new_code); #endif diff --git a/src/runtime/gencgc-internal.h b/src/runtime/gencgc-internal.h index 779c747..3cb2837 100644 --- a/src/runtime/gencgc-internal.h +++ b/src/runtime/gencgc-internal.h @@ -116,9 +116,10 @@ extern struct page *page_table; /* forward declarations */ - +#ifdef LISP_FEATURE_X86 void sniff_code_object(struct code *code, os_vm_size_t displacement); void gencgc_apply_code_fixups(struct code *old_code, struct code *new_code); +#endif sword_t update_dynamic_space_free_pointer(void); void gc_alloc_update_page_tables(int page_type_flag, struct alloc_region *alloc_region); diff --git a/src/runtime/gencgc.c b/src/runtime/gencgc.c index 0c87faf..fce1824 100644 --- a/src/runtime/gencgc.c +++ b/src/runtime/gencgc.c @@ -125,8 +125,10 @@ boolean verify_after_free_heap = 0; * during a heap verify? */ boolean verify_dynamic_code_check = 0; +#ifdef LISP_FEATURE_X86 /* Should we check code objects for fixup errors after they are transported? */ boolean check_code_fixups = 0; +#endif /* Should we check that newly allocated regions are zero filled? */ boolean gencgc_zero_check = 0; @@ -1650,10 +1652,10 @@ static lispobj trans_boxed(lispobj object); * * Currently only absolute fixups to the constant vector, or to the * code area are checked. */ +#ifdef LISP_FEATURE_X86 void sniff_code_object(struct code *code, os_vm_size_t displacement) { -#ifdef LISP_FEATURE_X86 sword_t nheader_words, ncode_words, nwords; os_vm_address_t constants_start_addr = NULL, constants_end_addr, p; os_vm_address_t code_start_addr, code_end_addr; @@ -1822,14 +1824,13 @@ sniff_code_object(struct code *code, os_vm_size_t displacement) "/code start = %x, end = %x\n", code_start_addr, code_end_addr)); } -#endif } +#endif +#ifdef LISP_FEATURE_X86 void gencgc_apply_code_fixups(struct code *old_code, struct code *new_code) { -/* x86-64 uses pc-relative addressing instead of this kludge */ -#ifndef LISP_FEATURE_X86_64 sword_t nheader_words, ncode_words, nwords; os_vm_address_t constants_start_addr, constants_end_addr; os_vm_address_t code_start_addr, code_end_addr; @@ -1925,9 +1926,8 @@ gencgc_apply_code_fixups(struct code *old_code, struct code *new_code) if (check_code_fixups) { sniff_code_object(new_code,displacement); } -#endif } - +#endif static lispobj trans_boxed_large(lispobj object) -- 1.7.10.4