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

Side by Side Diff: runtime/vm/object.cc

Issue 1153963002: Remove value check from ICData checks/house-keeping (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: c Created 5 years, 7 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 11714 matching lines...) Expand 10 before | Expand all | Expand 10 after
11725 const intptr_t len = NumberOfChecks(); 11725 const intptr_t len = NumberOfChecks();
11726 for (intptr_t i = 0; i < len; i++) { 11726 for (intptr_t i = 0; i < len; i++) {
11727 if (GetReceiverClassIdAt(i) == class_id) { 11727 if (GetReceiverClassIdAt(i) == class_id) {
11728 return GetTargetAt(i); 11728 return GetTargetAt(i);
11729 } 11729 }
11730 } 11730 }
11731 return Function::null(); 11731 return Function::null();
11732 } 11732 }
11733 11733
11734 11734
11735 RawICData* ICData::AsUnaryClassChecksForCids(
11736 const GrowableArray<intptr_t>& cids, const Function& target) const {
11737 ASSERT(!IsNull());
11738 const intptr_t kNumArgsTested = 1;
11739 ICData& result = ICData::Handle(ICData::NewFrom(*this, kNumArgsTested));
11740 for (intptr_t i = 0; i < cids.length(); i++) {
11741 const intptr_t class_id = cids[i];
11742 const intptr_t count = GetCountAt(0);
Cutch 2015/05/27 02:53:55 We are creating a new ICData and filling it with c
srdjan 2015/05/27 19:10:57 The count is interesting as as it means different
11743 // This will make sure that Smi is first if it exists.
11744 result.AddReceiverCheck(class_id, target, count);
11745 }
11746 return result.raw();
11747 }
11748
11749
11750 RawICData* ICData::AsUnaryClassChecksForCid(
11751 intptr_t cid, const Function& target) const {
11752 ASSERT(!IsNull());
11753 const intptr_t kNumArgsTested = 1;
11754 ICData& result = ICData::Handle(ICData::NewFrom(*this, kNumArgsTested));
11755
11756 result.AddReceiverCheck(cid, target, GetCountAt(0));
11757 return result.raw();
11758 }
11759
11760
11735 RawICData* ICData::AsUnaryClassChecksForArgNr(intptr_t arg_nr) const { 11761 RawICData* ICData::AsUnaryClassChecksForArgNr(intptr_t arg_nr) const {
11736 ASSERT(!IsNull()); 11762 ASSERT(!IsNull());
11737 ASSERT(NumArgsTested() > arg_nr); 11763 ASSERT(NumArgsTested() > arg_nr);
11738 if ((arg_nr == 0) && (NumArgsTested() == 1)) { 11764 if ((arg_nr == 0) && (NumArgsTested() == 1)) {
11739 // Frequent case. 11765 // Frequent case.
11740 return raw(); 11766 return raw();
11741 } 11767 }
11742 const intptr_t kNumArgsTested = 1; 11768 const intptr_t kNumArgsTested = 1;
11743 ICData& result = ICData::Handle(ICData::New( 11769 ICData& result = ICData::Handle(ICData::NewFrom(*this, kNumArgsTested));
11744 Function::Handle(owner()),
11745 String::Handle(target_name()),
11746 Array::Handle(arguments_descriptor()),
11747 deopt_id(),
11748 kNumArgsTested));
11749 const intptr_t len = NumberOfChecks(); 11770 const intptr_t len = NumberOfChecks();
11750 for (intptr_t i = 0; i < len; i++) { 11771 for (intptr_t i = 0; i < len; i++) {
11751 const intptr_t class_id = GetClassIdAt(i, arg_nr); 11772 const intptr_t class_id = GetClassIdAt(i, arg_nr);
11752 const intptr_t count = GetCountAt(i); 11773 const intptr_t count = GetCountAt(i);
11753 if (count == 0) { 11774 if (count == 0) {
11754 continue; 11775 continue;
11755 } 11776 }
11756 intptr_t duplicate_class_id = -1; 11777 intptr_t duplicate_class_id = -1;
11757 const intptr_t result_len = result.NumberOfChecks(); 11778 const intptr_t result_len = result.NumberOfChecks();
11758 for (intptr_t k = 0; k < result_len; k++) { 11779 for (intptr_t k = 0; k < result_len; k++) {
11759 if (class_id == result.GetReceiverClassIdAt(k)) { 11780 if (class_id == result.GetReceiverClassIdAt(k)) {
11760 duplicate_class_id = k; 11781 duplicate_class_id = k;
11761 break; 11782 break;
11762 } 11783 }
11763 } 11784 }
11764 if (duplicate_class_id >= 0) { 11785 if (duplicate_class_id >= 0) {
11765 // This check is valid only when checking the receiver. 11786 // This check is valid only when checking the receiver.
11766 ASSERT((arg_nr != 0) || 11787 ASSERT((arg_nr != 0) ||
11767 (result.GetTargetAt(duplicate_class_id) == GetTargetAt(i))); 11788 (result.GetTargetAt(duplicate_class_id) == GetTargetAt(i)));
11768 result.IncrementCountAt(duplicate_class_id, count); 11789 result.IncrementCountAt(duplicate_class_id, count);
11769 } else { 11790 } else {
11770 // This will make sure that Smi is first if it exists. 11791 // This will make sure that Smi is first if it exists.
11771 result.AddReceiverCheck(class_id, 11792 result.AddReceiverCheck(class_id,
11772 Function::Handle(GetTargetAt(i)), 11793 Function::Handle(GetTargetAt(i)),
11773 count); 11794 count);
11774 } 11795 }
11775 } 11796 }
11776 // Copy deoptimization reasons.
11777 result.SetDeoptReasons(DeoptReasons());
11778 11797
11779 return result.raw(); 11798 return result.raw();
11780 } 11799 }
11781 11800
11782 11801
11783 bool ICData::AllTargetsHaveSameOwner(intptr_t owner_cid) const { 11802 bool ICData::AllTargetsHaveSameOwner(intptr_t owner_cid) const {
11784 if (NumberOfChecks() == 0) return false; 11803 if (NumberOfChecks() == 0) return false;
11785 Class& cls = Class::Handle(); 11804 Class& cls = Class::Handle();
11786 const intptr_t len = NumberOfChecks(); 11805 const intptr_t len = NumberOfChecks();
11787 for (intptr_t i = 0; i < len; i++) { 11806 for (intptr_t i = 0; i < len; i++) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
11890 // Number of array elements in one test entry. 11909 // Number of array elements in one test entry.
11891 intptr_t len = result.TestEntryLength(); 11910 intptr_t len = result.TestEntryLength();
11892 // IC data array must be null terminated (sentinel entry). 11911 // IC data array must be null terminated (sentinel entry).
11893 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); 11912 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld));
11894 result.set_ic_data(ic_data); 11913 result.set_ic_data(ic_data);
11895 result.WriteSentinel(ic_data); 11914 result.WriteSentinel(ic_data);
11896 return result.raw(); 11915 return result.raw();
11897 } 11916 }
11898 11917
11899 11918
11919 RawICData* ICData::NewFrom(const ICData& from, intptr_t num_args_tested) {
11920 const ICData& result = ICData::Handle(ICData::New(
11921 Function::Handle(from.owner()),
11922 String::Handle(from.target_name()),
11923 Array::Handle(from.arguments_descriptor()),
11924 from.deopt_id(),
11925 num_args_tested));
11926 // Copy deoptimization reasons.
11927 result.SetDeoptReasons(from.DeoptReasons());
11928 return result.raw();
11929 }
11930
11931
11900 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const { 11932 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const {
11901 Object::PrintJSONImpl(stream, ref); 11933 Object::PrintJSONImpl(stream, ref);
11902 } 11934 }
11903 11935
11904 11936
11905 void ICData::PrintToJSONArray(const JSONArray& jsarray, 11937 void ICData::PrintToJSONArray(const JSONArray& jsarray,
11906 intptr_t token_pos, 11938 intptr_t token_pos,
11907 bool is_static_call) const { 11939 bool is_static_call) const {
11908 Isolate* isolate = Isolate::Current(); 11940 Isolate* isolate = Isolate::Current();
11909 Class& cls = Class::Handle(); 11941 Class& cls = Class::Handle();
(...skipping 8891 matching lines...) Expand 10 before | Expand all | Expand 10 after
20801 return tag_label.ToCString(); 20833 return tag_label.ToCString();
20802 } 20834 }
20803 20835
20804 20836
20805 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20837 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20806 Instance::PrintJSONImpl(stream, ref); 20838 Instance::PrintJSONImpl(stream, ref);
20807 } 20839 }
20808 20840
20809 20841
20810 } // namespace dart 20842 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698