Bug 123956 - Change CallFrameRegister to architected frame pointer register
Summary: Change CallFrameRegister to architected frame pointer register
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Michael Saboff
URL:
Keywords:
Depends on:
Blocks: 116888
  Show dependency treegraph
 
Reported: 2013-11-06 22:23 PST by Michael Saboff
Modified: 2013-11-07 15:44 PST (History)
1 user (show)

See Also:


Attachments
Patch (17.34 KB, patch)
2013-11-06 22:49 PST, Michael Saboff
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Saboff 2013-11-06 22:23:45 PST
This is part of moving to the C++ stack.
Comment 1 Michael Saboff 2013-11-06 22:49:29 PST
Created attachment 216260 [details]
Patch
Comment 2 Filip Pizlo 2013-11-06 23:05:58 PST
Comment on attachment 216260 [details]
Patch

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

> Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:166
> +    if (MacroAssembler::framePointerRegister == GPRInfo::callFrameRegister)
> +        jit.pop(GPRInfo::regT3); // ignore prior framePointer
> +    else
> +        jit.pop(MacroAssembler::framePointerRegister);

Why is this an 'if' statement?  Isn't it always true after your patch?
Comment 3 Michael Saboff 2013-11-06 23:16:52 PST
(In reply to comment #2)
> (From update of attachment 216260 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=216260&action=review
> 
> > Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:166
> > +    if (MacroAssembler::framePointerRegister == GPRInfo::callFrameRegister)
> > +        jit.pop(GPRInfo::regT3); // ignore prior framePointer
> > +    else
> > +        jit.pop(MacroAssembler::framePointerRegister);
> 
> Why is this an 'if' statement?  Isn't it always true after your patch?

It isn't needed, but I thought it would be helpful for debugging if one wants to change the register assignments.  Also, MacroAssembler::framePointerRegister and GPRInfo::callFrameRegister are different names.  If you like, I can change this to a RELEASE_ASSERT.
Comment 4 Geoffrey Garen 2013-11-07 10:33:10 PST
> If you like, I can change this to a RELEASE_ASSERT.

static_assert is even better for something like this, since the two sides are both constants.
Comment 5 Geoffrey Garen 2013-11-07 11:46:36 PST
Comment on attachment 216260 [details]
Patch

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

You mentioned that this patch broke the debugger in some way. Did you get to the bottom of that? Do we need a bug about that?

r=me, with some fixups below.

> Source/JavaScriptCore/ChangeLog:8
> +        Changed X86 and ARM variants as well as MIPS to use their respective arcitected

Should be "architected" or "architectures'".

> Source/JavaScriptCore/ChangeLog:9
> +        frame pointer register.  For X86, this freed up another register as a temp or for

Should be "frame pointer registers".

As a temp for what? Baseline JIT? Did you start using that register somewhere?

> Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:80
> +    // Restore the callFrame value into a temp, as the framePointerRegister may be the callFrameRegister
> +    // Below we use the temp register when accessing the destination call frame.

There are two problems with this comment.

(1) You say "may be" when you mean "I have been working for months to ensure that this is definitely so, and many levels of our architecture rely on it being so". When you say "may" it implies that sometimes this many not be the case, and it's the reader's job to worry about the times when it's not the case. Very confusing.

(2) Your comment explains why you changed from the old code to the new code, and it makes sense in the context of a diff that shows you removing the old code that used callFrameRegister. However, it won't make any sense to a future programmer, who only sees the new code.

I think this comment should just say "regT4 points to the exiting function's call frame".

>>> Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:166
>>> +        jit.pop(MacroAssembler::framePointerRegister);
>> 
>> Why is this an 'if' statement?  Isn't it always true after your patch?
> 
> It isn't needed, but I thought it would be helpful for debugging if one wants to change the register assignments.  Also, MacroAssembler::framePointerRegister and GPRInfo::callFrameRegister are different names.  If you like, I can change this to a RELEASE_ASSERT.

static_assert, please.
Comment 6 Michael Saboff 2013-11-07 15:43:21 PST
(In reply to comment #5)
> (From update of attachment 216260 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=216260&action=review
> 
> You mentioned that this patch broke the debugger in some way. Did you get to the bottom of that? Do we need a bug about that?

lldb won't display registers via "reg read" in some cases after this change.  I'll create a test case and file a bug.

> r=me, with some fixups below.
> 
> > Source/JavaScriptCore/ChangeLog:8
> > +        Changed X86 and ARM variants as well as MIPS to use their respective arcitected
> 
> Should be "architected" or "architectures'".

Fixed.

> > Source/JavaScriptCore/ChangeLog:9
> > +        frame pointer register.  For X86, this freed up another register as a temp or for
> 
> Should be "frame pointer registers".

Fixed.
 
> As a temp for what? Baseline JIT? Did you start using that register somewhere?

Actually I added a new temp and made the register available to the DFG allocator.  I updated the code since this review to add back all the JSC specific callFrame registers made available with the change.  I updated the comment accordingly.
 
> > Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:80
> > +    // Restore the callFrame value into a temp, as the framePointerRegister may be the callFrameRegister
> > +    // Below we use the temp register when accessing the destination call frame.
> 
> There are two problems with this comment.
> 
> (1) You say "may be" when you mean "I have been working for months to ensure that this is definitely so, and many levels of our architecture rely on it being so". When you say "may" it implies that sometimes this many not be the case, and it's the reader's job to worry about the times when it's not the case. Very confusing.
> 
> (2) Your comment explains why you changed from the old code to the new code, and it makes sense in the context of a diff that shows you removing the old code that used callFrameRegister. However, it won't make any sense to a future programmer, who only sees the new code.
> 
> I think this comment should just say "regT4 points to the exiting function's call frame".

I changed it to: "Restore the exiting function's callFrame value into a regT4".

> >>> Source/JavaScriptCore/ftl/FTLOSRExitCompiler.cpp:166
> >>> +        jit.pop(MacroAssembler::framePointerRegister);
> >> 
> >> Why is this an 'if' statement?  Isn't it always true after your patch?
> > 
> > It isn't needed, but I thought it would be helpful for debugging if one wants to change the register assignments.  Also, MacroAssembler::framePointerRegister and GPRInfo::callFrameRegister are different names.  If you like, I can change this to a RELEASE_ASSERT.
> 
> static_assert, please.

Done.
Comment 7 Michael Saboff 2013-11-07 15:44:01 PST
Committed r158883: <http://trac.webkit.org/changeset/158883>