| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 } else if (oracle->StoreIsPolymorphic(id)) { | 496 } else if (oracle->StoreIsPolymorphic(id)) { |
| 497 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); | 497 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); |
| 498 oracle->CollectKeyedReceiverTypes(id, &receiver_types_); | 498 oracle->CollectKeyedReceiverTypes(id, &receiver_types_); |
| 499 } | 499 } |
| 500 store_mode_ = oracle->GetStoreMode(id); | 500 store_mode_ = oracle->GetStoreMode(id); |
| 501 type_ = oracle->IncrementType(this); | 501 type_ = oracle->IncrementType(this); |
| 502 } | 502 } |
| 503 | 503 |
| 504 | 504 |
| 505 void CaseClause::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 505 void CaseClause::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
| 506 TypeInfo info = oracle->SwitchType(this); | 506 compare_type_ = oracle->ClauseType(CompareId()); |
| 507 if (info.IsUninitialized()) info = TypeInfo::Unknown(); | |
| 508 if (info.IsSmi()) { | |
| 509 compare_type_ = SMI_ONLY; | |
| 510 } else if (info.IsInternalizedString()) { | |
| 511 compare_type_ = NAME_ONLY; | |
| 512 } else if (info.IsNonInternalizedString()) { | |
| 513 compare_type_ = STRING_ONLY; | |
| 514 } else if (info.IsNonPrimitive()) { | |
| 515 compare_type_ = OBJECT_ONLY; | |
| 516 } else { | |
| 517 ASSERT(compare_type_ == NONE); | |
| 518 } | |
| 519 } | 507 } |
| 520 | 508 |
| 521 | 509 |
| 522 bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) { | 510 bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) { |
| 523 // If there is an interceptor, we can't compute the target for a direct call. | 511 // If there is an interceptor, we can't compute the target for a direct call. |
| 524 if (type->has_named_interceptor()) return false; | 512 if (type->has_named_interceptor()) return false; |
| 525 | 513 |
| 526 if (check_type_ == RECEIVER_MAP_CHECK) { | 514 if (check_type_ == RECEIVER_MAP_CHECK) { |
| 527 // For primitive checks the holder is set up to point to the corresponding | 515 // For primitive checks the holder is set up to point to the corresponding |
| 528 // prototype object, i.e. one step of the algorithm below has been already | 516 // prototype object, i.e. one step of the algorithm below has been already |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 // Go up the prototype chain, recording where we are currently. | 551 // Go up the prototype chain, recording where we are currently. |
| 564 holder_ = Handle<JSObject>(JSObject::cast(type->prototype())); | 552 holder_ = Handle<JSObject>(JSObject::cast(type->prototype())); |
| 565 type = Handle<Map>(holder()->map()); | 553 type = Handle<Map>(holder()->map()); |
| 566 } | 554 } |
| 567 } | 555 } |
| 568 | 556 |
| 569 | 557 |
| 570 bool Call::ComputeGlobalTarget(Handle<GlobalObject> global, | 558 bool Call::ComputeGlobalTarget(Handle<GlobalObject> global, |
| 571 LookupResult* lookup) { | 559 LookupResult* lookup) { |
| 572 target_ = Handle<JSFunction>::null(); | 560 target_ = Handle<JSFunction>::null(); |
| 573 cell_ = Handle<JSGlobalPropertyCell>::null(); | 561 cell_ = Handle<Cell>::null(); |
| 574 ASSERT(lookup->IsFound() && | 562 ASSERT(lookup->IsFound() && |
| 575 lookup->type() == NORMAL && | 563 lookup->type() == NORMAL && |
| 576 lookup->holder() == *global); | 564 lookup->holder() == *global); |
| 577 cell_ = Handle<JSGlobalPropertyCell>(global->GetPropertyCell(lookup)); | 565 cell_ = Handle<Cell>(global->GetPropertyCell(lookup)); |
| 578 if (cell_->value()->IsJSFunction()) { | 566 if (cell_->value()->IsJSFunction()) { |
| 579 Handle<JSFunction> candidate(JSFunction::cast(cell_->value())); | 567 Handle<JSFunction> candidate(JSFunction::cast(cell_->value())); |
| 580 // If the function is in new space we assume it's more likely to | 568 // If the function is in new space we assume it's more likely to |
| 581 // change and thus prefer the general IC code. | 569 // change and thus prefer the general IC code. |
| 582 if (!HEAP->InNewSpace(*candidate)) { | 570 if (!HEAP->InNewSpace(*candidate)) { |
| 583 target_ = candidate; | 571 target_ = candidate; |
| 584 return true; | 572 return true; |
| 585 } | 573 } |
| 586 } | 574 } |
| 587 return false; | 575 return false; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 | 656 |
| 669 | 657 |
| 670 void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 658 void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
| 671 receiver_type_ = oracle->ObjectLiteralStoreIsMonomorphic(this) | 659 receiver_type_ = oracle->ObjectLiteralStoreIsMonomorphic(this) |
| 672 ? oracle->GetObjectLiteralStoreMap(this) | 660 ? oracle->GetObjectLiteralStoreMap(this) |
| 673 : Handle<Map>::null(); | 661 : Handle<Map>::null(); |
| 674 } | 662 } |
| 675 | 663 |
| 676 | 664 |
| 677 void UnaryOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 665 void UnaryOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
| 678 type_ = oracle->UnaryType(this); | 666 type_ = oracle->UnaryType(UnaryOperationFeedbackId()); |
| 679 } | 667 } |
| 680 | 668 |
| 681 | 669 |
| 682 void BinaryOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 670 void BinaryOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
| 683 oracle->BinaryType(this, &left_type_, &right_type_, &result_type_, | 671 oracle->BinaryType(BinaryOperationFeedbackId(), |
| 672 &left_type_, &right_type_, &result_type_, |
| 684 &has_fixed_right_arg_, &fixed_right_arg_value_); | 673 &has_fixed_right_arg_, &fixed_right_arg_value_); |
| 685 } | 674 } |
| 686 | 675 |
| 687 | 676 |
| 677 // TODO(rossberg): this function (and all other RecordTypeFeedback functions) |
| 678 // should disappear once we use the common type field in the AST consistently. |
| 688 void CompareOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 679 void CompareOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
| 689 oracle->CompareType(this, &left_type_, &right_type_, &overall_type_); | 680 oracle->CompareTypes(CompareOperationFeedbackId(), |
| 690 if (!overall_type_.IsUninitialized() && overall_type_.IsNonPrimitive() && | 681 &left_type_, &right_type_, &overall_type_, &compare_nil_type_); |
| 691 (op_ == Token::EQ || op_ == Token::EQ_STRICT)) { | |
| 692 map_ = oracle->GetCompareMap(this); | |
| 693 } else { | |
| 694 // May be a compare to nil. | |
| 695 map_ = oracle->CompareNilMonomorphicReceiverType(this); | |
| 696 if (op_ != Token::EQ_STRICT) | |
| 697 compare_nil_types_ = oracle->CompareNilTypes(this); | |
| 698 } | |
| 699 } | 682 } |
| 700 | 683 |
| 701 | 684 |
| 702 // ---------------------------------------------------------------------------- | 685 // ---------------------------------------------------------------------------- |
| 703 // Implementation of AstVisitor | 686 // Implementation of AstVisitor |
| 704 | 687 |
| 705 void AstVisitor::VisitDeclarations(ZoneList<Declaration*>* declarations) { | 688 void AstVisitor::VisitDeclarations(ZoneList<Declaration*>* declarations) { |
| 706 for (int i = 0; i < declarations->length(); i++) { | 689 for (int i = 0; i < declarations->length(); i++) { |
| 707 Visit(declarations->at(i)); | 690 Visit(declarations->at(i)); |
| 708 } | 691 } |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 } | 1048 } |
| 1066 | 1049 |
| 1067 | 1050 |
| 1068 CaseClause::CaseClause(Isolate* isolate, | 1051 CaseClause::CaseClause(Isolate* isolate, |
| 1069 Expression* label, | 1052 Expression* label, |
| 1070 ZoneList<Statement*>* statements, | 1053 ZoneList<Statement*>* statements, |
| 1071 int pos) | 1054 int pos) |
| 1072 : label_(label), | 1055 : label_(label), |
| 1073 statements_(statements), | 1056 statements_(statements), |
| 1074 position_(pos), | 1057 position_(pos), |
| 1075 compare_type_(NONE), | 1058 compare_type_(Type::None(), isolate), |
| 1076 compare_id_(AstNode::GetNextId(isolate)), | 1059 compare_id_(AstNode::GetNextId(isolate)), |
| 1077 entry_id_(AstNode::GetNextId(isolate)) { | 1060 entry_id_(AstNode::GetNextId(isolate)) { |
| 1078 } | 1061 } |
| 1079 | 1062 |
| 1080 | 1063 |
| 1081 #define REGULAR_NODE(NodeType) \ | 1064 #define REGULAR_NODE(NodeType) \ |
| 1082 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1065 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1083 increase_node_count(); \ | 1066 increase_node_count(); \ |
| 1084 } | 1067 } |
| 1085 #define DONT_OPTIMIZE_NODE(NodeType) \ | 1068 #define DONT_OPTIMIZE_NODE(NodeType) \ |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 OS::SNPrintF(buffer, "%d", Smi::cast(*handle_)->value()); | 1176 OS::SNPrintF(buffer, "%d", Smi::cast(*handle_)->value()); |
| 1194 str = arr; | 1177 str = arr; |
| 1195 } else { | 1178 } else { |
| 1196 str = DoubleToCString(handle_->Number(), buffer); | 1179 str = DoubleToCString(handle_->Number(), buffer); |
| 1197 } | 1180 } |
| 1198 return factory->NewStringFromAscii(CStrVector(str)); | 1181 return factory->NewStringFromAscii(CStrVector(str)); |
| 1199 } | 1182 } |
| 1200 | 1183 |
| 1201 | 1184 |
| 1202 } } // namespace v8::internal | 1185 } } // namespace v8::internal |
| OLD | NEW |