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 12552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12563 } | 12563 } |
12564 | 12564 |
12565 | 12565 |
12566 void ICData::AddDeoptReason(DeoptReasonId reason) const { | 12566 void ICData::AddDeoptReason(DeoptReasonId reason) const { |
12567 if (reason <= kLastRecordedDeoptReason) { | 12567 if (reason <= kLastRecordedDeoptReason) { |
12568 SetDeoptReasons(DeoptReasons() | (1 << reason)); | 12568 SetDeoptReasons(DeoptReasons() | (1 << reason)); |
12569 } | 12569 } |
12570 } | 12570 } |
12571 | 12571 |
12572 | 12572 |
| 12573 void ICData::SetIsStaticCall(bool static_call) const { |
| 12574 StoreNonPointer(&raw_ptr()->state_bits_, |
| 12575 StaticCallBit::update(static_call, raw_ptr()->state_bits_)); |
| 12576 } |
| 12577 |
| 12578 |
| 12579 bool ICData::is_static_call() const { |
| 12580 return StaticCallBit::decode(raw_ptr()->state_bits_); |
| 12581 } |
| 12582 |
| 12583 |
12573 void ICData::set_state_bits(uint32_t bits) const { | 12584 void ICData::set_state_bits(uint32_t bits) const { |
12574 StoreNonPointer(&raw_ptr()->state_bits_, bits); | 12585 StoreNonPointer(&raw_ptr()->state_bits_, bits); |
12575 } | 12586 } |
12576 | 12587 |
12577 | 12588 |
12578 intptr_t ICData::TestEntryLengthFor(intptr_t num_args) { | 12589 intptr_t ICData::TestEntryLengthFor(intptr_t num_args) { |
12579 return num_args + 1 /* target function*/ + 1 /* frequency */; | 12590 return num_args + 1 /* target function*/ + 1 /* frequency */; |
12580 } | 12591 } |
12581 | 12592 |
12582 | 12593 |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13375 } | 13386 } |
13376 | 13387 |
13377 | 13388 |
13378 | 13389 |
13379 // Does not initialize ICData array. | 13390 // Does not initialize ICData array. |
13380 RawICData* ICData::NewDescriptor(Zone* zone, | 13391 RawICData* ICData::NewDescriptor(Zone* zone, |
13381 const Function& owner, | 13392 const Function& owner, |
13382 const String& target_name, | 13393 const String& target_name, |
13383 const Array& arguments_descriptor, | 13394 const Array& arguments_descriptor, |
13384 intptr_t deopt_id, | 13395 intptr_t deopt_id, |
13385 intptr_t num_args_tested) { | 13396 intptr_t num_args_tested, |
| 13397 bool is_static_call) { |
13386 ASSERT(!owner.IsNull()); | 13398 ASSERT(!owner.IsNull()); |
13387 ASSERT(!target_name.IsNull()); | 13399 ASSERT(!target_name.IsNull()); |
13388 ASSERT(!arguments_descriptor.IsNull()); | 13400 ASSERT(!arguments_descriptor.IsNull()); |
13389 ASSERT(Object::icdata_class() != Class::null()); | 13401 ASSERT(Object::icdata_class() != Class::null()); |
13390 ASSERT(num_args_tested >= 0); | 13402 ASSERT(num_args_tested >= 0); |
13391 ICData& result = ICData::Handle(zone); | 13403 ICData& result = ICData::Handle(zone); |
13392 { | 13404 { |
13393 // IC data objects are long living objects, allocate them in old generation. | 13405 // IC data objects are long living objects, allocate them in old generation. |
13394 RawObject* raw = Object::Allocate(ICData::kClassId, | 13406 RawObject* raw = Object::Allocate(ICData::kClassId, |
13395 ICData::InstanceSize(), | 13407 ICData::InstanceSize(), |
13396 Heap::kOld); | 13408 Heap::kOld); |
13397 NoSafepointScope no_safepoint; | 13409 NoSafepointScope no_safepoint; |
13398 result ^= raw; | 13410 result ^= raw; |
13399 } | 13411 } |
13400 result.set_owner(owner); | 13412 result.set_owner(owner); |
13401 result.set_target_name(target_name); | 13413 result.set_target_name(target_name); |
13402 result.set_arguments_descriptor(arguments_descriptor); | 13414 result.set_arguments_descriptor(arguments_descriptor); |
13403 result.set_deopt_id(deopt_id); | 13415 result.set_deopt_id(deopt_id); |
13404 result.set_state_bits(0); | 13416 result.set_state_bits(0); |
13405 #if defined(TAG_IC_DATA) | 13417 #if defined(TAG_IC_DATA) |
13406 result.set_tag(-1); | 13418 result.set_tag(-1); |
13407 #endif | 13419 #endif |
| 13420 result.SetIsStaticCall(is_static_call); |
13408 result.SetNumArgsTested(num_args_tested); | 13421 result.SetNumArgsTested(num_args_tested); |
13409 return result.raw(); | 13422 return result.raw(); |
13410 } | 13423 } |
13411 | 13424 |
13412 | 13425 |
13413 bool ICData::IsImmutable() const { | 13426 bool ICData::IsImmutable() const { |
13414 const Array& data = Array::Handle(ic_data()); | 13427 const Array& data = Array::Handle(ic_data()); |
13415 return data.IsImmutable(); | 13428 return data.IsImmutable(); |
13416 } | 13429 } |
13417 | 13430 |
(...skipping 24 matching lines...) Expand all Loading... |
13442 result.set_tag(-1); | 13455 result.set_tag(-1); |
13443 #endif | 13456 #endif |
13444 return result.raw(); | 13457 return result.raw(); |
13445 } | 13458 } |
13446 | 13459 |
13447 | 13460 |
13448 RawICData* ICData::New(const Function& owner, | 13461 RawICData* ICData::New(const Function& owner, |
13449 const String& target_name, | 13462 const String& target_name, |
13450 const Array& arguments_descriptor, | 13463 const Array& arguments_descriptor, |
13451 intptr_t deopt_id, | 13464 intptr_t deopt_id, |
13452 intptr_t num_args_tested) { | 13465 intptr_t num_args_tested, |
| 13466 bool is_static_call) { |
13453 Zone* zone = Thread::Current()->zone(); | 13467 Zone* zone = Thread::Current()->zone(); |
13454 const ICData& result = ICData::Handle(zone, | 13468 const ICData& result = ICData::Handle(zone, |
13455 NewDescriptor(zone, | 13469 NewDescriptor(zone, |
13456 owner, | 13470 owner, |
13457 target_name, | 13471 target_name, |
13458 arguments_descriptor, | 13472 arguments_descriptor, |
13459 deopt_id, | 13473 deopt_id, |
13460 num_args_tested)); | 13474 num_args_tested, |
| 13475 is_static_call)); |
13461 result.set_ic_data_array( | 13476 result.set_ic_data_array( |
13462 Array::Handle(zone, NewEmptyICDataArray(num_args_tested))); | 13477 Array::Handle(zone, NewEmptyICDataArray(num_args_tested))); |
13463 return result.raw(); | 13478 return result.raw(); |
13464 } | 13479 } |
13465 | 13480 |
13466 | 13481 |
13467 RawICData* ICData::NewFrom(const ICData& from, intptr_t num_args_tested) { | 13482 RawICData* ICData::NewFrom(const ICData& from, intptr_t num_args_tested) { |
13468 const ICData& result = ICData::Handle(ICData::New( | 13483 const ICData& result = ICData::Handle(ICData::New( |
13469 Function::Handle(from.Owner()), | 13484 Function::Handle(from.Owner()), |
13470 String::Handle(from.target_name()), | 13485 String::Handle(from.target_name()), |
13471 Array::Handle(from.arguments_descriptor()), | 13486 Array::Handle(from.arguments_descriptor()), |
13472 from.deopt_id(), | 13487 from.deopt_id(), |
13473 num_args_tested)); | 13488 num_args_tested, |
| 13489 from.is_static_call())); |
13474 // Copy deoptimization reasons. | 13490 // Copy deoptimization reasons. |
13475 result.SetDeoptReasons(from.DeoptReasons()); | 13491 result.SetDeoptReasons(from.DeoptReasons()); |
13476 return result.raw(); | 13492 return result.raw(); |
13477 } | 13493 } |
13478 | 13494 |
13479 | 13495 |
13480 RawICData* ICData::Clone(const ICData& from) { | 13496 RawICData* ICData::Clone(const ICData& from) { |
13481 Zone* zone = Thread::Current()->zone(); | 13497 Zone* zone = Thread::Current()->zone(); |
13482 const ICData& result = ICData::Handle(ICData::NewDescriptor( | 13498 const ICData& result = ICData::Handle(ICData::NewDescriptor( |
13483 zone, | 13499 zone, |
13484 Function::Handle(zone, from.Owner()), | 13500 Function::Handle(zone, from.Owner()), |
13485 String::Handle(zone, from.target_name()), | 13501 String::Handle(zone, from.target_name()), |
13486 Array::Handle(zone, from.arguments_descriptor()), | 13502 Array::Handle(zone, from.arguments_descriptor()), |
13487 from.deopt_id(), | 13503 from.deopt_id(), |
13488 from.NumArgsTested())); | 13504 from.NumArgsTested(), |
| 13505 from.is_static_call())); |
13489 // Clone entry array. | 13506 // Clone entry array. |
13490 const Array& from_array = Array::Handle(zone, from.ic_data()); | 13507 const Array& from_array = Array::Handle(zone, from.ic_data()); |
13491 const intptr_t len = from_array.Length(); | 13508 const intptr_t len = from_array.Length(); |
13492 const Array& cloned_array = | 13509 const Array& cloned_array = |
13493 Array::Handle(zone, Array::New(len, Heap::kOld)); | 13510 Array::Handle(zone, Array::New(len, Heap::kOld)); |
13494 Object& obj = Object::Handle(zone); | 13511 Object& obj = Object::Handle(zone); |
13495 for (intptr_t i = 0; i < len; i++) { | 13512 for (intptr_t i = 0; i < len; i++) { |
13496 obj = from_array.At(i); | 13513 obj = from_array.At(i); |
13497 cloned_array.SetAt(i, obj); | 13514 cloned_array.SetAt(i, obj); |
13498 } | 13515 } |
(...skipping 9150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22649 return UserTag::null(); | 22666 return UserTag::null(); |
22650 } | 22667 } |
22651 | 22668 |
22652 | 22669 |
22653 const char* UserTag::ToCString() const { | 22670 const char* UserTag::ToCString() const { |
22654 const String& tag_label = String::Handle(label()); | 22671 const String& tag_label = String::Handle(label()); |
22655 return tag_label.ToCString(); | 22672 return tag_label.ToCString(); |
22656 } | 22673 } |
22657 | 22674 |
22658 } // namespace dart | 22675 } // namespace dart |
OLD | NEW |