Cook onions and garlic in oil in a 4- to 5-quart heavy pot over moderate heat, stirring occasionally, until golden, about 5 minutes. Add wine and boil, uncovered, until almost all of wine is evaporated, 10 to 15 minutes. Stir in cream, rosemary, salt, and pepper and simmer, uncovered, stirring occasionally, until mixture is reduced to about 1 1/2 cups, about 30 minutes. Add corn and simmer 5 minutes. Discard rosemary.