| 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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 } | 568 } |
| 569 | 569 |
| 570 | 570 |
| 571 // ---------------------------------------------------------------------------- | 571 // ---------------------------------------------------------------------------- |
| 572 // Recording of type feedback | 572 // Recording of type feedback |
| 573 | 573 |
| 574 // TODO(rossberg): all RecordTypeFeedback functions should disappear | 574 // TODO(rossberg): all RecordTypeFeedback functions should disappear |
| 575 // once we use the common type field in the AST consistently. | 575 // once we use the common type field in the AST consistently. |
| 576 | 576 |
| 577 | 577 |
| 578 void ForInStatement::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | |
| 579 for_in_type_ = static_cast<ForInType>(oracle->ForInType(this)); | |
| 580 } | |
| 581 | |
| 582 | |
| 583 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { | 578 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { |
| 584 to_boolean_types_ = oracle->ToBooleanTypes(test_id()); | 579 to_boolean_types_ = oracle->ToBooleanTypes(test_id()); |
| 585 } | 580 } |
| 586 | 581 |
| 587 | 582 |
| 588 void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle, | |
| 589 Zone* zone) { | |
| 590 // Record type feedback from the oracle in the AST. | |
| 591 is_uninitialized_ = oracle->LoadIsUninitialized(this); | |
| 592 if (is_uninitialized_) return; | |
| 593 | |
| 594 is_pre_monomorphic_ = oracle->LoadIsPreMonomorphic(this); | |
| 595 is_monomorphic_ = oracle->LoadIsMonomorphicNormal(this); | |
| 596 ASSERT(!is_pre_monomorphic_ || !is_monomorphic_); | |
| 597 receiver_types_.Clear(); | |
| 598 if (key()->IsPropertyName()) { | |
| 599 FunctionPrototypeStub proto_stub(Code::LOAD_IC); | |
| 600 if (oracle->LoadIsStub(this, &proto_stub)) { | |
| 601 is_function_prototype_ = true; | |
| 602 } else { | |
| 603 Literal* lit_key = key()->AsLiteral(); | |
| 604 ASSERT(lit_key != NULL && lit_key->value()->IsString()); | |
| 605 Handle<String> name = Handle<String>::cast(lit_key->value()); | |
| 606 oracle->LoadReceiverTypes(this, name, &receiver_types_); | |
| 607 } | |
| 608 } else if (oracle->LoadIsBuiltin(this, Builtins::kKeyedLoadIC_String)) { | |
| 609 is_string_access_ = true; | |
| 610 } else if (is_monomorphic_) { | |
| 611 receiver_types_.Add(oracle->LoadMonomorphicReceiverType(this), zone); | |
| 612 } else if (oracle->LoadIsPolymorphic(this)) { | |
| 613 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); | |
| 614 oracle->CollectKeyedReceiverTypes(PropertyFeedbackId(), &receiver_types_); | |
| 615 } | |
| 616 } | |
| 617 | |
| 618 | |
| 619 void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle, | 583 void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle, |
| 620 Zone* zone) { | 584 Zone* zone) { |
| 621 Property* prop = target()->AsProperty(); | 585 Property* prop = target()->AsProperty(); |
| 622 ASSERT(prop != NULL); | 586 ASSERT(prop != NULL); |
| 623 TypeFeedbackId id = AssignmentFeedbackId(); | 587 TypeFeedbackId id = AssignmentFeedbackId(); |
| 624 is_uninitialized_ = oracle->StoreIsUninitialized(id); | 588 is_uninitialized_ = oracle->StoreIsUninitialized(id); |
| 625 if (is_uninitialized_) return; | 589 if (is_uninitialized_) return; |
| 626 | 590 |
| 627 is_pre_monomorphic_ = oracle->StoreIsPreMonomorphic(id); | 591 is_pre_monomorphic_ = oracle->StoreIsPreMonomorphic(id); |
| 628 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(id); | 592 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(id); |
| 629 ASSERT(!is_pre_monomorphic_ || !is_monomorphic_); | 593 ASSERT(!is_pre_monomorphic_ || !is_monomorphic_); |
| 630 receiver_types_.Clear(); | 594 receiver_types_.Clear(); |
| 631 if (prop->key()->IsPropertyName()) { | 595 if (prop->key()->IsPropertyName()) { |
| 632 Literal* lit_key = prop->key()->AsLiteral(); | 596 Literal* lit_key = prop->key()->AsLiteral(); |
| 633 ASSERT(lit_key != NULL && lit_key->value()->IsString()); | 597 ASSERT(lit_key != NULL && lit_key->value()->IsString()); |
| 634 Handle<String> name = Handle<String>::cast(lit_key->value()); | 598 Handle<String> name = Handle<String>::cast(lit_key->value()); |
| 635 oracle->StoreReceiverTypes(this, name, &receiver_types_); | 599 oracle->StoreReceiverTypes(this, name, &receiver_types_); |
| 636 } else if (is_monomorphic_) { | 600 } else if (is_monomorphic_) { |
| 637 // Record receiver type for monomorphic keyed stores. | 601 // Record receiver type for monomorphic keyed stores. |
| 638 receiver_types_.Add(oracle->StoreMonomorphicReceiverType(id), zone); | 602 receiver_types_.Add(oracle->StoreMonomorphicReceiverType(id), zone); |
| 639 store_mode_ = oracle->GetStoreMode(id); | 603 store_mode_ = oracle->GetStoreMode(id); |
| 640 } else if (oracle->StoreIsKeyedPolymorphic(id)) { | 604 } else if (oracle->StoreIsKeyedPolymorphic(id)) { |
| 641 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); | 605 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); |
| 642 oracle->CollectKeyedReceiverTypes(id, &receiver_types_); | 606 oracle->CollectKeyedReceiverTypes(id, &receiver_types_); |
| 643 store_mode_ = oracle->GetStoreMode(id); | 607 store_mode_ = oracle->GetStoreMode(id); |
| 644 } | 608 } |
| 645 } | 609 } |
| 646 | 610 |
| 647 | 611 |
| 648 void CountOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle, | |
| 649 Zone* zone) { | |
| 650 TypeFeedbackId id = CountStoreFeedbackId(); | |
| 651 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(id); | |
| 652 receiver_types_.Clear(); | |
| 653 if (is_monomorphic_) { | |
| 654 // Record receiver type for monomorphic keyed stores. | |
| 655 receiver_types_.Add( | |
| 656 oracle->StoreMonomorphicReceiverType(id), zone); | |
| 657 } else if (oracle->StoreIsKeyedPolymorphic(id)) { | |
| 658 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); | |
| 659 oracle->CollectKeyedReceiverTypes(id, &receiver_types_); | |
| 660 } else { | |
| 661 oracle->CollectPolymorphicStoreReceiverTypes(id, &receiver_types_); | |
| 662 } | |
| 663 store_mode_ = oracle->GetStoreMode(id); | |
| 664 type_ = oracle->IncrementType(this); | |
| 665 } | |
| 666 | |
| 667 | |
| 668 void CaseClause::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | |
| 669 compare_type_ = oracle->ClauseType(CompareId()); | |
| 670 } | |
| 671 | |
| 672 | |
| 673 bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) { | 612 bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) { |
| 674 // If there is an interceptor, we can't compute the target for a direct call. | 613 // If there is an interceptor, we can't compute the target for a direct call. |
| 675 if (type->has_named_interceptor()) return false; | 614 if (type->has_named_interceptor()) return false; |
| 676 | 615 |
| 677 if (check_type_ == RECEIVER_MAP_CHECK) { | 616 if (check_type_ == RECEIVER_MAP_CHECK) { |
| 678 // For primitive checks the holder is set up to point to the corresponding | 617 // For primitive checks the holder is set up to point to the corresponding |
| 679 // prototype object, i.e. one step of the algorithm below has been already | 618 // prototype object, i.e. one step of the algorithm below has been already |
| 680 // performed. For non-primitive checks we clear it to allow computing | 619 // performed. For non-primitive checks we clear it to allow computing |
| 681 // targets for polymorphic calls. | 620 // targets for polymorphic calls. |
| 682 holder_ = Handle<JSObject>::null(); | 621 holder_ = Handle<JSObject>::null(); |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); | 1270 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); |
| 1332 str = arr; | 1271 str = arr; |
| 1333 } else { | 1272 } else { |
| 1334 str = DoubleToCString(value_->Number(), buffer); | 1273 str = DoubleToCString(value_->Number(), buffer); |
| 1335 } | 1274 } |
| 1336 return isolate_->factory()->NewStringFromAscii(CStrVector(str)); | 1275 return isolate_->factory()->NewStringFromAscii(CStrVector(str)); |
| 1337 } | 1276 } |
| 1338 | 1277 |
| 1339 | 1278 |
| 1340 } } // namespace v8::internal | 1279 } } // namespace v8::internal |
| OLD | NEW |