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

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

Issue 1245653002: [turbofan] Move workaround with TDZ of 'this' variable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « no previous file | no next file » | 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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 // It will be replaced with {Dead} after typing and optimizations. 513 // It will be replaced with {Dead} after typing and optimizations.
514 NewNode(common()->OsrNormalEntry()); 514 NewNode(common()->OsrNormalEntry());
515 } 515 }
516 516
517 // Initialize the incoming context. 517 // Initialize the incoming context.
518 ContextScope incoming(this, scope, GetFunctionContext()); 518 ContextScope incoming(this, scope, GetFunctionContext());
519 519
520 // Initialize control scope. 520 // Initialize control scope.
521 ControlScope control(this); 521 ControlScope control(this);
522 522
523 // TODO(mstarzinger): For now we cannot assume that the {this} parameter is
524 // not {the_hole}, because for derived classes {this} has a TDZ and the
525 // JSConstructStubForDerived magically passes {the_hole} as a receiver.
526 if (scope->has_this_declaration() && scope->receiver()->is_const_mode()) {
527 env.RawParameterBind(0, jsgraph()->TheHoleConstant());
528 }
529
523 // Build receiver check for sloppy mode if necessary. 530 // Build receiver check for sloppy mode if necessary.
524 // TODO(mstarzinger/verwaest): Should this be moved back into the CallIC? 531 // TODO(mstarzinger/verwaest): Should this be moved back into the CallIC?
525 if (scope->has_this_declaration()) { 532 if (scope->has_this_declaration()) {
526 Node* original_receiver = env.RawParameterLookup(0); 533 Node* original_receiver = env.RawParameterLookup(0);
527 Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver); 534 Node* patched_receiver = BuildPatchReceiverToGlobalProxy(original_receiver);
528 env.RawParameterBind(0, patched_receiver); 535 env.RawParameterBind(0, patched_receiver);
529 } 536 }
530 537
531 // Build function context only if there are context allocated variables. 538 // Build function context only if there are context allocated variables.
532 if (info()->num_heap_slots() > 0) { 539 if (info()->num_heap_slots() > 0) {
(...skipping 2812 matching lines...) Expand 10 before | Expand all | Expand 10 after
3345 if (mode == CONST_LEGACY) { 3352 if (mode == CONST_LEGACY) {
3346 // Perform check for uninitialized legacy const variables. 3353 // Perform check for uninitialized legacy const variables.
3347 if (value->op() == the_hole->op()) { 3354 if (value->op() == the_hole->op()) {
3348 value = jsgraph()->UndefinedConstant(); 3355 value = jsgraph()->UndefinedConstant();
3349 } else if (value->opcode() == IrOpcode::kPhi) { 3356 } else if (value->opcode() == IrOpcode::kPhi) {
3350 Node* undefined = jsgraph()->UndefinedConstant(); 3357 Node* undefined = jsgraph()->UndefinedConstant();
3351 value = BuildHoleCheckSilent(value, undefined, value); 3358 value = BuildHoleCheckSilent(value, undefined, value);
3352 } 3359 }
3353 } else if (mode == LET || mode == CONST) { 3360 } else if (mode == LET || mode == CONST) {
3354 // Perform check for uninitialized let/const variables. 3361 // Perform check for uninitialized let/const variables.
3355 // TODO(mstarzinger): For now we cannot use the below optimization for
3356 // the {this} parameter, because JSConstructStubForDerived magically
3357 // passes {the_hole} as a receiver.
3358 if (value->op() == the_hole->op()) { 3362 if (value->op() == the_hole->op()) {
3359 value = BuildThrowReferenceError(variable, bailout_id); 3363 value = BuildThrowReferenceError(variable, bailout_id);
3360 } else if (value->opcode() == IrOpcode::kPhi || variable->is_this()) { 3364 } else if (value->opcode() == IrOpcode::kPhi) {
3361 value = BuildHoleCheckThenThrow(value, variable, value, bailout_id); 3365 value = BuildHoleCheckThenThrow(value, variable, value, bailout_id);
3362 } 3366 }
3363 } 3367 }
3364 return value; 3368 return value;
3365 } 3369 }
3366 case VariableLocation::CONTEXT: { 3370 case VariableLocation::CONTEXT: {
3367 // Context variable (potentially up the context chain). 3371 // Context variable (potentially up the context chain).
3368 int depth = current_scope()->ContextChainLength(variable->scope()); 3372 int depth = current_scope()->ContextChainLength(variable->scope());
3369 bool immutable = variable->maybe_assigned() == kNotAssigned; 3373 bool immutable = variable->maybe_assigned() == kNotAssigned;
3370 const Operator* op = 3374 const Operator* op =
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
4307 // Phi does not exist yet, introduce one. 4311 // Phi does not exist yet, introduce one.
4308 value = NewPhi(inputs, value, control); 4312 value = NewPhi(inputs, value, control);
4309 value->ReplaceInput(inputs - 1, other); 4313 value->ReplaceInput(inputs - 1, other);
4310 } 4314 }
4311 return value; 4315 return value;
4312 } 4316 }
4313 4317
4314 } // namespace compiler 4318 } // namespace compiler
4315 } // namespace internal 4319 } // namespace internal
4316 } // namespace v8 4320 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698