Lazy Sequentialization for TSO and PSO via Shared Memory Abstractions