Open Bug 1271654 Opened 8 years ago Updated 2 years ago

Implement a C++ interface for Debugger.Script instances.

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

Iteration:
50.4 - Aug 1

People

(Reporter: ejpbruel, Assigned: jimb)

References

(Blocks 2 open bugs)

Details

Attachments

(11 files, 1 obsolete file)

12.06 KB, patch
jimb
: review+
Details | Diff | Splinter Review
1.11 KB, patch
jimb
: review+
Details | Diff | Splinter Review
5.23 KB, patch
jimb
: review+
Details | Diff | Splinter Review
4.08 KB, patch
jimb
: review+
Details | Diff | Splinter Review
3.95 KB, patch
jimb
: review+
Details | Diff | Splinter Review
13.58 KB, patch
jimb
: review+
Details | Diff | Splinter Review
11.92 KB, patch
jimb
: review+
Details | Diff | Splinter Review
4.37 KB, patch
jimb
: review+
Details | Diff | Splinter Review
4.45 KB, patch
jimb
: review+
Details | Diff | Splinter Review
5.08 KB, patch
jimb
: review+
Details | Diff | Splinter Review
6.31 KB, patch
jimb
: review-
Details | Diff | Splinter Review
This bug is part of the effort to implement a C++ interface for the debugger API. See the parent bug 1271641 for more context.
Whiteboard: [devtools-html] [triage]
Blocks: 1263289
Flags: qe-verify-
Priority: -- → P2
Whiteboard: [devtools-html] [triage] → [devtools-html]
No longer blocks: 1263289
Blocks: 1263289
Attachment #8770488 - Flags: review?(jimb)
Assignee: nobody → ejpbruel
Hi Jim. I know we should be reluctant about changing the semantics of the debugger API in this patch series, but if I'm right, this patch just removes redundant code.

The displayName of a JSFunction is a JSAtom. According to jandem, because all atoms live in the same zone, they don't have to be copied by a call to cx->compartment()->wrap (unlike JSStrings, which can live in different zones).

There is precedent for this change too: we already don't wrap the result in DebuggerObject::displayName, which accesses the same property.

All in all, the change seems small enough to me that it's ok to land this in a separate patch. Let me know if you agree.
Attachment #8770490 - Flags: review?(jimb)
Status: NEW → ASSIGNED
Iteration: --- → 50.3 - Jul 18
Priority: P2 → P1
Attachment #8770490 - Flags: review?(jimb) → review+
Comment on attachment 8770488 [details] [diff] [review]
Implement a DebuggerScript class.

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

Looks good.

::: js/src/vm/Debugger.cpp
@@ +5122,5 @@
>  
>  /*** Debugger.Script *****************************************************************************/
>  
> +/* static */ NativeObject*
> +DebuggerScript::initClass(JSContext* cx, HandleObject debugCtor, HandleObject obj)

Couldn't this return a DebuggerScript*? The prototype does use the right class.

@@ +5137,5 @@
> +
> +    return scriptProto;
> +}
> +
> +class DebuggerScriptSetPrivateMatcher

If we made this class private to DebuggerScript, it might make things a little less verbose. You'd put:

    class SetPrivateMatcher;

inside the definition of class DebuggerScript in Debugger.h, change this to

    class DebuggerScript::SetPrivateMatcher { ... };

and then change DebuggerScript::create to just say:

    SetPrivateMatcher matcher(&script);

Just a suggestion.
Attachment #8770488 - Flags: review?(jimb) → review+
Iteration: 50.3 - Jul 18 → 50.4 - Aug 1
Whiteboard: [devtools-html]
Fixed a minor (and rather daft) bug in this patch.
Attachment #8815389 - Attachment is obsolete: true
Attachment #8815389 - Flags: review?(jimb)
Attachment #8815684 - Flags: review?(jimb)
Note that this patch depends on the patch in bug 1271655.
Attachment #8815704 - Flags: review?(jimb)
Comment on attachment 8815391 [details] [diff] [review]
Implement a C++ interface for DebuggerScript.url.

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

::: js/src/vm/Debugger.cpp
@@ +5560,3 @@
>  
> +    if (!DebuggerScript::requireScript(cx, script))
> +        return false;

Okay, now I see that the displayName patch introduces THIS_DEBUGGER_SCRIPT and DebuggerScript::requireScript, so I'll review that first.
Comment on attachment 8815684 [details] [diff] [review]
Implement a C++ interface for DebuggerScript.displayName (v2).

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

Okay, skipping the wrap makes sense to me. I like the requireScript check, better than the existing DebuggerScript_checkThis.
Attachment #8815684 - Flags: review?(jimb) → review+
To be useful as a C++ API, DebuggerScript will need `isJavaScript` and `isWasm` methods.
Attachment #8815391 - Flags: review?(jimb) → review+
Comment on attachment 8815393 [details] [diff] [review]
Implement a C++ interface for DebuggerScript.startLine.

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

::: js/src/vm/Debugger.cpp
@@ +5585,5 @@
> +
> +    if (!DebuggerScript::requireScript(cx, script))
> +        return false;
> +
> +    args.rval().setNumber(uint32_t(script->startLine()));

This cast doesn't do anything, does it?
Attachment #8815393 - Flags: review?(jimb) → review+
Comment on attachment 8815394 [details] [diff] [review]
Implement a C++ interface for DebuggerScript.lineCount.

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

::: js/src/vm/Debugger.cpp
@@ +5606,2 @@
>  
> +    args.rval().setNumber(uint32_t(script->lineCount()));

This cast doesn't do anything, that I can see.
Attachment #8815394 - Flags: review?(jimb) → review+
Attachment #8815704 - Flags: review?(jimb) → review+
Attachment #8815706 - Flags: review?(jimb) → review+
Attachment #8815710 - Flags: review?(jimb) → review+
Attachment #8816111 - Flags: review?(jimb) → review+
Comment on attachment 8816112 [details] [diff] [review]
Implement a C++ interface for DebuggerScript.format.

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

::: js/src/vm/Debugger.cpp
@@ +5737,5 @@
>  
> +    JSString* str;
> +    switch (script->format()) {
> +      case DebuggerScriptFormat::JS:
> +        str = cx->names().js; 

Space at end of line.

@@ +6814,5 @@
>      JS_PSG("source", DebuggerScript::sourceGetter, 0),
>      JS_PSG("sourceStart", DebuggerScript::sourceStartGetter, 0),
>      JS_PSG("sourceLength", DebuggerScript::sourceLengthGetter, 0),
>      JS_PSG("global", DebuggerScript::globalGetter, 0),
> +    JS_PSG("format", DebuggerScript::formatGetter, 0),

This is a new JS-visible API, so it needs tests and documentation.

::: js/src/vm/Debugger.h
@@ +1552,5 @@
>      static MOZ_MUST_USE bool getErrorReport(JSContext* cx, HandleObject maybeError,
>                                              JSErrorReport*& report);
>  };
>  
> +enum class DebuggerScriptFormat {

Make this a public member type, DebuggerScript::Format?
Attachment #8816112 - Flags: review?(jimb) → review-
Assignee: ejpbruel → nobody
Status: ASSIGNED → NEW
I'm going to work on getting this landed.
Assignee: nobody → jimb
Priority: P1 → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: