+ All Categories
Home > Documents > 10.1.1.32.2422

10.1.1.32.2422

Date post: 05-Apr-2018
Category:
Upload: scratchname
View: 215 times
Download: 0 times
Share this document with a friend

of 9

Transcript
  • 8/2/2019 10.1.1.32.2422

    1/9

    A x i o m a t i c B o o t s t r a p p i n g :

    A g u i d e f o r c o m p i l e r h a c k e r s

    A n d r e w W . A p p e l

    P r i n c e t o n U n i v e r s i t y

    A b s t r a c t

    I f a c o m p i l e r f o r l a n g u a g e L i s i m p l e m e n t e d i n L , t h e n

    i t s h o u l d b e a b l e t o c o m p i l e i t s e l f . B u t f o r s y s t e m s u s e d

    i n t e r a c t i v e l y , c o m m a n d s a r e c o m p i l e d a n d i m m e d i a t e l y

    e x e c u t e d , a n d t h e s e c o m m a n d s m a y i n v o k e t h e c o m p i l e r ,

    t h e r e i s t h e q u e s t i o n o f h o w e v e r t o c r o s s - c o m p i l e f o r

    a n o t h e r a r c h i t e c t u r e . A l s o , w h e r e t h e c o m p i l e r w r i t e s

    b i n a r y l e s o f s t a t i c t y p e i n f o r m a t i o n t h a t m u s t t h e n b e

    r e a d i n b y t h e b o o t s t r a p p e d i n t e r a c t i v e c o m p i l e r , h o w c a n

    o n e e v e r c h a n g e t h e f o r m a t o f d i g e s t e d t y p e i n f o r m a t i o n

    i n b i n a r y l e s ?

    H e r e I a t t e m p t a n a x i o m a t i c c l a r i c a t i o n o f t h e b o o t -

    s t r a p p i n g t e c h n i q u e . I u s e t h e S t a n d a r d M L o f N e w J e r -

    s e y a s a c a s e s t u d y . T h i s s h o u l d b e u s e f u l t o i m p l e m e n -

    t o r s o f a n y s e l f - a p p l i c a b l e i n t e r a c t i v e c o m p i l e r w i t h n o n -

    t r i v i a l o b j e c t - l e a n d r u n t i m e - s y s t e m c o m p a t i b i l i t y p r o b -

    l e m s .

    1 I n t r o d u c t i o n

    A c o n v e n t i o n a l C c o m p i l e r , w r i t t e n i n C , i s s a i d t o b e

    \ b o o t s t r a p p e d " i f i t c o m p i l e s i t s e l f . N o w , s u p p o s e a n e w

    v e r s i o n o f t h e c o m p i l e r s o u r c e i s w r i t t e n , t h a t u s e s d i f -

    f e r e n t r e g i s t e r s f o r p a s s i n g a r g u m e n t s . T h e o l d c o m p i l e r

    c a n c o m p i l e t h i s s o u r c e , y i e l d i n g a n e w c o m p i l e r .

    B u t l o o k ! T h e e x e c u t a b l e v e r s i o n c c ' o f t h e n e w c o m -

    p i l e r u s e s t h e o l d p a r a m e t e r - p a s s i n g s t y l e , b u t g e n e r a t e s

    c o d e t h a t u s e s t h e n e w s t y l e . O n e c a n u s e t h e n e w c o m -

    p i l e r , h o w e v e r , t o r e - c o m p i l e a l l t h e l i b r a r i e s ( a n d t h e n e w

    c o m p i l e r i t s e l f ) a n d g e t a \ n e w n e w " e x e c u t a b l e t h a t b o t h

    u s e s a n d g e n e r a t e s t h e n e w p a r a m e t e r - p a s s i n g s t y l e .

    T h e r e ' s n o t m u c h e l s e t o b e s a i d a b o u t b o o t s t r a p p i n g

    C c o m p i l e r s ( t h o u g h s e e s e c t i o n 6 ) . B u t i n a l a n g u a g e

    w i t h a n i n t e r a c t i v e r e a d - e v a l - p r i n t l o o p , c o m m a n d s a r e

    t y p e d b y t h e u s e r , c o m p i l e d i m m e d i a t e l y , a n d e x e c u t e d .

    S u c h a c o m m a n d , w h e n c o m p i l e d , m a y b e a r e c u r s i v e

    c a l l t o t h e c o m p i l e r i t s e l f , t h i s t i m e t o c o m p i l e a s p e c i -

    e d s o u r c e l e i n t o a b i n a r y l e . T h e c o m p i l e r p r o c e s s -

    i n g i n t e r a c t i v e c o m m a n d s i s t h e s a m e o n e t h a t c o m p i l e s

    a s o u r c e l e ; t h i s m a k e s i t d i c u l t t o c r o s s - c o m p i l e f o r

    a d i e r e n t t a r g e t a r c h i t e c t u r e ! I n f a c t , i n a s u c i e n t l y

    f e a t u r e - l a d e n i n t e r a c t i v e c o m p i l a t i o n s y s t e m , t h e r e a r e

    m a n y c o n s t r a i n t s o n t h e r e t a r g e t i n g a n d b o o t s t r a p p r o -

    c e s s . T h i s p a p e r i s a c a s e s t u d y o f t h e S t a n d a r d M L o f

    N e w J e r s e y ( S M L / N J ) s y s t e m , e x p l a i n i n g t h e d i c u l t i e s

    a n d h o w t o m a n a g e t h e m .

    B i n l e s . S o u r c e l e s a r e t r a n s a t e d b y S M L / N J i n t o

    \ b i n " l e s ;

    1

    e a c h b i n l e c o n t a i n s t h e e x e c u t a b l e

    m a c h i n e c o d e f o r t h e c o r r e s p o n d i n g s o u r c e , a n d t h e

    e x p o r t e d s t a t i c e n v i r o n m e n t f o r t h a t s o u r c e 1 ] . F o r

    e x a m p l e , i f a s o u r c e l e d e n e s t w o s t r u c t u r e s S a n d

    T , e a c h w i t h s e v e r a l c o m p o n e n t s , t h e n t h e s t a t i c

    p a r t o f t h e b i n l e i s a d e s c r i p t i o n o f t h e s t r u c t u r e s

    S a n d T : t h e n a m e s a n d t y p e s o f t h e i r c o m p o n e n t s

    a n d s u b s t r u c t u r e s .

    T h e s t a t i c p a r t o f t h e b i n l e s i s a n M L d a t a s t r u c -

    t u r e , c o m p l e t e w i t h p o i n t e r s , d a t a t y p e c o n s t r u c t o r s

    e t c . , c r e a t e d b y t h e c o m p i l e r a n d w r i t t e n i n b i n a r y

    f o r m t o t h e b i n l e . O r d i n a r i l y , w h e n a p r o g r a m

    i s c o m p i l e d t o b i n l e s b y t h e i n t e r a c t i v e s y s t e m ,

    t h e b i n l e s ( i n c l u d i n g s t a t i c p a r t ) w i l l b e r e a d

    b a c k i n t o t h e s a m e v e r s i o n o f t h e s y s t e m . B u t i n

    b o o t s t r a p p i n g , t h e c o m p i l e d p r o g r a m i s t h e \ n e w "

    c o m p i l e r , a n d w e w a n t t o d i s c a r d t h e \ o l d " c o m -

    p i l e r . T h u s , t h e n e w c o m p i l e r e x e c u t e s , a n d l o a d s

    i n s t a t i c i n f o r m a t i o n ( f r o m t h e b i n l e s ) a b o u t i t -

    s e l f . F o r t h i s t o w o r k , t h e r e p r e s e n t a t i o n o f s t a t i c

    e n v i r o n m e n t s i n t h e o l d a n d n e w c o m p i l e r s m u s t

    a g r e e . T h i s r e p r e s e n t a t i o n h a s t w o p a r t s : t h e M L

    d a t a t y p e s E ( a n d t h e i r i n t e r p r e t a t i o n ) c h o s e n b y

    t h e p r o g r a m m e r ; a n d t h e r e p r e s e n t a t i o n D o f t h e s e

    d a t a t y p e s a s p o i n t e r s a n d r e c o r d s i n m e m o r y . C o n -

    s t r a i n t s o n E m i g h t o c c u r i n a n y c o m p i l e r t h a t

    s t o r e s d i g e s t e d s t a t i c i n f o r m a t i o n ; c o n s t r a i n t s o n D

    a r e a c o n s e q u e n c e o f t h e f a c t t h a t S M L / N J u s e s a

    p i c k l e r t o w r i t e r e l o c a t a b l e p o i n t e r d a t a s t r u c t u r e s

    t o t h e b i n a r y l e j u s t a s t h e y a p p e a r i n m e m o r y .

    I n - l i n e p r i m o p s . W h e n t h e S M L / N J c o m p i l e r r s t e x -

    e c u t e s , i t i n i t i a l i z e s i t s s t a t i c e n v i r o n m e n t b y c o n -

    s t r u c t i n g a s p e c i a l p r i m i t i v e b a s i s c o n t a i n i n g t h e

    i n - l i n e p r i m i t i v e o p e r a t i o n s ( s u c h a s + , : = , e t c . ) .

    T h i s s t a t i c e n v i r o n m e n t i s b u i l t u s i n g t h e s a m e M L

    d a t a t y p e s a s o r d i n a r y s t a t i c e n v i r o n m e n t s , b u t i t

    i s d i r e c t l y c o n s t r u c t e d w i t h o u t p a r s i n g a n y i n p u t .

    T h e p r i m i t i v e e n v i r o n m e n t i s t h e n i m p o r t e d a n d

    u s e d b y t h e M L c o d e t h a t i m p l e m e n t s t h e i n i t i a l

    b a s i s .

    W h e n c o m p i l i n g a n e w v e r s i o n o f t h e c o m p i l e r , o n e

    c a n a u g m e n t o r c h a n g e t h e p r i m i t i v e e n v i r o n m e n t .

    B u t o n e c a n n o t m a k e u s e o f t h e c h a n g e d p r i m i t i v e s

    u n t i l t h e n e w c o m p i l e r c o m p i l e s a \ n e w n e w " c o m -

    p i l e r .

    1

    T h i s i s t r u e o f S M L / N J v e r s i o n s s i n c e 0 . 9 6 .

    1 4 8

  • 8/2/2019 10.1.1.32.2422

    2/9

    I n i t i a l B a s i s . M L p r o g r a m s c a n a s s u m e a n \ i n i t i a l b a -

    s i s " 5 , p a g e 7 7 ] , a n e n v i r o n m e n t i n w h i c h c e r t a i n

    t y p e s a n d v a l u e s a r e d e n e d . T h e c o m p i l e r i t s e l f

    a l s o r e l i e s u p o n t h e i n i t i a l b a s i s . F u r t h e r m o r e , t h e

    s o u r c e c o d e f o r t h e i n i t i a l b a s i s i s p a r t o f t h e s o u r c e

    c o d e f o r t h e c o m p i l e r . F i n a l l y , t h e s o u r c e c o d e

    f o r t h e i n i t i a l b a s i s u s e s , i n p l a c e s , e l e m e n t s o f t h e

    p r i m i t i v e b a s i s c o n t a i n i n g n a m e s o f s p e c i a l l y i m p l e -

    m e n t e d i n - l i n e f u n c t i o n s .

    T h i s m e a n s t h a t i f s o m e n e w v e r s i o n o f t h e i n i t i a l

    b a s i s i s d e s i r e d , t h e r e a r e p o t e n t i a l i n t e r a c t i o n s w i t h

    t h e r e s t o f t h e s y s t e m t h a t m u s t b e c o n s i d e r e d .

    I n t e r a c t i v e s y s t e m . T h e n o r m a l m o d e o f o p e r a t i n g

    S M L / N J i s t o c o m p i l e b o t h i n t e r a c t i v e i n p u t a n d

    M L p r o g r a m s f r o m s o u r c e l e s , a n d r u n t h e c o m -

    p i l e d p r o g r a m s i n t h e s a m e p r o c e s s a s t h e c o m p i l e r .

    I t i s p a r t i c u l a r l y c o n v e n i e n t t o h a v e a n \ i n t e r a c t i v e "

    c o m p i l e r d u r i n g t h e c o m p i l e r d e v e l o p m e n t p r o c e s s ,

    w h e r e i n d i v i d u a l c o m p i l e r m o d u l e s c a n b e r e p l a c e d

    \ o n - t h e - y . " T h e c o m p i l e d p r o g r a m s u s e t h e s a m e

    i n i t i a l b a s i s a s t h e c o m p i l e r . T h e c o m p i l e d p r o -

    g r a m s m u s t b e c a l l a b l e f r o m t h e c o m p i l e r , a n d m u s t

    b e a b l e t o c a l l t h e s a m e i n i t i a l f u n c t i o n s t h a t t h e

    c o m p i l e r c a l l s ; t h u s , c o m p i l e d p r o g r a m s m u s t u s e

    t h e s a m e c a l l i n g c o n v e n t i o n s ( e t c . ) a s t h e c o m p i l e r

    i t s e l f . T h i s m a k e s i t d i c u l t t o b o o t s t r a p a n e w

    v e r s i o n o f t h e c o m p i l e r t h a t u s e s d i e r e n t c a l l i n g

    c o n v e n t i o n s .

    T h e s e i n t e r a c t i o n s b e t w e e n t h e c o m p i l e r a n d t h e e x -

    e c u t i n g p r o g r a m m a k e f o r c o m p l i c a t i o n s w h e n ( a n e w

    v e r s i o n o f ) t h e c o m p i l e r i s t h e e x e c u t i n g p r o g r a m .

    E x a m p l e

    T h e t e r m i n o l o g y o f t h i s e x a m p l e w i l l b e e x p l a i n e d i n s e c -

    t i o n 3 , b u t t h e p o i n t h e r e i s t o i l l u s t r a t e w h a t c a n g o

    w r o n g i f o n e i s n o t c a r e f u l .

    S u p p o s e t h e r e i s a v e r s i o n \ 1 " o f t h e s y s t e m a s a s e t

    o f M L s o u r c e l e s

    1

    a n d b i n l e s

    1

    . T h e b i n l e s a r e

    c o m p i l e d o b j e c t l e s ( l i k e \ . o " l e s i n a C s y s t e m ) , a n d

    a r e t h e r e s u l t o f c o m p i l i n g t h e s o u r c e l e s u s i n g s o m e

    c o m p a t i b l e v e r s i o n o f t h e c o m p i l e r .

    W e w i s h t o u s e

    1

    t o c o m p i l e

    1

    , y i e l d i n g a n e w v e r -

    s i o n o f t h e e x e c u t a b l e c o m p i l e r .

    F i r s t , b o o t b u i l d s a n e x e c u t a b l e

    1

    . T h i s i s l i k e a

    l i n k - l o a d i n g s t e p i n a c o n v e n t i o n a l s y s t e m , b u t i t m u s t

    a l s o l o a d f r o m

    1

    t h e d i g e s t e d d e s c r i p t i o n o f t h e i n i t i a l

    s t a t i c e n v i r o n m e n t , s o t h a t c o m p i l a t i o n s i n

    1

    w i l l h a v e

    a c c e s s t o l i b r a r y m o d u l e s ( a n d t h e c o m p i l e r i t s e l f ) s h a r e d

    w i t h

    1

    . T h i s s h a r i n g i s e s s e n t i a l , i f o n l y s o t h a t

    1

    a n d

    t h e i n t e r a c t i v e c o m m a n d s r u n n i n g w i t h i n m u

    1

    d o n ' t h a v e

    s e p a r a t e c o p i e s o f r u n t i m e - s y s t e m m a n a g e m e n t d a t a t h a t

    w o u l d t r i p o v e r e a c h o t h e r .

    b o o t (

    1

    ) =

    1

    N o w

    1

    c o m p i l e s t h e s o u r c e

    1

    i n t o b i n a r y o b j e c t l e s

    0

    1

    :

    c o m p i l e (

    1

    ;

    1

    ) =

    0

    1

    N o w w e h o p e t h a t

    1

    =

    0

    1

    , w h a t e v e r t h a t m e a n s .

    H o w e v e r , s u p p o s e o n e e d i t s t h e s o u r c e l e s t o p r o d u c e

    2

    , a n e w v e r s i o n o f t h e c o m p i l e r t h a t u s e s a d i e r e n t

    c a l l i n g c o n v e n t i o n . O n e m i g h t t r y t h e f o l l o w i n g s t e p s :

    c o m p i l e (

    1

    ;

    2

    ) =

    2

    b o o t (

    2

    ) =

    T h e b o o t s t e p f a i l s b e c a u s e

    2

    i s n o t s e l f - c o n s i s t e n t .

    T h e c o d e g e n e r a t e d b y

    2

    f r o m a t o p - l e v e l i n t e r a c t i v e

    e x p r e s s i o n ( u s i n g t h e n e w c a l l i n g c o n v e n t i o n s ) a b l e t o c a l l

    f u n c t i o n s i n t h e B a s i s w i t h i n

    2

    ( c o m p i l e d u s i n g t h e o l d

    c o n v e n t i o n s ) , s o t h e r s t t o p - l e v e l c o m m a n d w i l l d u m p

    c o r e .

    O n t h e o t h e r h a n d , s o m e c h a n g e s a r e h a r m l e s s : i f

    t h e o n l y c h a n g e i s a d i e r e n t a l g o r i t h m f o r c o d e o p t i -

    m i z a t i o n , b o o t w i l l p r o b a b l y s u c c e e d . F i n a l l y , s o m e s e l f -

    i n c o n s i s t e n c i e s w i l l m a n i f e s t t h e m s e l v e s a t s t a g e s o t h e r

    t h a n b o o t

    H o w c a n o n e t e l l w h e t h e r a c h a n g e i s h a r m l e s s ? A n d ,

    s i n c e \ n o n - h a r m l e s s " c h a n g e s a r e o f t e n n e c e s s a r y , h o w

    c a n o n e c o r r e c t l y c o m p i l e a n d b o o t s t r a p t h e m ? T h e r e s t

    o f t h e p a p e r a d d r e s s e s t h e s e q u e s t i o n s .

    2 C h a r a c t e r i z a t i o n

    I w i l l u s e t h e f o l l o w i n g s y m b o l s t o d e s c r i b e c h a r a c t e r i s t i c s

    o f a \ v e r s i o n " o f t h e c o m p i l e r :

    A A r c h i t e c t u r e f o r w h i c h t h e c o m p i l e r g e n e r a t e s c o d e , o r

    o n w h i c h i t r u n s .

    C C a l l i n g c o n v e n t i o n s f o r w h i c h t h e c o m p i l e r g e n e r a t e s

    c o d e : w h i c h r e g i s t e r s a r e u s e d f o r w h a t p u r p o s e ;

    h o w e n d - o f - h e a p i s d e t e c t e d ; w h e t h e r a s t a c k i s

    u s e d ; e t c .

    D D a t a t y p e l a y o u t : h o w M L d a t a t y p e s a r e l a i d o u t i n

    m e m o r y .

    E E n v i r o n m e n t r e p r e s e n t a t i o n : h o w s t a t i c e n v i r o n m e n t s

    a r e d e s c r i b e d i n t e r m s o f M L d a t a t y p e s .

    B B a s i s : t h e s i g n a t u r e o f t h e i n i t i a l e n v i r o n m e n t a v a i l -

    a b l e t o o r d i n a r y p r o g r a m s ( a n d t h e c o m p i l e r ) u p o n

    s t a r t u p .

    P P r i m i t i v e B a s i s : t h e s t a t i c e n v i r o n m e n t c r e a t e d b y

    t h e c o m p i l e r , d e s c r i b i n g i n - l i n e p r i m i t i v e o p e r a t i o n s

    a n d d a t a t y p e s . N o r m a l l y t h e p r i m i t i v e b a s i s i s

    u s e d o n l y i n c o m p i l i n g t h e s o u r c e c o d e f o r t h e i n i -

    t i a l b a s i s .

    2 . 1 S o u r c e c h a r a c t e r i s t i c s

    T h e s e c h a r a c t e r i s t i c s a r e n o w u s e d t o d e s c r i b e t h e s o u r c e

    c o d e f o r s o m e v e r s i o n o f t h e c o m p i l e r . T h e e q u a t i o n s i n

    t h i s s e c t i o n j u s t e x p l a i n , i n i n f o r m a l t e r m s , t h e m e a n i n g

    o f n o t a t i o n t h a t w i l l b e u s e d i n t h e a x i o m s o f s e c t i o n 3 .

    a 2 A

    g e n

    ( ) T h e c o m p i l e r m a y c o n t a i n c o d e g e n e r a t o r s

    f o r s e v e r a l d i e r e n t t a r g e t a r c h i t e c t u r e s ; a r c h i t e c -

    t u r e a i s a m e m b e r o f t h i s s e t .

    C

    g e n

    ( ) = c T h e c o m p i l e r g e n e r a t e s c o d e t h a t u s e s t h e

    c c a l l i n g c o n v e n t i o n s .

    1 4 9

  • 8/2/2019 10.1.1.32.2422

    3/9

    D

    g e n

    ( ) = d T h e c o m p i l e r g e n e r a t e s c o d e t h a t u s e s t h e

    d d a t a t y p e l a y o u t s c h e m e .

    E

    g e n

    ( ) = e T h e c o m p i l e r u s e s ( a n d w r i t e s t o b i n l e s )

    t h e e s t a t i c e n v i r o n m e n t r e p r e s e n t a t i o n .

    B

    u s e

    ( ) = b T h e n o n - b a s i s p a r t o f t h e s y s t e m ( t h a t i s ,

    t h e c o m p i l e r p r o p e r ) i s a p r o g r a m t h a t m a k e s u s e

    o f f u n c t i o n s i n B a s i s b

    B

    i m p

    ( ) = b T h e b a s i s p a r t o f t h e s y s t e m i m p l e m e n t s

    t h e b a s i s b

    P

    u s e

    ( ) = p T h e b a s i s p a r t o f t h e s y s t e m i s a p r o g r a m

    t h a t m a k e s u s e o f t h e f u n c t i o n s i n P r i m i t i v e b a s i s

    p

    P

    g e n

    ( ) = p T h e c o m p i l e r d e n e s a p r i m i t i v e e n v i r o n -

    m e n t p f o r i t s c o m p i l e d c o d e .

    2 . 2 B i n a r y l e c h a r a c t e r i s t i c s

    O n e c a n d e s c r i b e t h e s e a s p e c t s o f c o m p i l e d b i n a r y l e s

    i n m u c h t h e s a m e w a y :

    A

    r u n

    ( ) = a T h e p r o g r a m r u n s o n a r c h i t e c t u r e a

    a 2 A

    g e n

    ( ) T h e c o m p i l e r g e n e r a t e s c o d e f o r t h e a a r -

    c h i t e c t u r e .

    C

    r u n

    ( ) = c T h e p r o g r a m f o l l o w s t h e c c a l l i n g c o n v e n -

    t i o n s .

    C

    g e n

    ( ) = c T h e c o m p i l e r g e n e r a t e s c o d e t h a t u s e s t h e

    c c a l l i n g c o n v e n t i o n s .

    D

    r u n

    ( ) = d T h e i n t e r n a l d a t a s t r u c t u r e s o f p r o g r a m

    o b e y t h e d d a t a t y p e l a y o u t s c h e m e .

    D

    e n v

    ( ) = d T h e s t a t i c e n v i r o n m e n t s i n b i n l e s u s e

    t h e d d a t a t y p e l a y o u t s c h e m e .

    D

    g e n

    ( ) = d T h e c o m p i l e r g e n e r a t e s c o d e t h a t u s e s t h e

    d d a t a t y p e l a y o u t s c h e m e .

    E

    e n v

    ( ) = e T h e s t a t i c e n v i r o n m e n t ' s b i n l e s a r e i n

    t h e e e n v i r o n m e n t r e p r e s e n t a t i o n .

    E

    g e n

    ( ) = e T h e c o m p i l e r u s e s a n d g e n e r a t e s t h e e e n -

    v i r o n m e n t r e p r e s e n t a t i o n .

    B

    u s e

    ( ) = b T h e n o n - b a s i s p a r t o f ( t h a t i s , t h e c o m -

    p i l e r p r o p e r ) i s a p r o g r a m t h a t m a k e s u s e o f f u n c -

    t i o n s i n b a s i s b

    B

    i m p

    ( ) = b T h e b a s i s p a r t o f i m p l e m e n t s t h e b a s i s b

    P

    g e n

    ( ) = p T h e c o m p i l e r

    1

    d e n e s a p r i m i t i v e e n v i r o n -

    m e n t p

    1

    f o r i t s c o m p i l e d c o d e .

    2 . 3 E x e c u t a b l e l e c h a r a c t e r i s t i c s

    T h e b i n l e s a r e l i n k e d w i t h a r u n t i m e s y s t e m ( a n d s t a t i c

    e n v i r o n m e n t s a r e r e a d f r o m t h e b i n l e s t o i n i t i a l i z e t h e

    c o m p i l e r ' s u s e r - v i s i b l e \ i n i t i a l b a s i s " ) t o f o r m a n e x e -

    c u t a b l e l e , w h o s e c h a r a c t e r i s t i c s a r e j u s t l i k e t h o s e

    f o r b i n l e s , e x c e p t t h a t :

    E x e c u t a b l e l e s d o n o t h a v e s e p a r a t e s t a t i c e n v i -

    r o n m e n t s e c t i o n s a s b i n l e s d o , s o E

    e n v

    a n d D

    e n v

    d o n o t a p p l y .

    E x e c u t a b l e s y s t e m s g e n e r a t e c o d e f o r o n l y o n e m a -

    c h i n e , s o A

    g e n

    ( ) i s a s i n g l e a r c h i t e c t u r e r a t h e r t h a n

    a s e t o f a r c h i t e c t u r e s .

    3 A x i o m s

    I w i l l g i v e a x i o m s d e s c r i b i n g t h e p r o c e d u r e s o f c o m p i l i n g ,

    b o o t s t r a p p i n g , r e t a r g e t i n g , a n d e l a b o r a t i o n ; t h e s e a x i o m s

    w i l l t h e n b e u s e d t o p r o v e t h e o r e m s i n s e c t i o n 4 .

    3 . 1 C o m p i l i n g

    T o c o m p i l e s o u r c e c o d e , o n e e x e c u t e s t h e i n t e r a c t i v e s y s -

    t e m , a n d g i v e s c o m m a n d s t o c o m p i l e s o u r c e l e s i n t o

    b i n a r y l e s :

    c o m p i l e ( ; ) =

    f o r w h i c h t h e f o l l o w i n g e q u a t i o n s m u s t h o l d :

    B

    u s e

    ( ) v B

    i m p

    ( )

    P

    u s e

    ( ) v P

    g e n

    ( )

    T h e r e l a t i o n v e x p r e s s e s t h e M L s i g n a t u r e m a t c h -

    i n g r e l a t i o n . T h a t i s , P

    u s e

    ( ) v P

    g e n

    ( ) m e a n s t h a t t h e

    s o u r c e l e s c a n b e c o m p i l e d i n a p r i m i t i v e e n v i r o n m e n t

    c r e a t e d b y : e v e r y i d e n t i e r l o o k e d u p w i l l b e p r e s e n t

    a n d h a v e a n a p p r o p r i a t e t y p e . T h e \ b a s i s " ( B ) p a r t o f

    d e n e s m o d u l e s t h a t a r e t h e n u s e d b y t h e \ c o m p i l e r "

    p a r t o f , s o t h e r s t e q u a t i o n i s s t r a i g h t f o r w a r d . B u t

    t h e \ p r i m i t i v e s " ( P ) c o n t a i n i n g s p e c i a l i n - l i n e f u n c t i o n

    d e n i t i o n s m u s t b e s p e c i a l l y c o n s t r u c t e d b y

    T h e b i n a r y l e s ( i . e . t h e l e s i n t h e b i n d i r e c t o r y )

    a r e t h e n c h a r a c t e r i z e d b y t h e f o l l o w i n g e q u a t i o n s .

    A

    r u n

    ( ) = A

    g e n

    ( )

    A

    g e n

    ( ) = A

    g e n

    ( )

    C

    r u n

    ( ) = C

    g e n

    ( )

    C

    g e n

    ( ) = C

    g e n

    ( )

    D

    r u n

    ( ) = D

    g e n

    ( )

    D

    g e n

    ( ) = D

    g e n

    ( ) T h e s e r s t s i x e q u a t i o n s a r e u n r e -

    m a r k a b l e , a n d w o u l d o c c u r i n p r a c t i c a l l y a n y c o m -

    p i l e r .

    D

    e n v

    ( ) = D

    r u n

    ( ) T h i s e q u a t i o n r e s u l t s f r o m t h e u s e o f

    a \ p i c k l e r " f o r w r i t i n g t h e s t a t i c t y p e i n f o r m a t i o n

    ( p o i n t e r d a t a s t r u c t u r e s ) t o a l e i n t h e s a m e b i n a r y

    f o r m a t t h a t i s u s e d i n c o r e .

    E

    e n v

    ( ) = E

    g e n

    ( )

    E

    g e n

    ( ) = E

    g e n

    ( ) T h e s e t w o e q u a t i o n s o n E w o u l d h o l d

    i n a n y c o m p i l e r t h a t w r i t e s d i g e s t e d s t a t i c t y p e i n -

    f o r m a t i o n , w i t h o r w i t h o u t t h e u s e o f a p i c k l e r .

    1 5 0

  • 8/2/2019 10.1.1.32.2422

    4/9

    B

    i m p

    ( ) = I ( B

    i m p

    ( ) ) w h e r e I i s a h a s h f u n c t i o n t h a t

    c o m p u t e s \ p e r s i s t e n t i d e n t i e r s " f r o m t h e s t a t i c e n -

    v i r o n m e n t e x p o r t e d b y a s o u r c e p r o g r a m . T h e p e r -

    s i s t e n t i d e n t i e r s a r e t h e n u s e d f o r l i n k i n g t h e m a -

    c h i n e c o d e o f d i e r e n t m o d u l e s t o g e t h e r , i n a g u a r -

    a n t e e d t y p e - s a f e w a y .

    B

    u s e

    ( ) = B

    i m p

    ( ) T h e t w o e q u a t i o n s o n B a r e a c o n -

    s e q u e n c e o f s h a r i n g l i b r a r y c o d e a n d d a t a b e t w e e n

    t h e i n t e r a c t i v e s y s t e m a n d t h e c o m p i l e d u s e r c o d e .

    P

    g e n

    ( ) = P

    g e n

    ( ) T r u e i n a n y c o m p i l e r t h a t d e n e s f u n c -

    t i o n s t h a t l o o k o r d i n a r y t o t h e u s e r b u t a r e c o m -

    p i l e d s p e c i a l l y ( e . g . , i n - l i n e ) .

    3 . 2 B o o t s t r a p p i n g

    T h e b o o t s t r a p p e r i s a p a r t o f t h e C - l a n g u a g e r u n t i m e s y s -

    t e m . I t k n o w s j u s t e n o u g h t o e x t r a c t t h e d y n a m i c p a r t

    ( m a c h i n e c o d e ) f r o m b i n l e s ; b u t n o t t h e f o r m a t o f

    s t a t i c e n v i r o n m e n t r e p r e s e n t a t i o n s , w h i c h o n l y t h e c o m -

    p i l e r u n d e r s t a n d s . H o w e v e r , t h e m a c h i n e c o d e w i t h i n

    i s t h e c o m p i l e r ; o n c e i t s t a r t s r u n n i n g , i t c a n l o a d t h e

    s t a t i c p a r t o f t o f o r m a n e n v i r o n m e n t ( s y m b o l t a b l e o f

    t h e i n i t i a l b a s i s ) f o r c o m p i l i n g u s e r p r o g r a m s . T h e r e s u l t

    i s a n i n t e r a c t i v e c o m p i l e r :

    b o o t ( ) =

    F o r t h i s t o w o r k , t h e f o l l o w i n g e q u a t i o n s m u s t h o l d :

    A

    r u n

    ( ) 2 A

    g e n

    ( ) s o t h a t t h e c o m p i l e r a n d t o p - l e v e l i n -

    t e r a c t i v e c o m m a n d s c a n b o t h r u n o n t h e s a m e c o m -

    p u t e r .

    C

    r u n

    ( ) = C

    g e n

    ( ) s o t h a t t o p - l e v e l i n t e r a c t i v e c o m m a n d s

    c a n c a l l a n d b e c a l l e d b y t h e c o m p i l e r a n d i n i t i a l

    b a s i s .

    D

    r u n

    ( ) = D

    g e n

    ( ) f o r t h e s a m e r e a s o n .

    D

    e n v

    ( ) = D

    r u n

    ( ) s o t h e b o o t s t r a p p i n g c o m p i l e r c a n r e a d

    s t a t i c e n v i r o n m e n t s f r o m b i n l e s .

    E

    e n v

    ( ) = E

    g e n

    ( ) f o r t h e s a m e r e a s o n .

    T h e r e m a i n i n g e q u a t i o n s c h a r a c t e r i z e t h e o u t p u t :

    A

    r u n

    ( ) = A

    r u n

    ( ) = A

    g e n

    ( )

    C

    r u n

    ( ) = C

    r u n

    ( )

    C

    g e n

    ( ) = C

    g e n

    ( )

    D

    r u n

    ( ) = D

    r u n

    ( )

    D

    g e n

    ( ) = D

    g e n

    ( )

    E

    g e n

    ( ) = E

    g e n

    ( )

    B

    u s e

    ( ) = B

    u s e

    ( )

    B

    i m p

    ( ) = B

    i m p

    ( )

    P

    g e n

    ( ) = P

    g e n

    ( )

    N o w , f o r e x a m p l e , o n e c a n s e e t h a t t h e b o o t f a i l u r e

    d e s c r i b e d i n s e c t i o n 1 i s b e c a u s e C

    r u n

    (

    2

    ) 6= C

    g e n

    (

    2

    )

    v i o l a t i n g o n e o f t h e p r e c o n d i t i o n s f o r b o o t

    3 . 3 R e t a r g e t i n g

    B e c a u s e i t i s i m p o s s i b l e t o b o o t s t r a p u s i n g c o m p i l e a n d

    b o o t i f t h e n e w c o m p i l e r u s e s a n e w c a l l i n g s e q u e n c e o r

    e n v i r o n m e n t r e p r e s e n t a t i o n , t w o s p e c i a l p r o c e d u r e s a r e

    p r o v i d e d . T h e r s t o f t h e s e i s c a l l e d r e t a r g e t : R u n

    a n i n t e r a c t i v e c o m p i l e r

    1

    , a n d l o a d t h e b i n l e s f o r

    a d i e r e n t v e r s i o n o f t h e c o m p i l e r a s a \ u s e r p r o g r a m . "

    S i n c e m a y i n c l u d e c o d e g e n e r a t o r s f o r m a n y m a c h i n e s ,

    o n e c a n a l s o s p e c i f y w h i c h t a r g e t a r c h i t e c t u r e a ' s c o d e

    g e n e r a t o r s h o u l d b e s e l e c t e d f r o m

    r e t a r g e t (

    1

    ; ; a ) =

    2

    T h e c o m p i l e r o r i g i n a l l y p r e s e n t i n

    1

    w i l l b e u s e d i n

    2

    f o r c o m p i l i n g t o p - l e v e l i n t e r a c t i v e c o m m a n d s , b u t t h e

    c o m p i l e r w i l l b e u s e d i n

    2

    f o r t u r n i n g s o u r c e l e s i n t o

    b i n l e s .

    O r d i n a r y u s e r p r o g r a m s d o n o t p r o v i d e t h e i r o w n i m -

    p l e m e n t a t i o n o f t h e i n i t i a l b a s i s , s o t h e b a s i s p o r t i o n o f

    ( c o r r e s p o n d i n g t o t h e t h a t i m p l e m e n t B

    i m p

    ( ) ) w i l l n o t

    b e l o a d e d : B

    i m p

    ( ) i s i r r e l e v a n t . H o w e v e r , t h e n o n - b a s i s

    p o r t i o n o f t h e c o m p i l e r m u s t b e c o m p a t i b l e w i t h t h e

    b a s i s a l r e a d y r u n n i n g i n

    1

    , s o t h a t c a n c a l l u p o n s t a n -

    d a r d I / O f u n c t i o n s ( e t c . ) b u i l t i n t o

    1

    A s a n o r d i n a r y u s e r p r o g r a m , t h e b i n l e s e x e c u t i n g

    u n d e r t h e s u p e r v i s i o n o f

    1

    c a n g e n e r a t e c o d e f o r a n y

    a r c h i t e c t u r e o r a n y c a l l i n g s e q u e n c e . T h i s i s b e c a u s e t h e

    c o d e i s n o t g o i n g t o b e e x e c u t e d i n t h e c u r r e n t p r o c e s s ,

    s o i t d o e s n ' t n e e d t o b e c o m p a t i b l e w i t h t h e i n s t r u c t i o n

    s e t o r c a l l i n g c o n v e n t i o n s t h a t

    1

    i t s e l f i s u s i n g . T h i s

    f r e e d o m i s c r u c i a l f o r c r o s s - c o m p i l a t i o n ( c o m p i l a t i o n f o r

    a d i e r e n t t a r g e t a r c h i t e c t u r e o r c a l l i n g c o n v e n t i o n ) .

    T h e f o l l o w i n g r e s t r i c t i o n s a p p l y :

    a 2 A

    g e n

    ( )

    A

    r u n

    ( ) = A

    r u n

    (

    1

    )

    C

    r u n

    ( ) = C

    r u n

    (

    1

    )

    D

    r u n

    ( ) = D

    e n v

    ( ) = D

    r u n

    (

    1

    )

    E

    e n v

    ( ) = E

    g e n

    (

    1

    )

    B

    u s e

    ( ) = B

    i m p

    (

    1

    ) T h i s r e l a t i o n s h i p i s a n e x a c t s i g n a -

    t u r e m a t c h . I n p a r t i c u l a r , i t m e a n s t h a t t h e i n t r i n -

    s i c p e r s i s t e n t i d e n t i e r s g e n e r a t e d f r o m t h e c o m -

    p i l a t i o n o f t h e i n i t i a l b a s i s ( l e s i n t h e s r c / b o o t

    d i r e c t o r y ) i n b u i l d i n g t h e b i n l e s w i t h i n

    1

    m u s t

    b e i d e n t i c a l t o t h e c o r r e s p o n d i n g i d e n t i e r s i n t h e

    i n i t i a l b a s i s p o r t i o n o f

    2

    2

    T h i s c a n b e g u a r a n t e e d b y p r o d u c i n g a n d

    1

    f r o m t h e s a m e

    c o m p i l e r

    0

    , i n t h e f o l l o w i n g w a y :

    c o m p i l e (

    0

    ;

    1

    ) =

    1

    b o o t (

    1

    ) =

    1

    c o m p i l e (

    0

    ;

    2

    ) =

    w h e r e t h e s o u r c e c o d e s f o r t h e B

    i m p

    p o r t i o n s o f

    1

    a n d

    2

    a r e

    i d e n t i c a l

    T h i s w o r k s b e c a u s e I i s r e a l l y a f u n c t i o n : ( x = y ) ) ( I ( x ) =

    I ( y ) )

    I n v e r s i o n s 0 . 9 6 { 0 . 9 8 o f t h e S M L / N J s y s t e m , t h e \ p e r s i s t e n t

    i d e n t i e r s " w e r e j u s t t i m e s t a m p s , s o t h a t I w o u l d r e t u r n d i e r e n t

    r e s u l t s a t d i e r e n t t i m e s . T h e r e f o r e , w i t h t h e p r o c e d u r e o u t l i n e d

    a t t h e t o p o f t h i s f o o t n o t e , B ( ) a n d B (

    1

    ) w o u l d n o t e x p o r t

    t h e s a m e \ p e r s i s t e n t i d e n t i e r s " e v e n t h o u g h t h e s o u r c e c o d e w a s

    1 5 1

  • 8/2/2019 10.1.1.32.2422

    5/9

    T h e f o l l o w i n g e q u a t i o n s c h a r a c t e r i z e t h e o u t p u t

    2

    :

    A

    r u n

    (

    2

    ) = A

    r u n

    (

    1

    )

    A

    g e n

    (

    2

    ) = a

    C

    r u n

    (

    2

    ) = C

    r u n

    (

    1

    )

    C

    g e n

    (

    2

    ) = C

    g e n

    ( )

    D

    r u n

    (

    2

    ) = D

    r u n

    (

    1

    )

    E

    g e n

    (

    2

    ) = E

    g e n

    ( )

    B

    u s e

    (

    2

    ) = B

    u s e

    (

    1

    )

    B

    i m p

    (

    2

    ) = B

    i m p

    (

    1

    )

    P

    g e n

    (

    2

    ) = P

    g e n

    ( )

    A f u n n y h y b r i d i n d e e d .

    3 . 4 E l a b o r a t i o n

    F i n a l l y , e l a b i s a s p e c i a l v a r i a t i o n o n b o o t t h a t r e - p a r s e s

    t h e s o u r c e l e s t o b u i l d t h e s t a t i c e n v i r o n m e n t , i n s t e a d

    o f r e a d i n g i t f r o m t h e b i n l e s : e l a b ( ; ) =

    N o w , g i v e n t h e t w o s t e p s

    c o m p i l e (

    0

    ; ) =

    e l a b ( ; ) =

    m u s t s a t i s f y a l l t h e e q u a t i o n s g i v e n f o r b o o t a b o v e

    e x c e p t f o r t h e o n e s i n v o l v i n g D

    e n v

    ( ) a n d E

    e n v

    ( ) , b e -

    c a u s e t h e e n v i r o n m e n t s w i l l n o t b e r e a d f r o m t h e b i n

    l e s . A n o t h e r r e q u i r e m e n t f o r e l a b i s t h a t a n d m u s t

    b e r e l a t e d b y t h e c o m p i l e c o m m a n d s h o w n .

    T h e r e s u l t i n g e x e c u t a b l e i s d e n e d b y t h e s a m e

    e q u a t i o n s a s f o r b o o t ( ) . I n f a c t , w i t h e l a b t h e r e i s n o

    n e e d f o r b o o t , e x c e p t t h a t e l a b i s m u c h s l o w e r b e c a u s e

    i t r e - p a r s e s a l l t h e s o u r c e .

    4 S t a b l e v e r s i o n s

    D e n i t i o n : ( ; ) f o r m a s t a b l e v e r s i o n i f t h e f o l l o w i n g

    e q u a t i o n s h o l d :

    A

    r u n

    ( ) 2 A

    g e n

    ( ) = A

    g e n

    ( )

    C

    g e n

    ( ) = C

    r u n

    ( ) = C

    g e n

    ( )

    D

    g e n

    ( ) = D

    r u n

    ( ) = D

    g e n

    ( ) = D

    e n v

    ( )

    E

    g e n

    ( ) = E

    e n v

    ( ) = E

    g e n

    ( )

    B

    u s e

    ( ) v B

    i m p

    ( )

    B

    i m p

    ( ) = I ( B

    i m p

    ( ) )

    B

    u s e

    ( ) = B

    i m p

    ( )

    P

    u s e

    ( ) v P

    g e n

    ( ) = P

    g e n

    ( )

    R e m a r k : I f c o m p i l e ( b o o t ( ;

    0

    ) ; ) =

    0

    t h e n ( ; )

    i s a x e d p o i n t , a s t r o n g e r p r o p e r t y . B u t w e c a n n o t p r o v e

    x e d - p o i n t p r o p e r t i e s f r o m t h e a x i o m s i n t h i s p a p e r .

    S u p p o s e o n e s t a r t s w i t h a s t a b l e v e r s i o n (

    1

    ;

    1

    ) a n d

    c r e a t e s a n e w s o u r c e

    2

    . H o w c a n o n e o b t a i n b i n l e s

    2

    t o m a k e a s t a b l e v e r s i o n w i t h t h e n e w s o u r c e ?

    A l l o f t h e \ t h e o r e m s " i n t h i s s e c t i o n a r e p r o v e d u s i n g

    o n l y t h e a x i o m s o f s e c t i o n 3 a n d t h e d e n i t i o n o f a s t a b l e

    v e r s i o n .

    i d e n t i c a l . I n s t e a d , o n e w o u l d h a v e t o c r e a t e a n e w , e m p t y b i n

    d i r e c t o r y ; c o p y j u s t t h e b i n l e s f o r t h e i n i t i a l b a s i s f r o m

    1

    t o

    t h e n e w b i n d i r e c t o r y ; a n d t h e n p r o c e e d w i t h a c o m p i l e t h a t

    w o u l d u s e t h e s e l e s a s a s t a r t i n g p o i n t .

    4 . 1 N e w P r i m i t i v e B a s i s

    S u p p o s e P

    g e n

    (

    2

    ) 6= P

    g e n

    (

    1

    ) , P

    u s e

    (

    2

    ) v P

    g e n

    (

    2

    ) , b u t

    a l l o t h e r c h a r a c t e r i s t i c s ( A

    g e n

    , C

    g e n

    , D

    g e n

    , E

    g e n

    , B

    u s e

    ,

    B

    g e n

    , P

    u s e

    ) a r e i d e n t i c a l f r o m o n e s o u r c e t o a n o t h e r .

    T h e n

    b o o t (

    1

    ) =

    1

    c o m p i l e (

    1

    ;

    2

    ) =

    2

    T h e r e a d e r c a n v e r i f y t h a t b o t h o f t h e s e s t e p s s u c c e e d ,

    a n d t h a t (

    2

    ;

    2

    ) i s s t a b l e .

    4 . 2 N e w I n i t i a l B a s i s

    N o w s u p p o s e

    2

    d i e r s f r o m

    1

    i n t h e i n i t i a l b a s i s ( t h e

    l e s i n t h e b o o t d i r e c t o r y ) , a n d p e r h a p s a l s o i n P

    u s e

    , t h e

    s e t o f p r i m i t i v e s u s e d i n t h e i n i t i a l b a s i s .

    b o o t (

    1

    ) =

    1

    c o m p i l e (

    1

    ;

    2

    ) =

    2

    T h e r e a d e r c a n v e r i f y t h a t t h e s e s t e p s s u c c e e d a n d r e s u l t

    i n (

    1

    ;

    2

    ) s t a b l e .

    4 . 3 N e w e n v i r o n m e n t s

    S u p p o s e

    2

    u s e s a d i e r e n t e n v i r o n m e n t r e p r e s e n t a t i o n

    ( E

    g e n

    ) f r o m

    1

    T h e \ o r d i n a r y " p r o c e d u r e w i l l n o t w o r k :

    b o o t (

    1

    ) =

    1

    c o m p i l e (

    1

    ;

    2

    ) =

    2

    b o o t (

    2

    ) =

    N o w E

    g e n

    (

    2

    ) 6= E

    e n v

    (

    2

    ) , s o

    2

    c a n n o t b e u s e d i n b o o t

    T h e r e a r e t w o w a y s t o b u i l d a s t a b l e v e r s i o n :

    e l a b (

    2

    ;

    2

    ) =

    2

    c o m p i l e (

    2

    ;

    2

    ) =

    0

    2

    o r

    r e t a r g e t (

    1

    ;

    2

    ; A

    r u n

    (

    1

    ) ) =

    0

    2

    c o m p i l e (

    0

    2

    ;

    2

    ) =

    0 0

    2

    N o w , (

    2

    ;

    0

    2

    ) i s s t a b l e , a n d s o i s (

    2

    ;

    0 0

    2

    ) ;

    0

    2

    a n d

    0 0

    2

    a r e e q u i v a l e n t i n a l l p r o p e r t i e s .

    4 . 4 N e w d a t a t y p e l a y o u t

    I f t h e n e w c o m p i l e r u s e s a d i e r e n t d a t a t y p e l a y o u t ( t h a t

    i s , D

    g e n

    (

    2

    ) 6= D

    g e n

    (

    1

    ) ) t h e n t h e f o l l o w i n g s t e p s w i l l

    b u i l d a s t a b l e v e r s i o n :

    b o o t (

    1

    ) =

    1

    c o m p i l e (

    1

    ;

    2

    ) =

    2

    e l a b (

    2

    ;

    2

    ) =

    2

    1 5 2

  • 8/2/2019 10.1.1.32.2422

    6/9

    R e t a r g e t w i l l n o t d o t h e j o b ; f o r s u p p o s e

    b o o t (

    1

    ) =

    1

    c o m p i l e (

    1

    ;

    2

    ) =

    2

    r e t a r g e t (

    1

    ;

    2

    ; a ) =

    0

    2

    c o m p i l e (

    0

    2

    ;

    2

    ) =

    0

    2

    t h e n D

    e n v

    (

    0

    2

    ) = D

    g e n

    (

    1

    ) , w h i l e D

    r u n

    (

    0

    2

    ) = D

    g e n

    (

    2

    )

    T h u s

    0

    2

    c a n n o t b e u s e d a s i n p u t t o e i t h e r b o o t o r r e t a r g e t

    4 . 5 N e w c a l l i n g c o n v e n t i o n s

    S u p p o s e

    2

    u s e s n e w c a l l i n g c o n v e n t i o n s : C

    g e n

    (

    2

    ) 6=

    C

    g e n

    (

    1

    )

    T h e p r o c e d u r e i s :

    b o o t (

    1

    ) =

    1

    c o m p i l e (

    1

    ;

    2

    ) =

    2

    r e t a r g e t (

    1

    ;

    2

    ; A

    r u n

    (

    1

    ) ) =

    2

    c o m p i l e (

    0

    1

    ;

    2

    ) =

    0

    2

    N o w (

    2

    ;

    0

    2

    ) i s s t a b l e . T h e r e a d e r c a n v e r i f y t h a t

    r e t a r g e t i s n e c e s s a r y , a n d t h a t e l a b w o u l d n o t s u c e .

    4 . 6 N e w t a r g e t a r c h i t e c t u r e

    G i v e n ( ; ) s t a b l e , A

    r u n

    ( ) = a

    1

    , s u p p o s e o n e w i s h e s t o

    m a k e a c o m p i l e r t h a t r u n s o n a r c h i t e c t u r e a

    2

    , f o r a

    2

    2

    A

    g e n

    ( )

    b o o t ( ) =

    1

    r e t a r g e t (

    1

    ; ; a

    2

    ) =

    2

    c o m p i l e (

    2

    ; ) =

    2

    N o w ( ;

    2

    ) i s a s t a b l e c o m p i l e r r u n n i n g o n , a n d g e n -

    e r a t i n g c o d e f o r , a r c h i t e c t u r e a

    2

    4 . 7 G e t t i n g f r o m h e r e t o t h e r e

    S u p p o s e t h e r e i s a s t a b l e v e r s i o n (

    1

    ;

    1

    ) , a n d a c o m p i l e r

    1

    = b o o t (

    1

    ) . T h e p r o g r a m m e r m a k e s a n e w s o u r c e

    2

    t h a t d i e r s i n e v e r y c h a r a c t e r i s t i c f r o m

    1

    . L e t u s

    a s s u m e , h o w e v e r , t h a t P

    u s e

    (

    1

    ) v P

    g e n

    (

    2

    )

    T h e r e m a y w e l l e x i s t a

    2

    s u c h t h a t (

    2

    ;

    2

    ) i s s t a b l e ,

    b u t w e d o n o t h a v e s u c h a

    2

    . H o w i s i t t o b e o b t a i n e d ?

    T h e r s t p r o b l e m i s t h a t c o m p i l e i s i n a p p l i c a b l e , s i n c e

    w e c a n n o t a s s u m e e i t h e r B

    u s e

    (

    2

    ) v B

    i m p

    (

    2

    ) o r P

    u s e

    (

    2

    ) v

    P

    g e n

    (

    1

    )

    T h e p r o c e d u r e s b o o t , r e t a r g e t , a n d e l a b a r e n o t u s e -

    f u l , s i n c e t h e y j u s t t a k e t h e b i n a r y l e s

    1

    t h a t w e a l r e a d y

    h a v e . e l a b (

    1

    ;

    2

    ) i s i l l e g a l ( a s t h e r e a d e r m a y v e r i f y ) ,

    a n d t h e a u t h o r c a n n o t e v e n i m a g i n e w h y i t m i g h t b e u s e -

    f u l .

    T h e t r i c k i s t o m a k e s o m e i n t e r m e d i a t e v e r s i o n s o f t h e

    s o u r c e c o d e :

    x

    i s l i k e

    1

    b u t d e n e s a u g m e n t e d p r i m i -

    t i v e s P ;

    y

    i s l i k e

    x

    , b u t m a k e s u s e o f t h e a u g m e n t e d

    p r i m i t i v e s a n d p r o v i d e s a n a u g m e n t e d b a s i s B

    i m p

    S o ,

    x

    i s a s f o l l o w s :

    A

    g e n

    (

    x

    ) = A

    g e n

    (

    1

    )

    C

    g e n

    (

    x

    ) = C

    g e n

    (

    1

    )

    D

    g e n

    (

    x

    ) = D

    g e n

    (

    1

    )

    E

    g e n

    (

    x

    ) = E

    g e n

    (

    1

    )

    B

    u s e

    (

    x

    ) = B

    u s e

    (

    1

    )

    B

    i m p

    (

    x

    ) = B

    i m p

    (

    1

    )

    P

    u s e

    (

    x

    ) = P

    u s e

    (

    1

    )

    P

    g e n

    (

    x

    ) = P

    g e n

    (

    2

    )

    T h e n

    c o m p i l e (

    1

    ;

    x

    ) =

    x

    b o o t (

    x

    ) =

    x

    N o w v e r s i o n

    y

    i s a n o t h e r i n t e r m e d i a t e v e r s i o n :

    A

    g e n

    (

    y

    ) = A

    g e n

    (

    1

    )

    C

    g e n

    (

    y

    ) = C

    g e n

    (

    1

    )

    D

    g e n

    (

    y

    ) = D

    g e n

    (

    1

    )

    E

    g e n

    (

    y

    ) = E

    g e n

    (

    1

    )

    B

    u s e

    (

    y

    ) = B

    u s e

    (

    2

    )

    B

    i m p

    (

    y

    ) = B

    i m p

    (

    2

    )

    P

    u s e

    (

    y

    ) = P

    u s e

    (

    2

    )

    P

    g e n

    (

    y

    ) = P

    g e n

    (

    2

    )

    N o w

    c o m p i l e (

    x

    ;

    y

    ) =

    y

    b o o t (

    y

    ) =

    y

    c o m p i l e (

    y

    ;

    2

    ) =

    z

    r e t a r g e t (

    y

    ;

    z

    ) =

    z

    c o m p i l e (

    z

    ;

    2

    ) =

    0

    z

    e l a b (

    0

    z

    ;

    2

    ) =

    2

    c o m p i l e (

    2

    ;

    2

    ) =

    2

    N o w (

    2

    ;

    2

    ) i s s t a b l e . T h e p r o o f i s j u s t s i m p l e ( b u t

    t e d i o u s ) e q u a t i o n a l r e a s o n i n g , c h e c k i n g t h a t t h e p r e c o n -

    d i t i o n s o f e a c h s t e p a r e s a t i s e d a n d c h a r a c t e r i z i n g t h e

    i n t e r m e d i a t e r e s u l t s

    x

    ;

    x

    ;

    y

    ;

    y

    ; e t c .

    I t d o e s s e e m a m a z i n g t h a t v e c o m p i l a t i o n s a r e r e -

    q u i r e d t o g e t f r o m s t a b l e v e r s i o n 1 t o s t a b l e v e r s i o n 2 .

    B u t I h a v e n o t f o u n d a s h o r t e r s e q u e n c e .

    5 G e n e r a l i t y

    I n w h a t s e n s e d o t h e \ c h a r a c t e r i s t i c s " A ; C ; D ; E ; B ; P

    f o r m , i n a n y s e n s e , a c o m p l e t e s e t ?

    T h e a x i o m s c a n n o t a s s u r e t h e c o r r e c t n e s s o f t h e c o m -

    p i l e r . S p e c i f y i n g t h a t a 5 0 , 0 0 0 l i n e p r o g r a m f a i t h f u l l y

    i m p l e m e n t s t h e 1 0 0 - p a g e D e n i t i o n o f S t a n d a r d M L 5 ] i s

    n o t s o m e t h i n g t h a t c a n b e d o n e w i t h e i g h t o r t e n s i m p l e

    e q u a t i o n s i n t h e s t y l e s h o w n i n t h i s p a p e r . T h e a x i o m s

    1 5 3

  • 8/2/2019 10.1.1.32.2422

    7/9

    a r e m e a n t a s a b s t r a c t i o n s o f o n l y t h o s e a s p e c t s o f b o o t -

    s t r a p p i n g t h a t o f t e n p r o v e p r o b l e m a t i c a l . M a n y o t h e r

    a s p e c t s o f M L c o m p i l a t i o n , t h o u g h d i c u l t o r i n t e r e s t -

    i n g , p o s e n o s p e c i a l p r o b l e m s w h e n b o o t s t r a p p i n g a n d

    a r e e n t i r e l y i g n o r e d b y t h e a x i o m s .

    H o w e v e r , p e r h a p s t h e r e a r e o t h e r i m p o r t a n t i s s u e s r e -

    l a t e d t o b o o t s t r a p p i n g t h a t a r e n o t a c c u r a t e l y c h a r a c t e r -

    i z e d b y a n y o f t h e a x i o m s .

    5 . 1 R u n t i m e s y s t e m

    M L r e q u i r e s a r u n t i m e s y s t e m , t o d o g a r b a g e c o l l e c t i o n ,

    t o h a n d l e s y s t e m c a l l s , a n d t o p r o v i d e v a r i o u s f u n c t i o n s

    i m p l e m e n t e d i n C o r a s s e m b l y l a n g u a g e . T h e r u n t i m e

    s y s t e m m u s t k n o w t h e f o r m a t o f M L d a t a t y p e s ( t o d o

    g a r b a g e c o l l e c t i o n ) a n d m u s t s a t i s f y o t h e r c o n s t r a i n t s . A

    r u n t i m e s y s t e m h a s t h e p r o p e r t i e s A

    r u n

    ( ) , t h e a r c h i t e c -

    t u r e o n w h i c h i t r u n s ; C

    r u n

    ( ) , t h e c a l l i n g c o n v e n t i o n s f o r

    M L - c a l l a b l e e n t r y p o i n t s ; a n d D

    r u n

    ( ) , t h e M L d a t a t y p e

    l a y o u t t h a t i t u n d e r s t a n d s .

    T o m o d e l r u n t i m e s y s t e m s , w e e x t e n d b o o t w i t h a

    r u n t i m e - s y s t e m a r g u m e n t : b o o t ( ; ) = w i t h e x t r a

    p r e c o n d i t i o n s

    A

    r u n

    ( ) = A

    r u n

    ( )

    C

    r u n

    ( ) = C

    r u n

    ( )

    D

    r u n

    ( ) = D

    r u n

    ( )

    E l a b o r a t i o n a l s o r e q u i r e s a p a r t i c u l a r r u n t i m e s y s t e m :

    e l a b ( ; ; ) w i t h t h e s a m e t h r e e p r e c o n d i t i o n s .

    T h e i m p l i c a t i o n s o f t h e s e c o n s t r a i n t s t u r n o u t t o b e

    q u i t e t r i v i a l ; r u n t i m e s y s t e m i s s u e s d o n ' t c a u s e b o o t -

    s t r a p p i n g p r o b l e m s , e x c e p t a s d e s c r i b e d i n t h e n e x t s u b -

    s e c t i o n .

    5 . 2 S t r u c t u r e d I / O f o r m a t

    F o r e x a m p l e , J o h n R e p p y r e c e n t l y r e w r o t e t h e \ p i c k l e r "

    i n t h e r u n t i m e s y s t e m , t h a t w r i t e s p o i n t e r d a t a s t r u c t u r e s

    t o l e s ( a n d r e a d s t h e m b a c k ) . I n p a r t i c u l a r , t h e p i c k l e r

    w r i t e s s t a t i c e n v i r o n m e n t r e p r e s e n t a t i o n s t o b i n l e s

    R e p p y ' s n e w p i c k l e r u s e s a d i e r e n t l e f o r m a t f r o m t h e

    o l d o n e . T h e i m p l e m e n t a t i o n o f ( e i t h e r v e r s i o n o f ) t h e

    p i c k l e r , a n d a n y k n o w l e d g e a b o u t l e f o r m a t , i s e n t i r e l y

    w i t h i n t h e r u n t i m e s y s t e m .

    W e c o u l d c h a r a c t e r i z e t h i s a s F

    g e n

    ( ) , t h e f o r m a t t h a t

    a g i v e n r u n t i m e s y s t e m u s e s t o w r i t e M L d a t a t y p e s t o

    a l e . T h e n t h e b i n l e w o u l d h a v e a c h a r a c t e r i s t i c

    F

    e n v

    ( ) , t h e f o r m a t i n w h i c h s t a t i c e n v i r o n m e n t s h a v e

    b e e n w r i t t e n ; a n d e x e c u t a b l e s w o u l d h a v e t h e c h a r -

    a c t e r i s t i c F

    g e n

    ( ) b a s e d o n t h e f o r m a t t h a t ' s r u n t i m e

    s y s t e m u s e s .

    T h e n w e h a v e t h e f o l l o w i n g a d d i t i o n a l a x i o m s . F o r

    c o m p i l e ( ; ) = w e h a v e F

    g e n

    ( ) = F

    e n v

    ( )

    F o r b o o t ( ; ) = w e h a v e

    F

    e n v

    ( ) = F

    g e n

    ( )

    F

    g e n

    ( ) = F

    g e n

    ( )

    ( t h e r s t i s a p r e c o n d i t i o n , t h e s e c o n d c h a r a c t e r i z e s t h e

    o u t p u t )

    F o r r e t a r g e t (

    1

    ; ; a ) =

    2

    w e h a v e

    F

    e n v

    ( ) = F

    g e n

    (

    1

    )

    F

    g e n

    (

    2

    ) = F

    g e n

    (

    1

    )

    A n d n a l l y , f o r e l a b ( ; ; ) = w e h a v e o n l y F

    g e n

    ( ) =

    F

    g e n

    ( ) , a n d F

    e n v

    ( ) i r r e l e v a n t .

    C l e a r l y , R e p p y w i l l n e e d t o u s e e l a b i n o r d e r t o b o o t -

    s t r a p h i s n e w s t r u c t u r e - b l a s t e r f o r m a t , s i n c e b o o t a n d

    r e t a r g e t a r e t o o r e s t r i c t i v e .

    T h i s e x a m p l e h a s i l l u s t r a t e d t h a t t h e a x i o m s o f s e c -

    t i o n 3 d o n o t n e c e s s a r i l y f o r m a c o m p l e t e s e t , b u t t h e

    a x i o m a t i c m e t h o d i s e a s i l y e x t e n s i b l e t o m e e t n e w c h a l -

    l e n g e s .

    5 . 3 N e w m o d u l e - e l d l a y o u t

    O l d e r v e r s i o n s o f S M L / N J s o r t e d t h e v a l u e e l d s o f a

    s i g n a t u r e i n t o a l p h a b e t i c a l o r d e r b e f o r e g e n e r a t i n g c o d e .

    T h i s m e a n t t h a t i n t h e t r a n s l a t i o n o f t h i s m o d u l e S

    s t r u c t u r e S =

    s t r u c t

    v a l b = 5

    v a l a = 7

    e n d

    w o u l d b e a s a r e c o r d i n m e m o r y i n w h i c h a ( 7 ) a p p e a r e d

    r s t , f o l l o w e d b y b ( 5 ) .

    C u r r e n t v e r s i o n s o f S M L / N J d o n o t s o r t i n t o a l p h a -

    b e t i c a l o r d e r . T h u s , b i n l e s c o m p i l e d b y t h e n e w v e r s i o n

    s h o u l d b e i n c o m p a t i b l e w i t h e x e c u t a b l e s o f t h e o l d v e r -

    s i o n .

    C o n s i d e r t h e a x i o m a t i z a t i o n . W e s a y t h a t

    G

    g e n

    ( ) i s t h e s o r t i n g ( n o n s o r t i n g ) t e c h n i q u e u s e d f o r

    s t r u c t u r e e l d s b y s o u r c e c o d e ;

    G

    r u n

    ( ) i s t h e s t r u c t u r e - e l d l a y o u t a l g o r i t h m t h a t h a d

    b e e n u s e d i n c o m p i l i n g ;

    G

    g e n

    (

    1

    ) i s t h e s t r u c t u r e - e l d l a y o u t a l g o r i t h m t h a t

    u s e s i n g e n e r a t i n g o u t p u t c o d e ;

    G

    r u n

    ( ) i s a n a l o g o u s t o G

    r u n

    ( ) ;

    G

    g e n

    ( ) i s a n a l o g o u s t o G

    g e n

    ( ) ;

    G

    r u n

    ( ) i s t h e o r d e r i n g t h a t u s e s f o r i n t e r f a c i n g i t s

    o w n \ p r i m i t i v e " s t r u c t u r e s v i s i b l e f r o m t h e M L p r o -

    g r a m .

    T h e n e x t s t e p i s t o w r i t e a x i o m s f o r G . T h i s i s n o t

    t r i v i a l , a s i t i n v o l v e s a n u n d e r s t a n d i n g o f h o w t h e c o m -

    p i l e r a n d g e n e r a t e d c o d e w o r k . I t t u r n s o u t , h o w e v e r ,

    t h a t t h e e q u a t i o n s f o r G i n t h e s t e p s c o m p i l e , b o o t ,

    r e t a r g e t , e l a b a r e e x a c t l y p a r a l l e l t o t h e e q u a t i o n s f o r

    C . T h i s i m p l i e s t h a t G w a s n o t n e c e s s a r y a t a l l , a n d t h a t

    C e x p r e s s e s ( a m o n g o t h e r t h i n g s ) t h e o r d e r i n g o f s t r u c -

    t u r e e l d s . T h i s i s a m e a s u r e o f t h e r o b u s t n e s s o f t h e

    o r i g i n a l a x i o m s .

    5 . 4 R e c o r d e l d o r d e r i n g

    R e c o r d e l d s a r e a l s o s o r t e d b y l a b e l i n S M L / N J . S o r t -

    i n g i s r e q u i r e d b y t h e s e m a n t i c s o f t h e l a n g u a g e , b u t a n y

    c o n s i s t e n t o r d e r i n g w i l l d o . T h e s o r t i n g c o u l d , i n p r i n c i -

    p l e , b e d o n e i n s o m e n o n s t a n d a r d ( i . e . n o n - a l p h a b e t i c a l )

    o r d e r .

    S i n c e r e c o r d s a r e u s e d d i r e c t l y i n t h e i m p l e m e n t a t i o n

    o f s t a t i c e n v i r o n m e n t s , a n d s t r u c t u r e s a r e n o t , t h e e e c t

    o f r e c o r d e l d s t u r n s o u t t o b e a x i o m a t i z e d e x a c t l y l i k e

    1 5 4

  • 8/2/2019 10.1.1.32.2422

    8/9

    d a t a t y p e l a y o u t s D , n o t l i k e c a l l i n g s e q u e n c e s C . T h i s

    s h o u l d n o t b e s u r p r i s i n g , a s t h e r e c o r d t y p e { a , b } i s i n -

    d e e d a k i n d o f t y p e c o n s t r u c t o r ( j u s t l i k e a d a t a t y p e ) a n d

    t h e l a y o u t i n t o b i t s o f M L d a t a t y p e s i s e x a c t l y w h a t D

    w a s s u p p o s e d t o c h a r a c t e r i z e .

    6 R e l a t e d w o r k

    L e c a r m e e t a l . 4 ] p r e s e n t a g o o d e x p l a n a t i o n o f a t h e o r y

    o f b o o t s t r a p p i n g u s i n g T - d i a g r a m s , a n o t a t i o n i n v e n t e d

    b y B r a t m a n 2 ] a n d f o r m a l i z e d b y E a r l e y a n d S t u r g i s 3 ] .

    T h i s t h e o r y i s s i m p l e a n d e l e g a n t , a n d t h e d i a g r a m s a r e

    p r e t t y t o l o o k a t . I t i s v e r y s u c c e s s f u l i n d e s c r i b i n g t h e

    s t e p s n e e d e d t o p r o d u c e a c o m p i l e r f r o m s o u r c e l a n g u a g e

    S L t o o b j e c t l a n g u a g e O L w r i t t e n i n i m p l e m e n t a t i o n l a n -

    g u a g e W L , w h e n o n e h a s ( f o r e x a m p l e ) a m a c h i n e e x e -

    c u t i n g i n s t r u c t i o n s e t X L , a t r a n s l a t o r f r o m W L t o X L

    i m p l e m e n t e d i n X L , a n i n t e r p r e t e r f o r O L w r i t t e n i n A L ,

    a n d a t r a n s l a t o r f o r A L w r i t t e n i n . . . a n d s o o n . T h e T -

    d i a g r a m s s e e m m o r e c o m p a c t , a n d e a s i e r t o r e a d o n c e o n e

    l e a r n s h o w , t h a n t h e c o r r e s p o n d i n g e q u a t i o n a l t h e o r y .

    I n f a c t , E a r l e y a n d S t u r g i s p r o v i d e a n a l g o r i t h m t o

    c o n s t r u c t a b o o t s t r a p s e q u e n c e : G i v e n a s e t o f t r a n s -

    l a t o r s a n d i n t e r p r e t e r s ( c h a r a c t e r i z e d b y s o u r c e , o b j e c t ,

    a n d i m p l e m e n t a t i o n l a n g u a g e s ) , a n d a d e s i r e d t r a n s l a t o r

    ( s i m i l a r l y c h a r a c t e r i z e d ) t h e i r a l g o r i t h m c a n e i t h e r s h o w

    h o w t o c o n s t r u c t t h e d e s i r e d r e s u l t o r p r o v e t h a t i t c a n -

    n o t b e d o n e . P e r h a p s a n a l g o r i t h m s u c h a s t h i s c o u l d b e

    d e v i s e d t o p r o v e t h e t h e o r e m s o f s e c t i o n s 4 . 1 { 4 . 6 .

    L e c a r m e g o e s f u r t h e r , w i t h a o w c h a r t t h a t p r o v i d e s

    h i n t s a b o u t w h a t e x i s t i n g t r a n s l a t o r s h o u l d b e m o d i e d

    \ b y h a n d " ( t o p r o d u c e a d i e r e n t t a r g e t l a n g u a g e , o r t o

    a c c e p t a d i e r e n t s o u r c e l a n g u a g e , o r t o r u n i n a d i e r e n t

    i m p l e m e n t a t i o n l a n g u a g e ) t o g e t t o t h e d e s i r e d r e s u l t .

    N o t e t h e s i m i l a r i t i e s w i t h t h e h a n d - m a d e i n t e r m e d i a t e

    v e r s i o n s

    x

    ;

    y

    n e e d e d i n s e c t i o n 4 . 7 .

    W h y d o I a b a n d o n T - d i a g r a m s ? T h e a d d e d p r o b -

    l e m i n S M L / N J ( a n d i n s i m i l a r i n t e r a c t i v e s y s t e m s , e s -

    p e c i a l l y t h o s e t h a t h a v e p r e d i g e s t e d t y p e i n f o r m a t i o n ) i s

    t h a t t h e r e a r e e x t r a c o n s t r a i n t s b e t w e e n t h e i m p l e m e n t a -

    t i o n l a n g u a g e a n d t h e o b j e c t l a n g u a g e t h a t T - d i a g r a m s

    d o n o t e x p r e s s . F u r t h e r m o r e , t h e d i e r e n t l a n g u a g e s i n

    q u e s t i o n a r e a l l q u i t e s i m i l a r : e x e c u t a b l e c o d e d e s c r i b e d

    b y ( i n t h i s c a s e ) s i x c h a r a c t e r i s t i c s , w h e r e m a n y o f t h e

    c h a r a c t e r i s t i c s a r e l i k e l y t o m a t c h b e t w e e n a n y t w o v e r -

    s i o n s . I n u s i n g T - d i a g r a m s , t h e s i m i l a r i t i e s b e t w e e n t w o

    e x e c u t a b l e s ( e . g . i d e n t i c a l d a t a t y p e r e p r e s e n t a t i o n ) a r e

    l o s t , a n d w o u l d h a v e t o b e e x p r e s s e d s e p a r a t e l y i n a s e t

    o f e q u a t i o n s .

    T h o m p s o n ' s T u r i n g a w a r d l e c t u r e 6 ] d e s c r i b e s h o w

    b u g s ( a n d v i r u s e s ) c a n p r o p a g a t e t h r o u g h t h e b o o t s t r a p -

    p i n g p r o c e s s .

    7 C o n c l u s i o n

    W h e n c o m p i l e d c o d e s h a r e s i m p o r t a n t p a r t s o f t h e e n v i -

    r o n m e n t w i t h t h e c o m p i l e r i t s e l f , b o o t s t r a p p i n g n e w v e r -

    s i o n s c a n b e c o m p l i c a t e d , a n d p r e v i o u s t h e o r i e s o f b o o t -

    s t r a p p i n g d o n o t s e e m t o e x t e n d w e l l . C l e a r l y w r i t t e n

    a x i o m s c a n h e l p t h e p o o r c o m p i l e r h a c k e r d e a l w i t h t h e

    c o m p l e x i t y .

    C e r t a i n c h o i c e s m a d e i n t h e S M L / N J s y s t e m c o m p l i -

    c a t e b o o t s t r a p p r o c e s s :

    T h e S M L / N J s y s t e m u s e s a \ p i c k l e r " t o w r i t e s t a t i c

    e n v i r o n m e n t s t o b i n a r y l e s i n ( a l m o s t ) e x a c t l y t h e

    s a m e f o r m a t t h a t ' s u s e d i n m e m o r y . T h e r e s u l t -

    i n g c o n s t r a i n t s o n D

    e n v

    ( ) c a u s e t h e p r o c e d u r e s o f

    s e c t i o n s 4 . 4 a n d 4 . 7 t o t a k e e x t r a e l a b s t e p s .

    T h e s h a r i n g o f c o d e a n d d a t a b e t w e e n t h e c o m p i l e r

    a n d u s e r p r o g r a m s r e q u i r e s t h e c o m p i l e r t o l o a d i t s

    o w n s t a t i c e n v i r o n m e n t s , c a u s i n g c o n s t r a i n t s o n E

    a n d B

    T h e u s e o f t h e s a m e c o m p i l e r f o r c o m p i l i n g i n t e r -

    a c t i v e c o m m a n d s a n d s o u r c e l e s f o r t h e c o m p i l e r

    i t s e l f r e q u i r e s a s p e c i a l r e t a r g e t m e c h a n i s m f o r r e -

    l a x i n g c o n s t r a i n t s o n A a n d C

    H o w e v e r , e a c h o f t h e s e f e a t u r e s i s u s e f u l i n i t s o w n w a y .

    T h e a x i o m a t i z a t i o n o f b o o t s t r a p p i n g m a k e s i t e a s i e r t o

    t o l e r a t e c o m p l e x i t y i n t h e p r o c e s s , s o t h a t t h e s e f e a t u r e s

    c a n b e m o r e e a s i l y s u p p o r t e d .

    A C o m m a n d r e a l i z a t i o n

    E a c h o f t h e a b s t r a c t f u n c t i o n s c o m p i l e , b o o t , r e t a r g e t ,

    e l a b c o r r e s p o n d s t o a s e q u e n c e o f o p e r a t i n g - s y s t e m c o m -

    m a n d s ( a s h e l l s c r i p t ) o r M L c o m m a n d s . L e t b e a n i n -

    t e r a c t i v e s m l e x e c u t a b l e w i t h t h e C o m p i l a t i o n M a n a g e r

    ( m a k e s y s t e m ) l o a d e d , c a l l e d s m l - c m . L e t b e a s e t

    o f s o u r c e l e s f o r t h e c o m p i l e r i n d i r e c t o r y s r c . T h e n

    c o m p i l e ( ; ) i s j u s t

    c d s r c ; e c h o " B a t c h . m a k e ( ) " | s m l - c m

    S u p p o s i n g t h a t t h e t a r g e t a r c h i t e c t u r e i s s p a r c ( A

    g e n

    ( ) =

    s p a r c ) , t h i s c r e a t e s a d i r e c t o r y = b i n s p a r c c o n t a i n i n g

    b i n l e s .

    B o o t s t r a p p i n g ( b o o t ( ; ) ) i s d o n e b y t w o s h e l l s c r i p t s :

    m a k e m l c o m p i l e s t h e r u n t i m e s y s t e m ( w r i t t e n i n C a n d

    a s s e m b l y l a n g u a g e ) f r o m t h e s r c / r u n t i m e s u b d i r e c t o r y

    r u n s i t t o l o a d t h e b i n l e s t o c r e a t e a n e x e c u t a b l e

    s m l , a n d m a k e c m e x e c u t e s s m l t o l o a d t h e C o m p i l a t i o n

    M a n a g e r , c r e a t i n g a n e x e c u t a b l e = s m l - c m :

    c d s r c ; m a k e m l - b i n b i n . s p a r c ; m a k e c m

    R e t a r g e t i n g i s d o n e b y i n s t r u c t i n g t h e c o m p i l a t i o n

    m a n a g e r = s m l ? c m t o l o a d b i n l e s f o r a n a l t e r n a t e

    c o m p i l e r i n d i r e c t o r y = a l t = b i n s p a r c ( f o r e x a m p l e )

    a n d t o s e l e c t t h e a l p h a c o d e g e n e r a t o r w i t h i n t h o s e l e s :

    e c h o ' r e t a r g e t ( " a l t / b i n . s p a r c " , " . a l p h a " ) ;

    e x p o r t M L ( " s m l - a " ) ' | s m l - c m

    T h e r e s u l t o f t h i s r e t a r g e t ( ; ; ) i s

    2

    = s m l - a

    F i n a l l y , e l a b o r a t i o n i s j u s t l i k e b o o t b u t w i t h a n e x t r a

    c o m m a n d - l i n e a g - e l a b t o m a k e m l

    R e f e r e n c e s

    1 ] A . W . A p p e l a n d D . B . M a c Q u e e n . S e p a r a t e c o m p i l a -

    t i o n f o r S t a n d a r d M L . I n P r o c . S I G P L A N ' 9 4 S y m p .

    o n P r o g . L a n g u a g e D e s i g n a n d I m p l e m e n t a t i o n , p a g e

    ( t o a p p e a r ) . A C M P r e s s , J u n e 1 9 9 4 .

    2 ] H . B r a t m a n . A n a l t e r n a t e f o r m o f t h e U N C O L d i a -

    g r a m . C o m m u n . A C M , 4 ( 3 ) : 1 4 2 , M a r . 1 9 6 1 . A o n e -

    p a g e p a p e r t h a t i s h a l f d i a g r a m s !

    1 5 5

  • 8/2/2019 10.1.1.32.2422

    9/9

    3 ] J . E a r l e y a n d H . S t u r g i s . A f o r m a l i s m f o r t r a n s l a t o r

    i n t e r a c t i o n s . C o m m u n . A C M , 1 3 ( 1 0 ) : 6 0 7 { 6 1 7 , O c t .

    1 9 7 0 .

    4 ] O . L e c a r m e , M . P e l l i s s i e r , a n d M . - C . T h o m a s .

    C o m p u t e r - a i d e d p r o d u c t i o n o f l a n g u a g e i m p l e m e n t a -

    t i o n s y s t e m s : A r e v i e w a n d c l a s s i c a t i o n . S o f t w a r e |

    P r a c t i c e a n d E x p e r i e n c e , 1 2 ( 9 ) : 7 8 5 { 8 2 4 , 1 9 8 2 .

    5 ] R . M i l n e r , M . T o f t e , a n d R . H a r p e r . T h e D e n i t i o n

    o f S t a n d a r d M L . M I T P r e s s , C a m b r i d g e , M A , 1 9 9 0 .

    6 ] K . T h o m p s o n . R e e c t i o n s o n t r u s t i n g t r u s t . C o m -

    m u n . A C M , 2 7 ( 8 ) : 7 6 1 { 7 6 3 , 1 9 8 4 .

    1 5 6