Bug 97964 - Web Inspector: NMI make String* instrumentation non intrusive
Summary: Web Inspector: NMI make String* instrumentation non intrusive
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Ilya Tikhonovsky
URL:
Keywords:
Depends on: 98125
Blocks: 98500
  Show dependency treegraph
 
Reported: 2012-09-29 07:22 PDT by Ilya Tikhonovsky
Modified: 2012-10-05 01:58 PDT (History)
18 users (show)

See Also:


Attachments
Patch (22.15 KB, patch)
2012-09-29 07:27 PDT, Ilya Tikhonovsky
no flags Details | Formatted Diff | Diff
Patch (23.19 KB, patch)
2012-09-29 08:03 PDT, Ilya Tikhonovsky
no flags Details | Formatted Diff | Diff
fix for KURL (23.65 KB, patch)
2012-09-29 08:21 PDT, Ilya Tikhonovsky
no flags Details | Formatted Diff | Diff
comments addressed (25.86 KB, patch)
2012-10-01 02:57 PDT, Ilya Tikhonovsky
no flags Details | Formatted Diff | Diff
comments addressed (26.97 KB, patch)
2012-10-01 07:07 PDT, Ilya Tikhonovsky
no flags Details | Formatted Diff | Diff
usesInternalBuffer was renamed to hasInternalBuffer. hasOwnedBuffer was added. (26.92 KB, patch)
2012-10-01 08:19 PDT, Ilya Tikhonovsky
no flags Details | Formatted Diff | Diff
rebaselined. (27.25 KB, patch)
2012-10-01 09:00 PDT, Ilya Tikhonovsky
yurys: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ilya Tikhonovsky 2012-09-29 07:22:52 PDT
EOM
Comment 1 Ilya Tikhonovsky 2012-09-29 07:27:41 PDT
Created attachment 166361 [details]
Patch
Comment 2 Gyuyoung Kim 2012-09-29 07:40:02 PDT
Comment on attachment 166361 [details]
Patch

Attachment 166361 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/14084213
Comment 3 Early Warning System Bot 2012-09-29 07:45:15 PDT
Comment on attachment 166361 [details]
Patch

Attachment 166361 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/14091212
Comment 4 Early Warning System Bot 2012-09-29 07:49:52 PDT
Comment on attachment 166361 [details]
Patch

Attachment 166361 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/14078272
Comment 5 Build Bot 2012-09-29 07:56:04 PDT
Comment on attachment 166361 [details]
Patch

Attachment 166361 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/14074243
Comment 6 Build Bot 2012-09-29 07:56:32 PDT
Comment on attachment 166361 [details]
Patch

Attachment 166361 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/14079219
Comment 7 Ilya Tikhonovsky 2012-09-29 08:03:07 PDT
Created attachment 166362 [details]
Patch
Comment 8 Ilya Tikhonovsky 2012-09-29 08:21:42 PDT
Created attachment 166364 [details]
fix for KURL
Comment 9 Early Warning System Bot 2012-09-29 09:09:23 PDT
Comment on attachment 166364 [details]
fix for KURL

Attachment 166364 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/14088219
Comment 10 Gyuyoung Kim 2012-09-29 09:14:06 PDT
Comment on attachment 166364 [details]
fix for KURL

Attachment 166364 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/14081247
Comment 11 Early Warning System Bot 2012-09-29 09:28:52 PDT
Comment on attachment 166364 [details]
fix for KURL

Attachment 166364 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/14089236
Comment 12 Gyuyoung Kim 2012-09-29 09:49:44 PDT
Comment on attachment 166364 [details]
fix for KURL

Attachment 166364 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/14089246
Comment 13 Build Bot 2012-09-29 13:39:54 PDT
Comment on attachment 166364 [details]
fix for KURL

Attachment 166364 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/14078352

New failing tests:
svg/animations/smil-leak-dynamically-added-element-instances.svg
Comment 14 Yury Semikhatsky 2012-09-30 01:38:10 PDT
Comment on attachment 166364 [details]
fix for KURL

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

> Source/WTF/wtf/MemoryInstrumentation.h:34
> +#include <stdio.h>

Remove this.

> Source/WTF/wtf/MemoryInstrumentation.h:340
> +void reportMemoryUsage(const String* const&, MemoryObjectInfo*);

Please update comment at line 335

> Source/WTF/wtf/text/StringImpl.h:456
> +    bool usesInternalBuffer() const { return bufferOwnership() == BufferInternal && !hasTerminatingNullCharacter(); }

Why do you need !hasTerminatingNullCharacter() ?
Comment 15 Yury Semikhatsky 2012-09-30 23:57:49 PDT
Comment on attachment 166364 [details]
fix for KURL

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

> Source/WTF/wtf/MemoryInstrumentationString.h:46
> +    if (stringImpl->usesInternalBuffer() && !stringImpl->hasTerminatingNullCharacter())

It doesn't seem to work for BufferOwned type of character buffer ownership(everything created with StringImpl::adopt). Please fix that and provide a test for that case.

> Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp:277
>      }

Pleas add a test for substring and for a regular string without shadow.
Comment 16 Ilya Tikhonovsky 2012-10-01 02:57:49 PDT
Created attachment 166437 [details]
comments addressed
Comment 17 Yury Semikhatsky 2012-10-01 05:41:24 PDT
Comment on attachment 166437 [details]
comments addressed

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

> Source/WTF/wtf/MemoryInstrumentationString.h:46
> +    if (stringImpl->usesInternalBuffer() && !stringImpl->hasTerminatingNullCharacter())

BufferOwned case is still missing as well as test for that case, r- for that.
Comment 18 Ilya Tikhonovsky 2012-10-01 07:07:24 PDT
Created attachment 166470 [details]
comments addressed
Comment 19 Yury Semikhatsky 2012-10-01 07:41:37 PDT
Comment on attachment 166470 [details]
comments addressed

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

> Source/WTF/wtf/text/StringImpl.h:456
> +    bool usesInternalBuffer() const { return bufferOwnership() == BufferInternal && !hasTerminatingNullCharacter(); }

hasInternalBuffer ?
Comment 20 Ilya Tikhonovsky 2012-10-01 08:19:26 PDT
Created attachment 166477 [details]
usesInternalBuffer was renamed to hasInternalBuffer. hasOwnedBuffer was added.
Comment 21 Ilya Tikhonovsky 2012-10-01 09:00:59 PDT
Created attachment 166488 [details]
rebaselined.
Comment 22 Ilya Tikhonovsky 2012-10-02 00:44:40 PDT
Committed r130129: <http://trac.webkit.org/changeset/130129>
Comment 23 WebKit Review Bot 2012-10-02 01:22:25 PDT
Re-opened since this is blocked by bug 98125
Comment 24 Ilya Tikhonovsky 2012-10-02 02:43:30 PDT
Committed r130144: <http://trac.webkit.org/changeset/130144>
Comment 25 Benjamin Poulain 2012-10-04 17:49:45 PDT
Comment on attachment 166488 [details]
rebaselined.

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

> Source/WTF/wtf/MemoryInstrumentationString.h:47
> +    if (stringImpl->hasInternalBuffer())

This looks incorrect. StringImpl::createWithTerminatingNullCharacter() create strings with the same conditions as hasInternalBuffer().

> Source/WTF/wtf/MemoryInstrumentationString.h:59
> +                info.addRawBuffer(stringImpl->characters16(), stringImpl->length() * 2);

* 2, really?
Comment 26 Ilya Tikhonovsky 2012-10-04 22:34:37 PDT
Comment on attachment 166488 [details]
rebaselined.

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

>> Source/WTF/wtf/MemoryInstrumentationString.h:47
>> +    if (stringImpl->hasInternalBuffer())
> 
> This looks incorrect. StringImpl::createWithTerminatingNullCharacter() create strings with the same conditions as hasInternalBuffer().

Good point. Looks like in these two cases, construct from literal and create with terminating null character, we can't decide is the string uses internal buffer or not, and can't report correct physical size of the memory object.
The only way is to check that the buffer address equal to stringimpl address + sizeof(StringImpl).

>> Source/WTF/wtf/MemoryInstrumentationString.h:59
>> +                info.addRawBuffer(stringImpl->characters16(), stringImpl->length() * 2);
> 
> * 2, really?

why not?  we are calculating the size of buffer in bytes and this is 16-bit per symbol string.
Comment 27 Benjamin Poulain 2012-10-04 22:39:33 PDT
> The only way is to check that the buffer address equal to stringimpl address + sizeof(StringImpl).

Exactly (and that's cheaper to compute too) :)

> >> +                info.addRawBuffer(stringImpl->characters16(), stringImpl->length() * 2);
> > 
> > * 2, really?
> 
> why not?  we are calculating the size of buffer in bytes and this is 16-bit per symbol string.

Typically in WebKit, we don't use magic numbers. In this case, one would use sizeof(UChar).
Comment 28 Ilya Tikhonovsky 2012-10-05 00:18:58 PDT
(In reply to comment #27)
> > The only way is to check that the buffer address equal to stringimpl address + sizeof(StringImpl).
> 
> Exactly (and that's cheaper to compute too) :)
> 
> > >> +                info.addRawBuffer(stringImpl->characters16(), stringImpl->length() * 2);
> > > 
> > > * 2, really?
> > 
> > why not?  we are calculating the size of buffer in bytes and this is 16-bit per symbol string.
> 
> Typically in WebKit, we don't use magic numbers. In this case, one would use sizeof(UChar).

yep. my fault.