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

Unified Diff: src/compiler/ast-graph-builder.cc

Issue 1179893002: Add script context with context-allocated "const this" (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: arm64 fixups 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/bootstrapper.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index 43d402094539cfae9c31dd3f2f3395888a17db86..05819cdce6cd393a1d31a0ca66e61e1566b8e29c 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -2420,37 +2420,17 @@ void AstGraphBuilder::VisitCall(Call* expr) {
// Create node to ask for help resolving potential eval call. This will
// provide a fully resolved callee and the corresponding receiver.
Node* function = GetFunctionClosure();
- // TODO(wingo): ResolvePossibleDirectEval doesn't really need a receiver,
- // now that eval scopes don't have "this" declarations. Remove this hack
- // once ResolvePossibleDirectEval changes.
- Node* receiver;
- {
- Variable* variable = info()->scope()->LookupThis();
- if (variable->IsStackAllocated()) {
- receiver = environment()->Lookup(variable);
- } else {
- DCHECK(variable->IsContextSlot());
- int depth = current_scope()->ContextChainLength(variable->scope());
- bool immutable = variable->maybe_assigned() == kNotAssigned;
- const Operator* op =
- javascript()->LoadContext(depth, variable->index(), immutable);
- receiver = NewNode(op, current_context());
- }
- }
Node* language = jsgraph()->Constant(language_mode());
Node* position = jsgraph()->Constant(current_scope()->start_position());
const Operator* op =
- javascript()->CallRuntime(Runtime::kResolvePossiblyDirectEval, 6);
- Node* pair =
- NewNode(op, callee, source, function, receiver, language, position);
- PrepareFrameState(pair, expr->EvalOrLookupId(),
+ javascript()->CallRuntime(Runtime::kResolvePossiblyDirectEval, 5);
+ Node* new_callee =
+ NewNode(op, callee, source, function, language, position);
+ PrepareFrameState(new_callee, expr->EvalOrLookupId(),
OutputFrameStateCombine::PokeAt(arg_count + 1));
- Node* new_callee = NewNode(common()->Projection(0), pair);
- Node* new_receiver = NewNode(common()->Projection(1), pair);
- // Patch callee and receiver on the environment.
+ // Patch callee on the environment.
environment()->Poke(arg_count + 1, new_callee);
- environment()->Poke(arg_count + 0, new_receiver);
}
// Create node to perform the function call.
@@ -2873,7 +2853,13 @@ void AstGraphBuilder::VisitDelete(UnaryOperation* expr) {
// Delete of an unqualified identifier is only allowed in classic mode but
// deleting "this" is allowed in all language modes.
Variable* variable = expr->expression()->AsVariableProxy()->var();
- DCHECK(is_sloppy(language_mode()) || variable->is_this());
+ // Delete of an unqualified identifier is disallowed in strict mode but
+ // "delete this" is allowed. (It could be that the "this" variable has
Michael Starzinger 2015/06/12 08:06:10 nit: Can we merge this comment with the one two li
+ // DYNAMIC resolution though so we haven't been able to map it to
+ // Variable::THIS, but regardless if its name is "this" then it is
+ // "this".)
+ DCHECK(is_sloppy(language_mode()) ||
+ *variable->name() == *isolate()->factory()->this_string());
Michael Starzinger 2015/06/12 08:06:10 nit: This heavily relies on the fact that variable
value = BuildVariableDelete(variable, expr->id(),
ast_context()->GetStateCombine());
} else if (expr->expression()->IsProperty()) {
@@ -3321,9 +3307,11 @@ Node* AstGraphBuilder::BuildVariableDelete(Variable* variable,
}
case Variable::PARAMETER:
case Variable::LOCAL:
- case Variable::CONTEXT:
+ case Variable::CONTEXT: {
// Local var, const, or let variable or context variable.
- return jsgraph()->BooleanConstant(variable->is_this());
+ bool is_this = *variable->name() == *isolate()->factory()->this_string();
Michael Starzinger 2015/06/12 08:06:10 nit: See comment above.
+ return jsgraph()->BooleanConstant(is_this);
+ }
case Variable::LOOKUP: {
// Dynamic lookup of context variable (anywhere in the chain).
Node* name = jsgraph()->Constant(variable->name());
« no previous file with comments | « src/bootstrapper.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698