RESOLVED FIXED 108206
Structure::m_outOfLineCapacity is unnecessary
https://bugs.webkit.org/show_bug.cgi?id=108206
Summary Structure::m_outOfLineCapacity is unnecessary
Mark Hahnenberg
Reported 2013-01-29 10:59:58 PST
We can calculate our out of line capacity by using the outOfLineSize and our knowledge about our resize policy.
Attachments
Patch (6.02 KB, patch)
2013-01-29 11:16 PST, Mark Hahnenberg
no flags
Patch (7.53 KB, patch)
2013-01-29 12:41 PST, Mark Hahnenberg
no flags
Patch (7.65 KB, patch)
2013-01-29 13:19 PST, Mark Hahnenberg
no flags
Patch (7.58 KB, patch)
2013-01-29 13:30 PST, Mark Hahnenberg
no flags
Patch (7.57 KB, patch)
2013-01-29 18:42 PST, Mark Hahnenberg
no flags
Patch (2.28 KB, patch)
2013-01-30 18:33 PST, Mark Hahnenberg
no flags
Patch (3.06 KB, patch)
2013-02-04 10:28 PST, Mark Hahnenberg
darin: review+
Mark Hahnenberg
Comment 1 2013-01-29 11:16:24 PST
Geoffrey Garen
Comment 2 2013-01-29 11:25:37 PST
Comment on attachment 185273 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=185273&action=review r=me > Source/JavaScriptCore/runtime/Structure.h:187 > + unsigned sizeOutOfLine = outOfLineSize(); It's a pet peeve of mine when we invent two words for the same thing just to avoid compiler problems. I like to work around that issue by using "this->" instead of inventing a new name: unsigned outOfLineSize = this->outOfLineSize(); I'd suggest that technique here. > Source/JavaScriptCore/runtime/Structure.h:196 > + return round(pow(outOfLineGrowthFactor, ceil(log(sizeOutOfLine) / log(outOfLineGrowthFactor)))); This math looks expensive. Are we sure it's not hot? Since we're working with powers of two, there are probably good bit shifty ways to save here.
Mark Hahnenberg
Comment 3 2013-01-29 11:29:41 PST
> I'd suggest that technique here. Okiedokie. > > Source/JavaScriptCore/runtime/Structure.h:196 > > + return round(pow(outOfLineGrowthFactor, ceil(log(sizeOutOfLine) / log(outOfLineGrowthFactor)))); > > This math looks expensive. Are we sure it's not hot? Since we're working with powers of two, there are probably good bit shifty ways to save here. I thought about that, but there was nothing immediately available that I could see. WTF has roundUpToMultipleOf, but we need nextHighestPowerOfTwo or something. There's this guy here: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 , which I could add to StdLibExtras.h
Build Bot
Comment 4 2013-01-29 11:41:28 PST
Geoffrey Garen
Comment 5 2013-01-29 11:42:29 PST
> WTF has roundUpToMultipleOf, but we need nextHighestPowerOfTwo or something. There's this guy here: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 , which I could add to StdLibExtras.h Sure, let's do that, as template<size_t exponent> roundUpToPowerOf.
Mark Hahnenberg
Comment 6 2013-01-29 12:41:29 PST
Early Warning System Bot
Comment 7 2013-01-29 12:53:20 PST
Early Warning System Bot
Comment 8 2013-01-29 12:57:55 PST
Build Bot
Comment 9 2013-01-29 13:05:49 PST
Mark Hahnenberg
Comment 10 2013-01-29 13:19:23 PST
Early Warning System Bot
Comment 11 2013-01-29 13:27:11 PST
Mark Hahnenberg
Comment 12 2013-01-29 13:30:21 PST
Geoffrey Garen
Comment 13 2013-01-29 14:47:08 PST
Comment on attachment 185297 [details] Patch Let's add a compile assert vs runtime assert version here, and remove the slow path since it's unused, like we do for roundUpToMultipleOf.
Mark Hahnenberg
Comment 14 2013-01-29 18:42:34 PST
Sam Weinig
Comment 15 2013-01-29 22:36:38 PST
Comment on attachment 185372 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=185372&action=review > Source/WTF/wtf/MathExtras.h:451 > +#if USE(JSVALUE64) > + v |= v >> 32; > +#endif This doesn't seem like the right #ifdef for such a common header.
Mark Hahnenberg
Comment 16 2013-01-30 08:22:15 PST
(In reply to comment #15) > (From update of attachment 185372 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=185372&action=review > > > Source/WTF/wtf/MathExtras.h:451 > > +#if USE(JSVALUE64) > > + v |= v >> 32; > > +#endif > > This doesn't seem like the right #ifdef for such a common header. Is there another way to say "any 64-bit system"? I looked through Platform.h and it didn't seem like there was.
Geoffrey Garen
Comment 17 2013-01-30 11:30:54 PST
Let's use #if sizeof(size_t) == 8. This code is so low-level, that's probably more appropriate than any abstract #ifdef.
Geoffrey Garen
Comment 18 2013-01-30 11:31:04 PST
Comment on attachment 185372 [details] Patch r=me with that change
Mark Hahnenberg
Comment 19 2013-01-30 12:06:44 PST
Darin Adler
Comment 20 2013-01-30 17:45:08 PST
Comment on attachment 185372 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=185372&action=review >>> Source/WTF/wtf/MathExtras.h:451 >>> +#endif >> >> This doesn't seem like the right #ifdef for such a common header. > > Is there another way to say "any 64-bit system"? I looked through Platform.h and it didn't seem like there was. #if defined(__LP64__) && __LP64__ isn't right either. I think the right way to do this is to overload this function for both uint32_t and uint64_t rather than defining it for size_t.
Mark Hahnenberg
Comment 21 2013-01-30 18:29:40 PST
Reopening to address issues.
Mark Hahnenberg
Comment 22 2013-01-30 18:33:10 PST
Andreas Kling
Comment 23 2013-01-31 05:34:22 PST
This is awesome!
Geoffrey Garen
Comment 24 2013-01-31 14:11:42 PST
Comment on attachment 185651 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=185651&action=review r=me > Source/WTF/wtf/MathExtras.h:434 > +#define BITWISE_LOG2_32(v) \ This should just be an inline function.
Darin Adler
Comment 25 2013-01-31 19:11:44 PST
Comment on attachment 185651 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=185651&action=review I’m not sure of the value of implementing all these unused specializations of the template function. Currently we are using only the uint32_t version of roundUpToThePowerOf<2>, and I am not sure it’s good to have a super-slow implementation that is more general yet likely to never be useful anywhere. Seems unlikely we would actually want to use the version that converts to double in practice. I’d rather see a compile time error. That “be careful” comment is a sure giveaway we might not want this. >> Source/WTF/wtf/MathExtras.h:434 >> +#define BITWISE_LOG2_32(v) \ > > This should just be an inline function. It would have to be an inline function template, not just a function, to accommodate both integer types. I’m not sure you really want that. > Source/WTF/wtf/MathExtras.h:442 > +template<uint64_t exponent> inline uint64_t roundUpToPowerOf(uint64_t v) Why does the exponent need to be the same type as the number we are rounding? That’s a little strange.
Mark Hahnenberg
Comment 26 2013-02-04 10:28:53 PST
Darin Adler
Comment 27 2013-02-04 11:42:41 PST
Comment on attachment 186415 [details] Patch OK. But you could still have uses a template, and just not implement it for all those other powers and types at this time.
Mark Hahnenberg
Comment 28 2013-02-05 12:45:01 PST
Note You need to log in before you can comment on or make changes to this bug.