| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/full-codegen/full-codegen.h" | 5 #include "src/full-codegen/full-codegen.h" |
| 6 | 6 |
| 7 #include "src/ast/ast-numbering.h" | 7 #include "src/ast/ast-numbering.h" |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/prettyprinter.h" | 9 #include "src/ast/prettyprinter.h" |
| 10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 } | 846 } |
| 847 } | 847 } |
| 848 | 848 |
| 849 void FullCodeGenerator::VisitProperty(Property* expr) { | 849 void FullCodeGenerator::VisitProperty(Property* expr) { |
| 850 Comment cmnt(masm_, "[ Property"); | 850 Comment cmnt(masm_, "[ Property"); |
| 851 SetExpressionPosition(expr); | 851 SetExpressionPosition(expr); |
| 852 | 852 |
| 853 Expression* key = expr->key(); | 853 Expression* key = expr->key(); |
| 854 | 854 |
| 855 if (key->IsPropertyName()) { | 855 if (key->IsPropertyName()) { |
| 856 if (!expr->IsSuperAccess()) { | 856 DCHECK(!expr->IsSuperAccess()); |
| 857 VisitForAccumulatorValue(expr->obj()); | 857 VisitForAccumulatorValue(expr->obj()); |
| 858 __ Move(LoadDescriptor::ReceiverRegister(), result_register()); | 858 __ Move(LoadDescriptor::ReceiverRegister(), result_register()); |
| 859 EmitNamedPropertyLoad(expr); | 859 EmitNamedPropertyLoad(expr); |
| 860 } else { | |
| 861 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); | |
| 862 VisitForStackValue( | |
| 863 expr->obj()->AsSuperPropertyReference()->home_object()); | |
| 864 EmitNamedSuperPropertyLoad(expr); | |
| 865 } | |
| 866 } else { | 860 } else { |
| 867 if (!expr->IsSuperAccess()) { | 861 DCHECK(!expr->IsSuperAccess()); |
| 868 VisitForStackValue(expr->obj()); | 862 VisitForStackValue(expr->obj()); |
| 869 VisitForAccumulatorValue(expr->key()); | 863 VisitForAccumulatorValue(expr->key()); |
| 870 __ Move(LoadDescriptor::NameRegister(), result_register()); | 864 __ Move(LoadDescriptor::NameRegister(), result_register()); |
| 871 PopOperand(LoadDescriptor::ReceiverRegister()); | 865 PopOperand(LoadDescriptor::ReceiverRegister()); |
| 872 EmitKeyedPropertyLoad(expr); | 866 EmitKeyedPropertyLoad(expr); |
| 873 } else { | |
| 874 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); | |
| 875 VisitForStackValue( | |
| 876 expr->obj()->AsSuperPropertyReference()->home_object()); | |
| 877 VisitForStackValue(expr->key()); | |
| 878 EmitKeyedSuperPropertyLoad(expr); | |
| 879 } | |
| 880 } | 867 } |
| 881 PrepareForBailoutForId(expr->LoadId(), BailoutState::TOS_REGISTER); | 868 PrepareForBailoutForId(expr->LoadId(), BailoutState::TOS_REGISTER); |
| 882 context()->Plug(result_register()); | 869 context()->Plug(result_register()); |
| 883 } | 870 } |
| 884 | 871 |
| 885 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { | 872 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { |
| 886 VariableProxy* proxy = expr->AsVariableProxy(); | 873 VariableProxy* proxy = expr->AsVariableProxy(); |
| 887 DCHECK(!context()->IsEffect()); | 874 DCHECK(!context()->IsEffect()); |
| 888 DCHECK(!context()->IsTest()); | 875 DCHECK(!context()->IsTest()); |
| 889 | 876 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 | 1039 |
| 1053 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 1040 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
| 1054 SetExpressionPosition(prop); | 1041 SetExpressionPosition(prop); |
| 1055 Literal* key = prop->key()->AsLiteral(); | 1042 Literal* key = prop->key()->AsLiteral(); |
| 1056 DCHECK(!key->value()->IsSmi()); | 1043 DCHECK(!key->value()->IsSmi()); |
| 1057 DCHECK(!prop->IsSuperAccess()); | 1044 DCHECK(!prop->IsSuperAccess()); |
| 1058 | 1045 |
| 1059 CallLoadIC(prop->PropertyFeedbackSlot(), key->value()); | 1046 CallLoadIC(prop->PropertyFeedbackSlot(), key->value()); |
| 1060 } | 1047 } |
| 1061 | 1048 |
| 1062 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { | |
| 1063 // Stack: receiver, home_object | |
| 1064 SetExpressionPosition(prop); | |
| 1065 Literal* key = prop->key()->AsLiteral(); | |
| 1066 DCHECK(!key->value()->IsSmi()); | |
| 1067 DCHECK(prop->IsSuperAccess()); | |
| 1068 | |
| 1069 PushOperand(key->value()); | |
| 1070 CallRuntimeWithOperands(Runtime::kLoadFromSuper); | |
| 1071 } | |
| 1072 | |
| 1073 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 1049 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
| 1074 SetExpressionPosition(prop); | 1050 SetExpressionPosition(prop); |
| 1075 | 1051 |
| 1076 EmitLoadSlot(LoadDescriptor::SlotRegister(), prop->PropertyFeedbackSlot()); | 1052 EmitLoadSlot(LoadDescriptor::SlotRegister(), prop->PropertyFeedbackSlot()); |
| 1077 | 1053 |
| 1078 Handle<Code> code = CodeFactory::KeyedLoadIC(isolate()).code(); | 1054 Handle<Code> code = CodeFactory::KeyedLoadIC(isolate()).code(); |
| 1079 __ Call(code, RelocInfo::CODE_TARGET); | 1055 __ Call(code, RelocInfo::CODE_TARGET); |
| 1080 RestoreContext(); | 1056 RestoreContext(); |
| 1081 } | 1057 } |
| 1082 | 1058 |
| 1083 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { | |
| 1084 // Stack: receiver, home_object, key. | |
| 1085 SetExpressionPosition(prop); | |
| 1086 CallRuntimeWithOperands(Runtime::kLoadKeyedFromSuper); | |
| 1087 } | |
| 1088 | |
| 1089 void FullCodeGenerator::EmitPropertyKey(LiteralProperty* property, | 1059 void FullCodeGenerator::EmitPropertyKey(LiteralProperty* property, |
| 1090 BailoutId bailout_id) { | 1060 BailoutId bailout_id) { |
| 1091 VisitForStackValue(property->key()); | 1061 VisitForStackValue(property->key()); |
| 1092 CallRuntimeWithOperands(Runtime::kToName); | 1062 CallRuntimeWithOperands(Runtime::kToName); |
| 1093 PrepareForBailoutForId(bailout_id, BailoutState::TOS_REGISTER); | 1063 PrepareForBailoutForId(bailout_id, BailoutState::TOS_REGISTER); |
| 1094 PushOperand(result_register()); | 1064 PushOperand(result_register()); |
| 1095 } | 1065 } |
| 1096 | 1066 |
| 1097 void FullCodeGenerator::EmitLoadSlot(Register destination, | 1067 void FullCodeGenerator::EmitLoadSlot(Register destination, |
| 1098 FeedbackVectorSlot slot) { | 1068 FeedbackVectorSlot slot) { |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 VisitForStackValue(property->obj()); | 1367 VisitForStackValue(property->obj()); |
| 1398 EmitCallWithLoadIC(expr); | 1368 EmitCallWithLoadIC(expr); |
| 1399 break; | 1369 break; |
| 1400 } | 1370 } |
| 1401 case Call::KEYED_PROPERTY_CALL: { | 1371 case Call::KEYED_PROPERTY_CALL: { |
| 1402 Property* property = callee->AsProperty(); | 1372 Property* property = callee->AsProperty(); |
| 1403 VisitForStackValue(property->obj()); | 1373 VisitForStackValue(property->obj()); |
| 1404 EmitKeyedCallWithLoadIC(expr, property->key()); | 1374 EmitKeyedCallWithLoadIC(expr, property->key()); |
| 1405 break; | 1375 break; |
| 1406 } | 1376 } |
| 1407 case Call::NAMED_SUPER_PROPERTY_CALL: | |
| 1408 EmitSuperCallWithLoadIC(expr); | |
| 1409 break; | |
| 1410 case Call::KEYED_SUPER_PROPERTY_CALL: | |
| 1411 EmitKeyedSuperCallWithLoadIC(expr); | |
| 1412 break; | |
| 1413 case Call::OTHER_CALL: | 1377 case Call::OTHER_CALL: |
| 1414 // Call to an arbitrary expression not handled specially above. | 1378 // Call to an arbitrary expression not handled specially above. |
| 1415 VisitForStackValue(callee); | 1379 VisitForStackValue(callee); |
| 1416 OperandStackDepthIncrement(1); | 1380 OperandStackDepthIncrement(1); |
| 1417 __ PushRoot(Heap::kUndefinedValueRootIndex); | 1381 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 1418 // Emit function call. | 1382 // Emit function call. |
| 1419 EmitCall(expr); | 1383 EmitCall(expr); |
| 1420 break; | 1384 break; |
| 1385 case Call::NAMED_SUPER_PROPERTY_CALL: |
| 1386 case Call::KEYED_SUPER_PROPERTY_CALL: |
| 1421 case Call::SUPER_CALL: | 1387 case Call::SUPER_CALL: |
| 1422 case Call::WITH_CALL: | 1388 case Call::WITH_CALL: |
| 1423 UNREACHABLE(); | 1389 UNREACHABLE(); |
| 1424 } | 1390 } |
| 1425 | 1391 |
| 1426 #ifdef DEBUG | 1392 #ifdef DEBUG |
| 1427 // RecordJSReturnSite should have been called. | 1393 // RecordJSReturnSite should have been called. |
| 1428 DCHECK(expr->return_is_recorded_); | 1394 DCHECK(expr->return_is_recorded_); |
| 1429 #endif | 1395 #endif |
| 1430 } | 1396 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 return info_->has_simple_parameters(); | 1603 return info_->has_simple_parameters(); |
| 1638 } | 1604 } |
| 1639 | 1605 |
| 1640 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } | 1606 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } |
| 1641 | 1607 |
| 1642 #undef __ | 1608 #undef __ |
| 1643 | 1609 |
| 1644 | 1610 |
| 1645 } // namespace internal | 1611 } // namespace internal |
| 1646 } // namespace v8 | 1612 } // namespace v8 |
| OLD | NEW |