Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/ic/ic-state.h> | |
| 5 #include "src/runtime/runtime-utils.h" | 6 #include "src/runtime/runtime-utils.h" |
| 6 | 7 |
| 7 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 8 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 9 #include "src/debug/debug.h" | 10 #include "src/debug/debug.h" |
| 10 #include "src/isolate-inl.h" | 11 #include "src/isolate-inl.h" |
| 11 #include "src/messages.h" | 12 #include "src/messages.h" |
| 12 #include "src/property-descriptor.h" | 13 #include "src/property-descriptor.h" |
| 13 #include "src/runtime/runtime.h" | 14 #include "src/runtime/runtime.h" |
| 14 | 15 |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 673 LookupIterator it = LookupIterator::PropertyOrElement( | 674 LookupIterator it = LookupIterator::PropertyOrElement( |
| 674 isolate, object, name, object, LookupIterator::OWN); | 675 isolate, object, name, object, LookupIterator::OWN); |
| 675 // Cannot fail since this should only be called when | 676 // Cannot fail since this should only be called when |
| 676 // creating an object literal. | 677 // creating an object literal. |
| 677 CHECK(JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs, | 678 CHECK(JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs, |
| 678 Object::DONT_THROW) | 679 Object::DONT_THROW) |
| 679 .IsJust()); | 680 .IsJust()); |
| 680 return *object; | 681 return *object; |
| 681 } | 682 } |
| 682 | 683 |
| 684 RUNTIME_FUNCTION(Runtime_StoreTypeInformation) { | |
| 685 HandleScope scope(isolate); | |
| 686 DCHECK_EQ(4, args.length()); | |
| 687 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); | |
| 688 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | |
| 689 CONVERT_ARG_HANDLE_CHECKED(FeedbackVector, vector, 2); | |
| 690 CONVERT_SMI_ARG_CHECKED(index, 3); | |
| 691 | |
| 692 DCHECK(FLAG_type_profile); | |
| 693 | |
| 694 CollectTypeProfileICNexus nexus(vector, vector->ToSlot(index)); | |
|
Yang
2017/02/22 10:39:28
Do we need to fit this into the IC framework? We d
Franzi
2017/02/27 11:38:01
Yes, IC framework makes no sense for types. Simpli
| |
| 695 | |
| 696 // We've seen to much. Nothing to see here | |
| 697 if (nexus.ic_state() == MEGAMORPHIC) { | |
| 698 name->Print(); | |
| 699 printf("Too many types to list them.\n\n"); | |
| 700 return *name; | |
| 701 } | |
| 702 | |
| 703 Handle<Name> type = Object::TypeOf(isolate, value); | |
| 704 if (value->IsJSReceiver()) { | |
| 705 Handle<JSReceiver> object = Handle<JSReceiver>::cast(value); | |
| 706 type = JSReceiver::GetConstructorName(object); | |
| 707 } | |
| 708 if (nexus.ic_state() == UNINITIALIZED) { | |
| 709 nexus.ConfigureMonomorphic(type); | |
| 710 } else if (nexus.ic_state() == MONOMORPHIC) { | |
| 711 DCHECK(nexus.GetFeedback()->IsName()); | |
| 712 Handle<Name> known_type = | |
| 713 Handle<Name>::cast(Handle<Object>(nexus.GetFeedback(), isolate)); | |
| 714 // Do not store the value if it is the same type. | |
| 715 if (!known_type->Equals(*type)) { | |
| 716 nexus.ConfigurePolymorphic(type); | |
| 717 } | |
| 718 } else { | |
| 719 DCHECK(nexus.ic_state() == POLYMORPHIC); | |
| 720 DCHECK(nexus.GetFeedback()->IsArrayList()); | |
| 721 Handle<ArrayList> known_types = | |
| 722 Handle<ArrayList>::cast(Handle<Object>(nexus.GetFeedback(), isolate)); | |
| 723 if (known_types->Length() == kMaxKeyedPolymorphism) { | |
| 724 nexus.ConfigureMegamorphic(); | |
| 725 return *name; | |
| 726 } | |
| 727 nexus.ConfigurePolymorphic(type); | |
| 728 } | |
| 729 | |
| 730 name->Print(); | |
| 731 nexus.GetFeedback()->Print(); | |
| 732 printf("\n"); | |
| 733 | |
| 734 return *name; | |
| 735 } | |
| 736 | |
| 683 // Return property without being observable by accessors or interceptors. | 737 // Return property without being observable by accessors or interceptors. |
| 684 RUNTIME_FUNCTION(Runtime_GetDataProperty) { | 738 RUNTIME_FUNCTION(Runtime_GetDataProperty) { |
| 685 HandleScope scope(isolate); | 739 HandleScope scope(isolate); |
| 686 DCHECK_EQ(2, args.length()); | 740 DCHECK_EQ(2, args.length()); |
| 687 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 741 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
| 688 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 742 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 689 return *JSReceiver::GetDataProperty(object, name); | 743 return *JSReceiver::GetDataProperty(object, name); |
| 690 } | 744 } |
| 691 | 745 |
| 692 RUNTIME_FUNCTION(Runtime_GetConstructorName) { | 746 RUNTIME_FUNCTION(Runtime_GetConstructorName) { |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 984 if (!success) return isolate->heap()->exception(); | 1038 if (!success) return isolate->heap()->exception(); |
| 985 MAYBE_RETURN( | 1039 MAYBE_RETURN( |
| 986 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), | 1040 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), |
| 987 isolate->heap()->exception()); | 1041 isolate->heap()->exception()); |
| 988 return *value; | 1042 return *value; |
| 989 } | 1043 } |
| 990 | 1044 |
| 991 | 1045 |
| 992 } // namespace internal | 1046 } // namespace internal |
| 993 } // namespace v8 | 1047 } // namespace v8 |
| OLD | NEW |