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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 1226123010: Represent implicit 'this' binding by 'super' in AST. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ast.cc ('k') | src/compiler/ast-loop-assignment-analyzer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/js-type-feedback.h" 10 #include "src/compiler/js-type-feedback.h"
(...skipping 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 environment()->Push(result); 2009 environment()->Push(result);
2010 } 2010 }
2011 2011
2012 ast_context()->ProduceValue(environment()->Pop()); 2012 ast_context()->ProduceValue(environment()->Pop());
2013 } 2013 }
2014 2014
2015 2015
2016 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value, 2016 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value,
2017 const VectorSlotPair& feedback, 2017 const VectorSlotPair& feedback,
2018 BailoutId bailout_id) { 2018 BailoutId bailout_id) {
2019 DCHECK(expr->IsValidReferenceExpression()); 2019 DCHECK(expr->IsValidReferenceExpressionOrThis());
2020 2020
2021 // Left-hand side can only be a property, a global or a variable slot. 2021 // Left-hand side can only be a property, a global or a variable slot.
2022 Property* property = expr->AsProperty(); 2022 Property* property = expr->AsProperty();
2023 LhsKind assign_type = Property::GetAssignType(property); 2023 LhsKind assign_type = Property::GetAssignType(property);
2024 2024
2025 // Evaluate LHS expression and store the value. 2025 // Evaluate LHS expression and store the value.
2026 switch (assign_type) { 2026 switch (assign_type) {
2027 case VARIABLE: { 2027 case VARIABLE: {
2028 Variable* var = expr->AsVariableProxy()->var(); 2028 Variable* var = expr->AsVariableProxy()->var();
2029 FrameStateBeforeAndAfter states(this, BailoutId::None()); 2029 FrameStateBeforeAndAfter states(this, BailoutId::None());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 Node* store = BuildKeyedSuperStore(receiver, home_object, key, value, 2083 Node* store = BuildKeyedSuperStore(receiver, home_object, key, value,
2084 TypeFeedbackId::None()); 2084 TypeFeedbackId::None());
2085 states.AddToNode(store, bailout_id, OutputFrameStateCombine::Ignore()); 2085 states.AddToNode(store, bailout_id, OutputFrameStateCombine::Ignore());
2086 break; 2086 break;
2087 } 2087 }
2088 } 2088 }
2089 } 2089 }
2090 2090
2091 2091
2092 void AstGraphBuilder::VisitAssignment(Assignment* expr) { 2092 void AstGraphBuilder::VisitAssignment(Assignment* expr) {
2093 DCHECK(expr->target()->IsValidReferenceExpression()); 2093 DCHECK(expr->target()->IsValidReferenceExpressionOrThis());
2094 2094
2095 // Left-hand side can only be a property, a global or a variable slot. 2095 // Left-hand side can only be a property, a global or a variable slot.
2096 Property* property = expr->target()->AsProperty(); 2096 Property* property = expr->target()->AsProperty();
2097 LhsKind assign_type = Property::GetAssignType(property); 2097 LhsKind assign_type = Property::GetAssignType(property);
2098 bool needs_frame_state_before = true; 2098 bool needs_frame_state_before = true;
2099 2099
2100 // Evaluate LHS expression. 2100 // Evaluate LHS expression.
2101 switch (assign_type) { 2101 switch (assign_type) {
2102 case VARIABLE: { 2102 case VARIABLE: {
2103 Variable* variable = expr->target()->AsVariableProxy()->var(); 2103 Variable* variable = expr->target()->AsVariableProxy()->var();
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 ZoneList<Expression*>* args = expr->arguments(); 2513 ZoneList<Expression*>* args = expr->arguments();
2514 VisitForValues(args); 2514 VisitForValues(args);
2515 2515
2516 // Original constructor is loaded from the {new.target} variable. 2516 // Original constructor is loaded from the {new.target} variable.
2517 VisitForValue(super->new_target_var()); 2517 VisitForValue(super->new_target_var());
2518 2518
2519 // Create node to perform the super call. 2519 // Create node to perform the super call.
2520 const Operator* call = javascript()->CallConstruct(args->length() + 2); 2520 const Operator* call = javascript()->CallConstruct(args->length() + 2);
2521 Node* value = ProcessArguments(call, args->length() + 2); 2521 Node* value = ProcessArguments(call, args->length() + 2);
2522 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 2522 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
2523
2524 // TODO(mstarzinger): It sure would be nice if this were desugared.
2525 FrameStateBeforeAndAfter states(this, BailoutId::None());
2526 BuildVariableAssignment(super->this_var()->var(), value, Token::INIT_CONST,
2527 VectorSlotPair(), expr->id(), states);
2528
2529 ast_context()->ProduceValue(value); 2523 ast_context()->ProduceValue(value);
2530 } 2524 }
2531 2525
2532 2526
2533 void AstGraphBuilder::VisitCallNew(CallNew* expr) { 2527 void AstGraphBuilder::VisitCallNew(CallNew* expr) {
2534 VisitForValue(expr->expression()); 2528 VisitForValue(expr->expression());
2535 2529
2536 // Evaluate all arguments to the construct call. 2530 // Evaluate all arguments to the construct call.
2537 ZoneList<Expression*>* args = expr->arguments(); 2531 ZoneList<Expression*>* args = expr->arguments();
2538 VisitForValues(args); 2532 VisitForValues(args);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2620 return VisitTypeof(expr); 2614 return VisitTypeof(expr);
2621 case Token::NOT: 2615 case Token::NOT:
2622 return VisitNot(expr); 2616 return VisitNot(expr);
2623 default: 2617 default:
2624 UNREACHABLE(); 2618 UNREACHABLE();
2625 } 2619 }
2626 } 2620 }
2627 2621
2628 2622
2629 void AstGraphBuilder::VisitCountOperation(CountOperation* expr) { 2623 void AstGraphBuilder::VisitCountOperation(CountOperation* expr) {
2630 DCHECK(expr->expression()->IsValidReferenceExpression()); 2624 DCHECK(expr->expression()->IsValidReferenceExpressionOrThis());
2631 2625
2632 // Left-hand side can only be a property, a global or a variable slot. 2626 // Left-hand side can only be a property, a global or a variable slot.
2633 Property* property = expr->expression()->AsProperty(); 2627 Property* property = expr->expression()->AsProperty();
2634 LhsKind assign_type = Property::GetAssignType(property); 2628 LhsKind assign_type = Property::GetAssignType(property);
2635 2629
2636 // Reserve space for result of postfix operation. 2630 // Reserve space for result of postfix operation.
2637 bool is_postfix = expr->is_postfix() && !ast_context()->IsEffect(); 2631 bool is_postfix = expr->is_postfix() && !ast_context()->IsEffect();
2638 if (is_postfix) environment()->Push(jsgraph()->UndefinedConstant()); 2632 if (is_postfix) environment()->Push(jsgraph()->UndefinedConstant());
2639 2633
2640 // Evaluate LHS expression and get old value. 2634 // Evaluate LHS expression and get old value.
(...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after
4320 // Phi does not exist yet, introduce one. 4314 // Phi does not exist yet, introduce one.
4321 value = NewPhi(inputs, value, control); 4315 value = NewPhi(inputs, value, control);
4322 value->ReplaceInput(inputs - 1, other); 4316 value->ReplaceInput(inputs - 1, other);
4323 } 4317 }
4324 return value; 4318 return value;
4325 } 4319 }
4326 4320
4327 } // namespace compiler 4321 } // namespace compiler
4328 } // namespace internal 4322 } // namespace internal
4329 } // namespace v8 4323 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/compiler/ast-loop-assignment-analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698