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 "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 12311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12322 if ((receiver_class_id == kSmiCid) && (data_pos > 0)) { | 12322 if ((receiver_class_id == kSmiCid) && (data_pos > 0)) { |
12323 ASSERT(GetReceiverClassIdAt(0) != kSmiCid); | 12323 ASSERT(GetReceiverClassIdAt(0) != kSmiCid); |
12324 // Move class occupying position 0 to the data_pos. | 12324 // Move class occupying position 0 to the data_pos. |
12325 for (intptr_t i = 0; i < TestEntryLength(); i++) { | 12325 for (intptr_t i = 0; i < TestEntryLength(); i++) { |
12326 data.SetAt(data_pos + i, Object::Handle(data.At(i))); | 12326 data.SetAt(data_pos + i, Object::Handle(data.At(i))); |
12327 } | 12327 } |
12328 // Insert kSmiCid in position 0. | 12328 // Insert kSmiCid in position 0. |
12329 data_pos = 0; | 12329 data_pos = 0; |
12330 } | 12330 } |
12331 data.SetAt(data_pos, Smi::Handle(Smi::New(receiver_class_id))); | 12331 data.SetAt(data_pos, Smi::Handle(Smi::New(receiver_class_id))); |
12332 data.SetAt(data_pos + 1, target); | 12332 if (Isolate::Current()->compilation_allowed()) { |
12333 data.SetAt(data_pos + 2, Smi::Handle(Smi::New(count))); | 12333 data.SetAt(data_pos + 1, target); |
| 12334 data.SetAt(data_pos + 2, Smi::Handle(Smi::New(count))); |
| 12335 } else { |
| 12336 // Precompilation only, after all functions have been compiled. |
| 12337 ASSERT(target.HasCode()); |
| 12338 const Code& code = Code::Handle(target.CurrentCode()); |
| 12339 const Smi& entry_point = |
| 12340 Smi::Handle(Smi::FromAlignedAddress(code.EntryPoint())); |
| 12341 data.SetAt(data_pos + 1, code); |
| 12342 data.SetAt(data_pos + 2, entry_point); |
| 12343 } |
12334 // Multithreaded access to ICData requires setting of array to be the last | 12344 // Multithreaded access to ICData requires setting of array to be the last |
12335 // operation. | 12345 // operation. |
12336 set_ic_data_array(data); | 12346 set_ic_data_array(data); |
12337 } | 12347 } |
12338 | 12348 |
12339 | 12349 |
12340 void ICData::GetCheckAt(intptr_t index, | 12350 void ICData::GetCheckAt(intptr_t index, |
12341 GrowableArray<intptr_t>* class_ids, | 12351 GrowableArray<intptr_t>* class_ids, |
12342 Function* target) const { | 12352 Function* target) const { |
12343 ASSERT(index < NumberOfChecks()); | 12353 ASSERT(index < NumberOfChecks()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12397 intptr_t ICData::GetReceiverClassIdAt(intptr_t index) const { | 12407 intptr_t ICData::GetReceiverClassIdAt(intptr_t index) const { |
12398 ASSERT(index < NumberOfChecks()); | 12408 ASSERT(index < NumberOfChecks()); |
12399 const intptr_t data_pos = index * TestEntryLength(); | 12409 const intptr_t data_pos = index * TestEntryLength(); |
12400 NoSafepointScope no_safepoint; | 12410 NoSafepointScope no_safepoint; |
12401 RawArray* raw_data = ic_data(); | 12411 RawArray* raw_data = ic_data(); |
12402 return Smi::Value(Smi::RawCast(raw_data->ptr()->data()[data_pos])); | 12412 return Smi::Value(Smi::RawCast(raw_data->ptr()->data()[data_pos])); |
12403 } | 12413 } |
12404 | 12414 |
12405 | 12415 |
12406 RawFunction* ICData::GetTargetAt(intptr_t index) const { | 12416 RawFunction* ICData::GetTargetAt(intptr_t index) const { |
| 12417 ASSERT(Isolate::Current()->compilation_allowed()); |
12407 const intptr_t data_pos = index * TestEntryLength() + NumArgsTested(); | 12418 const intptr_t data_pos = index * TestEntryLength() + NumArgsTested(); |
12408 ASSERT(Object::Handle(Array::Handle(ic_data()).At(data_pos)).IsFunction()); | 12419 ASSERT(Object::Handle(Array::Handle(ic_data()).At(data_pos)).IsFunction()); |
12409 | 12420 |
12410 NoSafepointScope no_safepoint; | 12421 NoSafepointScope no_safepoint; |
12411 RawArray* raw_data = ic_data(); | 12422 RawArray* raw_data = ic_data(); |
12412 return reinterpret_cast<RawFunction*>(raw_data->ptr()->data()[data_pos]); | 12423 return reinterpret_cast<RawFunction*>(raw_data->ptr()->data()[data_pos]); |
12413 } | 12424 } |
12414 | 12425 |
12415 | 12426 |
| 12427 RawObject* ICData::GetTargetOrCodeAt(intptr_t index) const { |
| 12428 const intptr_t data_pos = index * TestEntryLength() + NumArgsTested(); |
| 12429 |
| 12430 NoSafepointScope no_safepoint; |
| 12431 RawArray* raw_data = ic_data(); |
| 12432 return raw_data->ptr()->data()[data_pos]; |
| 12433 } |
| 12434 |
| 12435 |
12416 void ICData::IncrementCountAt(intptr_t index, intptr_t value) const { | 12436 void ICData::IncrementCountAt(intptr_t index, intptr_t value) const { |
12417 ASSERT(0 <= value); | 12437 ASSERT(0 <= value); |
12418 ASSERT(value <= Smi::kMaxValue); | 12438 ASSERT(value <= Smi::kMaxValue); |
12419 SetCountAt(index, Utils::Minimum(GetCountAt(index) + value, Smi::kMaxValue)); | 12439 SetCountAt(index, Utils::Minimum(GetCountAt(index) + value, Smi::kMaxValue)); |
12420 } | 12440 } |
12421 | 12441 |
12422 | 12442 |
12423 void ICData::SetCountAt(intptr_t index, intptr_t value) const { | 12443 void ICData::SetCountAt(intptr_t index, intptr_t value) const { |
12424 ASSERT(0 <= value); | 12444 ASSERT(0 <= value); |
12425 ASSERT(value <= Smi::kMaxValue); | 12445 ASSERT(value <= Smi::kMaxValue); |
12426 | 12446 |
12427 const Array& data = Array::Handle(ic_data()); | 12447 const Array& data = Array::Handle(ic_data()); |
12428 const intptr_t data_pos = index * TestEntryLength() + | 12448 const intptr_t data_pos = index * TestEntryLength() + |
12429 CountIndexFor(NumArgsTested()); | 12449 CountIndexFor(NumArgsTested()); |
12430 data.SetAt(data_pos, Smi::Handle(Smi::New(value))); | 12450 data.SetAt(data_pos, Smi::Handle(Smi::New(value))); |
12431 } | 12451 } |
12432 | 12452 |
12433 | 12453 |
12434 intptr_t ICData::GetCountAt(intptr_t index) const { | 12454 intptr_t ICData::GetCountAt(intptr_t index) const { |
| 12455 ASSERT(Isolate::Current()->compilation_allowed()); |
12435 const Array& data = Array::Handle(ic_data()); | 12456 const Array& data = Array::Handle(ic_data()); |
12436 const intptr_t data_pos = index * TestEntryLength() + | 12457 const intptr_t data_pos = index * TestEntryLength() + |
12437 CountIndexFor(NumArgsTested()); | 12458 CountIndexFor(NumArgsTested()); |
12438 return Smi::Value(Smi::RawCast(data.At(data_pos))); | 12459 return Smi::Value(Smi::RawCast(data.At(data_pos))); |
12439 } | 12460 } |
12440 | 12461 |
12441 | 12462 |
12442 intptr_t ICData::AggregateCount() const { | 12463 intptr_t ICData::AggregateCount() const { |
12443 if (IsNull()) return 0; | 12464 if (IsNull()) return 0; |
12444 const intptr_t len = NumberOfChecks(); | 12465 const intptr_t len = NumberOfChecks(); |
12445 intptr_t count = 0; | 12466 intptr_t count = 0; |
12446 for (intptr_t i = 0; i < len; i++) { | 12467 for (intptr_t i = 0; i < len; i++) { |
12447 count += GetCountAt(i); | 12468 count += GetCountAt(i); |
12448 } | 12469 } |
12449 return count; | 12470 return count; |
12450 } | 12471 } |
12451 | 12472 |
12452 | 12473 |
| 12474 void ICData::SetCodeAt(intptr_t index, const Code& value) const { |
| 12475 ASSERT(!Isolate::Current()->compilation_allowed()); |
| 12476 const Array& data = Array::Handle(ic_data()); |
| 12477 const intptr_t data_pos = index * TestEntryLength() + |
| 12478 CodeIndexFor(NumArgsTested()); |
| 12479 data.SetAt(data_pos, value); |
| 12480 } |
| 12481 |
| 12482 |
| 12483 void ICData::SetEntryPointAt(intptr_t index, const Smi& value) const { |
| 12484 ASSERT(!Isolate::Current()->compilation_allowed()); |
| 12485 const Array& data = Array::Handle(ic_data()); |
| 12486 const intptr_t data_pos = index * TestEntryLength() + |
| 12487 EntryPointIndexFor(NumArgsTested()); |
| 12488 data.SetAt(data_pos, value); |
| 12489 } |
| 12490 |
| 12491 |
12453 RawFunction* ICData::GetTargetForReceiverClassId(intptr_t class_id) const { | 12492 RawFunction* ICData::GetTargetForReceiverClassId(intptr_t class_id) const { |
12454 const intptr_t len = NumberOfChecks(); | 12493 const intptr_t len = NumberOfChecks(); |
12455 for (intptr_t i = 0; i < len; i++) { | 12494 for (intptr_t i = 0; i < len; i++) { |
12456 if (GetReceiverClassIdAt(i) == class_id) { | 12495 if (GetReceiverClassIdAt(i) == class_id) { |
12457 return GetTargetAt(i); | 12496 return GetTargetAt(i); |
12458 } | 12497 } |
12459 } | 12498 } |
12460 return Function::null(); | 12499 return Function::null(); |
12461 } | 12500 } |
12462 | 12501 |
(...skipping 9454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21917 return UserTag::null(); | 21956 return UserTag::null(); |
21918 } | 21957 } |
21919 | 21958 |
21920 | 21959 |
21921 const char* UserTag::ToCString() const { | 21960 const char* UserTag::ToCString() const { |
21922 const String& tag_label = String::Handle(label()); | 21961 const String& tag_label = String::Handle(label()); |
21923 return tag_label.ToCString(); | 21962 return tag_label.ToCString(); |
21924 } | 21963 } |
21925 | 21964 |
21926 } // namespace dart | 21965 } // namespace dart |
OLD | NEW |