| 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/become.h" | 10 #include "vm/become.h" |
| (...skipping 12955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12966 THR_Print("Check[%" Pd "]:", i); | 12966 THR_Print("Check[%" Pd "]:", i); |
| 12967 GetClassIdsAt(i, &class_ids); | 12967 GetClassIdsAt(i, &class_ids); |
| 12968 for (intptr_t c = 0; c < class_ids.length(); c++) { | 12968 for (intptr_t c = 0; c < class_ids.length(); c++) { |
| 12969 THR_Print(" %" Pd "", class_ids[c]); | 12969 THR_Print(" %" Pd "", class_ids[c]); |
| 12970 } | 12970 } |
| 12971 THR_Print("--- %" Pd " hits\n", GetCountAt(i)); | 12971 THR_Print("--- %" Pd " hits\n", GetCountAt(i)); |
| 12972 } | 12972 } |
| 12973 } | 12973 } |
| 12974 | 12974 |
| 12975 | 12975 |
| 12976 void ICData::ValidateSentinelLocations() const { | |
| 12977 } | |
| 12978 | |
| 12979 | |
| 12980 void ICData::AddReceiverCheck(intptr_t receiver_class_id, | 12976 void ICData::AddReceiverCheck(intptr_t receiver_class_id, |
| 12981 const Function& target, | 12977 const Function& target, |
| 12982 intptr_t count) const { | 12978 intptr_t count) const { |
| 12983 #if defined(DEBUG) | 12979 #if defined(DEBUG) |
| 12984 GrowableArray<intptr_t> class_ids(1); | 12980 GrowableArray<intptr_t> class_ids(1); |
| 12985 class_ids.Add(receiver_class_id); | 12981 class_ids.Add(receiver_class_id); |
| 12986 ASSERT(!HasCheck(class_ids)); | 12982 ASSERT(!HasCheck(class_ids)); |
| 12987 #endif // DEBUG | 12983 #endif // DEBUG |
| 12988 ASSERT(!target.IsNull()); | 12984 ASSERT(!target.IsNull()); |
| 12989 ASSERT(NumArgsTested() == 1); // Otherwise use 'AddCheck'. | 12985 ASSERT(NumArgsTested() == 1); // Otherwise use 'AddCheck'. |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13409 RawArray* ICData::NewNonCachedEmptyICDataArray(intptr_t num_args_tested) { | 13405 RawArray* ICData::NewNonCachedEmptyICDataArray(intptr_t num_args_tested) { |
| 13410 // IC data array must be null terminated (sentinel entry). | 13406 // IC data array must be null terminated (sentinel entry). |
| 13411 const intptr_t len = TestEntryLengthFor(num_args_tested); | 13407 const intptr_t len = TestEntryLengthFor(num_args_tested); |
| 13412 const Array& array = Array::Handle(Array::New(len, Heap::kOld)); | 13408 const Array& array = Array::Handle(Array::New(len, Heap::kOld)); |
| 13413 WriteSentinel(array, len); | 13409 WriteSentinel(array, len); |
| 13414 array.MakeImmutable(); | 13410 array.MakeImmutable(); |
| 13415 return array.raw(); | 13411 return array.raw(); |
| 13416 } | 13412 } |
| 13417 | 13413 |
| 13418 | 13414 |
| 13419 RawArray* ICData::NewEmptyICDataArray(intptr_t num_args_tested) { | 13415 RawArray* ICData::CachedEmptyICDataArray(intptr_t num_args_tested) { |
| 13420 ASSERT(num_args_tested >= 0); | 13416 ASSERT(num_args_tested >= 0); |
| 13421 if (num_args_tested < kCachedICDataArrayCount) { | 13417 ASSERT(num_args_tested < kCachedICDataArrayCount); |
| 13422 return cached_icdata_arrays_[num_args_tested]; | 13418 return cached_icdata_arrays_[num_args_tested]; |
| 13423 } | |
| 13424 return NewNonCachedEmptyICDataArray(num_args_tested); | |
| 13425 } | 13419 } |
| 13426 | 13420 |
| 13427 | 13421 |
| 13428 | 13422 |
| 13429 // Does not initialize ICData array. | 13423 // Does not initialize ICData array. |
| 13430 RawICData* ICData::NewDescriptor(Zone* zone, | 13424 RawICData* ICData::NewDescriptor(Zone* zone, |
| 13431 const Function& owner, | 13425 const Function& owner, |
| 13432 const String& target_name, | 13426 const String& target_name, |
| 13433 const Array& arguments_descriptor, | 13427 const Array& arguments_descriptor, |
| 13434 intptr_t deopt_id, | 13428 intptr_t deopt_id, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 13461 return result.raw(); | 13455 return result.raw(); |
| 13462 } | 13456 } |
| 13463 | 13457 |
| 13464 | 13458 |
| 13465 bool ICData::IsImmutable() const { | 13459 bool ICData::IsImmutable() const { |
| 13466 const Array& data = Array::Handle(ic_data()); | 13460 const Array& data = Array::Handle(ic_data()); |
| 13467 return data.IsImmutable(); | 13461 return data.IsImmutable(); |
| 13468 } | 13462 } |
| 13469 | 13463 |
| 13470 | 13464 |
| 13471 void ICData::ResetData() const { | |
| 13472 // Number of array elements in one test entry. | |
| 13473 intptr_t len = TestEntryLength(); | |
| 13474 // IC data array must be null terminated (sentinel entry). | |
| 13475 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); | |
| 13476 set_ic_data_array(ic_data); | |
| 13477 WriteSentinel(ic_data, len); | |
| 13478 } | |
| 13479 | |
| 13480 | |
| 13481 RawICData* ICData::New() { | 13465 RawICData* ICData::New() { |
| 13482 ICData& result = ICData::Handle(); | 13466 ICData& result = ICData::Handle(); |
| 13483 { | 13467 { |
| 13484 // IC data objects are long living objects, allocate them in old generation. | 13468 // IC data objects are long living objects, allocate them in old generation. |
| 13485 RawObject* raw = Object::Allocate(ICData::kClassId, | 13469 RawObject* raw = Object::Allocate(ICData::kClassId, |
| 13486 ICData::InstanceSize(), | 13470 ICData::InstanceSize(), |
| 13487 Heap::kOld); | 13471 Heap::kOld); |
| 13488 NoSafepointScope no_safepoint; | 13472 NoSafepointScope no_safepoint; |
| 13489 result ^= raw; | 13473 result ^= raw; |
| 13490 } | 13474 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 13506 Zone* zone = Thread::Current()->zone(); | 13490 Zone* zone = Thread::Current()->zone(); |
| 13507 const ICData& result = ICData::Handle(zone, | 13491 const ICData& result = ICData::Handle(zone, |
| 13508 NewDescriptor(zone, | 13492 NewDescriptor(zone, |
| 13509 owner, | 13493 owner, |
| 13510 target_name, | 13494 target_name, |
| 13511 arguments_descriptor, | 13495 arguments_descriptor, |
| 13512 deopt_id, | 13496 deopt_id, |
| 13513 num_args_tested, | 13497 num_args_tested, |
| 13514 is_static_call)); | 13498 is_static_call)); |
| 13515 result.set_ic_data_array( | 13499 result.set_ic_data_array( |
| 13516 Array::Handle(zone, NewEmptyICDataArray(num_args_tested))); | 13500 Array::Handle(zone, CachedEmptyICDataArray(num_args_tested))); |
| 13517 return result.raw(); | 13501 return result.raw(); |
| 13518 } | 13502 } |
| 13519 | 13503 |
| 13520 | 13504 |
| 13521 RawICData* ICData::NewFrom(const ICData& from, intptr_t num_args_tested) { | 13505 RawICData* ICData::NewFrom(const ICData& from, intptr_t num_args_tested) { |
| 13522 const ICData& result = ICData::Handle(ICData::New( | 13506 const ICData& result = ICData::Handle(ICData::New( |
| 13523 Function::Handle(from.Owner()), | 13507 Function::Handle(from.Owner()), |
| 13524 String::Handle(from.target_name()), | 13508 String::Handle(from.target_name()), |
| 13525 Array::Handle(from.arguments_descriptor()), | 13509 Array::Handle(from.arguments_descriptor()), |
| 13526 from.deopt_id(), | 13510 from.deopt_id(), |
| (...skipping 9195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22722 return UserTag::null(); | 22706 return UserTag::null(); |
| 22723 } | 22707 } |
| 22724 | 22708 |
| 22725 | 22709 |
| 22726 const char* UserTag::ToCString() const { | 22710 const char* UserTag::ToCString() const { |
| 22727 const String& tag_label = String::Handle(label()); | 22711 const String& tag_label = String::Handle(label()); |
| 22728 return tag_label.ToCString(); | 22712 return tag_label.ToCString(); |
| 22729 } | 22713 } |
| 22730 | 22714 |
| 22731 } // namespace dart | 22715 } // namespace dart |
| OLD | NEW |