According to an interview Barrie gave during the 50th anniversary celebrations for It's a Mad Mad Mad Mad World (1963) she was in Sweden when her agent called and told her Stanley Kramer wanted to see her the next day about a part in a movie. She thought it was just an audition, but she flew back anyway. It turned out his wife had suggested he hire Barrie for the role so it was hers if she wanted it (she did).
After the meeting she was walking down the Sunset Strip when she ran into an actor friend, and she told him she'd just gotten a part that was shooting the next day but she had no idea how to play the character. He read her script pages and he noticed the name was a Mrs. He asked her if the guy in the scene was her husband and she said no. It's easy then, he said, they are stoned.
The next day Barrie told Kramer, who was directing as well as producing the picture, of her plan to play it as if she were stoned and he liked the idea.
But this presented a problem - Barrie had never been stoned, and didn't know how to properly "toke a doobie" (watch closely the next time when she sits on the bed - she's not lighting a cigarette - it's a prop joint). A helpful member of the crew had to take her aside and give her a quick tutorial on the procedure. This was probably the first time such a thing appeared in a comedy movie, but since it wasn't common in 1963 society most people then, and still, missed it, but it accounts for Barrie's strange zoned-out look during the dance. Her interpretation also came in handy because it was the only way to keep a straight face while Dick Shawn (Sylvester) ricocheted around her and screamed in her ear.
Oh, and the actor who had helped her "find" the character - that was Steve McQueen.