Bug 71135 - Pack RenderTableCell bits
Summary: Pack RenderTableCell bits
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tables (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Julien Chaffraix
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-28 13:18 PDT by Julien Chaffraix
Modified: 2011-11-01 18:12 PDT (History)
5 users (show)

See Also:


Attachments
Proposed packing. Added some unit tests to cover the limit cases. (9.21 KB, patch)
2011-10-28 13:32 PDT, Julien Chaffraix
no flags Details | Formatted Diff | Diff
Updated test after Dave's comments. (9.70 KB, patch)
2011-10-28 15:34 PDT, Julien Chaffraix
no flags Details | Formatted Diff | Diff
Oupsy, DeathTest is for the class name not the individual methods. (9.73 KB, patch)
2011-10-28 15:57 PDT, Julien Chaffraix
no flags Details | Formatted Diff | Diff
Don't repeat Test in the class name. (9.70 KB, patch)
2011-10-28 18:21 PDT, Julien Chaffraix
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Julien Chaffraix 2011-10-28 13:18:34 PDT
Following bug 69569, RenderTableCell has 2 bit fields that are not packed and thus use the size of an integer.

After bug 70369, m_col and m_rows are using unsigned and thus the signed bit can be used to pack the 2 previous bits.

Patch forthcoming.
Comment 1 Julien Chaffraix 2011-10-28 13:32:52 PDT
Created attachment 112901 [details]
Proposed packing. Added some unit tests to cover the limit cases.
Comment 2 David Levin 2011-10-28 13:48:56 PDT
Comment on attachment 112901 [details]
Proposed packing. Added some unit tests to cover the limit cases.

View in context: https://bugs.webkit.org/attachment.cgi?id=112901&action=review

The test part looks fine to me with a few minor changes and one question about test location.

> Source/WebKit/chromium/tests/RenderTableCellTest.cpp:2
> + * Copyright (C) 2011 Google Inc. All rights reserved.

Why is this in the chromium test directory instead of "Tools/TestWebKitAPI/Tests/" and then run for WebKit in general?

> Source/WebKit/chromium/tests/RenderTableCellTest.cpp:92
> +TEST_F(RenderTableCellTest, CanSetRow)

The test case name should end with DeathTest (instead of just Test) for death test (see http://code.google.com/p/googletest/wiki/AdvancedGuide#Death_Tests_And_Threads for more background on this).

Ditto for other places below.

> Source/WebKit/chromium/tests/RenderTableCellTest.cpp:101
> +    ASSERT_DEATH(m_cell->setCol(maxColumnIndex + 1), "");

Seems odd to test "maxColumnIndex + 1" and not maxColumnIndex but I think I understand why.
Comment 3 Julien Chaffraix 2011-10-28 14:05:17 PDT
Comment on attachment 112901 [details]
Proposed packing. Added some unit tests to cover the limit cases.

View in context: https://bugs.webkit.org/attachment.cgi?id=112901&action=review

>> Source/WebKit/chromium/tests/RenderTableCellTest.cpp:2
>> + * Copyright (C) 2011 Google Inc. All rights reserved.
> 
> Why is this in the chromium test directory instead of "Tools/TestWebKitAPI/Tests/" and then run for WebKit in general?

I assumed that as the name implies, this is an API testing directory. Thus testing some WebCore internal field would not feel at home there.

After checking, I can see that WTF has a directory there but most of code is very tied to a platform. I don't mind moving the code in Tools/TestWebKitAPI but it looks like we will need to introduce some more boiler-plate code to get the test running (maybe using some EmptyClients would help). I don't mind either way.

>> Source/WebKit/chromium/tests/RenderTableCellTest.cpp:92
>> +TEST_F(RenderTableCellTest, CanSetRow)
> 
> The test case name should end with DeathTest (instead of just Test) for death test (see http://code.google.com/p/googletest/wiki/AdvancedGuide#Death_Tests_And_Threads for more background on this).
> 
> Ditto for other places below.

Thanks, it looks like it would help the test.

>> Source/WebKit/chromium/tests/RenderTableCellTest.cpp:101
>> +    ASSERT_DEATH(m_cell->setCol(maxColumnIndex + 1), "");
> 
> Seems odd to test "maxColumnIndex + 1" and not maxColumnIndex but I think I understand why.

That's a good point. maxColumnIndex is our boundary so we could test both (making sure maxColumnIndex works as intended too).
Comment 4 David Levin 2011-10-28 14:09:09 PDT
(In reply to comment #3)
> (From update of attachment 112901 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=112901&action=review
> 
> >> Source/WebKit/chromium/tests/RenderTableCellTest.cpp:2
> >> + * Copyright (C) 2011 Google Inc. All rights reserved.
> > 
> > Why is this in the chromium test directory instead of "Tools/TestWebKitAPI/Tests/" and then run for WebKit in general?
> 
> I assumed that as the name implies, this is an API testing directory. Thus testing some WebCore internal field would not feel at home there.
> 
> After checking, I can see that WTF has a directory there but most of code is very tied to a platform. I don't mind moving the code in Tools/TestWebKitAPI.

It started out as a WebKitAPI test, but now it is basically the unit test directory.

Just no one has added a WebCore test yet.

> but it looks like we will need to introduce some more boiler-plate code to get the test running (maybe using some EmptyClients would help). I don't mind either way.

I don't want to cause you to have to write a lot of other stuff. If there isn't a good way to do this right now (due to missing a Client or other stuff usually supplied by the WebKit dir), then leaving it at the chromium level is ok.
Comment 5 Julien Chaffraix 2011-10-28 15:25:10 PDT
> > After checking, I can see that WTF has a directory there but most of code is very tied to a platform. I don't mind moving the code in Tools/TestWebKitAPI.
> 
> It started out as a WebKitAPI test, but now it is basically the unit test directory.
> 
> Just no one has added a WebCore test yet.

It makes sense.

> > but it looks like we will need to introduce some more boiler-plate code to get the test running (maybe using some EmptyClients would help). I don't mind either way.
> 
> I don't want to cause you to have to write a lot of other stuff. If there isn't a good way to do this right now (due to missing a Client or other stuff usually supplied by the WebKit dir), then leaving it at the chromium level is ok.

So here is the state. I tried to add a cross-platform version of the test that would use the EmptyClients. I am having some crashes on Chromium which means this is not really a designed way to handle that. There is also WebKit2 which would likely not play nicely with the experiment...

It's unfortunate but I think I will stick with a Chromium-only version of the test.
Comment 6 Julien Chaffraix 2011-10-28 15:34:13 PDT
Created attachment 112924 [details]
Updated test after Dave's comments.
Comment 7 Julien Chaffraix 2011-10-28 15:57:00 PDT
Created attachment 112930 [details]
Oupsy, DeathTest is for the class name not the individual methods.
Comment 8 Julien Chaffraix 2011-10-28 18:21:05 PDT
Created attachment 112957 [details]
Don't repeat Test in the class name.
Comment 9 Darin Adler 2011-10-29 08:44:26 PDT
Comment on attachment 112957 [details]
Don't repeat Test in the class name.

View in context: https://bugs.webkit.org/attachment.cgi?id=112957&action=review

> Source/WebCore/ChangeLog:23
> +        (the limit is currently above 2 billions rows or columns
> +        which is high enough to prevent it being hit by accident)

I don’t understand. Whether on purpose or by accident, how can you hit this? Can we make a test case?
Comment 10 Darin Adler 2011-10-29 08:45:02 PDT
Comment on attachment 112957 [details]
Don't repeat Test in the class name.

View in context: https://bugs.webkit.org/attachment.cgi?id=112957&action=review

>> Source/WebCore/ChangeLog:23
>> +        which is high enough to prevent it being hit by accident)
> 
> I don’t understand. Whether on purpose or by accident, how can you hit this? Can we make a test case?

I mean a markup and JavaScript test case. Clearly we do have a unit test test case.
Comment 11 Julien Chaffraix 2011-10-29 17:39:02 PDT
Comment on attachment 112957 [details]
Don't repeat Test in the class name.

View in context: https://bugs.webkit.org/attachment.cgi?id=112957&action=review

>>> Source/WebCore/ChangeLog:23
>>> +        which is high enough to prevent it being hit by accident)
>> 
>> I don’t understand. Whether on purpose or by accident, how can you hit this? Can we make a test case?
> 
> I mean a markup and JavaScript test case. Clearly we do have a unit test test case.

The only way that I know to hit the limit is to generate a table with 2 billions+ rows or columns (either through markup or through JS).

Although it is possible for us to have such a table test, it will likely be too slow to be practical. I will double check on Monday exactly how slow it is.
Comment 12 Julien Chaffraix 2011-11-01 16:14:43 PDT
Comment on attachment 112957 [details]
Don't repeat Test in the class name.

View in context: https://bugs.webkit.org/attachment.cgi?id=112957&action=review

>>>> Source/WebCore/ChangeLog:23
>>>> +        which is high enough to prevent it being hit by accident)
>>> 
>>> I don’t understand. Whether on purpose or by accident, how can you hit this? Can we make a test case?
>> 
>> I mean a markup and JavaScript test case. Clearly we do have a unit test test case.
> 
> The only way that I know to hit the limit is to generate a table with 2 billions+ rows or columns (either through markup or through JS).
> 
> Although it is possible for us to have such a table test, it will likely be too slow to be practical. I will double check on Monday exactly how slow it is.

Following up, V8 seems to be running out of memory on the test case before we even reach the limit. It is also painfully slow (several minutes) so not suitable for a LayoutTests. Let me know if you are satisfied with the investigation / answer, Darin.
Comment 13 Julien Chaffraix 2011-11-01 17:08:13 PDT
Comment on attachment 112957 [details]
Don't repeat Test in the class name.

View in context: https://bugs.webkit.org/attachment.cgi?id=112957&action=review

>>>>> Source/WebCore/ChangeLog:23
>>>>> +        which is high enough to prevent it being hit by accident)
>>>> 
>>>> I don’t understand. Whether on purpose or by accident, how can you hit this? Can we make a test case?
>>> 
>>> I mean a markup and JavaScript test case. Clearly we do have a unit test test case.
>> 
>> The only way that I know to hit the limit is to generate a table with 2 billions+ rows or columns (either through markup or through JS).
>> 
>> Although it is possible for us to have such a table test, it will likely be too slow to be practical. I will double check on Monday exactly how slow it is.
> 
> Following up, V8 seems to be running out of memory on the test case before we even reach the limit. It is also painfully slow (several minutes) so not suitable for a LayoutTests. Let me know if you are satisfied with the investigation / answer, Darin.

I take the r+ for a yes. :-)

Thanks Darin!
Comment 14 Darin Adler 2011-11-01 17:13:15 PDT
(In reply to comment #13)
> > Following up, V8 seems to be running out of memory on the test case before we even reach the limit. It is also painfully slow (several minutes) so not suitable for a LayoutTests. Let me know if you are satisfied with the investigation / answer, Darin.
> 
> I take the r+ for a yes. :-)

If this truly is unreachable code, it’s OK to have the CRASH() in there, but maybe not necessary. It might be worth thinking a little more on how this kind of thing should be handled in WebKit.
Comment 15 Julien Chaffraix 2011-11-01 17:54:19 PDT
(In reply to comment #14)
> (In reply to comment #13)
> > > Following up, V8 seems to be running out of memory on the test case before we even reach the limit. It is also painfully slow (several minutes) so not suitable for a LayoutTests. Let me know if you are satisfied with the investigation / answer, Darin.
> > 
> > I take the r+ for a yes. :-)
> 
> If this truly is unreachable code, it’s OK to have the CRASH() in there, but maybe not necessary.

The current limit makes it extremely unlikely to be reached but not theoretically impossible. IMHO it would be a source of badness if it is reached thus the CRASH makes sense in this corner case.

> It might be worth thinking a little more on how this kind of thing should be handled in WebKit.

It would be terrific for any contributors if we could come up with some strategy or loose rules. It is also a broader issue. I would rather follow up on that in another bug or just on webkit-dev as it requires some investigations on what we are currently doing (or not doing) and more discussion.
Comment 16 WebKit Review Bot 2011-11-01 18:12:17 PDT
Comment on attachment 112957 [details]
Don't repeat Test in the class name.

Clearing flags on attachment: 112957

Committed r99020: <http://trac.webkit.org/changeset/99020>
Comment 17 WebKit Review Bot 2011-11-01 18:12:22 PDT
All reviewed patches have been landed.  Closing bug.