Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(816)

Issue 27128: Go into slow case when encountering object initialization on the top level to... (Closed)

Created:
11 years, 10 months ago by olehougaard
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

Go into slow case when encountering object initialization on the top level to optimize performance of code like C.prototype.x = ...; C.prototype.y = ...; ... C.prototype.z = ...; Committed: http://code.google.com/p/v8/source/detail?r=1372

Patch Set 1 #

Total comments: 14
Unified diffs Side-by-side diffs Delta from patch set Stats (+163 lines, -2 lines) Patch
M src/ast.h View 2 chunks +13 lines, -1 line 0 comments Download
M src/codegen-ia32.cc View 2 chunks +17 lines, -0 lines 2 comments Download
M src/parser.cc View 3 chunks +115 lines, -1 line 12 comments Download
M src/runtime.h View 1 chunk +2 lines, -0 lines 0 comments Download
M src/runtime.cc View 1 chunk +16 lines, -0 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
olehougaard
11 years, 10 months ago (2009-02-25 12:20:50 UTC) #1
iposva
Drive by comments. -Ivan http://codereview.chromium.org/27128/diff/1/5 File src/parser.cc (right): http://codereview.chromium.org/27128/diff/1/5#newcode1269 Line 1269: if (assignment->op() != Token::ASSIGN) ...
11 years, 10 months ago (2009-02-25 12:54:45 UTC) #2
Mads Ager (chromium)
LGTM You should add some tests though. I'm not sure that any of our test ...
11 years, 10 months ago (2009-02-25 13:11:07 UTC) #3
olehougaard
11 years, 10 months ago (2009-02-26 07:31:44 UTC) #4
I've added a unit test to show we haven't messed up top-level assignments in
addition to fixing the issues below.

http://codereview.chromium.org/27128/diff/1/6
File src/codegen-ia32.cc (right):

http://codereview.chromium.org/27128/diff/1/6#newcode2764
Line 2764: // Changing to slow case in the beginning of an initialization block
On 2009/02/25 13:11:07, Mads Ager wrote:
> Change to slow case ... to avoid ...
> 
> or
> 
> Changing to slow case ... avoids ...
> 
> ?

Fixed

http://codereview.chromium.org/27128/diff/1/5
File src/parser.cc (right):

http://codereview.chromium.org/27128/diff/1/5#newcode74
Line 74: static const int kMinInitializationBlock = 3;
On 2009/02/25 13:11:07, Mads Ager wrote:
> Is this limit based on benchmarking?  We should make sure to only perform the
> two runtime calls if that overhead is less than the instance descriptor
copying
> overhead.

It's based on benchmarking. I've added a comment to that effect.

http://codereview.chromium.org/27128/diff/1/5#newcode1242
Line 1242: if (!InBlock() && (assignment != NULL)) StartBlock(assignment);
On 2009/02/25 13:11:07, Mads Ager wrote:
> In BlockContinues, you check if the operation is Token::ASSIGN.  You should do
> that here (or in StartBlock) as well?
> 
> Please add a test case that hits this.

Fixed.

http://codereview.chromium.org/27128/diff/1/5#newcode1269
Line 1269: if (assignment->op() != Token::ASSIGN) return false;
On 2009/02/25 12:54:45, iposva wrote:
> You check here that only ASSIGN statements are added when the block continues,
> but you do not check for the initial node to be an ASSIGN statement anywhere I
> can tell.

Fixed.

http://codereview.chromium.org/27128/diff/1/5#newcode1304
Line 1304: bool InitializationBlockFinder::SameObject(Expression* e1,
Expression* e2) {
On 2009/02/25 12:54:45, iposva wrote:
> What made you put this method outside the class declaration? Since this is a
> private class I would just put all of the code in the declaration, or at least
> pull all non-trivial (aka 1-liners) out to be consistent.

I've put all the code in the declaration for consistency.

http://codereview.chromium.org/27128/diff/1/5#newcode1307
Line 1307: if (v1 != NULL && v2 != NULL) {
On 2009/02/25 12:54:45, iposva wrote:
> In general I find code more readable when () are added around boolean
> expressions such as
> 
> if ((v1 != NULL) && (v2 != NULL))
> 
> 

Fixed where found.

http://codereview.chromium.org/27128/diff/1/5#newcode1345
Line 1345: // degradation in any other scopes.
On 2009/02/25 13:11:07, Mads Ager wrote:
> You should write here that the reason for only doing this in top level code is
> that map transitions are not used in this case leading to different maps for
all
> objects going through this series of assignments.

Fixed.

Powered by Google App Engine
This is Rietveld 408576698