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

Issue 9691040: Ensure that generated code for object literals will call Runtime_DefineOrRedefineAccessorProperty o… (Closed)

Created:
8 years, 9 months ago by Sven Panne
Modified:
8 years, 9 months ago
CC:
v8-dev
Visibility:
Public.

Description

Ensure that generated code for object literals will call Runtime_DefineOrRedefineAccessorProperty only once per accessor property. To do this, we collect all accessor properties in a first pass and emit code for defining those properties afterwards in a second pass. As a finger exercise, the table used for collecting accessors has a (subset of an) STL-like iterator interface, including STL-like names and operators. Although C++ is quite verbose here (as usual, but partly this is caused by our current slightly clumsy classes/templates), things work out quite nicely and it cleans up some confusion, e.g. a table entry is not an iterator etc. Everything compiles into very efficient code, e.g. the loop condition 'it != accessor_table.end()' compiles into a single 'testl' instruction on ia32. +1 for using standard APIs! Committed: https://code.google.com/p/v8/source/detail?r=11051

Patch Set 1 #

Patch Set 2 : Rebased. Extraced method. #

Total comments: 8

Patch Set 3 : Rebased and incorporated review comments #

Patch Set 4 : Rebased and incorporated review comments #

Total comments: 4

Patch Set 5 : Rebased #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+204 lines, -72 lines) Patch
M src/arm/full-codegen-arm.cc View 1 2 3 chunks +29 lines, -16 lines 0 comments Download
M src/ast.h View 1 2 1 chunk +6 lines, -0 lines 0 comments Download
M src/full-codegen.h View 1 2 2 chunks +24 lines, -0 lines 0 comments Download
M src/hashmap.h View 1 2 10 chunks +59 lines, -14 lines 0 comments Download
M src/ia32/full-codegen-ia32.cc View 1 2 4 chunks +29 lines, -13 lines 1 comment Download
M src/mips/full-codegen-mips.cc View 1 2 3 chunks +29 lines, -16 lines 0 comments Download
M src/x64/full-codegen-x64.cc View 1 2 3 chunks +27 lines, -12 lines 0 comments Download
M src/zone.h View 1 2 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 7 (0 generated)
Sven Panne
8 years, 9 months ago (2012-03-13 12:25:55 UTC) #1
rossberg
While I agree that this is a nicer interface, I think full-codegen is the wrong ...
8 years, 9 months ago (2012-03-13 13:59:10 UTC) #2
Sven Panne
https://chromiumcodereview.appspot.com/9691040/diff/2001/src/full-codegen.h File src/full-codegen.h (right): https://chromiumcodereview.appspot.com/9691040/diff/2001/src/full-codegen.h#newcode816 src/full-codegen.h:816: class Accessors: public ZoneObject { On 2012/03/13 13:59:10, rossberg ...
8 years, 9 months ago (2012-03-14 15:26:56 UTC) #3
rossberg
LGTM, with small changes. https://chromiumcodereview.appspot.com/9691040/diff/7013/src/full-codegen.h File src/full-codegen.h (right): https://chromiumcodereview.appspot.com/9691040/diff/7013/src/full-codegen.h#newcode820 src/full-codegen.h:820: Iterator lookup(Literal* literal) { Nit: ...
8 years, 9 months ago (2012-03-14 16:29:03 UTC) #4
Sven Panne
https://chromiumcodereview.appspot.com/9691040/diff/7013/src/full-codegen.h File src/full-codegen.h (right): https://chromiumcodereview.appspot.com/9691040/diff/7013/src/full-codegen.h#newcode820 src/full-codegen.h:820: Iterator lookup(Literal* literal) { On 2012/03/14 16:29:03, rossberg wrote: ...
8 years, 9 months ago (2012-03-15 07:12:56 UTC) #5
Vitaly Repeshko
Drive by comments. I don't think adding STL-like things to V8 is a good idea. ...
8 years, 9 months ago (2012-03-15 07:59:26 UTC) #6
Sven Panne
8 years, 9 months ago (2012-03-15 09:08:44 UTC) #7
This isn't intended to be a full drop-in replacement for an STL container, it is
just templatizing things more to get more compile-time checking instead of
insane casts all over the code, and it is reducing our usual ad-hoc inconsistent
naming of things by using well-known names.

Folding things together is normally only a good idea if things are really,
really performance-critical, which is not the case here: We need a mapping from
the property names to their getters/setters only during a very short time span
(during a single method), so adding this info to the AST nodes feels plainly
wrong and increases the permanent memory usage.

In general we should not fold things together more than they already are, but do
the exact opposite and untangle things. Ask Andreas about his fun in the parser
while trying to implement modules... :-)

Powered by Google App Engine
This is Rietveld 408576698