Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: src/ast.cc

Issue 95033003: Move more logic from AST to oracle, pt 3 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ast.h ('k') | src/type-info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { 578 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) {
579 to_boolean_types_ = oracle->ToBooleanTypes(test_id()); 579 to_boolean_types_ = oracle->ToBooleanTypes(test_id());
580 } 580 }
581 581
582 582
583 void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle,
584 Zone* zone) {
585 Property* prop = target()->AsProperty();
586 ASSERT(prop != NULL);
587 TypeFeedbackId id = AssignmentFeedbackId();
588 is_uninitialized_ = oracle->StoreIsUninitialized(id);
589 if (is_uninitialized_) return;
590
591 is_pre_monomorphic_ = oracle->StoreIsPreMonomorphic(id);
592 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(id);
593 ASSERT(!is_pre_monomorphic_ || !is_monomorphic_);
594 receiver_types_.Clear();
595 if (prop->key()->IsPropertyName()) {
596 Literal* lit_key = prop->key()->AsLiteral();
597 ASSERT(lit_key != NULL && lit_key->value()->IsString());
598 Handle<String> name = Handle<String>::cast(lit_key->value());
599 oracle->StoreReceiverTypes(this, name, &receiver_types_);
600 } else if (is_monomorphic_) {
601 // Record receiver type for monomorphic keyed stores.
602 receiver_types_.Add(oracle->StoreMonomorphicReceiverType(id), zone);
603 store_mode_ = oracle->GetStoreMode(id);
604 } else if (oracle->StoreIsKeyedPolymorphic(id)) {
605 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone);
606 oracle->CollectKeyedReceiverTypes(id, &receiver_types_);
607 store_mode_ = oracle->GetStoreMode(id);
608 }
609 }
610
611
612 bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) { 583 bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) {
613 // If there is an interceptor, we can't compute the target for a direct call. 584 // If there is an interceptor, we can't compute the target for a direct call.
614 if (type->has_named_interceptor()) return false; 585 if (type->has_named_interceptor()) return false;
615 586
616 if (check_type_ == RECEIVER_MAP_CHECK) { 587 if (check_type_ == RECEIVER_MAP_CHECK) {
617 // For primitive checks the holder is set up to point to the corresponding 588 // For primitive checks the holder is set up to point to the corresponding
618 // prototype object, i.e. one step of the algorithm below has been already 589 // prototype object, i.e. one step of the algorithm below has been already
619 // performed. For non-primitive checks we clear it to allow computing 590 // performed. For non-primitive checks we clear it to allow computing
620 // targets for polymorphic calls. 591 // targets for polymorphic calls.
621 holder_ = Handle<JSObject>::null(); 592 holder_ = Handle<JSObject>::null();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 function = native_context->boolean_function(); 675 function = native_context->boolean_function();
705 break; 676 break;
706 } 677 }
707 ASSERT(function != NULL); 678 ASSERT(function != NULL);
708 return Handle<JSObject>(JSObject::cast(function->instance_prototype())); 679 return Handle<JSObject>(JSObject::cast(function->instance_prototype()));
709 } 680 }
710 681
711 682
712 void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle, 683 void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle,
713 CallKind call_kind) { 684 CallKind call_kind) {
714 is_monomorphic_ = oracle->CallIsMonomorphic(this); 685 is_monomorphic_ = oracle->CallIsMonomorphic(CallFeedbackId());
715 Property* property = expression()->AsProperty(); 686 Property* property = expression()->AsProperty();
716 if (property == NULL) { 687 if (property == NULL) {
717 // Function call. Specialize for monomorphic calls. 688 // Function call. Specialize for monomorphic calls.
718 if (is_monomorphic_) target_ = oracle->GetCallTarget(this); 689 if (is_monomorphic_) target_ = oracle->GetCallTarget(CallFeedbackId());
719 } else if (property->key()->IsPropertyName()) { 690 } else if (property->key()->IsPropertyName()) {
720 // Method call. Specialize for the receiver types seen at runtime. 691 // Method call. Specialize for the receiver types seen at runtime.
721 Literal* key = property->key()->AsLiteral(); 692 Literal* key = property->key()->AsLiteral();
722 ASSERT(key != NULL && key->value()->IsString()); 693 ASSERT(key != NULL && key->value()->IsString());
723 Handle<String> name = Handle<String>::cast(key->value()); 694 Handle<String> name = Handle<String>::cast(key->value());
724 check_type_ = oracle->GetCallCheckType(this); 695 check_type_ = oracle->GetCallCheckType(CallFeedbackId());
725 receiver_types_.Clear(); 696 receiver_types_.Clear();
726 if (check_type_ == RECEIVER_MAP_CHECK) { 697 if (check_type_ == RECEIVER_MAP_CHECK) {
727 oracle->CallReceiverTypes(this, name, call_kind, &receiver_types_); 698 oracle->CallReceiverTypes(CallFeedbackId(),
699 name, arguments()->length(), call_kind, &receiver_types_);
728 is_monomorphic_ = is_monomorphic_ && receiver_types_.length() > 0; 700 is_monomorphic_ = is_monomorphic_ && receiver_types_.length() > 0;
729 } else { 701 } else {
730 holder_ = GetPrototypeForPrimitiveCheck(check_type_, oracle->isolate()); 702 holder_ = GetPrototypeForPrimitiveCheck(check_type_, oracle->isolate());
731 receiver_types_.Add(handle(holder_->map()), oracle->zone()); 703 receiver_types_.Add(handle(holder_->map()), oracle->zone());
732 } 704 }
733 #ifdef ENABLE_SLOW_ASSERTS 705 #ifdef ENABLE_SLOW_ASSERTS
734 if (FLAG_enable_slow_asserts) { 706 if (FLAG_enable_slow_asserts) {
735 int length = receiver_types_.length(); 707 int length = receiver_types_.length();
736 for (int i = 0; i < length; i++) { 708 for (int i = 0; i < length; i++) {
737 Handle<Map> map = receiver_types_.at(i); 709 Handle<Map> map = receiver_types_.at(i);
738 ASSERT(!map.is_null() && *map != NULL); 710 ASSERT(!map.is_null() && *map != NULL);
739 } 711 }
740 } 712 }
741 #endif 713 #endif
742 if (is_monomorphic_) { 714 if (is_monomorphic_) {
743 Handle<Map> map = receiver_types_.first(); 715 Handle<Map> map = receiver_types_.first();
744 is_monomorphic_ = ComputeTarget(map, name); 716 is_monomorphic_ = ComputeTarget(map, name);
745 } 717 }
746 } else { 718 } else {
747 if (is_monomorphic_) { 719 if (is_monomorphic_) {
748 keyed_array_call_is_holey_ = oracle->KeyedArrayCallIsHoley(this); 720 keyed_array_call_is_holey_ =
721 oracle->KeyedArrayCallIsHoley(CallFeedbackId());
749 } 722 }
750 } 723 }
751 } 724 }
752 725
753 726
754 void CallNew::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 727 void CallNew::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
755 allocation_info_cell_ = oracle->GetCallNewAllocationInfoCell(this); 728 allocation_info_cell_ =
756 is_monomorphic_ = oracle->CallNewIsMonomorphic(this); 729 oracle->GetCallNewAllocationInfoCell(CallNewFeedbackId());
730 is_monomorphic_ = oracle->CallNewIsMonomorphic(CallNewFeedbackId());
757 if (is_monomorphic_) { 731 if (is_monomorphic_) {
758 target_ = oracle->GetCallNewTarget(this); 732 target_ = oracle->GetCallNewTarget(CallNewFeedbackId());
759 Object* value = allocation_info_cell_->value(); 733 Object* value = allocation_info_cell_->value();
760 ASSERT(!value->IsTheHole()); 734 ASSERT(!value->IsTheHole());
761 if (value->IsAllocationSite()) { 735 if (value->IsAllocationSite()) {
762 AllocationSite* site = AllocationSite::cast(value); 736 AllocationSite* site = AllocationSite::cast(value);
763 elements_kind_ = site->GetElementsKind(); 737 elements_kind_ = site->GetElementsKind();
764 } 738 }
765 } 739 }
766 } 740 }
767 741
768 742
769 void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 743 void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
770 receiver_type_ = oracle->ObjectLiteralStoreIsMonomorphic(this) 744 TypeFeedbackId id = key()->LiteralFeedbackId();
771 ? oracle->GetObjectLiteralStoreMap(this) 745 receiver_type_ = oracle->ObjectLiteralStoreIsMonomorphic(id)
772 : Handle<Map>::null(); 746 ? oracle->GetObjectLiteralStoreMap(id) : Handle<Map>::null();
773 } 747 }
774 748
775 749
776 // ---------------------------------------------------------------------------- 750 // ----------------------------------------------------------------------------
777 // Implementation of AstVisitor 751 // Implementation of AstVisitor
778 752
779 void AstVisitor::VisitDeclarations(ZoneList<Declaration*>* declarations) { 753 void AstVisitor::VisitDeclarations(ZoneList<Declaration*>* declarations) {
780 for (int i = 0; i < declarations->length(); i++) { 754 for (int i = 0; i < declarations->length(); i++) {
781 Visit(declarations->at(i)); 755 Visit(declarations->at(i));
782 } 756 }
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); 1244 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value());
1271 str = arr; 1245 str = arr;
1272 } else { 1246 } else {
1273 str = DoubleToCString(value_->Number(), buffer); 1247 str = DoubleToCString(value_->Number(), buffer);
1274 } 1248 }
1275 return isolate_->factory()->NewStringFromAscii(CStrVector(str)); 1249 return isolate_->factory()->NewStringFromAscii(CStrVector(str));
1276 } 1250 }
1277 1251
1278 1252
1279 } } // namespace v8::internal 1253 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/type-info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698