Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/compiler/CodeGen/main/object-desc.sml
ViewVC logotype

Annotation of /sml/trunk/compiler/CodeGen/main/object-desc.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2162 - (view) (download)

1 : monnier 245 (* object-desc.sml
2 :     *
3 :     * COPYRIGHT (c) 1998 Bell Labs, Lucent Technologies.
4 :     *
5 :     * The encoding of object description headers.
6 :     *
7 :     * WARNING: this file must agree with the run-time system values and those
8 :     * used in boot/core.sml and boot/Unsafe/object.sml.
9 :     *)
10 :    
11 :     structure ObjectDesc :> OBJECT_DESC =
12 :     struct
13 :    
14 :     type tag = word
15 :    
16 :     structure W = Word
17 :     structure LW = LargeWord
18 :    
19 :     (* taken from runtime/tags.h *)
20 :     val tagWidth = 7 (* 5 minor tag bits plus 2 major tag bits *)
21 :     (* one greater than the maximum length field value (sign should be 0) *)
22 :     val maxLength = W.toInt(W.<<(0w1, W.-(0w31, W.fromInt tagWidth)))
23 :     val powTagWidth = W.toInt(W.<<(0w1, W.fromInt tagWidth))
24 :    
25 :     (* tag values *)
26 :     local
27 :     fun mkTag t = W.orb(W.<<(t, 0w2), 0w2)
28 :     in
29 :     val tag_record = mkTag 0w0
30 :     val tag_vec_hdr = mkTag 0w1
31 :     val tag_vec_data = tag_record
32 :     val tag_arr_hdr = mkTag 0w2
33 :     val tag_arr_data = mkTag 0w3
34 :     val tag_ref = tag_arr_data
35 :     val tag_raw32 = mkTag 0w4
36 :     val tag_raw64 = mkTag 0w5
37 :     val tag_special = mkTag 0w6
38 :     end (* local *)
39 :    
40 :     (* build a descriptor from a tag and length *)
41 :     fun makeDesc (len, t) =
42 :     LW.orb(LW.<<(LW.fromInt len, W.fromInt tagWidth), W.toLargeWord t)
43 :    
44 :     (* array/vector header codes *)
45 :     val seq_poly = 0
46 :     val seq_word8 = 1
47 :     val seq_word16 = 2
48 :     val seq_word31 = 3
49 :     val seq_word32 = 4
50 :     val seq_real32 = 5
51 :     val seq_real64 = 6
52 :    
53 :     (* fixed descriptors *)
54 :     val desc_pair = makeDesc(2, tag_record)
55 :     val desc_ref = makeDesc(1, tag_ref)
56 :     val desc_real64 = makeDesc(2, tag_raw64)
57 :     val desc_polyvec = makeDesc(seq_poly, tag_vec_hdr)
58 :     val desc_polyarr = makeDesc(seq_poly, tag_arr_hdr)
59 :     val desc_special = makeDesc(0, tag_special)
60 :    
61 :     (* special descriptors *)
62 :     val special_unevaled_susp = 0
63 :     val special_evaled_susp = 1
64 :     val special_weak = 2
65 :     val special_nulled_weak = 3
66 :    
67 :     end;
68 :    
69 : monnier 469

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0