| 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 6421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6432 count = 0; | 6432 count = 0; |
| 6433 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) { | 6433 for (intptr_t i = 0; i < deopt_id_to_ic_data.length(); i++) { |
| 6434 if (deopt_id_to_ic_data[i] != NULL) { | 6434 if (deopt_id_to_ic_data[i] != NULL) { |
| 6435 a.SetAt(count++, *deopt_id_to_ic_data[i]); | 6435 a.SetAt(count++, *deopt_id_to_ic_data[i]); |
| 6436 } | 6436 } |
| 6437 } | 6437 } |
| 6438 set_ic_data_array(a); | 6438 set_ic_data_array(a); |
| 6439 } | 6439 } |
| 6440 | 6440 |
| 6441 | 6441 |
| 6442 RawArray* Function::RestoreICDataMap() const { | 6442 void Function::RestoreICDataMap( |
| 6443 const Array& saved_icd = Array::Handle(ic_data_array()); | 6443 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data) const { |
| 6444 Isolate* isolate = Isolate::Current(); |
| 6445 const Array& saved_icd = Array::Handle(isolate, ic_data_array()); |
| 6444 if (saved_icd.Length() == 0) { | 6446 if (saved_icd.Length() == 0) { |
| 6445 return Array::empty_array().raw(); | 6447 deopt_id_to_ic_data->Clear(); |
| 6448 return;; |
| 6446 } | 6449 } |
| 6447 ICData& icd = ICData::Handle(); | 6450 ICData& icd = ICData::Handle(); |
| 6448 icd ^= saved_icd.At(saved_icd.Length() - 1); | 6451 icd ^= saved_icd.At(saved_icd.Length() - 1); |
| 6449 const Array& result = Array::Handle(Array::New(icd.deopt_id() + 1)); | 6452 const intptr_t len = icd.deopt_id() + 1; |
| 6453 deopt_id_to_ic_data->SetLength(len); |
| 6454 for (intptr_t i = 0; i < len; i++) { |
| 6455 (*deopt_id_to_ic_data)[i] = NULL; |
| 6456 } |
| 6450 for (intptr_t i = 0; i < saved_icd.Length(); i++) { | 6457 for (intptr_t i = 0; i < saved_icd.Length(); i++) { |
| 6458 ICData& icd = ICData::ZoneHandle(isolate); |
| 6451 icd ^= saved_icd.At(i); | 6459 icd ^= saved_icd.At(i); |
| 6452 result.SetAt(icd.deopt_id(), icd); | 6460 (*deopt_id_to_ic_data)[icd.deopt_id()] = &icd; |
| 6453 } | 6461 } |
| 6454 return result.raw(); | |
| 6455 } | 6462 } |
| 6456 | 6463 |
| 6457 | 6464 |
| 6458 void Function::set_ic_data_array(const Array& value) const { | 6465 void Function::set_ic_data_array(const Array& value) const { |
| 6459 StorePointer(&raw_ptr()->ic_data_array_, value.raw()); | 6466 StorePointer(&raw_ptr()->ic_data_array_, value.raw()); |
| 6460 } | 6467 } |
| 6461 | 6468 |
| 6462 | 6469 |
| 6463 RawArray* Function::ic_data_array() const { | 6470 RawArray* Function::ic_data_array() const { |
| 6464 return raw_ptr()->ic_data_array_; | 6471 return raw_ptr()->ic_data_array_; |
| (...skipping 5574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12039 for (intptr_t i = 0; i < this->pointer_offsets_length(); i++) { | 12046 for (intptr_t i = 0; i < this->pointer_offsets_length(); i++) { |
| 12040 const intptr_t offset = this->GetPointerOffsetAt(i); | 12047 const intptr_t offset = this->GetPointerOffsetAt(i); |
| 12041 if ((start_offset <= offset) && (offset < end_offset)) { | 12048 if ((start_offset <= offset) && (offset < end_offset)) { |
| 12042 return false; | 12049 return false; |
| 12043 } | 12050 } |
| 12044 } | 12051 } |
| 12045 return true; | 12052 return true; |
| 12046 } | 12053 } |
| 12047 | 12054 |
| 12048 | 12055 |
| 12049 intptr_t Code::ExtractIcDataArraysAtCalls( | |
| 12050 GrowableArray<intptr_t>* node_ids, | |
| 12051 const GrowableObjectArray& ic_data_objs) const { | |
| 12052 ASSERT(node_ids != NULL); | |
| 12053 ASSERT(!ic_data_objs.IsNull()); | |
| 12054 const PcDescriptors& descriptors = | |
| 12055 PcDescriptors::Handle(this->pc_descriptors()); | |
| 12056 ICData& ic_data_obj = ICData::Handle(); | |
| 12057 intptr_t max_id = -1; | |
| 12058 for (intptr_t i = 0; i < descriptors.Length(); i++) { | |
| 12059 PcDescriptors::Kind kind = descriptors.DescriptorKind(i); | |
| 12060 if ((kind == PcDescriptors::kIcCall) || | |
| 12061 (kind == PcDescriptors::kUnoptStaticCall)) { | |
| 12062 intptr_t deopt_id = descriptors.DeoptId(i); | |
| 12063 if (deopt_id > max_id) { | |
| 12064 max_id = deopt_id; | |
| 12065 } | |
| 12066 node_ids->Add(deopt_id); | |
| 12067 uword ret_addr = descriptors.PC(i); | |
| 12068 if (kind == PcDescriptors::kIcCall) { | |
| 12069 CodePatcher::GetInstanceCallAt(ret_addr, *this, &ic_data_obj); | |
| 12070 } else { | |
| 12071 CodePatcher::GetUnoptimizedStaticCallAt(ret_addr, *this, &ic_data_obj); | |
| 12072 } | |
| 12073 ic_data_objs.Add(ic_data_obj); | |
| 12074 } | |
| 12075 } | |
| 12076 return max_id; | |
| 12077 } | |
| 12078 | |
| 12079 | |
| 12080 RawArray* Code::ExtractTypeFeedbackArray() const { | |
| 12081 ASSERT(!IsNull() && !is_optimized()); | |
| 12082 GrowableArray<intptr_t> deopt_ids; | |
| 12083 const GrowableObjectArray& ic_data_objs = | |
| 12084 GrowableObjectArray::Handle(GrowableObjectArray::New()); | |
| 12085 const intptr_t max_id = | |
| 12086 ExtractIcDataArraysAtCalls(&deopt_ids, ic_data_objs); | |
| 12087 const Array& result = Array::Handle(Array::New(max_id + 1)); | |
| 12088 for (intptr_t i = 0; i < deopt_ids.length(); i++) { | |
| 12089 intptr_t result_index = deopt_ids[i]; | |
| 12090 ASSERT(result.At(result_index) == Object::null()); | |
| 12091 result.SetAt(result_index, Object::Handle(ic_data_objs.At(i))); | |
| 12092 } | |
| 12093 return result.raw(); | |
| 12094 } | |
| 12095 | |
| 12096 | |
| 12097 RawStackmap* Code::GetStackmap(uword pc, Array* maps, Stackmap* map) const { | 12056 RawStackmap* Code::GetStackmap(uword pc, Array* maps, Stackmap* map) const { |
| 12098 // This code is used during iterating frames during a GC and hence it | 12057 // This code is used during iterating frames during a GC and hence it |
| 12099 // should not in turn start a GC. | 12058 // should not in turn start a GC. |
| 12100 NoGCScope no_gc; | 12059 NoGCScope no_gc; |
| 12101 if (stackmaps() == Array::null()) { | 12060 if (stackmaps() == Array::null()) { |
| 12102 // No stack maps are present in the code object which means this | 12061 // No stack maps are present in the code object which means this |
| 12103 // frame relies on tagged pointers. | 12062 // frame relies on tagged pointers. |
| 12104 return Stackmap::null(); | 12063 return Stackmap::null(); |
| 12105 } | 12064 } |
| 12106 // A stack map is present in the code object, use the stack map to visit | 12065 // A stack map is present in the code object, use the stack map to visit |
| (...skipping 7014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19121 return tag_label.ToCString(); | 19080 return tag_label.ToCString(); |
| 19122 } | 19081 } |
| 19123 | 19082 |
| 19124 | 19083 |
| 19125 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19084 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 19126 Instance::PrintJSONImpl(stream, ref); | 19085 Instance::PrintJSONImpl(stream, ref); |
| 19127 } | 19086 } |
| 19128 | 19087 |
| 19129 | 19088 |
| 19130 } // namespace dart | 19089 } // namespace dart |
| OLD | NEW |