Make JSGCTraceKind a C++11 enum class

RESOLVED FIXED in Firefox 41

Status

()

Core
JavaScript: GC
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: terrence, Assigned: terrence)

Tracking

(Blocks: 1 bug)

Trunk
mozilla41
Points:
---

Firefox Tracking Flags

(firefox41 fixed)

Details

Attachments

(1 attachment)

(Assignee)

Description

3 years ago
Created attachment 8609089 [details] [diff] [review]
jstrace_kind_as_enum_class-v0.diff

This allows us to make the enum names the same as the display names, which allows us to use macro expansions in most of the places where we can't use DispatchTyped, saving us about 50 lines. Also, it looks nicer.

It's a pretty big patch, but it's 100% name change. Code removals are all in the form of ripping out switch guts in favor of macro expansions. Otherwise, you should be able to get away with a quick scan.
Attachment #8609089 - Flags: review?(jcoppeard)
Comment on attachment 8609089 [details] [diff] [review]
jstrace_kind_as_enum_class-v0.diff

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

::: js/public/TracingAPI.h
@@ +49,3 @@
>  
>      // A kind that indicates the real kind should be looked up in the arena.
> +    OutOfLine = 0x07,

I was wondering whether OutOfLine would be better as an external constant.  It's not a trace kind itself, and all uses are wrapped in uintptr_t() or equivalent.

Also we should probably have asserts that the out of line kinds below all have these bits set.
Attachment #8609089 - Flags: review?(jcoppeard) → review+
https://hg.mozilla.org/mozilla-central/rev/93320d4629be
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
status-firefox41: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
This change causes compilation errors in recent versions of gcc:
 0:19.89 In file included from /home/martin/code/obj/cert_mgmt/linux/js/src/jsapi-tests/Unified_cpp_js_src_jsapi-tests2.cpp:2:0:
 0:19.89 /home/martin/code/gecko-dev/js/src/jsapi-tests/testGCMarking.cpp: In member function ‘void CCWTestTracer::callback(void**, JS::TraceKind)’:
 0:19.89 /home/martin/code/gecko-dev/js/src/jsapi-tests/testGCMarking.cpp:21:43: error: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘JS::TraceKind’ [-Werror=format=]
 0:19.89          printf("kind         = %d\n", kind);
 0:19.89                                            ^
 0:19.89 /home/martin/code/gecko-dev/js/src/jsapi-tests/testGCMarking.cpp:22:51: error: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘JS::TraceKind’ [-Werror=format=]
 0:19.89          printf("expectedKind = %d\n", expectedKind);
 0:19.89                                                    ^
 0:19.89 cc1plus: all warnings being treated as errors
Forgot gcc --version:
gcc (GCC) 5.1.1 20150422 (Red Hat 5.1.1-1)
You need to log in before you can comment on or make changes to this bug.