[CS 61] Data Representation
Overview
- Bytes of memory
- Objects
- Segments
- Abstract machine and hardware
- Unsigned integer representation
- Signed integer representation
- Pointer representation
- Array access performance
- Array representation
- Compiler layout
- Alignment
- Collection representation
- Consequences of the size and alignment rules
- unintialized objects
- Compiler hijinks
- Pointer arithmetic
- Undefined behavior
- Undefined behavior and optimization
- Integer undefiend behavior
- Sanitizers
- Signed integer undefined behavior
- Computer arithmetic and bitwise operations
- Arena allocation
Bytes of memory
- Bit
- The smallest unit of storage
- A base-two digit : 0 or 1
- Physical address
- The lowest-level kind of address
- It really does take on values between 0 and M-1
( M bytes of memory , 16 gigabutes of memory => M = 16 * 2^30 = 2^34 )
- Virtual address
- The addresses used in programs
- It is incredibly useful for protection
Objects
- Object : a region of data storage that contains a value
- The compiler, hardware, and standard together define how objects of different types map to bytes
- sizeof : returns the size of object x
- size_t : a value of result for 'sizeof', unsigned integer type
- On 64-bit architectures, size_t can hold numbers between 0 and 2^64-1
- aliases : The different names of an object