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

Issue 3434004: Prevent inline constructor generation when duplicate properties are present i... (Closed)

Created:
10 years, 3 months ago by Vladislav Kaznacheev
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

Prevent inline constructor generation when duplicate properties are present in the constructor. Currenly the constructor like this: function f() { this.a = 0; this.a = 1; this.a = 2; } creates a map with duplicate desciptors which is bad in many ways. Committed: http://code.google.com/p/v8/source/detail?r=5476

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+103 lines, -17 lines) Patch
M src/heap.cc View 2 chunks +41 lines, -16 lines 2 comments Download
M src/objects.h View 2 chunks +9 lines, -0 lines 0 comments Download
M src/objects.cc View 3 chunks +12 lines, -1 line 0 comments Download
A test/mjsunit/this-property-assignment.js View 1 chunk +41 lines, -0 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
Vladislav Kaznacheev
10 years, 3 months ago (2010-09-15 14:34:40 UTC) #1
Mads Ager (chromium)
Drive-by: when you agree on the patch, please merge to 2.2 and 2.3 branches. :)
10 years, 3 months ago (2010-09-15 14:42:25 UTC) #2
Søren Thygesen Gjesse
LGTM, good catch Whether you want to move the checking to SharedFunctionInfo::SetThisPropertyAssignmentsInfo is up to ...
10 years, 3 months ago (2010-09-16 06:43:41 UTC) #3
Vladislav Kaznacheev
10 years, 3 months ago (2010-09-16 10:50:21 UTC) #4
http://codereview.chromium.org/3434004/diff/1/2
File src/heap.cc (right):

http://codereview.chromium.org/3434004/diff/1/2#newcode2717
src/heap.cc:2717: // guarantee the uniqueness of property names (it would have
required
On 2010/09/16 06:43:41, Søren Gjesse wrote:
> We could do the sorting and checking for duplicates in
> SharedFunctionInfo::SetThisPropertyAssignmentsInfo instead. If there are
> duplicates then disable there.

I have considered this and decided against it. If we do the sorting/checking at
parse time we will have to do it even if the function is never called as a
constructor. So this would probably be slower, and require more code (separate
sorting function).

> There we could also weed out all but the last assignment to a property and
> support the case of multiple assignments to a property, but it is probably
> (hopefuly) a rare case.

This is extremely rare case. It never occurs in any of our tests (the is an
assert for IsSortedNoDuplicate, so we would have noticed).

> If the sorting is done in SharedFunctionInfo::SetThisPropertyAssignmentsInfo
we
> should not need to sort here.

Powered by Google App Engine
This is Rietveld 408576698