Last Comment Bug 683862 - Using JSGCTraceKind in the public API
: Using JSGCTraceKind in the public API
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Trunk
: All All
: -- normal (vote)
: mozilla9
Assigned To: Igor Bukanov
: Jason Orendorff [:jorendorff]
Depends on: 674251
  Show dependency treegraph
Reported: 2011-09-01 03:43 PDT by Igor Bukanov
Modified: 2011-09-02 08:34 PDT (History)
19 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

v1 (24.19 KB, patch)
2011-09-01 07:47 PDT, Igor Bukanov
luke: review+
Details | Diff | Splinter Review

Description Igor Bukanov 2011-09-01 03:43:36 PDT
In the bug 674251 I have added JSGCTraceKind enumeration to type the GC tracing constants. This way, when we add a new tracing kind, a compiler at least can warn about missing cases in various switches over these kinds. It also provided better debugging experience and allowed to eliminate few redundant JS_ASSERT(kind < JSTRACE_LIMIT) asserts delegating those to the compiler. 

However, in the patch I have not touched the public API. The various GC-tracing related functions continue to take untyped unsigned parameter. I suppose we should fix those as well.
Comment 1 Igor Bukanov 2011-09-01 07:47:36 PDT
Created attachment 557496 [details] [diff] [review]

The patch replaces uint32 with JSGCTraceKind in all pubic API calls.
Comment 2 Luke Wagner [:luke] 2011-09-01 08:21:50 PDT
Comment on attachment 557496 [details] [diff] [review]

Review of attachment 557496 [details] [diff] [review]:

::: js/src/jsapi.h
@@ +1644,5 @@
>  {
>      jsval_layout l;
>      l.asBits = JSVAL_BITS(v);
> +    return (JSGCTraceKind) JSVAL_TRACE_KIND_IMPL(l);

Can you change the return type of JSVAL_TRACE_KIND_IMPL instead?
Comment 3 Igor Bukanov 2011-09-01 08:26:31 PDT
(In reply to Luke Wagner [:luke] from comment #2)
> > +    return (JSGCTraceKind) JSVAL_TRACE_KIND_IMPL(l);
> Can you change the return type of JSVAL_TRACE_KIND_IMPL instead?

That does not work as jsval.h is included even before jspubtd.h and JSVAL_TRACE_KIND_IMPL is an inline function, not a macro. So to avoid defining the enum in jsval.h I left the type as uint32 and cast it in jsapi.h
Comment 4 Luke Wagner [:luke] 2011-09-01 08:27:03 PDT
Fair enough.

Note You need to log in before you can comment on or make changes to this bug.