A search for supersymmetry in hadronic final states with highly boosted W bosons and b jets is presented, focusing on compressed scenarios. The search is performed using proton-proton collision data at a center-of-mass energy of 8 TeV, collected by the CMS experiment at the LHC, corresponding to an integrated luminosity of 19.7 fb-1. Events containing candidates for hadronic decays of boosted W bosons are identified using jet substructure techniques, and are analyzed using the razor variables MR and R2, which characterize a possible signal as a peak on a smoothly falling background. The observed event yields in the signal regions are found to be consistent with the expected contributions from standard model processes, which are predicted using control samples in the data. The results are interpreted in terms of gluino-pair production followed by their exclusive decay into top squarks and top quarks. The analysis excludes gluino masses up to 1.1 TeV for light top squarks decaying solely to a charm quark and a neutralino, and up to 700 GeV for heavier top squarks decaying solely to a top quark and a neutralino.