Advertisement
Guest User

Untitled

a guest
Apr 5th, 2025
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. ocalm has a uniform representation of data
  2. everything is one word, which is either an immediate or a pointer to the heap
  3. polymorphism
  4. in ocaml, can have same machine code for all
  5. C++: compile multime assembly-language versions
  6. C#: do it at run time
  7. jit
  8. ocalm 5.0 was the first version to have parallelism
  9. all threads share the same heap
  10. C++: data race can result in crazy behavior
  11. data race on one variable can corrupt other variables
  12. things can go wrong before you access the variable
  13. bounded in time and space
  14. rust has a race-free programming model; can use a safe fragment
  15. of rust, and there's a guarantee of no data races
  16. ocaml
  17. doesn't give much control over memory layout of data
  18. an int64 takes 24 bytes
  19. an arry with elements that are not immediates has values that
  20. are all over the heap, can't be cached
  21. has to rule out data races dynamically, can't be done statically
  22. they want to fit into the main, normal ocaml ecosystem
  23. three features
  24. narrow and flat data layouts
  25. add new unboxed primitives like int32#
  26. unboxed records, passed in two registers
  27. arrays of unboxed records
  28. "Unboxed types are characterized by their layout," which is a kind
  29. a kind is a type of type
  30. bits64 = a layout for types that fit in 64 bits
  31. implement polymorphism using one copy of the function per layout,
  32. which is better than what C++ does, one function per type
  33. stack allocation
  34. ocaml has a major heap and minor heap
  35. stack allocation is faster: deallocation is trivial
  36. but what about pointers to the stack that have become invalid?
  37. don't create pointers from heap to stack
  38. don't return stack values
  39. add features to type system to keep track of what can and can't
  40. be stack-allocated
  41. why not use rust-style lifetimes?
  42. rust is manually managed, every value has a lifetime
  43. lifetimes aren't limited by lexical scope
  44. issues with higher-order polymorphism, type inference is
  45. undecidable, so user sometimes has to annotate lifetimes
  46. so instead of lifetimes, use modes, which are properties that
  47. can be applied to any type
  48. global mode = default, unconstrained
  49. local mode = must follow stack discipline
  50. type system automatically figures out the mode based on how you
  51. use the value
  52. race-free parallel programming
  53. create new modes for this
  54. contention = has been shared across threads
  55. portability = is safe to share between threads
  56. when you have a function that mutates data,
  57. that function is not portable
  58. they have 15 modes in 5 dimensions
  59. semantics of spawn and join makes requirements on modes
  60. manipulating pointers to shared memory
  61. as one choice, they provide an API for doing locking
  62. "we're nervous about complexity!"
  63. paper: "Data Race Freedom a la Mode"
  64. https://dl.acm.org/doi/10.1145/3704859
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement