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

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

Issue 10594002: More ICData cleanups: try to use ICData instead of converting it to another intermediate representa… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('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 (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 "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 6640 matching lines...) Expand 10 before | Expand all | Expand 10 after
6651 6651
6652 6652
6653 intptr_t ICData::NumberOfChecks() const { 6653 intptr_t ICData::NumberOfChecks() const {
6654 // Do not count the sentinel; 6654 // Do not count the sentinel;
6655 return (Array::Handle(ic_data()).Length() / TestEntryLength()) - 1; 6655 return (Array::Handle(ic_data()).Length() / TestEntryLength()) - 1;
6656 } 6656 }
6657 6657
6658 6658
6659 void ICData::AddCheck(const GrowableArray<intptr_t>& class_ids, 6659 void ICData::AddCheck(const GrowableArray<intptr_t>& class_ids,
6660 const Function& target) const { 6660 const Function& target) const {
6661 ASSERT(num_args_tested() > 1); // Otherwise use 'AddReceiverCheck'.
6661 ASSERT(class_ids.length() == num_args_tested()); 6662 ASSERT(class_ids.length() == num_args_tested());
6662 intptr_t old_num = NumberOfChecks(); 6663 intptr_t old_num = NumberOfChecks();
6663 Array& data = Array::Handle(ic_data()); 6664 Array& data = Array::Handle(ic_data());
6664 intptr_t new_len = data.Length() + TestEntryLength(); 6665 intptr_t new_len = data.Length() + TestEntryLength();
6665 data = Array::Grow(data, new_len, Heap::kOld); 6666 data = Array::Grow(data, new_len, Heap::kOld);
6666 set_ic_data(data); 6667 set_ic_data(data);
6667 intptr_t data_pos = old_num * TestEntryLength(); 6668 intptr_t data_pos = old_num * TestEntryLength();
6668 for (intptr_t i = 0; i < class_ids.length(); i++) { 6669 for (intptr_t i = 0; i < class_ids.length(); i++) {
6669 // Null is used as terminating value, do not add it. 6670 // Null is used as terminating value, do not add it.
6670 ASSERT(class_ids[i] != kNullClass); 6671 ASSERT(class_ids[i] != kNullClass);
6672 ASSERT(class_ids[i] != kIllegalObjectKind);
6671 data.SetAt(data_pos++, Smi::Handle(Smi::New(class_ids[i]))); 6673 data.SetAt(data_pos++, Smi::Handle(Smi::New(class_ids[i])));
6672 } 6674 }
6673 ASSERT(!target.IsNull()); 6675 ASSERT(!target.IsNull());
6674 data.SetAt(data_pos, target); 6676 data.SetAt(data_pos, target);
6675 } 6677 }
6676 6678
6677 6679
6680 void ICData::AddReceiverCheck(intptr_t receiver_class_id,
6681 const Function& target) const {
6682 ASSERT(num_args_tested() == 1); // Otherwise use 'AddCheck'.
6683 // Not supporting collection of null receivers.
6684 ASSERT(receiver_class_id != kNullClass);
6685 ASSERT(receiver_class_id != kIllegalObjectKind);
6686 ASSERT(!target.IsNull());
6687
6688 intptr_t old_num = NumberOfChecks();
6689 Array& data = Array::Handle(ic_data());
6690 intptr_t new_len = data.Length() + TestEntryLength();
6691 data = Array::Grow(data, new_len, Heap::kOld);
6692 set_ic_data(data);
6693 intptr_t data_pos = old_num * TestEntryLength();
6694 if ((receiver_class_id == kSmi) && (data_pos > 0)) {
6695 // Instert kSmi in position 0.
6696 const intptr_t zero_class_id = GetReceiverClassIdAt(0);
6697 ASSERT(zero_class_id != kSmi); // Simple duplicate entry check.
6698 const Function& zero_target = Function::Handle(GetTargetAt(0));
6699 data.SetAt(0, Smi::Handle(Smi::New(receiver_class_id)));
6700 data.SetAt(1, target);
6701 data.SetAt(data_pos, Smi::Handle(Smi::New(zero_class_id)));
6702 data.SetAt(data_pos + 1, zero_target);
6703 } else {
6704 data.SetAt(data_pos, Smi::Handle(Smi::New(receiver_class_id)));
6705 data.SetAt(data_pos + 1, target);
6706 }
6707 }
6708
6709
6678 void ICData::GetCheckAt(intptr_t index, 6710 void ICData::GetCheckAt(intptr_t index,
6679 GrowableArray<intptr_t>* class_ids, 6711 GrowableArray<intptr_t>* class_ids,
6680 Function* target) const { 6712 Function* target) const {
6681 ASSERT(class_ids != NULL); 6713 ASSERT(class_ids != NULL);
6682 ASSERT(target != NULL); 6714 ASSERT(target != NULL);
6683 class_ids->Clear(); 6715 class_ids->Clear();
6684 const Array& data = Array::Handle(ic_data()); 6716 const Array& data = Array::Handle(ic_data());
6685 intptr_t data_pos = index * TestEntryLength(); 6717 intptr_t data_pos = index * TestEntryLength();
6686 Smi& smi = Smi::Handle(); 6718 Smi& smi = Smi::Handle();
6687 for (intptr_t i = 0; i < num_args_tested(); i++) { 6719 for (intptr_t i = 0; i < num_args_tested(); i++) {
(...skipping 11 matching lines...) Expand all
6699 ASSERT(num_args_tested() == 1); 6731 ASSERT(num_args_tested() == 1);
6700 const Array& data = Array::Handle(ic_data()); 6732 const Array& data = Array::Handle(ic_data());
6701 intptr_t data_pos = index * TestEntryLength(); 6733 intptr_t data_pos = index * TestEntryLength();
6702 Smi& smi = Smi::Handle(); 6734 Smi& smi = Smi::Handle();
6703 smi ^= data.At(data_pos); 6735 smi ^= data.At(data_pos);
6704 *class_id = smi.Value(); 6736 *class_id = smi.Value();
6705 *target ^= data.At(data_pos + 1); 6737 *target ^= data.At(data_pos + 1);
6706 } 6738 }
6707 6739
6708 6740
6741 intptr_t ICData::GetReceiverClassIdAt(intptr_t index) const {
6742 const Array& data = Array::Handle(ic_data());
6743 const intptr_t data_pos = index * TestEntryLength();
6744 Smi& smi = Smi::Handle();
6745 smi ^= data.At(data_pos);
6746 return smi.Value();
6747 }
6748
6749
6750 RawFunction* ICData::GetTargetAt(intptr_t index) const {
6751 const Array& data = Array::Handle(ic_data());
6752 const intptr_t data_pos = index * TestEntryLength() + num_args_tested();
6753 Function& target = Function::Handle();
6754 target ^= data.At(data_pos);
6755 return target.raw();
6756 }
6757
6758
6709 RawICData* ICData::New(const Function& function, 6759 RawICData* ICData::New(const Function& function,
6710 const String& target_name, 6760 const String& target_name,
6711 intptr_t id, 6761 intptr_t id,
6712 intptr_t num_args_tested) { 6762 intptr_t num_args_tested) {
6713 ASSERT(num_args_tested > 0); 6763 ASSERT(num_args_tested > 0);
6714 const Class& cls = Class::Handle(Object::icdata_class()); 6764 const Class& cls = Class::Handle(Object::icdata_class());
6715 ASSERT(!cls.IsNull()); 6765 ASSERT(!cls.IsNull());
6716 ICData& result = ICData::Handle(); 6766 ICData& result = ICData::Handle();
6717 { 6767 {
6718 // IC data objects are long living objects, allocate them in old generation. 6768 // IC data objects are long living objects, allocate them in old generation.
(...skipping 3409 matching lines...) Expand 10 before | Expand all | Expand 10 after
10128 const String& str = String::Handle(pattern()); 10178 const String& str = String::Handle(pattern());
10129 const char* format = "JSRegExp: pattern=%s flags=%s"; 10179 const char* format = "JSRegExp: pattern=%s flags=%s";
10130 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 10180 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
10131 char* chars = reinterpret_cast<char*>( 10181 char* chars = reinterpret_cast<char*>(
10132 Isolate::Current()->current_zone()->Allocate(len + 1)); 10182 Isolate::Current()->current_zone()->Allocate(len + 1));
10133 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 10183 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
10134 return chars; 10184 return chars;
10135 } 10185 }
10136 10186
10137 } // namespace dart 10187 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698