| 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" |
| 11 #include "src/compiler/node-properties-inl.h" | 11 #include "src/compiler/node-properties-inl.h" |
| 12 #include "src/full-codegen.h" | 12 #include "src/full-codegen.h" |
| 13 #include "src/parser.h" | 13 #include "src/parser.h" |
| 14 #include "src/scopes.h" | 14 #include "src/scopes.h" |
| 15 | 15 |
| 16 namespace v8 { | 16 namespace v8 { |
| 17 namespace internal { | 17 namespace internal { |
| 18 namespace compiler { | 18 namespace compiler { |
| 19 | 19 |
| 20 AstGraphBuilder::AstGraphBuilder(CompilationInfo* info, JSGraph* jsgraph) | 20 AstGraphBuilder::AstGraphBuilder(CompilationInfo* info, JSGraph* jsgraph) |
| 21 : StructuredGraphBuilder(jsgraph->graph(), jsgraph->common()), | 21 : StructuredGraphBuilder(jsgraph->graph(), jsgraph->common()), |
| 22 info_(info), | 22 info_(info), |
| 23 vector_(handle(info->shared_info()->feedback_vector())), |
| 23 jsgraph_(jsgraph), | 24 jsgraph_(jsgraph), |
| 24 globals_(0, info->zone()), | 25 globals_(0, info->zone()), |
| 25 breakable_(NULL), | 26 breakable_(NULL), |
| 26 execution_context_(NULL) { | 27 execution_context_(NULL) { |
| 27 InitializeAstVisitor(info->zone()); | 28 InitializeAstVisitor(info->zone()); |
| 28 } | 29 } |
| 29 | 30 |
| 30 | 31 |
| 31 Node* AstGraphBuilder::GetFunctionClosure() { | 32 Node* AstGraphBuilder::GetFunctionClosure() { |
| 32 if (!function_closure_.is_set()) { | 33 if (!function_closure_.is_set()) { |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 compare_if.Then(); | 831 compare_if.Then(); |
| 831 Visit(expr->then_expression()); | 832 Visit(expr->then_expression()); |
| 832 compare_if.Else(); | 833 compare_if.Else(); |
| 833 Visit(expr->else_expression()); | 834 Visit(expr->else_expression()); |
| 834 compare_if.End(); | 835 compare_if.End(); |
| 835 ast_context()->ReplaceValue(); | 836 ast_context()->ReplaceValue(); |
| 836 } | 837 } |
| 837 | 838 |
| 838 | 839 |
| 839 void AstGraphBuilder::VisitVariableProxy(VariableProxy* expr) { | 840 void AstGraphBuilder::VisitVariableProxy(VariableProxy* expr) { |
| 840 Node* value = BuildVariableLoad(expr->var(), expr->id()); | 841 Node* value = BuildVariableLoad(expr, expr->id()); |
| 841 ast_context()->ProduceValue(value); | 842 ast_context()->ProduceValue(value); |
| 842 } | 843 } |
| 843 | 844 |
| 844 | 845 |
| 845 void AstGraphBuilder::VisitLiteral(Literal* expr) { | 846 void AstGraphBuilder::VisitLiteral(Literal* expr) { |
| 846 Node* value = jsgraph()->Constant(expr->value()); | 847 Node* value = jsgraph()->Constant(expr->value()); |
| 847 ast_context()->ProduceValue(value); | 848 ast_context()->ProduceValue(value); |
| 848 } | 849 } |
| 849 | 850 |
| 850 | 851 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 break; | 1085 break; |
| 1085 } | 1086 } |
| 1086 } | 1087 } |
| 1087 | 1088 |
| 1088 // Evaluate the value and potentially handle compound assignments by loading | 1089 // Evaluate the value and potentially handle compound assignments by loading |
| 1089 // the left-hand side value and performing a binary operation. | 1090 // the left-hand side value and performing a binary operation. |
| 1090 if (expr->is_compound()) { | 1091 if (expr->is_compound()) { |
| 1091 Node* old_value = NULL; | 1092 Node* old_value = NULL; |
| 1092 switch (assign_type) { | 1093 switch (assign_type) { |
| 1093 case VARIABLE: { | 1094 case VARIABLE: { |
| 1094 Variable* variable = expr->target()->AsVariableProxy()->var(); | 1095 VariableProxy* proxy = expr->target()->AsVariableProxy(); |
| 1095 old_value = BuildVariableLoad(variable, expr->target()->id()); | 1096 old_value = BuildVariableLoad(proxy, expr->target()->id()); |
| 1096 break; | 1097 break; |
| 1097 } | 1098 } |
| 1098 case NAMED_PROPERTY: { | 1099 case NAMED_PROPERTY: { |
| 1099 Node* object = environment()->Top(); | 1100 Node* object = environment()->Top(); |
| 1100 Unique<Name> name = | 1101 Unique<Name> name = |
| 1101 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); | 1102 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); |
| 1102 old_value = NewNode(javascript()->LoadNamed(name), object); | 1103 int slot = property->PropertyFeedbackSlot(); |
| 1104 old_value = NewNode( |
| 1105 javascript()->LoadNamed(name, LoadNamedFeedback(slot)), object); |
| 1103 PrepareFrameState(old_value, property->LoadId(), | 1106 PrepareFrameState(old_value, property->LoadId(), |
| 1104 OutputFrameStateCombine::Push()); | 1107 OutputFrameStateCombine::Push()); |
| 1105 break; | 1108 break; |
| 1106 } | 1109 } |
| 1107 case KEYED_PROPERTY: { | 1110 case KEYED_PROPERTY: { |
| 1108 Node* key = environment()->Top(); | 1111 Node* key = environment()->Top(); |
| 1109 Node* object = environment()->Peek(1); | 1112 Node* object = environment()->Peek(1); |
| 1110 old_value = NewNode(javascript()->LoadProperty(), object, key); | 1113 int slot = property->PropertyFeedbackSlot(); |
| 1114 old_value = |
| 1115 NewNode(javascript()->LoadProperty(LoadPropertyFeedback(slot)), |
| 1116 object, key); |
| 1111 PrepareFrameState(old_value, property->LoadId(), | 1117 PrepareFrameState(old_value, property->LoadId(), |
| 1112 OutputFrameStateCombine::Push()); | 1118 OutputFrameStateCombine::Push()); |
| 1113 break; | 1119 break; |
| 1114 } | 1120 } |
| 1115 } | 1121 } |
| 1116 environment()->Push(old_value); | 1122 environment()->Push(old_value); |
| 1117 VisitForValue(expr->value()); | 1123 VisitForValue(expr->value()); |
| 1118 Node* right = environment()->Pop(); | 1124 Node* right = environment()->Pop(); |
| 1119 Node* left = environment()->Pop(); | 1125 Node* left = environment()->Pop(); |
| 1120 Node* value = BuildBinaryOp(left, right, expr->binary_op()); | 1126 Node* value = BuildBinaryOp(left, right, expr->binary_op()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 Node* exception = environment()->Pop(); | 1178 Node* exception = environment()->Pop(); |
| 1173 const Operator* op = javascript()->CallRuntime(Runtime::kThrow, 1); | 1179 const Operator* op = javascript()->CallRuntime(Runtime::kThrow, 1); |
| 1174 Node* value = NewNode(op, exception); | 1180 Node* value = NewNode(op, exception); |
| 1175 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 1181 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); |
| 1176 ast_context()->ProduceValue(value); | 1182 ast_context()->ProduceValue(value); |
| 1177 } | 1183 } |
| 1178 | 1184 |
| 1179 | 1185 |
| 1180 void AstGraphBuilder::VisitProperty(Property* expr) { | 1186 void AstGraphBuilder::VisitProperty(Property* expr) { |
| 1181 Node* value; | 1187 Node* value; |
| 1188 int slot = expr->PropertyFeedbackSlot(); |
| 1182 if (expr->key()->IsPropertyName()) { | 1189 if (expr->key()->IsPropertyName()) { |
| 1183 VisitForValue(expr->obj()); | 1190 VisitForValue(expr->obj()); |
| 1184 Node* object = environment()->Pop(); | 1191 Node* object = environment()->Pop(); |
| 1185 Unique<Name> name = MakeUnique(expr->key()->AsLiteral()->AsPropertyName()); | 1192 Unique<Name> name = MakeUnique(expr->key()->AsLiteral()->AsPropertyName()); |
| 1186 value = NewNode(javascript()->LoadNamed(name), object); | 1193 value = |
| 1194 NewNode(javascript()->LoadNamed(name, LoadNamedFeedback(slot)), object); |
| 1187 } else { | 1195 } else { |
| 1188 VisitForValue(expr->obj()); | 1196 VisitForValue(expr->obj()); |
| 1189 VisitForValue(expr->key()); | 1197 VisitForValue(expr->key()); |
| 1190 Node* key = environment()->Pop(); | 1198 Node* key = environment()->Pop(); |
| 1191 Node* object = environment()->Pop(); | 1199 Node* object = environment()->Pop(); |
| 1192 value = NewNode(javascript()->LoadProperty(), object, key); | 1200 value = NewNode(javascript()->LoadProperty(LoadPropertyFeedback(slot)), |
| 1201 object, key); |
| 1193 } | 1202 } |
| 1194 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 1203 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); |
| 1195 ast_context()->ProduceValue(value); | 1204 ast_context()->ProduceValue(value); |
| 1196 } | 1205 } |
| 1197 | 1206 |
| 1198 | 1207 |
| 1199 void AstGraphBuilder::VisitCall(Call* expr) { | 1208 void AstGraphBuilder::VisitCall(Call* expr) { |
| 1200 Expression* callee = expr->expression(); | 1209 Expression* callee = expr->expression(); |
| 1201 Call::CallType call_type = expr->GetCallType(isolate()); | 1210 Call::CallType call_type = expr->GetCallType(isolate()); |
| 1202 | 1211 |
| 1203 // Prepare the callee and the receiver to the function call. This depends on | 1212 // Prepare the callee and the receiver to the function call. This depends on |
| 1204 // the semantics of the underlying call type. | 1213 // the semantics of the underlying call type. |
| 1205 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; | 1214 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; |
| 1206 Node* receiver_value = NULL; | 1215 Node* receiver_value = NULL; |
| 1207 Node* callee_value = NULL; | 1216 Node* callee_value = NULL; |
| 1208 bool possibly_eval = false; | 1217 bool possibly_eval = false; |
| 1209 switch (call_type) { | 1218 switch (call_type) { |
| 1210 case Call::GLOBAL_CALL: { | 1219 case Call::GLOBAL_CALL: { |
| 1211 Variable* variable = callee->AsVariableProxy()->var(); | 1220 VariableProxy* proxy = callee->AsVariableProxy(); |
| 1212 callee_value = BuildVariableLoad(variable, expr->expression()->id()); | 1221 callee_value = BuildVariableLoad(proxy, expr->expression()->id()); |
| 1213 receiver_value = jsgraph()->UndefinedConstant(); | 1222 receiver_value = jsgraph()->UndefinedConstant(); |
| 1214 break; | 1223 break; |
| 1215 } | 1224 } |
| 1216 case Call::LOOKUP_SLOT_CALL: { | 1225 case Call::LOOKUP_SLOT_CALL: { |
| 1217 Variable* variable = callee->AsVariableProxy()->var(); | 1226 Variable* variable = callee->AsVariableProxy()->var(); |
| 1218 DCHECK(variable->location() == Variable::LOOKUP); | 1227 DCHECK(variable->location() == Variable::LOOKUP); |
| 1219 Node* name = jsgraph()->Constant(variable->name()); | 1228 Node* name = jsgraph()->Constant(variable->name()); |
| 1220 const Operator* op = | 1229 const Operator* op = |
| 1221 javascript()->CallRuntime(Runtime::kLoadLookupSlot, 2); | 1230 javascript()->CallRuntime(Runtime::kLoadLookupSlot, 2); |
| 1222 Node* pair = NewNode(op, current_context(), name); | 1231 Node* pair = NewNode(op, current_context(), name); |
| 1223 callee_value = NewNode(common()->Projection(0), pair); | 1232 callee_value = NewNode(common()->Projection(0), pair); |
| 1224 receiver_value = NewNode(common()->Projection(1), pair); | 1233 receiver_value = NewNode(common()->Projection(1), pair); |
| 1225 | 1234 |
| 1226 PrepareFrameState(pair, expr->EvalOrLookupId(), | 1235 PrepareFrameState(pair, expr->EvalOrLookupId(), |
| 1227 OutputFrameStateCombine::Push()); | 1236 OutputFrameStateCombine::Push()); |
| 1228 break; | 1237 break; |
| 1229 } | 1238 } |
| 1230 case Call::PROPERTY_CALL: { | 1239 case Call::PROPERTY_CALL: { |
| 1231 Property* property = callee->AsProperty(); | 1240 Property* property = callee->AsProperty(); |
| 1232 VisitForValue(property->obj()); | 1241 VisitForValue(property->obj()); |
| 1233 Node* object = environment()->Top(); | 1242 Node* object = environment()->Top(); |
| 1243 int slot = property->PropertyFeedbackSlot(); |
| 1234 if (property->key()->IsPropertyName()) { | 1244 if (property->key()->IsPropertyName()) { |
| 1235 Unique<Name> name = | 1245 Unique<Name> name = |
| 1236 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); | 1246 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); |
| 1237 callee_value = NewNode(javascript()->LoadNamed(name), object); | 1247 callee_value = NewNode( |
| 1248 javascript()->LoadNamed(name, LoadNamedFeedback(slot)), object); |
| 1238 } else { | 1249 } else { |
| 1239 VisitForValue(property->key()); | 1250 VisitForValue(property->key()); |
| 1240 Node* key = environment()->Pop(); | 1251 Node* key = environment()->Pop(); |
| 1241 callee_value = NewNode(javascript()->LoadProperty(), object, key); | 1252 callee_value = |
| 1253 NewNode(javascript()->LoadProperty(LoadPropertyFeedback(slot)), |
| 1254 object, key); |
| 1242 } | 1255 } |
| 1243 PrepareFrameState(callee_value, property->LoadId(), | 1256 PrepareFrameState(callee_value, property->LoadId(), |
| 1244 OutputFrameStateCombine::Push()); | 1257 OutputFrameStateCombine::Push()); |
| 1245 receiver_value = environment()->Pop(); | 1258 receiver_value = environment()->Pop(); |
| 1246 // Note that a PROPERTY_CALL requires the receiver to be wrapped into an | 1259 // Note that a PROPERTY_CALL requires the receiver to be wrapped into an |
| 1247 // object for sloppy callees. This could also be modeled explicitly here, | 1260 // object for sloppy callees. This could also be modeled explicitly here, |
| 1248 // thereby obsoleting the need for a flag to the call operator. | 1261 // thereby obsoleting the need for a flag to the call operator. |
| 1249 flags = CALL_AS_METHOD; | 1262 flags = CALL_AS_METHOD; |
| 1250 break; | 1263 break; |
| 1251 } | 1264 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 | 1332 |
| 1320 | 1333 |
| 1321 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { | 1334 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { |
| 1322 Handle<String> name = expr->name(); | 1335 Handle<String> name = expr->name(); |
| 1323 | 1336 |
| 1324 // The callee and the receiver both have to be pushed onto the operand stack | 1337 // The callee and the receiver both have to be pushed onto the operand stack |
| 1325 // before arguments are being evaluated. | 1338 // before arguments are being evaluated. |
| 1326 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; | 1339 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; |
| 1327 Node* receiver_value = BuildLoadBuiltinsObject(); | 1340 Node* receiver_value = BuildLoadBuiltinsObject(); |
| 1328 Unique<String> unique = MakeUnique(name); | 1341 Unique<String> unique = MakeUnique(name); |
| 1329 Node* callee_value = NewNode(javascript()->LoadNamed(unique), receiver_value); | 1342 int slot = expr->CallRuntimeFeedbackSlot(); |
| 1343 Node* callee_value = NewNode( |
| 1344 javascript()->LoadNamed(unique, LoadNamedFeedback(slot)), receiver_value); |
| 1330 // TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft | 1345 // TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft |
| 1331 // refuses to optimize functions with jsruntime calls). | 1346 // refuses to optimize functions with jsruntime calls). |
| 1332 PrepareFrameState(callee_value, BailoutId::None(), | 1347 PrepareFrameState(callee_value, BailoutId::None(), |
| 1333 OutputFrameStateCombine::Push()); | 1348 OutputFrameStateCombine::Push()); |
| 1334 environment()->Push(callee_value); | 1349 environment()->Push(callee_value); |
| 1335 environment()->Push(receiver_value); | 1350 environment()->Push(receiver_value); |
| 1336 | 1351 |
| 1337 // Evaluate all arguments to the JS runtime call. | 1352 // Evaluate all arguments to the JS runtime call. |
| 1338 ZoneList<Expression*>* args = expr->arguments(); | 1353 ZoneList<Expression*>* args = expr->arguments(); |
| 1339 VisitForValues(args); | 1354 VisitForValues(args); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1394 | 1409 |
| 1395 // Reserve space for result of postfix operation. | 1410 // Reserve space for result of postfix operation. |
| 1396 bool is_postfix = expr->is_postfix() && !ast_context()->IsEffect(); | 1411 bool is_postfix = expr->is_postfix() && !ast_context()->IsEffect(); |
| 1397 if (is_postfix) environment()->Push(jsgraph()->UndefinedConstant()); | 1412 if (is_postfix) environment()->Push(jsgraph()->UndefinedConstant()); |
| 1398 | 1413 |
| 1399 // Evaluate LHS expression and get old value. | 1414 // Evaluate LHS expression and get old value. |
| 1400 Node* old_value = NULL; | 1415 Node* old_value = NULL; |
| 1401 int stack_depth = -1; | 1416 int stack_depth = -1; |
| 1402 switch (assign_type) { | 1417 switch (assign_type) { |
| 1403 case VARIABLE: { | 1418 case VARIABLE: { |
| 1404 Variable* variable = expr->expression()->AsVariableProxy()->var(); | 1419 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| 1405 old_value = BuildVariableLoad(variable, expr->expression()->id()); | 1420 old_value = BuildVariableLoad(proxy, expr->expression()->id()); |
| 1406 stack_depth = 0; | 1421 stack_depth = 0; |
| 1407 break; | 1422 break; |
| 1408 } | 1423 } |
| 1409 case NAMED_PROPERTY: { | 1424 case NAMED_PROPERTY: { |
| 1410 VisitForValue(property->obj()); | 1425 VisitForValue(property->obj()); |
| 1411 Node* object = environment()->Top(); | 1426 Node* object = environment()->Top(); |
| 1412 Unique<Name> name = | 1427 Unique<Name> name = |
| 1413 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); | 1428 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); |
| 1414 old_value = NewNode(javascript()->LoadNamed(name), object); | 1429 int slot = property->PropertyFeedbackSlot(); |
| 1430 old_value = NewNode( |
| 1431 javascript()->LoadNamed(name, LoadNamedFeedback(slot)), object); |
| 1415 PrepareFrameState(old_value, property->LoadId(), | 1432 PrepareFrameState(old_value, property->LoadId(), |
| 1416 OutputFrameStateCombine::Push()); | 1433 OutputFrameStateCombine::Push()); |
| 1417 stack_depth = 1; | 1434 stack_depth = 1; |
| 1418 break; | 1435 break; |
| 1419 } | 1436 } |
| 1420 case KEYED_PROPERTY: { | 1437 case KEYED_PROPERTY: { |
| 1421 VisitForValue(property->obj()); | 1438 VisitForValue(property->obj()); |
| 1422 VisitForValue(property->key()); | 1439 VisitForValue(property->key()); |
| 1423 Node* key = environment()->Top(); | 1440 Node* key = environment()->Top(); |
| 1424 Node* object = environment()->Peek(1); | 1441 Node* object = environment()->Peek(1); |
| 1425 old_value = NewNode(javascript()->LoadProperty(), object, key); | 1442 int slot = property->PropertyFeedbackSlot(); |
| 1443 old_value = NewNode( |
| 1444 javascript()->LoadProperty(LoadPropertyFeedback(slot)), object, key); |
| 1426 PrepareFrameState(old_value, property->LoadId(), | 1445 PrepareFrameState(old_value, property->LoadId(), |
| 1427 OutputFrameStateCombine::Push()); | 1446 OutputFrameStateCombine::Push()); |
| 1428 stack_depth = 2; | 1447 stack_depth = 2; |
| 1429 break; | 1448 break; |
| 1430 } | 1449 } |
| 1431 } | 1450 } |
| 1432 | 1451 |
| 1433 // Convert old value into a number. | 1452 // Convert old value into a number. |
| 1434 old_value = NewNode(javascript()->ToNumber(), old_value); | 1453 old_value = NewNode(javascript()->ToNumber(), old_value); |
| 1435 | 1454 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1625 Node* value = jsgraph()->UndefinedConstant(); | 1644 Node* value = jsgraph()->UndefinedConstant(); |
| 1626 ast_context()->ProduceValue(value); | 1645 ast_context()->ProduceValue(value); |
| 1627 } | 1646 } |
| 1628 | 1647 |
| 1629 | 1648 |
| 1630 void AstGraphBuilder::VisitTypeof(UnaryOperation* expr) { | 1649 void AstGraphBuilder::VisitTypeof(UnaryOperation* expr) { |
| 1631 Node* operand; | 1650 Node* operand; |
| 1632 if (expr->expression()->IsVariableProxy()) { | 1651 if (expr->expression()->IsVariableProxy()) { |
| 1633 // Typeof does not throw a reference error on global variables, hence we | 1652 // Typeof does not throw a reference error on global variables, hence we |
| 1634 // perform a non-contextual load in case the operand is a variable proxy. | 1653 // perform a non-contextual load in case the operand is a variable proxy. |
| 1635 Variable* variable = expr->expression()->AsVariableProxy()->var(); | 1654 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| 1636 operand = | 1655 operand = |
| 1637 BuildVariableLoad(variable, expr->expression()->id(), NOT_CONTEXTUAL); | 1656 BuildVariableLoad(proxy, expr->expression()->id(), NOT_CONTEXTUAL); |
| 1638 } else { | 1657 } else { |
| 1639 VisitForValue(expr->expression()); | 1658 VisitForValue(expr->expression()); |
| 1640 operand = environment()->Pop(); | 1659 operand = environment()->Pop(); |
| 1641 } | 1660 } |
| 1642 Node* value = NewNode(javascript()->TypeOf(), operand); | 1661 Node* value = NewNode(javascript()->TypeOf(), operand); |
| 1643 ast_context()->ProduceValue(value); | 1662 ast_context()->ProduceValue(value); |
| 1644 } | 1663 } |
| 1645 | 1664 |
| 1646 | 1665 |
| 1647 void AstGraphBuilder::VisitNot(UnaryOperation* expr) { | 1666 void AstGraphBuilder::VisitNot(UnaryOperation* expr) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 hole_check.If(check); | 1789 hole_check.If(check); |
| 1771 hole_check.Then(); | 1790 hole_check.Then(); |
| 1772 environment()->Push(BuildThrowReferenceError(variable, bailout_id)); | 1791 environment()->Push(BuildThrowReferenceError(variable, bailout_id)); |
| 1773 hole_check.Else(); | 1792 hole_check.Else(); |
| 1774 environment()->Push(not_hole); | 1793 environment()->Push(not_hole); |
| 1775 hole_check.End(); | 1794 hole_check.End(); |
| 1776 return environment()->Pop(); | 1795 return environment()->Pop(); |
| 1777 } | 1796 } |
| 1778 | 1797 |
| 1779 | 1798 |
| 1780 Node* AstGraphBuilder::BuildVariableLoad(Variable* variable, | 1799 Node* AstGraphBuilder::BuildVariableLoad(VariableProxy* proxy, |
| 1781 BailoutId bailout_id, | 1800 BailoutId bailout_id, |
| 1782 ContextualMode contextual_mode) { | 1801 ContextualMode contextual_mode) { |
| 1802 Variable* variable = proxy->var(); |
| 1803 int slot = proxy->VariableFeedbackSlot(); |
| 1783 Node* the_hole = jsgraph()->TheHoleConstant(); | 1804 Node* the_hole = jsgraph()->TheHoleConstant(); |
| 1784 VariableMode mode = variable->mode(); | 1805 VariableMode mode = variable->mode(); |
| 1785 switch (variable->location()) { | 1806 switch (variable->location()) { |
| 1786 case Variable::UNALLOCATED: { | 1807 case Variable::UNALLOCATED: { |
| 1787 // Global var, const, or let variable. | 1808 // Global var, const, or let variable. |
| 1788 Node* global = BuildLoadGlobalObject(); | 1809 Node* global = BuildLoadGlobalObject(); |
| 1789 Unique<Name> name = MakeUnique(variable->name()); | 1810 Unique<Name> name = MakeUnique(variable->name()); |
| 1790 const Operator* op = javascript()->LoadNamed(name, contextual_mode); | 1811 const Operator* op = javascript()->LoadNamed( |
| 1812 name, LoadNamedFeedback(slot), contextual_mode); |
| 1791 Node* node = NewNode(op, global); | 1813 Node* node = NewNode(op, global); |
| 1792 PrepareFrameState(node, bailout_id, OutputFrameStateCombine::Push()); | 1814 PrepareFrameState(node, bailout_id, OutputFrameStateCombine::Push()); |
| 1793 return node; | 1815 return node; |
| 1794 } | 1816 } |
| 1795 case Variable::PARAMETER: | 1817 case Variable::PARAMETER: |
| 1796 case Variable::LOCAL: { | 1818 case Variable::LOCAL: { |
| 1797 // Local var, const, or let variable. | 1819 // Local var, const, or let variable. |
| 1798 Node* value = environment()->Lookup(variable); | 1820 Node* value = environment()->Lookup(variable); |
| 1799 if (mode == CONST_LEGACY) { | 1821 if (mode == CONST_LEGACY) { |
| 1800 // Perform check for uninitialized legacy const variables. | 1822 // Perform check for uninitialized legacy const variables. |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2082 DCHECK(NodeProperties::GetFrameStateInput(node)->opcode() == | 2104 DCHECK(NodeProperties::GetFrameStateInput(node)->opcode() == |
| 2083 IrOpcode::kDead); | 2105 IrOpcode::kDead); |
| 2084 NodeProperties::ReplaceFrameStateInput( | 2106 NodeProperties::ReplaceFrameStateInput( |
| 2085 node, environment()->Checkpoint(ast_id, combine)); | 2107 node, environment()->Checkpoint(ast_id, combine)); |
| 2086 } | 2108 } |
| 2087 } | 2109 } |
| 2088 | 2110 |
| 2089 } | 2111 } |
| 2090 } | 2112 } |
| 2091 } // namespace v8::internal::compiler | 2113 } // namespace v8::internal::compiler |
| OLD | NEW |