Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001444OCamlOCaml generalpublic2002-10-19 19:002013-08-30 22:08
Reporteradministrator 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0001444: Deltas in frametables
DescriptionFull_Name: Vassili Karpov
Version: 3.06
OS: Linux/Windows
Submission from: cache1-kh.comex.ru (217.10.35.250)


Size of object files and libraries can be slightly reduced
by using deltas(instead of offsets) in frametables, linking
time will also be reduced (less relocations to consider).
Following small patch implements this for i386:

diff -ur ocaml/asmcomp/i386/emit.mlp work/asmcomp/i386/emit.mlp
--- ocaml/asmcomp/i386/emit.mlp Mon Jul 22 20:37:50 2002
+++ work/asmcomp/i386/emit.mlp Sat Oct 19 19:07:48 2002
@@ -178,7 +178,7 @@
   let lbl = record_frame_label live in `{emit_label lbl}:\n`
 
 let emit_frame fd =
- ` .long {emit_label fd.fd_lbl}\n`;
+ ` .long {emit_label fd.fd_lbl} - bias\n`;
   ` {emit_string word_dir} {emit_int fd.fd_frame_size}\n`;
   ` {emit_string word_dir} {emit_int (List.length fd.fd_live_offset)}\n`;
   List.iter
@@ -812,6 +812,7 @@
   `{emit_symbol lbl_begin}:\n`;
   let lbl_begin = Compilenv.current_unit_name() ^ "__code_begin" in
   ` .text\n`;
+ ` bias={emit_symbol lbl_begin}\n`;
   ` .globl {emit_symbol lbl_begin}\n`;
   `{emit_symbol lbl_begin}:\n`
 
@@ -826,6 +827,7 @@
   `{emit_symbol lbl_end}:\n`;
   ` .long 0\n`;
   let lbl = Compilenv.current_unit_name() ^ "__frametable" in
+ ` .data 1\n`;
   ` .globl {emit_symbol lbl}\n`;
   `{emit_symbol lbl}:\n`;
   ` .long {emit_int (List.length !frame_descriptors)}\n`;
diff -ur ocaml/asmcomp/i386/emit_nt.mlp work/asmcomp/i386/emit_nt.mlp
--- ocaml/asmcomp/i386/emit_nt.mlp Fri Feb 8 19:55:31 2002
+++ work/asmcomp/i386/emit_nt.mlp Sat Oct 19 19:27:17 2002
@@ -161,7 +161,7 @@
   let lbl = record_frame_label live in `{emit_label lbl}:\n`
 
 let emit_frame fd =
- ` DWORD {emit_label fd.fd_lbl}\n`;
+ ` DWORD {emit_label fd.fd_lbl} - bias\n`;
   ` WORD {emit_int fd.fd_frame_size}\n`;
   ` WORD {emit_int (List.length fd.fd_live_offset)}\n`;
   List.iter
@@ -797,7 +797,8 @@
   let lbl_begin = Compilenv.current_unit_name() ^ "__code_begin" in
   add_def_symbol lbl_begin;
   ` PUBLIC {emit_symbol lbl_begin}\n`;
- `{emit_symbol lbl_begin} LABEL DWORD\n`
+ `{emit_symbol lbl_begin} LABEL DWORD\n`;
+ `bias LABEL DWORD\n`
 
 let end_assembly() =
   ` .CODE\n`;
diff -ur ocaml/asmrun/roots.c work/asmrun/roots.c
--- ocaml/asmrun/roots.c Mon Jan 21 01:20:51 2002
+++ work/asmrun/roots.c Sat Oct 19 19:12:10 2002
@@ -46,12 +46,16 @@
 #define Hash_retaddr(addr) \
   (((unsigned long)(addr) >> 3) & frame_descriptors_mask)
 
+struct segment { char * begin; char * end; };
+
 static void init_frame_descriptors(void)
 {
+ extern struct segment caml_code_segments[];
   long num_descr, tblsize, i, j, len;
   long * tbl;
   frame_descr * d;
- unsigned long h;
+ unsigned long h, bias;
+ struct segment *seg = caml_code_segments;
 
   /* Count the frame descriptors */
   num_descr = 0;
@@ -73,8 +77,13 @@
   for (i = 0; caml_frametable[i] != 0; i++) {
     tbl = caml_frametable[i];
     len = *tbl;
+ if (i != 1) {
+ bias = (unsigned long)seg->begin;
+ seg++;
+ } else bias = 0;
     d = (frame_descr *)(tbl + 1);
     for (j = 0; j < len; j++) {
+ d->retaddr += bias;
       h = Hash_retaddr(d->retaddr);
       while (frame_descriptors[h] != NULL) {
         h = (h+1) & frame_descriptors_mask;

Tagspatch
Attached Files

- Relationships

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue
2013-08-30 22:08 doligez Tag Attached: patch


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker