Bug 159549 - Move CallFrame header info from JSStack.h to CallFrame.h
Summary: Move CallFrame header info from JSStack.h to CallFrame.h
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords:
Depends on:
Blocks: 159545
  Show dependency treegraph
 
Reported: 2016-07-08 00:26 PDT by Mark Lam
Modified: 2016-07-08 15:59 PDT (History)
7 users (show)

See Also:


Attachments
proposed patch. (132.75 KB, patch)
2016-07-08 01:08 PDT, Mark Lam
mark.lam: review-
Details | Formatted Diff | Diff
proposed patch. (136.75 KB, patch)
2016-07-08 10:03 PDT, Mark Lam
ggaren: review+
Details | Formatted Diff | Diff
revised patch with Geoff's feedback. (136.75 KB, patch)
2016-07-08 14:57 PDT, Mark Lam
no flags Details | Formatted Diff | Diff
Patch for landing. (136.79 KB, patch)
2016-07-08 15:50 PDT, Mark Lam
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Lam 2016-07-08 00:26:30 PDT
... because CallFrame.h is the more appropriate place for the CallFrameHeader info.
Comment 1 Mark Lam 2016-07-08 01:08:46 PDT
Created attachment 283119 [details]
proposed patch.
Comment 2 WebKit Commit Bot 2016-07-08 01:09:59 PDT
Attachment 283119 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/jit/CallFrameShuffler.cpp:43:  Code inside a namespace should not be indented.  [whitespace/indent] [4]
Total errors found: 1 in 58 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Mark Lam 2016-07-08 07:23:06 PDT
Comment on attachment 283119 [details]
proposed patch.

Let me fix the build error on the debug build first.
Comment 4 Mark Lam 2016-07-08 10:03:21 PDT
Created attachment 283180 [details]
proposed patch.
Comment 5 WebKit Commit Bot 2016-07-08 10:05:07 PDT
Attachment 283180 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/jit/CallFrameShuffler.cpp:43:  Code inside a namespace should not be indented.  [whitespace/indent] [4]
Total errors found: 1 in 59 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Geoffrey Garen 2016-07-08 10:41:29 PDT
Comment on attachment 283180 [details]
proposed patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=283180&action=review

> Source/JavaScriptCore/interpreter/CallFrame.h:74
> +    struct CallFrameHeader {
> +        enum Entry {

This is odd C++ style.

The idiomatic way to namespace an enum is "enum class".

The idiomatic equivalent for what you've done is "enum class CallFrameHeaderEntry". I think that's probably better.

"CallFrameHeaderEntry" a bit long, so maybe just "CallFrameSlot" instead. I'm not sure any clients care that these values form a header, and in fact they're not quite a header since more data (function arguments) lies beyond them.
Comment 7 Mark Lam 2016-07-08 10:50:02 PDT
(In reply to comment #6)
> Comment on attachment 283180 [details]
> proposed patch.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=283180&action=review
> 
> > Source/JavaScriptCore/interpreter/CallFrame.h:74
> > +    struct CallFrameHeader {
> > +        enum Entry {
> 
> This is odd C++ style.
> 
> The idiomatic way to namespace an enum is "enum class".
> 
> The idiomatic equivalent for what you've done is "enum class
> CallFrameHeaderEntry". I think that's probably better.
> 
> "CallFrameHeaderEntry" a bit long, so maybe just "CallFrameSlot" instead.
> I'm not sure any clients care that these values form a header, and in fact
> they're not quite a header since more data (function arguments) lies beyond
> them.

I wanted to use an enum class at first, but that resulted in the enum values not being accepted as int values every where they are used.  For example, indexing with [CallFrameHeader::Callee] will yield an error saying that the indexing value, CallFrameHeader::Callee, is not an int.

I have already tried all of these:
    enum class CallFrameEntry { ...
    enum class CallFrameEntry : int { ...
    enum class CallFrameEntry : int {
        CallerFrameAndPCSize = ...
        CodeBlock = CallerFrameAndPCSize,
        Callee = CodeBlock + 1,
        ...

All of them did not resolve the error.  Hence, I fell back on how the pattern which we used previously i.e. an enum inside a class so that the class provides scoping for the enum while the enum values still int type.

As for the name of the class/struct, I'm not that comfortable with CallFrameHeader either given that it is more so a container for CallFrameConstants.  I kept CallFrameHeader to retain the legacy reference to what this values are for, but am open to changing it.

In light of enum class being not a viable solution, what do you propose I do?
Comment 8 Geoffrey Garen 2016-07-08 11:52:16 PDT
> I wanted to use an enum class at first, but that resulted in the enum values
> not being accepted as int values every where they are used.

That's right. enum class is type-safe, so you need to cast or invoke the int constructor to turn it into an int. Will casting work? I think it will.

It looks like our APIs that currently accept JSStack::CallFrameHeaderEntry are reasonably encapsulated, so they can do the casting for us.
Comment 9 Mark Lam 2016-07-08 14:57:46 PDT
Created attachment 283200 [details]
revised patch with Geoff's feedback.

After talking with Geoff offline, we decided to go with static const int fields. This has been applied to the revised patch.
Comment 10 WebKit Commit Bot 2016-07-08 14:59:22 PDT
Attachment 283200 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/jit/CallFrameShuffler.cpp:43:  Code inside a namespace should not be indented.  [whitespace/indent] [4]
Total errors found: 1 in 59 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 11 Mark Lam 2016-07-08 15:50:41 PDT
Created attachment 283208 [details]
Patch for landing.
Comment 12 WebKit Commit Bot 2016-07-08 15:53:15 PDT
Attachment 283208 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/jit/CallFrameShuffler.cpp:43:  Code inside a namespace should not be indented.  [whitespace/indent] [4]
Total errors found: 1 in 59 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Mark Lam 2016-07-08 15:59:33 PDT
Landed in r203006: <http://trac.webkit.org/r203006>.