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

Side by Side Diff: src/ast.cc

Issue 137403009: Adding a type vector to replace type cells. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Seperate file for feedback slot allocation. Created 6 years, 11 months 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
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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 // Recording of type feedback 587 // Recording of type feedback
588 588
589 // TODO(rossberg): all RecordTypeFeedback functions should disappear 589 // TODO(rossberg): all RecordTypeFeedback functions should disappear
590 // once we use the common type field in the AST consistently. 590 // once we use the common type field in the AST consistently.
591 591
592 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { 592 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) {
593 to_boolean_types_ = oracle->ToBooleanTypes(test_id()); 593 to_boolean_types_ = oracle->ToBooleanTypes(test_id());
594 } 594 }
595 595
596 596
597 int Call::ConsumeFeedbackSlots(Isolate* isolate, int current_slot) {
598 CallType call_type = GetCallType(isolate);
599 int slots = 0;
600 if (call_type == LOOKUP_SLOT_CALL || call_type == OTHER_CALL) {
601 // Call only uses a slot in some cases.
602 slots++;
603 call_feedback_slot_ = current_slot;
604 }
605
606 return current_slot + slots;
607 }
608
609
597 Call::CallType Call::GetCallType(Isolate* isolate) const { 610 Call::CallType Call::GetCallType(Isolate* isolate) const {
598 VariableProxy* proxy = expression()->AsVariableProxy(); 611 VariableProxy* proxy = expression()->AsVariableProxy();
599 if (proxy != NULL) { 612 if (proxy != NULL) {
600 if (proxy->var()->is_possibly_eval(isolate)) { 613 if (proxy->var()->is_possibly_eval(isolate)) {
601 return POSSIBLY_EVAL_CALL; 614 return POSSIBLY_EVAL_CALL;
602 } else if (proxy->var()->IsUnallocated()) { 615 } else if (proxy->var()->IsUnallocated()) {
603 return GLOBAL_CALL; 616 return GLOBAL_CALL;
604 } else if (proxy->var()->IsLookupSlot()) { 617 } else if (proxy->var()->IsLookupSlot()) {
605 return LOOKUP_SLOT_CALL; 618 return LOOKUP_SLOT_CALL;
606 } 619 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 case BOOLEAN_CHECK: 718 case BOOLEAN_CHECK:
706 function = native_context->boolean_function(); 719 function = native_context->boolean_function();
707 break; 720 break;
708 } 721 }
709 ASSERT(function != NULL); 722 ASSERT(function != NULL);
710 return Handle<JSObject>(JSObject::cast(function->instance_prototype())); 723 return Handle<JSObject>(JSObject::cast(function->instance_prototype()));
711 } 724 }
712 725
713 726
714 void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 727 void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
715 is_monomorphic_ = oracle->CallIsMonomorphic(CallFeedbackId()); 728 if (CallFeedbackSlot() >= 0) {
danno 2014/01/28 08:27:17 You probably want to turn this into a convenience
mvstanton 2014/01/30 15:13:41 Done.
716 Property* property = expression()->AsProperty(); 729 // We stored feedback in the type vector.
717 if (property == NULL) { 730 is_monomorphic_ = oracle->CallIsMonomorphic(CallFeedbackSlot());
718 // Function call. Specialize for monomorphic calls. 731 ASSERT(expression()->AsProperty() == NULL);
719 if (is_monomorphic_) target_ = oracle->GetCallTarget(CallFeedbackId()); 732 if (is_monomorphic_) target_ = oracle->GetCallTarget(CallFeedbackSlot());
720 } else if (property->key()->IsPropertyName()) { 733 } else {
721 // Method call. Specialize for the receiver types seen at runtime. 734 // We stored feedback in an IC.
722 Literal* key = property->key()->AsLiteral(); 735 is_monomorphic_ = oracle->CallIsMonomorphic(CallFeedbackId());
723 ASSERT(key != NULL && key->value()->IsString()); 736 Property* property = expression()->AsProperty();
724 Handle<String> name = Handle<String>::cast(key->value()); 737 if (property != NULL) {
725 check_type_ = oracle->GetCallCheckType(CallFeedbackId()); 738 if (property->key()->IsPropertyName()) {
726 receiver_types_.Clear(); 739 // Method call. Specialize for the receiver types seen at runtime.
727 if (check_type_ == RECEIVER_MAP_CHECK) { 740 Literal* key = property->key()->AsLiteral();
728 oracle->CallReceiverTypes(CallFeedbackId(), 741 ASSERT(key != NULL && key->value()->IsString());
729 name, arguments()->length(), &receiver_types_); 742 Handle<String> name = Handle<String>::cast(key->value());
730 is_monomorphic_ = is_monomorphic_ && receiver_types_.length() > 0; 743 check_type_ = oracle->GetCallCheckType(CallFeedbackId());
731 } else { 744 receiver_types_.Clear();
732 holder_ = GetPrototypeForPrimitiveCheck(check_type_, oracle->isolate()); 745 if (check_type_ == RECEIVER_MAP_CHECK) {
733 receiver_types_.Add(handle(holder_->map()), oracle->zone()); 746 oracle->CallReceiverTypes(CallFeedbackId(),
734 } 747 name, arguments()->length(),
748 &receiver_types_);
749 is_monomorphic_ = is_monomorphic_ && receiver_types_.length() > 0;
750 } else {
751 holder_ = GetPrototypeForPrimitiveCheck(check_type_,
752 oracle->isolate());
753 receiver_types_.Add(handle(holder_->map()), oracle->zone());
754 }
735 #ifdef ENABLE_SLOW_ASSERTS 755 #ifdef ENABLE_SLOW_ASSERTS
736 if (FLAG_enable_slow_asserts) { 756 if (FLAG_enable_slow_asserts) {
737 int length = receiver_types_.length(); 757 int length = receiver_types_.length();
738 for (int i = 0; i < length; i++) { 758 for (int i = 0; i < length; i++) {
739 Handle<Map> map = receiver_types_.at(i); 759 Handle<Map> map = receiver_types_.at(i);
740 ASSERT(!map.is_null() && *map != NULL); 760 ASSERT(!map.is_null() && *map != NULL);
761 }
762 }
763 #endif
764 if (is_monomorphic_) {
765 Handle<Map> map = receiver_types_.first();
766 is_monomorphic_ = ComputeTarget(map, name);
767 }
768 } else {
769 if (is_monomorphic_) {
770 keyed_array_call_is_holey_ =
771 oracle->KeyedArrayCallIsHoley(CallFeedbackId());
772 }
741 } 773 }
742 } 774 }
743 #endif
744 if (is_monomorphic_) {
745 Handle<Map> map = receiver_types_.first();
746 is_monomorphic_ = ComputeTarget(map, name);
747 }
748 } else {
749 if (is_monomorphic_) {
750 keyed_array_call_is_holey_ =
751 oracle->KeyedArrayCallIsHoley(CallFeedbackId());
752 }
753 } 775 }
754 } 776 }
755 777
756 778
757 void CallNew::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 779 void CallNew::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
758 allocation_site_ = 780 allocation_site_ =
759 oracle->GetCallNewAllocationSite(CallNewFeedbackId()); 781 oracle->GetCallNewAllocationSite(CallNewFeedbackSlot());
760 is_monomorphic_ = oracle->CallNewIsMonomorphic(CallNewFeedbackId()); 782 is_monomorphic_ = oracle->CallNewIsMonomorphic(CallNewFeedbackSlot());
761 if (is_monomorphic_) { 783 if (is_monomorphic_) {
762 target_ = oracle->GetCallNewTarget(CallNewFeedbackId()); 784 target_ = oracle->GetCallNewTarget(CallNewFeedbackSlot());
763 if (!allocation_site_.is_null()) { 785 if (!allocation_site_.is_null()) {
764 elements_kind_ = allocation_site_->GetElementsKind(); 786 elements_kind_ = allocation_site_->GetElementsKind();
765 } 787 }
766 } 788 }
767 } 789 }
768 790
769 791
770 void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 792 void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
771 TypeFeedbackId id = key()->LiteralFeedbackId(); 793 TypeFeedbackId id = key()->LiteralFeedbackId();
772 SmallMapList maps; 794 SmallMapList maps;
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); 1295 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value());
1274 str = arr; 1296 str = arr;
1275 } else { 1297 } else {
1276 str = DoubleToCString(value_->Number(), buffer); 1298 str = DoubleToCString(value_->Number(), buffer);
1277 } 1299 }
1278 return isolate_->factory()->NewStringFromAscii(CStrVector(str)); 1300 return isolate_->factory()->NewStringFromAscii(CStrVector(str));
1279 } 1301 }
1280 1302
1281 1303
1282 } } // namespace v8::internal 1304 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698