This question is similar to "What is the origin of Orcs", although a bit less debated, in the sense that it's not very clear and all a bit confusing.
I'm going to start with the following statement,
Tolkien never states that Trolls are a mockery of Ents. The only one to say so is Treebeard, and his statements are hardly the be all and end all of discussions.1
In the appendices to his Lord of the Rings, Tolkien states that Trolls were found long ago, a race likened to beasts rather than more sentient being such as man. Crediting Sauron with their evil and wits (noted in Christopher's notes below).
In Myths Transformed, Tolkien again suggests that Trolls were around before, but that they were tinkered with to turn them into the creatures of evil we're familiar with.
And are Orcs 'immortal', in the Elvish sense? Or trolls? It seems clearly implied in The Lord of the Rings that trolls existed in their own right, but were 'tinkered' with by Melkor.
Morgoth's Ring - Myths Transformed: VIII, "Orcs"
Christopher Tolkien's notes on the above
“In The Lord of the Rings Appendix F (I) it is said of Trolls:
In their beginning far back in the twilight of the Elder Days, these were creatures of dull and lumpish nature and had no more language than beasts. But Sauron had made use of them, teaching them what little they could learn, and increasing their wits with wickedness.
In the long letter of September 1954 cited in note 1 he wrote of them:
I am not sure about Trolls. I think they are mere 'counterfeits', and hence (though here I am of course only using elements of old barbarous mythmaking that had no 'aware' metaphysic) they return to mere stone images when not in the dark. But there are other sorts of Trolls beside these rather ridiculous, if brutal, Stone-trolls, for which other origins are suggested. Of course... when you make Trolls speak you are giving them a power, which in our world (probably) connotes the possession of a 'soul'.”
Morgoth's Ring - Myths Transformed: VIII, "Orcs", Note 3
Tolkien goes on to discuss trolls in Myths Transformed IX stating that they are similar to orcs in nature, but different physically, and they may have Been perversions of Human-types and therefore not Ents.
“The Elves would have classed the creatures called 'trolls' (in The Hobbit and The Lord of the Rings) as Orcs - in character and origin - but they were larger and slower. It would seem evident that they were corruptions of primitive human types.”
Morgoth's Ring - Myths Transformed: IX
It seems Tolkien himself was not certain of their origin. But one thing we can be certain of is that they were not mutilated Elves, and we can be almost certain they were not mockeries of the Ents.
Tolkien himself makes a note of this when asked about Trolls in Letter 153
Treebeard is a character in my story, not me; and though he has a great memory and some earthy wisdom, he is not one of the Wise, and there is quite a lot he does not know or understand.
Letters of J.R.R. Tolkien - Letter 153