Closed Bug 1144371 Opened 9 years ago Closed 9 years ago

JavaScript shell should provide a way to examine string representation

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: jimb, Assigned: jimb)

References

Details

Attachments

(1 file)

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+
Thanks for the review!

https://hg.mozilla.org/integration/mozilla-inbound/rev/d47928fa5fd9
Assignee: nobody → jimb
Flags: in-testsuite+
Target Milestone: --- → mozilla39
Depends on: 1145429
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: