| 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/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/compiler/control-builders.h" | 8 #include "src/compiler/control-builders.h" |
| 9 #include "src/compiler/machine-operator.h" | 9 #include "src/compiler/machine-operator.h" |
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 // Fall through. | 892 // Fall through. |
| 893 case ObjectLiteral::Property::COMPUTED: { | 893 case ObjectLiteral::Property::COMPUTED: { |
| 894 // It is safe to use [[Put]] here because the boilerplate already | 894 // It is safe to use [[Put]] here because the boilerplate already |
| 895 // contains computed properties with an uninitialized value. | 895 // contains computed properties with an uninitialized value. |
| 896 if (key->value()->IsInternalizedString()) { | 896 if (key->value()->IsInternalizedString()) { |
| 897 if (property->emit_store()) { | 897 if (property->emit_store()) { |
| 898 VisitForValue(property->value()); | 898 VisitForValue(property->value()); |
| 899 Node* value = environment()->Pop(); | 899 Node* value = environment()->Pop(); |
| 900 PrintableUnique<Name> name = MakeUnique(key->AsPropertyName()); | 900 PrintableUnique<Name> name = MakeUnique(key->AsPropertyName()); |
| 901 Node* store = | 901 Node* store = |
| 902 NewNode(javascript()->StoreNamed(name), literal, value); | 902 NewNode(javascript()->StoreNamed(info()->strict_mode(), name), |
| 903 literal, value); |
| 903 PrepareFrameState(store, key->id()); | 904 PrepareFrameState(store, key->id()); |
| 904 } else { | 905 } else { |
| 905 VisitForEffect(property->value()); | 906 VisitForEffect(property->value()); |
| 906 } | 907 } |
| 907 break; | 908 break; |
| 908 } | 909 } |
| 909 environment()->Push(literal); // Duplicate receiver. | 910 environment()->Push(literal); // Duplicate receiver. |
| 910 VisitForValue(property->key()); | 911 VisitForValue(property->key()); |
| 911 VisitForValue(property->value()); | 912 VisitForValue(property->value()); |
| 912 Node* value = environment()->Pop(); | 913 Node* value = environment()->Pop(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 | 986 |
| 986 // Create nodes to evaluate all the non-constant subexpressions and to store | 987 // Create nodes to evaluate all the non-constant subexpressions and to store |
| 987 // them into the newly cloned array. | 988 // them into the newly cloned array. |
| 988 for (int i = 0; i < expr->values()->length(); i++) { | 989 for (int i = 0; i < expr->values()->length(); i++) { |
| 989 Expression* subexpr = expr->values()->at(i); | 990 Expression* subexpr = expr->values()->at(i); |
| 990 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 991 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
| 991 | 992 |
| 992 VisitForValue(subexpr); | 993 VisitForValue(subexpr); |
| 993 Node* value = environment()->Pop(); | 994 Node* value = environment()->Pop(); |
| 994 Node* index = jsgraph()->Constant(i); | 995 Node* index = jsgraph()->Constant(i); |
| 995 Node* store = NewNode(javascript()->StoreProperty(), literal, index, value); | 996 Node* store = NewNode(javascript()->StoreProperty(info()->strict_mode()), |
| 997 literal, index, value); |
| 996 PrepareFrameState(store, expr->GetIdForElement(i)); | 998 PrepareFrameState(store, expr->GetIdForElement(i)); |
| 997 } | 999 } |
| 998 | 1000 |
| 999 environment()->Pop(); // Array literal index. | 1001 environment()->Pop(); // Array literal index. |
| 1000 ast_context()->ProduceValue(environment()->Pop()); | 1002 ast_context()->ProduceValue(environment()->Pop()); |
| 1001 } | 1003 } |
| 1002 | 1004 |
| 1003 | 1005 |
| 1004 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value) { | 1006 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value) { |
| 1005 DCHECK(expr->IsValidReferenceExpression()); | 1007 DCHECK(expr->IsValidReferenceExpression()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1016 BuildVariableAssignment(var, value, Token::ASSIGN, BailoutId::None()); | 1018 BuildVariableAssignment(var, value, Token::ASSIGN, BailoutId::None()); |
| 1017 break; | 1019 break; |
| 1018 } | 1020 } |
| 1019 case NAMED_PROPERTY: { | 1021 case NAMED_PROPERTY: { |
| 1020 environment()->Push(value); | 1022 environment()->Push(value); |
| 1021 VisitForValue(property->obj()); | 1023 VisitForValue(property->obj()); |
| 1022 Node* object = environment()->Pop(); | 1024 Node* object = environment()->Pop(); |
| 1023 value = environment()->Pop(); | 1025 value = environment()->Pop(); |
| 1024 PrintableUnique<Name> name = | 1026 PrintableUnique<Name> name = |
| 1025 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); | 1027 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); |
| 1026 Node* store = NewNode(javascript()->StoreNamed(name), object, value); | 1028 Node* store = NewNode( |
| 1029 javascript()->StoreNamed(info()->strict_mode(), name), object, value); |
| 1027 // TODO(jarin) Fill in the correct bailout id. | 1030 // TODO(jarin) Fill in the correct bailout id. |
| 1028 PrepareFrameState(store, BailoutId::None()); | 1031 PrepareFrameState(store, BailoutId::None()); |
| 1029 break; | 1032 break; |
| 1030 } | 1033 } |
| 1031 case KEYED_PROPERTY: { | 1034 case KEYED_PROPERTY: { |
| 1032 environment()->Push(value); | 1035 environment()->Push(value); |
| 1033 VisitForValue(property->obj()); | 1036 VisitForValue(property->obj()); |
| 1034 VisitForValue(property->key()); | 1037 VisitForValue(property->key()); |
| 1035 Node* key = environment()->Pop(); | 1038 Node* key = environment()->Pop(); |
| 1036 Node* object = environment()->Pop(); | 1039 Node* object = environment()->Pop(); |
| 1037 value = environment()->Pop(); | 1040 value = environment()->Pop(); |
| 1038 Node* store = NewNode(javascript()->StoreProperty(), object, key, value); | 1041 Node* store = NewNode(javascript()->StoreProperty(info()->strict_mode()), |
| 1042 object, key, value); |
| 1039 // TODO(jarin) Fill in the correct bailout id. | 1043 // TODO(jarin) Fill in the correct bailout id. |
| 1040 PrepareFrameState(store, BailoutId::None()); | 1044 PrepareFrameState(store, BailoutId::None()); |
| 1041 break; | 1045 break; |
| 1042 } | 1046 } |
| 1043 } | 1047 } |
| 1044 } | 1048 } |
| 1045 | 1049 |
| 1046 | 1050 |
| 1047 void AstGraphBuilder::VisitAssignment(Assignment* expr) { | 1051 void AstGraphBuilder::VisitAssignment(Assignment* expr) { |
| 1048 DCHECK(expr->target()->IsValidReferenceExpression()); | 1052 DCHECK(expr->target()->IsValidReferenceExpression()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 case VARIABLE: { | 1113 case VARIABLE: { |
| 1110 Variable* variable = expr->target()->AsVariableProxy()->var(); | 1114 Variable* variable = expr->target()->AsVariableProxy()->var(); |
| 1111 BuildVariableAssignment(variable, value, expr->op(), | 1115 BuildVariableAssignment(variable, value, expr->op(), |
| 1112 expr->AssignmentId()); | 1116 expr->AssignmentId()); |
| 1113 break; | 1117 break; |
| 1114 } | 1118 } |
| 1115 case NAMED_PROPERTY: { | 1119 case NAMED_PROPERTY: { |
| 1116 Node* object = environment()->Pop(); | 1120 Node* object = environment()->Pop(); |
| 1117 PrintableUnique<Name> name = | 1121 PrintableUnique<Name> name = |
| 1118 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); | 1122 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); |
| 1119 Node* store = NewNode(javascript()->StoreNamed(name), object, value); | 1123 Node* store = NewNode( |
| 1124 javascript()->StoreNamed(info()->strict_mode(), name), object, value); |
| 1120 PrepareFrameState(store, expr->AssignmentId()); | 1125 PrepareFrameState(store, expr->AssignmentId()); |
| 1121 break; | 1126 break; |
| 1122 } | 1127 } |
| 1123 case KEYED_PROPERTY: { | 1128 case KEYED_PROPERTY: { |
| 1124 Node* key = environment()->Pop(); | 1129 Node* key = environment()->Pop(); |
| 1125 Node* object = environment()->Pop(); | 1130 Node* object = environment()->Pop(); |
| 1126 Node* store = NewNode(javascript()->StoreProperty(), object, key, value); | 1131 Node* store = NewNode(javascript()->StoreProperty(info()->strict_mode()), |
| 1132 object, key, value); |
| 1127 PrepareFrameState(store, expr->AssignmentId()); | 1133 PrepareFrameState(store, expr->AssignmentId()); |
| 1128 break; | 1134 break; |
| 1129 } | 1135 } |
| 1130 } | 1136 } |
| 1131 | 1137 |
| 1132 ast_context()->ProduceValue(value); | 1138 ast_context()->ProduceValue(value); |
| 1133 } | 1139 } |
| 1134 | 1140 |
| 1135 | 1141 |
| 1136 void AstGraphBuilder::VisitYield(Yield* expr) { | 1142 void AstGraphBuilder::VisitYield(Yield* expr) { |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 case VARIABLE: { | 1420 case VARIABLE: { |
| 1415 Variable* variable = expr->expression()->AsVariableProxy()->var(); | 1421 Variable* variable = expr->expression()->AsVariableProxy()->var(); |
| 1416 BuildVariableAssignment(variable, value, expr->op(), | 1422 BuildVariableAssignment(variable, value, expr->op(), |
| 1417 expr->AssignmentId()); | 1423 expr->AssignmentId()); |
| 1418 break; | 1424 break; |
| 1419 } | 1425 } |
| 1420 case NAMED_PROPERTY: { | 1426 case NAMED_PROPERTY: { |
| 1421 Node* object = environment()->Pop(); | 1427 Node* object = environment()->Pop(); |
| 1422 PrintableUnique<Name> name = | 1428 PrintableUnique<Name> name = |
| 1423 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); | 1429 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); |
| 1424 Node* store = NewNode(javascript()->StoreNamed(name), object, value); | 1430 Node* store = NewNode( |
| 1431 javascript()->StoreNamed(info()->strict_mode(), name), object, value); |
| 1425 PrepareFrameState(store, expr->AssignmentId()); | 1432 PrepareFrameState(store, expr->AssignmentId()); |
| 1426 break; | 1433 break; |
| 1427 } | 1434 } |
| 1428 case KEYED_PROPERTY: { | 1435 case KEYED_PROPERTY: { |
| 1429 Node* key = environment()->Pop(); | 1436 Node* key = environment()->Pop(); |
| 1430 Node* object = environment()->Pop(); | 1437 Node* object = environment()->Pop(); |
| 1431 Node* store = NewNode(javascript()->StoreProperty(), object, key, value); | 1438 Node* store = NewNode(javascript()->StoreProperty(info()->strict_mode()), |
| 1439 object, key, value); |
| 1432 PrepareFrameState(store, expr->AssignmentId()); | 1440 PrepareFrameState(store, expr->AssignmentId()); |
| 1433 break; | 1441 break; |
| 1434 } | 1442 } |
| 1435 } | 1443 } |
| 1436 | 1444 |
| 1437 // Restore old value for postfix expressions. | 1445 // Restore old value for postfix expressions. |
| 1438 if (is_postfix) value = environment()->Pop(); | 1446 if (is_postfix) value = environment()->Pop(); |
| 1439 | 1447 |
| 1440 ast_context()->ProduceValue(value); | 1448 ast_context()->ProduceValue(value); |
| 1441 } | 1449 } |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 Node* AstGraphBuilder::BuildVariableAssignment(Variable* variable, Node* value, | 1839 Node* AstGraphBuilder::BuildVariableAssignment(Variable* variable, Node* value, |
| 1832 Token::Value op, | 1840 Token::Value op, |
| 1833 BailoutId bailout_id) { | 1841 BailoutId bailout_id) { |
| 1834 Node* the_hole = jsgraph()->TheHoleConstant(); | 1842 Node* the_hole = jsgraph()->TheHoleConstant(); |
| 1835 VariableMode mode = variable->mode(); | 1843 VariableMode mode = variable->mode(); |
| 1836 switch (variable->location()) { | 1844 switch (variable->location()) { |
| 1837 case Variable::UNALLOCATED: { | 1845 case Variable::UNALLOCATED: { |
| 1838 // Global var, const, or let variable. | 1846 // Global var, const, or let variable. |
| 1839 Node* global = BuildLoadGlobalObject(); | 1847 Node* global = BuildLoadGlobalObject(); |
| 1840 PrintableUnique<Name> name = MakeUnique(variable->name()); | 1848 PrintableUnique<Name> name = MakeUnique(variable->name()); |
| 1841 Operator* op = javascript()->StoreNamed(name); | 1849 Operator* op = javascript()->StoreNamed(info()->strict_mode(), name); |
| 1842 Node* store = NewNode(op, global, value); | 1850 Node* store = NewNode(op, global, value); |
| 1843 PrepareFrameState(store, bailout_id); | 1851 PrepareFrameState(store, bailout_id); |
| 1844 return store; | 1852 return store; |
| 1845 } | 1853 } |
| 1846 case Variable::PARAMETER: | 1854 case Variable::PARAMETER: |
| 1847 case Variable::LOCAL: | 1855 case Variable::LOCAL: |
| 1848 // Local var, const, or let variable. | 1856 // Local var, const, or let variable. |
| 1849 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { | 1857 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { |
| 1850 // Perform an initialization check for legacy const variables. | 1858 // Perform an initialization check for legacy const variables. |
| 1851 Node* current = environment()->Lookup(variable); | 1859 Node* current = environment()->Lookup(variable); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2031 | 2039 |
| 2032 // Continue with the original environment. | 2040 // Continue with the original environment. |
| 2033 set_environment(continuation_env); | 2041 set_environment(continuation_env); |
| 2034 NewNode(common()->Continuation()); | 2042 NewNode(common()->Continuation()); |
| 2035 } | 2043 } |
| 2036 } | 2044 } |
| 2037 | 2045 |
| 2038 } | 2046 } |
| 2039 } | 2047 } |
| 2040 } // namespace v8::internal::compiler | 2048 } // namespace v8::internal::compiler |
| OLD | NEW |