JavaScript shell should provide a way to examine string representation

RESOLVED FIXED in Firefox 39

Status

()

--
minor
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: jimb, Assigned: jimb)

Tracking

unspecified
mozilla39
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(firefox39 fixed)

Details

Attachments

(1 attachment)

(Assignee)

Description

4 years ago
Created attachment 8578927 [details] [diff] [review]
Implement DEBUG-only JS shell function |dumpStringRepresentation|.

This patch was helpful when I wanted to understand how string flattening and extensible strings worked.
Attachment #8578927 - Flags: review?(jdemooij)
Comment on attachment 8578927 [details] [diff] [review]
Implement DEBUG-only JS shell function |dumpStringRepresentation|.

Review of attachment 8578927 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/vm/String.cpp
@@ +159,5 @@
> +    fprintf(fp, "((%s *) %p) length: %zu  flags: 0x%x", subclass, this, length(), flags);
> +    if (flags & FLAT_BIT)               fputs(" FLAT", fp);
> +    if (flags & HAS_BASE_BIT)           fputs(" HAS_BASE", fp);
> +    if (flags & INLINE_CHARS_BIT)       fputs(" INLINE_CHARS", fp);
> +    if (flags & ATOM_BIT)               fputs(" ATOM", fp);

Ah, I was wondering why there's no JSAtom::dumpRepresentation, but this works just as well.

@@ +286,5 @@
>  
>      return true;
>  }
>  
> +#if DEBUG

Uber nit: #ifdef DEBUG for consistency with the rest of the file/patch.

@@ +631,5 @@
>             ? undependInternal<Latin1Char>(cx)
>             : undependInternal<char16_t>(cx);
>  }
>  
> +#if DEBUG

And here.

@@ +639,5 @@
> +    dumpRepresentationHeader(fp, indent, "JSDependentString");
> +    indent += 2;
> +
> +    fprintf(fp, "%*soffset: %zu\n", indent, "", baseOffset());
> +    fprintf(fp, "%*sbase: ", indent, "");

Nice, I didn't know this %*s trick.
Attachment #8578927 - Flags: review?(jdemooij) → review+
(Assignee)

Comment 2

4 years ago
Thanks for the review!

https://hg.mozilla.org/integration/mozilla-inbound/rev/d47928fa5fd9
Assignee: nobody → jimb
Flags: in-testsuite+
Target Milestone: --- → mozilla39
(Assignee)

Updated

4 years ago
Depends on: 1145429
https://hg.mozilla.org/mozilla-central/rev/d47928fa5fd9
Status: NEW → RESOLVED
Last Resolved: 4 years ago
status-firefox39: --- → fixed
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.