Chromium Code Reviews| 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 6766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6777 array.SetAt(count++, *deopt_id_to_ic_data[i]); | 6777 array.SetAt(count++, *deopt_id_to_ic_data[i]); |
| 6778 } | 6778 } |
| 6779 } | 6779 } |
| 6780 array.SetAt(0, edge_counters_array); | 6780 array.SetAt(0, edge_counters_array); |
| 6781 set_ic_data_array(array); | 6781 set_ic_data_array(array); |
| 6782 } | 6782 } |
| 6783 | 6783 |
| 6784 | 6784 |
| 6785 void Function::RestoreICDataMap( | 6785 void Function::RestoreICDataMap( |
| 6786 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data, | 6786 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data, |
| 6787 bool clone_descriptors) const { | 6787 bool clone_ic_data) const { |
| 6788 ASSERT(deopt_id_to_ic_data->is_empty()); | 6788 ASSERT(deopt_id_to_ic_data->is_empty()); |
| 6789 Zone* zone = Thread::Current()->zone(); | 6789 Zone* zone = Thread::Current()->zone(); |
| 6790 const Array& saved_ic_data = Array::Handle(zone, ic_data_array()); | 6790 const Array& saved_ic_data = Array::Handle(zone, ic_data_array()); |
| 6791 if (saved_ic_data.IsNull()) { | 6791 if (saved_ic_data.IsNull()) { |
| 6792 // Could happen with deferred loading. | 6792 // Could happen with deferred loading. |
| 6793 return; | 6793 return; |
| 6794 } | 6794 } |
| 6795 const intptr_t saved_length = saved_ic_data.Length(); | 6795 const intptr_t saved_length = saved_ic_data.Length(); |
| 6796 ASSERT(saved_length > 0); | 6796 ASSERT(saved_length > 0); |
| 6797 if (saved_length > 1) { | 6797 if (saved_length > 1) { |
| 6798 const intptr_t restored_length = ICData::Cast(Object::Handle( | 6798 const intptr_t restored_length = ICData::Cast(Object::Handle( |
| 6799 zone, saved_ic_data.At(saved_length - 1))).deopt_id() + 1; | 6799 zone, saved_ic_data.At(saved_length - 1))).deopt_id() + 1; |
| 6800 deopt_id_to_ic_data->SetLength(restored_length); | 6800 deopt_id_to_ic_data->SetLength(restored_length); |
| 6801 for (intptr_t i = 0; i < restored_length; i++) { | 6801 for (intptr_t i = 0; i < restored_length; i++) { |
| 6802 (*deopt_id_to_ic_data)[i] = NULL; | 6802 (*deopt_id_to_ic_data)[i] = NULL; |
| 6803 } | 6803 } |
| 6804 for (intptr_t i = 1; i < saved_length; i++) { | 6804 for (intptr_t i = 1; i < saved_length; i++) { |
| 6805 ICData& ic_data = ICData::ZoneHandle(zone); | 6805 ICData& ic_data = ICData::ZoneHandle(zone); |
| 6806 ic_data ^= saved_ic_data.At(i); | 6806 ic_data ^= saved_ic_data.At(i); |
| 6807 if (clone_descriptors) { | 6807 if (clone_ic_data) { |
| 6808 ICData& original_ic_data = ICData::Handle(zone, ic_data.raw()); | 6808 const ICData& original_ic_data = ICData::Handle(zone, ic_data.raw()); |
| 6809 ic_data = ICData::CloneDescriptor(ic_data); | 6809 ic_data = ICData::CloneDescriptorAndData(ic_data); |
| 6810 ic_data.SetOriginal(original_ic_data); | 6810 ic_data.SetOriginal(original_ic_data); |
| 6811 } | 6811 } |
| 6812 (*deopt_id_to_ic_data)[ic_data.deopt_id()] = &ic_data; | 6812 (*deopt_id_to_ic_data)[ic_data.deopt_id()] = &ic_data; |
| 6813 } | 6813 } |
| 6814 } | 6814 } |
| 6815 } | 6815 } |
| 6816 | 6816 |
| 6817 | 6817 |
| 6818 void Function::set_ic_data_array(const Array& value) const { | 6818 void Function::set_ic_data_array(const Array& value) const { |
| 6819 StorePointer(&raw_ptr()->ic_data_array_, value.raw()); | 6819 StorePointer(&raw_ptr()->ic_data_array_, value.raw()); |
| (...skipping 5479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12299 String::Handle(from.target_name()), | 12299 String::Handle(from.target_name()), |
| 12300 Array::Handle(from.arguments_descriptor()), | 12300 Array::Handle(from.arguments_descriptor()), |
| 12301 from.deopt_id(), | 12301 from.deopt_id(), |
| 12302 num_args_tested)); | 12302 num_args_tested)); |
| 12303 // Copy deoptimization reasons. | 12303 // Copy deoptimization reasons. |
| 12304 result.SetDeoptReasons(from.DeoptReasons()); | 12304 result.SetDeoptReasons(from.DeoptReasons()); |
| 12305 return result.raw(); | 12305 return result.raw(); |
| 12306 } | 12306 } |
| 12307 | 12307 |
| 12308 | 12308 |
| 12309 RawICData* ICData::CloneDescriptor(const ICData& from) { | 12309 RawICData* ICData::CloneDescriptorAndData(const ICData& from) { |
| 12310 Zone* zone = Thread::Current()->zone(); | 12310 Zone* zone = Thread::Current()->zone(); |
| 12311 const ICData& result = ICData::Handle(ICData::NewDescriptor( | 12311 const ICData& result = ICData::Handle(ICData::NewDescriptor( |
| 12312 zone, | 12312 zone, |
| 12313 Function::Handle(zone, from.Owner()), | 12313 Function::Handle(zone, from.Owner()), |
| 12314 String::Handle(zone, from.target_name()), | 12314 String::Handle(zone, from.target_name()), |
| 12315 Array::Handle(zone, from.arguments_descriptor()), | 12315 Array::Handle(zone, from.arguments_descriptor()), |
| 12316 from.deopt_id(), | 12316 from.deopt_id(), |
| 12317 from.NumArgsTested())); | 12317 from.NumArgsTested())); |
| 12318 // Preserve entry array. | 12318 // Clone entry array. |
| 12319 result.set_ic_data_array(Array::Handle(zone, from.ic_data())); | 12319 const Array& from_array = Array::Handle(zone, from.ic_data()); |
| 12320 const intptr_t len = from_array.Length(); | |
| 12321 const Array& cloned_array = | |
| 12322 Array::Handle(zone, Array::New(len, Heap::kOld)); | |
| 12323 Object& obj = Object::Handle(zone); | |
| 12324 for (intptr_t i = 0; i < len; i++) { | |
| 12325 obj = from_array.At(i); | |
| 12326 cloned_array.SetAt(i, obj); | |
| 12327 } | |
|
siva
2016/02/12 22:10:24
I think there are many places where we do this arr
srdjan
2016/02/12 22:20:38
Sounds good.
| |
| 12328 result.set_ic_data_array(cloned_array); | |
| 12320 // Copy deoptimization reasons. | 12329 // Copy deoptimization reasons. |
| 12321 result.SetDeoptReasons(from.DeoptReasons()); | 12330 result.SetDeoptReasons(from.DeoptReasons()); |
| 12322 return result.raw(); | 12331 return result.raw(); |
| 12323 } | 12332 } |
| 12324 | 12333 |
| 12325 | 12334 |
| 12326 static Token::Kind RecognizeArithmeticOp(const String& name) { | 12335 static Token::Kind RecognizeArithmeticOp(const String& name) { |
| 12327 ASSERT(name.IsSymbol()); | 12336 ASSERT(name.IsSymbol()); |
| 12328 if (name.raw() == Symbols::Plus().raw()) { | 12337 if (name.raw() == Symbols::Plus().raw()) { |
| 12329 return Token::kADD; | 12338 return Token::kADD; |
| (...skipping 9087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 21417 return UserTag::null(); | 21426 return UserTag::null(); |
| 21418 } | 21427 } |
| 21419 | 21428 |
| 21420 | 21429 |
| 21421 const char* UserTag::ToCString() const { | 21430 const char* UserTag::ToCString() const { |
| 21422 const String& tag_label = String::Handle(label()); | 21431 const String& tag_label = String::Handle(label()); |
| 21423 return tag_label.ToCString(); | 21432 return tag_label.ToCString(); |
| 21424 } | 21433 } |
| 21425 | 21434 |
| 21426 } // namespace dart | 21435 } // namespace dart |
| OLD | NEW |