[Vm-dev] VM Maker: MemoryAccess-dtl.5.mcz
commits at source.squeak.org
commits at source.squeak.org
Fri Mar 22 23:19:17 UTC 2013
David T. Lewis uploaded a new version of MemoryAccess to project VM Maker:
http://source.squeak.org/VMMaker/MemoryAccess-dtl.5.mcz
==================== Summary ====================
Name: MemoryAccess-dtl.5
Author: dtl
Time: 22 March 2013, 7:19:08.002 pm
UUID: 95c752da-f58d-43df-a9cc-9ebe7b2efd92
Ancestors: MemoryAccess-dtl.4
Move MemoryAccess under VMClass rather than object because it needs requiredMethodNames.
=============== Diff against MemoryAccess-dtl.4 ===============
Item was changed:
+ VMClass subclass: #MemoryAccess
- Object subclass: #MemoryAccess
instanceVariableNames: ''
classVariableNames: 'Enabled'
poolDictionaries: ''
category: 'MemoryAccess'!
+ !MemoryAccess commentStamp: 'dtl 3/21/2013 23:50' prior: 0!
+ MemoryAccess defines the low level mapping of object memory addresses to the underlying machine address space. When implemented as Smalltalk methods, the generated C code is available for debugging and profiling. The Squeak code generator inlines the methods such that the resulting VM will have performance very similar to that obtained with traditional C preprocessor macros or inlined static functions.
- !MemoryAccess commentStamp: 'dtl 4/5/2009 14:38' prior: 0!
- MemoryAccess defines the low level mapping of object memory addresses to the underlying machine address space. When implemented as Smalltalk methods, the generated C code
- is available for debugging and profiling. The Squeak code generator inlines the methods
- such that the resulting VM will have performance very similar to that obtained with
- traditional C preprocessor macros or inlined static functions.
+ Methods are categorized and commented in order to clarify the type casting and memory address translation.
- Methods are categorized and commented in order to clarify the type casting and memory
- address translation.
MemoryAccess replaces the traditional external definitions in sqMemoryAccess.h:
#ifdef USE_INLINE_MEMORY_ACCESSORS
/* Use static inline functions when the compiler produces efficient code for small accessors.
These are preferred because static type checking will prevent inadvertent confusion of pointers and oops. */
static inline sqInt byteAtPointer(char *ptr) { return (sqInt)(*((unsigned char *)ptr)); }
static inline sqInt byteAtPointerput(char *ptr, int val) { return (sqInt)(*((unsigned char *)ptr)= (unsigned char)val); }
static inline sqInt shortAtPointer(char *ptr) { return (sqInt)(*((short *)ptr)); }
static inline sqInt shortAtPointerput(char *ptr, int val) { return (sqInt)(*((short *)ptr)= (short)val); }
static inline sqInt intAtPointer(char *ptr) { return (sqInt)(*((unsigned int *)ptr)); }
static inline sqInt intAtPointerput(char *ptr, int val) { return (sqInt)(*((unsigned int *)ptr)= (int)val); }
static inline sqInt longAtPointer(char *ptr) { return (sqInt)(*((sqInt *)ptr)); }
static inline sqInt longAtPointerput(char *ptr, sqInt val) { return (sqInt)(*((sqInt *)ptr)= (sqInt)val); }
static inline sqInt oopAtPointer(char *ptr) { return (sqInt)(*((sqInt *)ptr)); }
static inline sqInt oopAtPointerput(char *ptr, sqInt val) { return (sqInt)(*((sqInt *)ptr)= (sqInt)val); }
static inline char *pointerForOop(usqInt oop) { return sqMemoryBase + oop; }
static inline sqInt oopForPointer(char *ptr) { return (sqInt)(ptr - sqMemoryBase); }
static inline sqInt byteAt(sqInt oop) { return byteAtPointer(pointerForOop(oop)); }
static inline sqInt byteAtput(sqInt oop, int val) { return byteAtPointerput(pointerForOop(oop), val); }
static inline sqInt shortAt(sqInt oop) { return shortAtPointer(pointerForOop(oop)); }
static inline sqInt shortAtput(sqInt oop, int val) { return shortAtPointerput(pointerForOop(oop), val); }
static inline sqInt intAt(sqInt oop) { return intAtPointer(pointerForOop(oop)); }
static inline sqInt intAtput(sqInt oop, int val) { return intAtPointerput(pointerForOop(oop), val); }
static inline sqInt longAt(sqInt oop) { return longAtPointer(pointerForOop(oop)); }
static inline sqInt longAtput(sqInt oop, sqInt val) { return longAtPointerput(pointerForOop(oop), val); }
static inline sqInt oopAt(sqInt oop) { return oopAtPointer(pointerForOop(oop)); }
static inline sqInt oopAtput(sqInt oop, sqInt val) { return oopAtPointerput(pointerForOop(oop), val); }
#else
/* Use macros when static inline functions aren't efficient. */
# define byteAtPointer(ptr) ((sqInt)(*((unsigned char *)(ptr))))
# define byteAtPointerput(ptr, val) ((sqInt)(*((unsigned char *)(ptr))= (unsigned char)(val)))
# define shortAtPointer(ptr) ((sqInt)(*((short *)(ptr))))
# define shortAtPointerput(ptr, val) ((sqInt)(*((short *)(ptr))= (short)(val)))
# define intAtPointer(ptr) ((sqInt)(*((unsigned int *)(ptr))))
# define intAtPointerput(ptr, val) ((sqInt)(*((unsigned int *)(ptr))= (int)(val)))
# define longAtPointer(ptr) ((sqInt)(*((sqInt *)(ptr))))
# define longAtPointerput(ptr, val) ((sqInt)(*((sqInt *)(ptr))= (sqInt)(val)))
# define oopAtPointer(ptr) (sqInt)(*((sqInt *)ptr))
# define oopAtPointerput(ptr, val) (sqInt)(*((sqInt *)ptr)= (sqInt)val)
# define pointerForOop(oop) ((char *)(sqMemoryBase + ((usqInt)(oop))))
# define oopForPointer(ptr) ((sqInt)(((char *)(ptr)) - (sqMemoryBase)))
# define byteAt(oop) byteAtPointer(pointerForOop(oop))
# define byteAtput(oop, val) byteAtPointerput(pointerForOop(oop), (val))
# define shortAt(oop) shortAtPointer(pointerForOop(oop))
# define shortAtput(oop, val) shortAtPointerput(pointerForOop(oop), (val))
# define longAt(oop) longAtPointer(pointerForOop(oop))
# define longAtput(oop, val) longAtPointerput(pointerForOop(oop), (val))
# define intAt(oop) intAtPointer(pointerForOop(oop))
# define intAtput(oop, val) intAtPointerput(pointerForOop(oop), (val))
# define oopAt(oop) oopAtPointer(pointerForOop(oop))
# define oopAtput(oop, val) oopAtPointerput(pointerForOop(oop), (val))
#endif
!
More information about the Vm-dev
mailing list