[Tinyos-commits] CVS: tinyos-1.x/tos/lib/VM/languages/motlle/mate MemoryM.nc, 1.9, 1.10 MotllePlatform.h, 1.2, 1.3

David Gay idgay at users.sourceforge.net
Wed Nov 30 10:10:42 PST 2005


Update of /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/mate
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23564/mate

Modified Files:
	MemoryM.nc MotllePlatform.h 
Log Message:
can't move code around inside capsule - confuses viral propagation
--> fallback to ensuring mcapsule.data and GC.base() are properly aligned


Index: MemoryM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/mate/MemoryM.nc,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** MemoryM.nc	29 Nov 2005 22:53:16 -0000	1.9
--- MemoryM.nc	30 Nov 2005 18:10:40 -0000	1.10
***************
*** 44,47 ****
--- 44,48 ----
    enum {
      BASE_FRAME_SIZE = ALIGN(sizeof(struct base_frame), MOTLLE_STACK_ALIGNMENT),
+     CAPSULE_HEADER_SIZE = 2
    };
  
***************
*** 59,67 ****
  
    inline command uint8_t *GC.base() { /* Return base of GC area */
! #ifdef PLATFORM_REQUIRES_ALIGNMENT
!     return (uint8_t *)ALIGN((intptr_t)mcapsule.data, MOTLLE_HEAP_ALIGNMENT);
! #else
!     return (uint8_t *)mcapsule.data + 1; // for the globals count
! #endif
    }
  
--- 60,67 ----
  
    inline command uint8_t *GC.base() { /* Return base of GC area */
!     // ASSUME: mcapsule.data + 2 is properly aligned
!     // (ideally we would fix this at runtime, but it interacts poorly with
!     // viral code sharing)
!     return (uint8_t *)mcapsule.data + CAPSULE_HEADER_SIZE; // for the globals count
    }
  
***************
*** 126,137 ****
      uint8_t i, nglobals = (uint8_t)mcapsule.data[0];
  
!     gvars = call GC.base() + mcapsule.dataSize - 1;
      posgc = gc_heap = gvars + sizeof(svalue) * nglobals;
- #ifdef PLATFORM_REQUIRES_ALIGNMENT
-     /* Don't write past the capsule. We'll abort out in the next test
-        anyway. */
-     if (gvars <= capsule_end())
-       memmove(call GC.base(), mcapsule.data + 1, mcapsule.dataSize - 1);
- #endif
      if (gc_heap > capsule_end())
        {
--- 126,131 ----
      uint8_t i, nglobals = (uint8_t)mcapsule.data[0];
  
!     gvars = call GC.base() + mcapsule.dataSize - CAPSULE_HEADER_SIZE;
      posgc = gc_heap = gvars + sizeof(svalue) * nglobals;
      if (gc_heap > capsule_end())
        {

Index: MotllePlatform.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/mate/MotllePlatform.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MotllePlatform.h	29 Nov 2005 22:53:16 -0000	1.2
--- MotllePlatform.h	30 Nov 2005 18:10:40 -0000	1.3
***************
*** 21,24 ****
--- 21,30 ----
     MINLINE to inline if you want to inline performance-critical routines
       and can afford the code space, or to nothing if you can't
+ 
+    Note also that you should check that the value returned by GC.base() in
+    MemoryM.nc is appropriately aligned for the MotlleValues.read and write
+    commands (if it isn't, the easiest "fix" is to modify the implementations
+    of read and write in rep-{16,float}/MotlleRepM.nc to accept unaligned
+    pointers).
  */
  



More information about the Tinyos-commits mailing list