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

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

Issue 1208873002: Reapply "Fix receiver when calling eval() bound by with scope" (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Record source position of "eval" in eval lookup calls Created 5 years, 6 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.h ('k') | src/full-codegen.h » ('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 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 case Call::LOOKUP_SLOT_CALL: { 2349 case Call::LOOKUP_SLOT_CALL: {
2350 Variable* variable = callee->AsVariableProxy()->var(); 2350 Variable* variable = callee->AsVariableProxy()->var();
2351 DCHECK(variable->location() == Variable::LOOKUP); 2351 DCHECK(variable->location() == Variable::LOOKUP);
2352 Node* name = jsgraph()->Constant(variable->name()); 2352 Node* name = jsgraph()->Constant(variable->name());
2353 const Operator* op = 2353 const Operator* op =
2354 javascript()->CallRuntime(Runtime::kLoadLookupSlot, 2); 2354 javascript()->CallRuntime(Runtime::kLoadLookupSlot, 2);
2355 Node* pair = NewNode(op, current_context(), name); 2355 Node* pair = NewNode(op, current_context(), name);
2356 callee_value = NewNode(common()->Projection(0), pair); 2356 callee_value = NewNode(common()->Projection(0), pair);
2357 receiver_value = NewNode(common()->Projection(1), pair); 2357 receiver_value = NewNode(common()->Projection(1), pair);
2358 2358
2359 PrepareFrameState(pair, expr->EvalOrLookupId(), 2359 PrepareFrameState(pair, expr->LookupId(),
2360 OutputFrameStateCombine::Push(2)); 2360 OutputFrameStateCombine::Push(2));
2361 break; 2361 break;
2362 } 2362 }
2363 case Call::PROPERTY_CALL: { 2363 case Call::PROPERTY_CALL: {
2364 Property* property = callee->AsProperty(); 2364 Property* property = callee->AsProperty();
2365 VectorSlotPair pair = 2365 VectorSlotPair pair =
2366 CreateVectorSlotPair(property->PropertyFeedbackSlot()); 2366 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2367 if (!property->IsSuperAccess()) { 2367 if (!property->IsSuperAccess()) {
2368 VisitForValue(property->obj()); 2368 VisitForValue(property->obj());
2369 Node* object = environment()->Top(); 2369 Node* object = environment()->Top();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2417 break; 2417 break;
2418 } 2418 }
2419 case Call::SUPER_CALL: 2419 case Call::SUPER_CALL:
2420 // TODO(dslomov): Implement super calls. 2420 // TODO(dslomov): Implement super calls.
2421 callee_value = jsgraph()->UndefinedConstant(); 2421 callee_value = jsgraph()->UndefinedConstant();
2422 receiver_value = jsgraph()->UndefinedConstant(); 2422 receiver_value = jsgraph()->UndefinedConstant();
2423 SetStackOverflow(); 2423 SetStackOverflow();
2424 break; 2424 break;
2425 case Call::POSSIBLY_EVAL_CALL: 2425 case Call::POSSIBLY_EVAL_CALL:
2426 possibly_eval = true; 2426 possibly_eval = true;
2427 if (callee->AsVariableProxy()->var()->IsLookupSlot()) {
2428 Variable* variable = callee->AsVariableProxy()->var();
2429 Node* name = jsgraph()->Constant(variable->name());
2430 const Operator* op =
2431 javascript()->CallRuntime(Runtime::kLoadLookupSlot, 2);
2432 Node* pair = NewNode(op, current_context(), name);
2433 callee_value = NewNode(common()->Projection(0), pair);
2434 receiver_value = NewNode(common()->Projection(1), pair);
2435 PrepareFrameState(pair, expr->LookupId(),
2436 OutputFrameStateCombine::Push(2));
2437 break;
2438 }
2427 // Fall through. 2439 // Fall through.
2428 case Call::OTHER_CALL: 2440 case Call::OTHER_CALL:
2429 VisitForValue(callee); 2441 VisitForValue(callee);
2430 callee_value = environment()->Pop(); 2442 callee_value = environment()->Pop();
2431 receiver_value = jsgraph()->UndefinedConstant(); 2443 receiver_value = jsgraph()->UndefinedConstant();
2432 break; 2444 break;
2433 } 2445 }
2434 2446
2435 // The callee and the receiver both have to be pushed onto the operand stack 2447 // The callee and the receiver both have to be pushed onto the operand stack
2436 // before arguments are being evaluated. 2448 // before arguments are being evaluated.
(...skipping 15 matching lines...) Expand all
2452 2464
2453 // Create node to ask for help resolving potential eval call. This will 2465 // Create node to ask for help resolving potential eval call. This will
2454 // provide a fully resolved callee and the corresponding receiver. 2466 // provide a fully resolved callee and the corresponding receiver.
2455 Node* function = GetFunctionClosure(); 2467 Node* function = GetFunctionClosure();
2456 Node* language = jsgraph()->Constant(language_mode()); 2468 Node* language = jsgraph()->Constant(language_mode());
2457 Node* position = jsgraph()->Constant(current_scope()->start_position()); 2469 Node* position = jsgraph()->Constant(current_scope()->start_position());
2458 const Operator* op = 2470 const Operator* op =
2459 javascript()->CallRuntime(Runtime::kResolvePossiblyDirectEval, 5); 2471 javascript()->CallRuntime(Runtime::kResolvePossiblyDirectEval, 5);
2460 Node* new_callee = 2472 Node* new_callee =
2461 NewNode(op, callee, source, function, language, position); 2473 NewNode(op, callee, source, function, language, position);
2462 PrepareFrameState(new_callee, expr->EvalOrLookupId(), 2474 PrepareFrameState(new_callee, expr->EvalId(),
2463 OutputFrameStateCombine::PokeAt(arg_count + 1)); 2475 OutputFrameStateCombine::PokeAt(arg_count + 1));
2464 2476
2465 // Patch callee on the environment. 2477 // Patch callee on the environment.
2466 environment()->Poke(arg_count + 1, new_callee); 2478 environment()->Poke(arg_count + 1, new_callee);
2467 } 2479 }
2468 2480
2469 // Create node to perform the function call. 2481 // Create node to perform the function call.
2470 VectorSlotPair feedback = CreateVectorSlotPair(expr->CallFeedbackICSlot()); 2482 VectorSlotPair feedback = CreateVectorSlotPair(expr->CallFeedbackICSlot());
2471 const Operator* call = javascript()->CallFunction(args->length() + 2, flags, 2483 const Operator* call = javascript()->CallFunction(args->length() + 2, flags,
2472 language_mode(), feedback); 2484 language_mode(), feedback);
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after
4158 // Phi does not exist yet, introduce one. 4170 // Phi does not exist yet, introduce one.
4159 value = NewPhi(inputs, value, control); 4171 value = NewPhi(inputs, value, control);
4160 value->ReplaceInput(inputs - 1, other); 4172 value->ReplaceInput(inputs - 1, other);
4161 } 4173 }
4162 return value; 4174 return value;
4163 } 4175 }
4164 4176
4165 } // namespace compiler 4177 } // namespace compiler
4166 } // namespace internal 4178 } // namespace internal
4167 } // namespace v8 4179 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/full-codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698