OLD | NEW |
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/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/compiler/ast-loop-assignment-analyzer.h" | 9 #include "src/compiler/ast-loop-assignment-analyzer.h" |
10 #include "src/compiler/control-builders.h" | 10 #include "src/compiler/control-builders.h" |
(...skipping 2918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2929 Node* node = NewNode(javascript()->StackCheck()); | 2929 Node* node = NewNode(javascript()->StackCheck()); |
2930 PrepareFrameState(node, stack_check_id); | 2930 PrepareFrameState(node, stack_check_id); |
2931 } | 2931 } |
2932 Visit(stmt->body()); | 2932 Visit(stmt->body()); |
2933 } | 2933 } |
2934 | 2934 |
2935 | 2935 |
2936 void AstGraphBuilder::VisitDelete(UnaryOperation* expr) { | 2936 void AstGraphBuilder::VisitDelete(UnaryOperation* expr) { |
2937 Node* value; | 2937 Node* value; |
2938 if (expr->expression()->IsVariableProxy()) { | 2938 if (expr->expression()->IsVariableProxy()) { |
2939 // Delete of an unqualified identifier is only allowed in classic mode but | |
2940 // deleting "this" is allowed in all language modes. | |
2941 Variable* variable = expr->expression()->AsVariableProxy()->var(); | |
2942 // Delete of an unqualified identifier is disallowed in strict mode but | 2939 // Delete of an unqualified identifier is disallowed in strict mode but |
2943 // "delete this" is allowed. | 2940 // "delete this" is allowed. |
2944 DCHECK(is_sloppy(language_mode()) || variable->HasThisName(isolate())); | 2941 Variable* variable = expr->expression()->AsVariableProxy()->var(); |
| 2942 DCHECK(is_sloppy(language_mode()) || variable->is_this()); |
2945 value = BuildVariableDelete(variable, expr->id(), | 2943 value = BuildVariableDelete(variable, expr->id(), |
2946 ast_context()->GetStateCombine()); | 2944 ast_context()->GetStateCombine()); |
2947 } else if (expr->expression()->IsProperty()) { | 2945 } else if (expr->expression()->IsProperty()) { |
2948 Property* property = expr->expression()->AsProperty(); | 2946 Property* property = expr->expression()->AsProperty(); |
2949 VisitForValue(property->obj()); | 2947 VisitForValue(property->obj()); |
2950 VisitForValue(property->key()); | 2948 VisitForValue(property->key()); |
2951 Node* key = environment()->Pop(); | 2949 Node* key = environment()->Pop(); |
2952 Node* object = environment()->Pop(); | 2950 Node* object = environment()->Pop(); |
2953 value = NewNode(javascript()->DeleteProperty(language_mode()), object, key); | 2951 value = NewNode(javascript()->DeleteProperty(language_mode()), object, key); |
2954 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 2952 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3396 Node* name = jsgraph()->Constant(variable->name()); | 3394 Node* name = jsgraph()->Constant(variable->name()); |
3397 const Operator* op = javascript()->DeleteProperty(language_mode()); | 3395 const Operator* op = javascript()->DeleteProperty(language_mode()); |
3398 Node* result = NewNode(op, global, name); | 3396 Node* result = NewNode(op, global, name); |
3399 PrepareFrameState(result, bailout_id, combine); | 3397 PrepareFrameState(result, bailout_id, combine); |
3400 return result; | 3398 return result; |
3401 } | 3399 } |
3402 case VariableLocation::PARAMETER: | 3400 case VariableLocation::PARAMETER: |
3403 case VariableLocation::LOCAL: | 3401 case VariableLocation::LOCAL: |
3404 case VariableLocation::CONTEXT: { | 3402 case VariableLocation::CONTEXT: { |
3405 // Local var, const, or let variable or context variable. | 3403 // Local var, const, or let variable or context variable. |
3406 return jsgraph()->BooleanConstant(variable->HasThisName(isolate())); | 3404 return jsgraph()->BooleanConstant(variable->is_this()); |
3407 } | 3405 } |
3408 case VariableLocation::LOOKUP: { | 3406 case VariableLocation::LOOKUP: { |
3409 // Dynamic lookup of context variable (anywhere in the chain). | 3407 // Dynamic lookup of context variable (anywhere in the chain). |
3410 Node* name = jsgraph()->Constant(variable->name()); | 3408 Node* name = jsgraph()->Constant(variable->name()); |
3411 const Operator* op = | 3409 const Operator* op = |
3412 javascript()->CallRuntime(Runtime::kDeleteLookupSlot); | 3410 javascript()->CallRuntime(Runtime::kDeleteLookupSlot); |
3413 Node* result = NewNode(op, name); | 3411 Node* result = NewNode(op, name); |
3414 PrepareFrameState(result, bailout_id, combine); | 3412 PrepareFrameState(result, bailout_id, combine); |
3415 return result; | 3413 return result; |
3416 } | 3414 } |
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4320 // Phi does not exist yet, introduce one. | 4318 // Phi does not exist yet, introduce one. |
4321 value = NewPhi(inputs, value, control); | 4319 value = NewPhi(inputs, value, control); |
4322 value->ReplaceInput(inputs - 1, other); | 4320 value->ReplaceInput(inputs - 1, other); |
4323 } | 4321 } |
4324 return value; | 4322 return value; |
4325 } | 4323 } |
4326 | 4324 |
4327 } // namespace compiler | 4325 } // namespace compiler |
4328 } // namespace internal | 4326 } // namespace internal |
4329 } // namespace v8 | 4327 } // namespace v8 |
OLD | NEW |