Bug 147666 - Interpreter::unwind shouldn't be responsible for assigning the correct scope.
Summary: Interpreter::unwind shouldn't be responsible for assigning the correct scope.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Saam Barati
URL:
Keywords:
Depends on: 147657
Blocks: 147374
  Show dependency treegraph
 
Reported: 2015-08-04 17:11 PDT by Saam Barati
Modified: 2015-08-07 12:46 PDT (History)
11 users (show)

See Also:


Attachments
patch (27.80 KB, patch)
2015-08-05 18:05 PDT, Saam Barati
no flags Details | Formatted Diff | Diff
patch (27.83 KB, patch)
2015-08-05 23:04 PDT, Saam Barati
ggaren: review+
ggaren: commit-queue-
Details | Formatted Diff | Diff
patch for landing. (27.18 KB, patch)
2015-08-07 08:18 PDT, Saam Barati
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Saam Barati 2015-08-04 17:11:53 PDT
BytecodeGenerator should do this since it will have the necessary info to do so.
Comment 1 Geoffrey Garen 2015-08-05 11:04:22 PDT
👍
Comment 2 Saam Barati 2015-08-05 18:05:57 PDT
Created attachment 258326 [details]
patch
Comment 3 WebKit Commit Bot 2015-08-05 18:09:28 PDT
Attachment 258326 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:2635:  Missing space before {  [whitespace/braces] [5]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Saam Barati 2015-08-05 23:04:33 PDT
Created attachment 258350 [details]
patch
Comment 5 WebKit Commit Bot 2015-08-05 23:09:43 PDT
Attachment 258350 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:2635:  Missing space before {  [whitespace/braces] [5]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Geoffrey Garen 2015-08-06 16:15:10 PDT
Comment on attachment 258350 [details]
patch

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

r=me, with a fixup below

> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:2840
> +    m_topMostScope = addVar();
> +    m_topMostScope->ref();
> +    emitMove(m_topMostScope, scopeRegister());

Not new to this patch, but: Does our new lexical scoping have the behavior that we now have var registers and temporary registers interleaved with each other, such that I might have:

[Var][Temp][Var][Temp]

?

That's a little sad because all temporary registers prior to the last vars will "leak" in the sense that the function will never reuse them, thus bloating its stack frame size.

Also, there's no need to ref m_topMostScope here because addVar() already refs.

Also, if you did want to ref(), I would ask you to use RefPtr.
Comment 7 Saam Barati 2015-08-06 16:35:30 PDT
Comment on attachment 258350 [details]
patch

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

>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:2840
>> +    emitMove(m_topMostScope, scopeRegister());
> 
> Not new to this patch, but: Does our new lexical scoping have the behavior that we now have var registers and temporary registers interleaved with each other, such that I might have:
> 
> [Var][Temp][Var][Temp]
> 
> ?
> 
> That's a little sad because all temporary registers prior to the last vars will "leak" in the sense that the function will never reuse them, thus bloating its stack frame size.
> 
> Also, there's no need to ref m_topMostScope here because addVar() already refs.
> 
> Also, if you did want to ref(), I would ask you to use RefPtr.

We don't do this. I believe we have an assert in addVar() that will prevent this from happening.
It would also be wrong if we did this because it would break op_enter. 

The way we handle register reuse for block scope variables like "let" is that
while we're generating code for the block's statements we'll reserve a non-temp
register for the block scope variable. Once we're done generating code for
that block scope, we will reclaim those block scoped registers. The code that
does this is in pushLexicalScopeInternal and popLexicalScopeInternal and reclaimFreeRegisters. 

This doesn't mean that we won't have some block scoped variables that are live for
the entire function. For example, functions with default parameter values will have
all parameters be in a block scope that never frees its variables. (These registers will
still be allocated after the "var" register locations).

I'll remove the ref and land later.
Comment 8 Saam Barati 2015-08-07 08:18:32 PDT
Created attachment 258502 [details]
patch for landing.
Comment 9 WebKit Commit Bot 2015-08-07 08:19:40 PDT
Attachment 258502 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:2635:  Missing space before {  [whitespace/braces] [5]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 10 WebKit Commit Bot 2015-08-07 10:41:38 PDT
Comment on attachment 258502 [details]
patch for landing.

Clearing flags on attachment: 258502

Committed r188136: <http://trac.webkit.org/changeset/188136>
Comment 11 WebKit Commit Bot 2015-08-07 10:41:42 PDT
All reviewed patches have been landed.  Closing bug.
Comment 12 Chris Dumez 2015-08-07 11:51:17 PDT
Committed r188144: <http://trac.webkit.org/changeset/188144>
Comment 13 Chris Dumez 2015-08-07 11:53:27 PDT
(In reply to comment #12)
> Committed r188144: <http://trac.webkit.org/changeset/188144>

Sorry, wrong bug. My changelog got messed up somehow.
Comment 14 Geoffrey Garen 2015-08-07 12:46:28 PDT
> The way we handle register reuse for block scope variables like "let" is that
> while we're generating code for the block's statements we'll reserve a
> non-temp
> register for the block scope variable. Once we're done generating code for
> that block scope, we will reclaim those block scoped registers. The code that
> does this is in pushLexicalScopeInternal and popLexicalScopeInternal and
> reclaimFreeRegisters. 

Oh! I get it now.