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

Issue 2142333002: Refactor class declaration logic to the parser and runtime

Created:
4 years, 5 months ago by bakkot
Modified:
4 years, 5 months ago
CC:
Michael Starzinger, oth, rmcilroy, v8-mips-ports_googlegroups.com, v8-ppc-ports_googlegroups.com, v8-reviews_googlegroups.com, v8-x87-ports_googlegroups.com
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

Refactor class declaration logic to the parser and runtime. ClassDeclarations and Expressions had a first-class representation in the AST, with implementations in all of the backends. This involved a significant amount of substantially-duplicated code, and made future changes and maintenance much harder than it needed to be. This CL modifies the parser to produce a DoExpression which calls out to a runtime function, DefineClass, which installs the given properties on the constructor and its prototype. DoExpressions AST nodes gain a new field to enable function name inference for class expressions. This comes at a roughly ten percent slowdown in both class parsing and execution in the worst case. Instantiation is not discernibly affected.

Patch Set 1 #

Patch Set 2 : fix bytecode test expectation #

Patch Set 3 : unconditionally call ToName #

Patch Set 4 : IsString to IsName #

Patch Set 5 : minor cleanup #

Total comments: 6

Patch Set 6 : cleanup per Adam #

Total comments: 3

Patch Set 7 : rebase #

Patch Set 8 : rebase harder #

Patch Set 9 : rebase harderr #

Patch Set 10 : non-inline ToName #

Total comments: 6

Patch Set 11 : remove accidental added file #

Patch Set 12 : minor cleanup per Adam #

Total comments: 7
Unified diffs Side-by-side diffs Delta from patch set Stats (+455 lines, -1207 lines) Patch
M src/asmjs/asm-wasm-builder.cc View 1 2 3 4 5 6 1 chunk +0 lines, -2 lines 0 comments Download
M src/ast/ast.h View 1 2 3 4 5 6 5 chunks +11 lines, -87 lines 0 comments Download
M src/ast/ast.cc View 1 2 3 4 5 6 4 chunks +6 lines, -37 lines 1 comment Download
M src/ast/ast-expression-rewriter.cc View 1 chunk +0 lines, -14 lines 0 comments Download
M src/ast/ast-expression-visitor.cc View 1 chunk +0 lines, -5 lines 0 comments Download
M src/ast/ast-literal-reindexer.cc View 1 chunk +0 lines, -12 lines 0 comments Download
M src/ast/ast-numbering.cc View 1 chunk +0 lines, -16 lines 0 comments Download
M src/ast/prettyprinter.cc View 1 2 3 4 5 6 7 2 chunks +0 lines, -18 lines 0 comments Download
M src/bailout-reason.h View 1 chunk +0 lines, -1 line 0 comments Download
M src/compiler/ast-graph-builder.h View 1 2 3 4 5 6 1 chunk +0 lines, -3 lines 0 comments Download
M src/compiler/ast-graph-builder.cc View 1 2 3 4 5 6 1 chunk +0 lines, -115 lines 0 comments Download
M src/compiler/ast-loop-assignment-analyzer.cc View 1 chunk +0 lines, -11 lines 0 comments Download
M src/crankshaft/hydrogen.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +0 lines, -8 lines 0 comments Download
M src/crankshaft/typing.cc View 1 chunk +0 lines, -3 lines 0 comments Download
M src/full-codegen/arm/full-codegen-arm.cc View 1 2 3 4 5 6 1 chunk +0 lines, -56 lines 0 comments Download
M src/full-codegen/arm64/full-codegen-arm64.cc View 1 2 3 4 5 6 1 chunk +0 lines, -56 lines 0 comments Download
M src/full-codegen/full-codegen.h View 2 chunks +0 lines, -22 lines 0 comments Download
M src/full-codegen/full-codegen.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +0 lines, -47 lines 0 comments Download
M src/full-codegen/ia32/full-codegen-ia32.cc View 1 2 3 4 5 6 1 chunk +0 lines, -51 lines 0 comments Download
M src/full-codegen/mips/full-codegen-mips.cc View 1 2 3 4 5 6 1 chunk +0 lines, -56 lines 0 comments Download
M src/full-codegen/mips64/full-codegen-mips64.cc View 1 2 3 4 5 6 1 chunk +0 lines, -56 lines 0 comments Download
M src/full-codegen/ppc/full-codegen-ppc.cc View 1 2 3 4 5 6 1 chunk +0 lines, -56 lines 0 comments Download
M src/full-codegen/s390/full-codegen-s390.cc View 1 2 3 4 5 6 1 chunk +0 lines, -55 lines 0 comments Download
M src/full-codegen/x64/full-codegen-x64.cc View 1 2 3 4 5 6 1 chunk +0 lines, -54 lines 0 comments Download
M src/full-codegen/x87/full-codegen-x87.cc View 1 2 3 4 5 6 1 chunk +0 lines, -51 lines 0 comments Download
M src/interpreter/bytecode-generator.h View 1 chunk +0 lines, -5 lines 0 comments Download
M src/interpreter/bytecode-generator.cc View 1 2 3 4 5 6 1 chunk +0 lines, -148 lines 0 comments Download
M src/parsing/parameter-initializer-rewriter.cc View 3 chunks +11 lines, -26 lines 0 comments Download
M src/parsing/parser.h View 3 chunks +10 lines, -11 lines 0 comments Download
M src/parsing/parser.cc View 1 2 3 4 5 6 7 8 9 10 11 8 chunks +146 lines, -16 lines 6 comments Download
M src/parsing/parser-base.h View 1 chunk +0 lines, -1 line 0 comments Download
M src/parsing/pattern-rewriter.cc View 1 2 3 4 5 6 1 chunk +0 lines, -1 line 0 comments Download
M src/parsing/preparser.h View 1 chunk +0 lines, -1 line 0 comments Download
M src/parsing/preparser.cc View 1 chunk +6 lines, -0 lines 0 comments Download
M src/runtime/runtime.h View 1 2 3 4 5 6 2 chunks +7 lines, -1 line 0 comments Download
M src/runtime/runtime-classes.cc View 1 2 3 4 5 2 chunks +101 lines, -4 lines 0 comments Download
M test/cctest/interpreter/bytecode_expectations/ClassDeclarations.golden View 1 9 10 6 chunks +115 lines, -95 lines 0 comments Download
M test/cctest/interpreter/bytecode_expectations/Generators.golden View 1 4 chunks +4 lines, -4 lines 0 comments Download
M test/cctest/test-parsing.cc View 1 1 chunk +1 line, -2 lines 0 comments Download
M test/mjsunit/es6/classes.js View 1 chunk +37 lines, -0 lines 0 comments Download

Messages

Total messages: 58 (47 generated)
bakkot
Please add other reviewers as necessary.
4 years, 5 months ago (2016-07-13 18:18:19 UTC) #19
adamk
First round of comments, will need more reading to better grok the whole thing, but ...
4 years, 5 months ago (2016-07-13 20:57:33 UTC) #20
adamk
Adding bmeurer as a reviewer (and CC mstarzinger) for compiler thoughts on this; he'd indicated ...
4 years, 5 months ago (2016-07-14 22:00:48 UTC) #43
bakkot
https://codereview.chromium.org/2142333002/diff/100001/src/parsing/parser.cc File src/parsing/parser.cc (right): https://codereview.chromium.org/2142333002/diff/100001/src/parsing/parser.cc#newcode5088 src/parsing/parser.cc:5088: Block* do_block = factory()->NewBlock(nullptr, 16, false, pos); On 2016/07/14 ...
4 years, 5 months ago (2016-07-14 22:46:01 UTC) #45
rmcilroy
> Adding bmeurer as a reviewer (and CC mstarzinger) for compiler thoughts on this; > ...
4 years, 5 months ago (2016-07-15 09:24:04 UTC) #51
dehrenberg1
On 2016/07/15 09:24:04, rmcilroy wrote: > > Adding bmeurer as a reviewer (and CC mstarzinger) ...
4 years, 5 months ago (2016-07-18 16:49:05 UTC) #52
Benedikt Meurer
+marja for parser changes. First round of comments. https://codereview.chromium.org/2142333002/diff/220001/src/parsing/parser.cc File src/parsing/parser.cc (right): https://codereview.chromium.org/2142333002/diff/220001/src/parsing/parser.cc#newcode5080 src/parsing/parser.cc:5080: property_key ...
4 years, 5 months ago (2016-07-19 04:04:28 UTC) #54
Dan Ehrenberg
First round of responses, based previous on discussions with Kevin, to save a day round ...
4 years, 5 months ago (2016-07-19 04:52:33 UTC) #55
marja
https://codereview.chromium.org/2142333002/diff/220001/src/ast/ast.cc File src/ast/ast.cc (right): https://codereview.chromium.org/2142333002/diff/220001/src/ast/ast.cc#newcode285 src/ast/ast.cc:285: represented_function_->raw_name()->length() == 0; This second part looks hacky; why ...
4 years, 5 months ago (2016-07-19 09:54:34 UTC) #56
bakkot
It sounds like this may not be worth doing, given forthcoming changes to the compilation ...
4 years, 5 months ago (2016-07-21 23:05:33 UTC) #57
bakkot
4 years, 5 months ago (2016-07-22 19:55:45 UTC) #58
On 2016/07/21 at 23:05:33, bakkot wrote:
> It sounds like this may not be worth doing, given forthcoming changes to the
compilation pipeline. I'll make a smaller change that just puts class literals
in their own block scope within a DoExpression (so that all block scopes are
attached to blocks).

Said change is at https://codereview.chromium.org/2176653003.

Powered by Google App Engine
This is Rietveld 408576698