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

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

Issue 1442643002: [turbofan] Rename "original constructor" to "new target". (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 5 years, 1 month 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 | « no previous file | src/compiler/js-generic-lowering.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/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 2485 matching lines...) Expand 10 before | Expand all | Expand 10 after
2496 const Operator* op = javascript()->CallRuntime(Runtime::kGetPrototype, 1); 2496 const Operator* op = javascript()->CallRuntime(Runtime::kGetPrototype, 1);
2497 Node* super_function = NewNode(op, this_function); 2497 Node* super_function = NewNode(op, this_function);
2498 // TODO(mstarzinger): This probably needs a proper bailout id. 2498 // TODO(mstarzinger): This probably needs a proper bailout id.
2499 PrepareFrameState(super_function, BailoutId::None()); 2499 PrepareFrameState(super_function, BailoutId::None());
2500 environment()->Push(super_function); 2500 environment()->Push(super_function);
2501 2501
2502 // Evaluate all arguments to the super call. 2502 // Evaluate all arguments to the super call.
2503 ZoneList<Expression*>* args = expr->arguments(); 2503 ZoneList<Expression*>* args = expr->arguments();
2504 VisitForValues(args); 2504 VisitForValues(args);
2505 2505
2506 // Original constructor is loaded from the {new.target} variable. 2506 // The new target is loaded from the {new.target} variable.
2507 VisitForValue(super->new_target_var()); 2507 VisitForValue(super->new_target_var());
2508 2508
2509 // Create node to perform the super call. 2509 // Create node to perform the super call.
2510 const Operator* call = javascript()->CallConstruct(args->length() + 2); 2510 const Operator* call = javascript()->CallConstruct(args->length() + 2);
2511 Node* value = ProcessArguments(call, args->length() + 2); 2511 Node* value = ProcessArguments(call, args->length() + 2);
2512 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 2512 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
2513 ast_context()->ProduceValue(value); 2513 ast_context()->ProduceValue(value);
2514 } 2514 }
2515 2515
2516 2516
2517 void AstGraphBuilder::VisitCallNew(CallNew* expr) { 2517 void AstGraphBuilder::VisitCallNew(CallNew* expr) {
2518 VisitForValue(expr->expression()); 2518 VisitForValue(expr->expression());
2519 2519
2520 // Evaluate all arguments to the construct call. 2520 // Evaluate all arguments to the construct call.
2521 ZoneList<Expression*>* args = expr->arguments(); 2521 ZoneList<Expression*>* args = expr->arguments();
2522 VisitForValues(args); 2522 VisitForValues(args);
2523 2523
2524 // Original constructor is the same as the callee. 2524 // The new target is the same as the callee.
2525 environment()->Push(environment()->Peek(args->length())); 2525 environment()->Push(environment()->Peek(args->length()));
2526 2526
2527 // Create node to perform the construct call. 2527 // Create node to perform the construct call.
2528 const Operator* call = javascript()->CallConstruct(args->length() + 2); 2528 const Operator* call = javascript()->CallConstruct(args->length() + 2);
2529 Node* value = ProcessArguments(call, args->length() + 2); 2529 Node* value = ProcessArguments(call, args->length() + 2);
2530 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 2530 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
2531 ast_context()->ProduceValue(value); 2531 ast_context()->ProduceValue(value);
2532 } 2532 }
2533 2533
2534 2534
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
3204 FrameStateBeforeAndAfter states(this, BailoutId::None()); 3204 FrameStateBeforeAndAfter states(this, BailoutId::None());
3205 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST, 3205 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST,
3206 VectorSlotPair(), BailoutId::None(), states); 3206 VectorSlotPair(), BailoutId::None(), states);
3207 return this_function; 3207 return this_function;
3208 } 3208 }
3209 3209
3210 3210
3211 Node* AstGraphBuilder::BuildNewTargetVariable(Variable* new_target_var) { 3211 Node* AstGraphBuilder::BuildNewTargetVariable(Variable* new_target_var) {
3212 if (new_target_var == nullptr) return nullptr; 3212 if (new_target_var == nullptr) return nullptr;
3213 3213
3214 // Retrieve the original constructor in case we are called as a constructor. 3214 // Retrieve the new target in case we are called as a constructor.
3215 const Operator* op = 3215 const Operator* op = javascript()->CallRuntime(Runtime::kGetNewTarget, 0);
3216 javascript()->CallRuntime(Runtime::kGetOriginalConstructor, 0);
3217 Node* object = NewNode(op); 3216 Node* object = NewNode(op);
3218 // TODO(4544): Bailout id only needed for JavaScriptFrame::Summarize. 3217 // TODO(4544): Bailout id only needed for JavaScriptFrame::Summarize.
3219 PrepareFrameState(object, BailoutId::FunctionContext()); 3218 PrepareFrameState(object, BailoutId::FunctionContext());
3220 3219
3221 // Assign the object to the {new.target} variable. This should never lazy 3220 // Assign the object to the {new.target} variable. This should never lazy
3222 // deopt, so it is fine to send invalid bailout id. 3221 // deopt, so it is fine to send invalid bailout id.
3223 FrameStateBeforeAndAfter states(this, BailoutId::None()); 3222 FrameStateBeforeAndAfter states(this, BailoutId::None());
3224 BuildVariableAssignment(new_target_var, object, Token::INIT_CONST, 3223 BuildVariableAssignment(new_target_var, object, Token::INIT_CONST,
3225 VectorSlotPair(), BailoutId::None(), states); 3224 VectorSlotPair(), BailoutId::None(), states);
3226 return object; 3225 return object;
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
4297 // Phi does not exist yet, introduce one. 4296 // Phi does not exist yet, introduce one.
4298 value = NewPhi(inputs, value, control); 4297 value = NewPhi(inputs, value, control);
4299 value->ReplaceInput(inputs - 1, other); 4298 value->ReplaceInput(inputs - 1, other);
4300 } 4299 }
4301 return value; 4300 return value;
4302 } 4301 }
4303 4302
4304 } // namespace compiler 4303 } // namespace compiler
4305 } // namespace internal 4304 } // namespace internal
4306 } // namespace v8 4305 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698