| OLD | NEW |
| 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 6634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6645 return num_args_tested() + 1 /* target function*/; | 6645 return num_args_tested() + 1 /* target function*/; |
| 6646 } | 6646 } |
| 6647 | 6647 |
| 6648 | 6648 |
| 6649 intptr_t ICData::NumberOfChecks() const { | 6649 intptr_t ICData::NumberOfChecks() const { |
| 6650 // Do not count the sentinel; | 6650 // Do not count the sentinel; |
| 6651 return (Array::Handle(ic_data()).Length() / TestEntryLength()) - 1; | 6651 return (Array::Handle(ic_data()).Length() / TestEntryLength()) - 1; |
| 6652 } | 6652 } |
| 6653 | 6653 |
| 6654 | 6654 |
| 6655 void ICData::AddCheck(const GrowableArray<const Class*>& classes, | 6655 void ICData::AddCheck(const GrowableArray<intptr_t>& class_ids, |
| 6656 const Function& target) const { | 6656 const Function& target) const { |
| 6657 ASSERT(classes.length() == num_args_tested()); | 6657 ASSERT(class_ids.length() == num_args_tested()); |
| 6658 intptr_t old_num = NumberOfChecks(); | 6658 intptr_t old_num = NumberOfChecks(); |
| 6659 Array& data = Array::Handle(ic_data()); | 6659 Array& data = Array::Handle(ic_data()); |
| 6660 intptr_t new_len = data.Length() + TestEntryLength(); | 6660 intptr_t new_len = data.Length() + TestEntryLength(); |
| 6661 data = Array::Grow(data, new_len, Heap::kOld); | 6661 data = Array::Grow(data, new_len, Heap::kOld); |
| 6662 set_ic_data(data); | 6662 set_ic_data(data); |
| 6663 intptr_t data_pos = old_num * TestEntryLength(); | 6663 intptr_t data_pos = old_num * TestEntryLength(); |
| 6664 for (intptr_t i = 0; i < classes.length(); i++) { | 6664 for (intptr_t i = 0; i < class_ids.length(); i++) { |
| 6665 // Null is used as terminating value, do not add it. | 6665 // Null is used as terminating value, do not add it. |
| 6666 ASSERT(!classes[i]->IsNull()); | 6666 ASSERT(class_ids[i] != kNullClass); |
| 6667 data.SetAt(data_pos++, *(classes[i])); | 6667 data.SetAt(data_pos++, Smi::Handle(Smi::New(class_ids[i]))); |
| 6668 } | 6668 } |
| 6669 ASSERT(!target.IsNull()); | 6669 ASSERT(!target.IsNull()); |
| 6670 data.SetAt(data_pos, target); | 6670 data.SetAt(data_pos, target); |
| 6671 } | 6671 } |
| 6672 | 6672 |
| 6673 | 6673 |
| 6674 void ICData::GetCheckAt(intptr_t index, | 6674 void ICData::GetCheckAt(intptr_t index, |
| 6675 GrowableArray<const Class*>* classes, | 6675 GrowableArray<intptr_t>* class_ids, |
| 6676 Function* target) const { | 6676 Function* target) const { |
| 6677 ASSERT(classes != NULL); | 6677 ASSERT(class_ids != NULL); |
| 6678 ASSERT(target != NULL); | 6678 ASSERT(target != NULL); |
| 6679 classes->Clear(); | 6679 class_ids->Clear(); |
| 6680 const Array& data = Array::Handle(ic_data()); | 6680 const Array& data = Array::Handle(ic_data()); |
| 6681 intptr_t data_pos = index * TestEntryLength(); | 6681 intptr_t data_pos = index * TestEntryLength(); |
| 6682 Smi& smi = Smi::Handle(); |
| 6682 for (intptr_t i = 0; i < num_args_tested(); i++) { | 6683 for (intptr_t i = 0; i < num_args_tested(); i++) { |
| 6683 Class& cls = Class::ZoneHandle(); | 6684 smi ^= data.At(data_pos++); |
| 6684 cls ^= data.At(data_pos++); | 6685 class_ids->Add(smi.Value()); |
| 6685 classes->Add(&cls); | |
| 6686 } | 6686 } |
| 6687 (*target) ^= data.At(data_pos); | 6687 (*target) ^= data.At(data_pos); |
| 6688 } | 6688 } |
| 6689 | 6689 |
| 6690 | 6690 |
| 6691 void ICData::GetOneClassCheckAt( | 6691 void ICData::GetOneClassCheckAt( |
| 6692 int index, Class* cls, Function* target) const { | 6692 int index, intptr_t* class_id, Function* target) const { |
| 6693 ASSERT(cls != NULL); | 6693 ASSERT(class_id != NULL); |
| 6694 ASSERT(target != NULL); | 6694 ASSERT(target != NULL); |
| 6695 ASSERT(num_args_tested() == 1); | 6695 ASSERT(num_args_tested() == 1); |
| 6696 const Array& data = Array::Handle(ic_data()); | 6696 const Array& data = Array::Handle(ic_data()); |
| 6697 intptr_t data_pos = index * TestEntryLength(); | 6697 intptr_t data_pos = index * TestEntryLength(); |
| 6698 *cls ^= data.At(data_pos); | 6698 Smi& smi = Smi::Handle(); |
| 6699 smi ^= data.At(data_pos); |
| 6700 *class_id = smi.Value(); |
| 6699 *target ^= data.At(data_pos + 1); | 6701 *target ^= data.At(data_pos + 1); |
| 6700 } | 6702 } |
| 6701 | 6703 |
| 6702 | 6704 |
| 6703 RawICData* ICData::New(const Function& function, | 6705 RawICData* ICData::New(const Function& function, |
| 6704 const String& target_name, | 6706 const String& target_name, |
| 6705 intptr_t id, | 6707 intptr_t id, |
| 6706 intptr_t num_args_tested) { | 6708 intptr_t num_args_tested) { |
| 6707 ASSERT(num_args_tested > 0); | 6709 ASSERT(num_args_tested > 0); |
| 6708 const Class& cls = Class::Handle(Object::icdata_class()); | 6710 const Class& cls = Class::Handle(Object::icdata_class()); |
| (...skipping 3413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10122 const String& str = String::Handle(pattern()); | 10124 const String& str = String::Handle(pattern()); |
| 10123 const char* format = "JSRegExp: pattern=%s flags=%s"; | 10125 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 10124 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 10126 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 10125 char* chars = reinterpret_cast<char*>( | 10127 char* chars = reinterpret_cast<char*>( |
| 10126 Isolate::Current()->current_zone()->Allocate(len + 1)); | 10128 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 10127 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 10129 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 10128 return chars; | 10130 return chars; |
| 10129 } | 10131 } |
| 10130 | 10132 |
| 10131 } // namespace dart | 10133 } // namespace dart |
| OLD | NEW |