| 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 6825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6836 | 6836 |
| 6837 void Function::set_ic_data_array(const Array& value) const { | 6837 void Function::set_ic_data_array(const Array& value) const { |
| 6838 StorePointer(&raw_ptr()->ic_data_array_, value.raw()); | 6838 StorePointer(&raw_ptr()->ic_data_array_, value.raw()); |
| 6839 } | 6839 } |
| 6840 | 6840 |
| 6841 | 6841 |
| 6842 RawArray* Function::ic_data_array() const { | 6842 RawArray* Function::ic_data_array() const { |
| 6843 return raw_ptr()->ic_data_array_; | 6843 return raw_ptr()->ic_data_array_; |
| 6844 } | 6844 } |
| 6845 | 6845 |
| 6846 |
| 6846 void Function::ClearICDataArray() const { | 6847 void Function::ClearICDataArray() const { |
| 6847 set_ic_data_array(Array::null_array()); | 6848 set_ic_data_array(Array::null_array()); |
| 6848 } | 6849 } |
| 6849 | 6850 |
| 6850 | 6851 |
| 6851 void Function::SetDeoptReasonForAll(intptr_t deopt_id, | 6852 void Function::SetDeoptReasonForAll(intptr_t deopt_id, |
| 6852 ICData::DeoptReasonId reason) { | 6853 ICData::DeoptReasonId reason) { |
| 6853 const Array& icd_array = Array::Handle(ic_data_array()); | 6854 const Array& icd_array = Array::Handle(ic_data_array()); |
| 6854 ICData& icd = ICData::Handle(); | 6855 ICData& icd = ICData::Handle(); |
| 6855 for (intptr_t i = 0; i < icd_array.Length(); i++) { | 6856 for (intptr_t i = 0; i < icd_array.Length(); i++) { |
| (...skipping 5946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12802 Array::New(RawCode::kInlinedMetadataSize, Heap::kOld)); | 12803 Array::New(RawCode::kInlinedMetadataSize, Heap::kOld)); |
| 12803 } | 12804 } |
| 12804 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); | 12805 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); |
| 12805 ASSERT(!metadata.IsNull()); | 12806 ASSERT(!metadata.IsNull()); |
| 12806 ASSERT(metadata.IsOld()); | 12807 ASSERT(metadata.IsOld()); |
| 12807 ASSERT(value.IsOld()); | 12808 ASSERT(value.IsOld()); |
| 12808 metadata.SetAt(RawCode::kInlinedIdToFunctionIndex, value); | 12809 metadata.SetAt(RawCode::kInlinedIdToFunctionIndex, value); |
| 12809 } | 12810 } |
| 12810 | 12811 |
| 12811 | 12812 |
| 12813 RawArray* Code::GetInlinedCallerIdMap() const { |
| 12814 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); |
| 12815 if (metadata.IsNull()) { |
| 12816 return metadata.raw(); |
| 12817 } |
| 12818 return reinterpret_cast<RawArray*>( |
| 12819 metadata.At(RawCode::kInlinedCallerIdMapIndex)); |
| 12820 } |
| 12821 |
| 12822 |
| 12823 void Code::SetInlinedCallerIdMap(const Array& value) const { |
| 12824 if (raw_ptr()->inlined_metadata_ == Array::null()) { |
| 12825 StorePointer(&raw_ptr()->inlined_metadata_, |
| 12826 Array::New(RawCode::kInlinedMetadataSize, Heap::kOld)); |
| 12827 } |
| 12828 const Array& metadata = Array::Handle(raw_ptr()->inlined_metadata_); |
| 12829 ASSERT(!metadata.IsNull()); |
| 12830 ASSERT(metadata.IsOld()); |
| 12831 ASSERT(value.IsOld()); |
| 12832 metadata.SetAt(RawCode::kInlinedCallerIdMapIndex, value); |
| 12833 } |
| 12834 |
| 12835 |
| 12812 RawCode* Code::New(intptr_t pointer_offsets_length) { | 12836 RawCode* Code::New(intptr_t pointer_offsets_length) { |
| 12813 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) { | 12837 if (pointer_offsets_length < 0 || pointer_offsets_length > kMaxElements) { |
| 12814 // This should be caught before we reach here. | 12838 // This should be caught before we reach here. |
| 12815 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %" Pd "\n", | 12839 FATAL1("Fatal error in Code::New: invalid pointer_offsets_length %" Pd "\n", |
| 12816 pointer_offsets_length); | 12840 pointer_offsets_length); |
| 12817 } | 12841 } |
| 12818 ASSERT(Object::code_class() != Class::null()); | 12842 ASSERT(Object::code_class() != Class::null()); |
| 12819 Code& result = Code::Handle(); | 12843 Code& result = Code::Handle(); |
| 12820 { | 12844 { |
| 12821 uword size = Code::InstanceSize(pointer_offsets_length); | 12845 uword size = Code::InstanceSize(pointer_offsets_length); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13170 end ^= intervals.At(i + Code::kInlIntNumEntries + Code::kInlIntStart); | 13194 end ^= intervals.At(i + Code::kInlIntNumEntries + Code::kInlIntStart); |
| 13171 | 13195 |
| 13172 // Format: [start, end, inline functions...] | 13196 // Format: [start, end, inline functions...] |
| 13173 JSONArray inline_interval(&inline_intervals); | 13197 JSONArray inline_interval(&inline_intervals); |
| 13174 inline_interval.AddValue(start.Value()); | 13198 inline_interval.AddValue(start.Value()); |
| 13175 inline_interval.AddValue(end.Value()); | 13199 inline_interval.AddValue(end.Value()); |
| 13176 | 13200 |
| 13177 temp_smi ^= intervals.At(i + Code::kInlIntInliningId); | 13201 temp_smi ^= intervals.At(i + Code::kInlIntInliningId); |
| 13178 intptr_t inlining_id = temp_smi.Value(); | 13202 intptr_t inlining_id = temp_smi.Value(); |
| 13179 ASSERT(inlining_id >= 0); | 13203 ASSERT(inlining_id >= 0); |
| 13180 temp_smi ^= intervals.At(i + Code::kInlIntCallerId); | 13204 intptr_t caller_id = GetCallerId(inlining_id); |
| 13181 intptr_t caller_id = temp_smi.Value(); | |
| 13182 while (inlining_id >= 0) { | 13205 while (inlining_id >= 0) { |
| 13183 inline_interval.AddValue(inlining_id); | 13206 inline_interval.AddValue(inlining_id); |
| 13184 inlining_id = caller_id; | 13207 inlining_id = caller_id; |
| 13185 caller_id = GetCallerId(inlining_id); | 13208 caller_id = GetCallerId(inlining_id); |
| 13186 } | 13209 } |
| 13187 } | 13210 } |
| 13188 } | 13211 } |
| 13189 } | 13212 } |
| 13190 | 13213 |
| 13191 | 13214 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13227 if (map->PcOffset() == pc_offset) { | 13250 if (map->PcOffset() == pc_offset) { |
| 13228 return map->raw(); // We found a stack map for this frame. | 13251 return map->raw(); // We found a stack map for this frame. |
| 13229 } | 13252 } |
| 13230 } | 13253 } |
| 13231 ASSERT(!is_optimized()); | 13254 ASSERT(!is_optimized()); |
| 13232 return Stackmap::null(); | 13255 return Stackmap::null(); |
| 13233 } | 13256 } |
| 13234 | 13257 |
| 13235 | 13258 |
| 13236 intptr_t Code::GetCallerId(intptr_t inlined_id) const { | 13259 intptr_t Code::GetCallerId(intptr_t inlined_id) const { |
| 13237 if (inlined_id < 0) return -1; | 13260 if (inlined_id < 0) { |
| 13238 const Array& intervals = Array::Handle(GetInlinedIntervals()); | 13261 return -1; |
| 13239 if (intervals.IsNull() || (intervals.Length() == 0)) return -1; | |
| 13240 Smi& temp_smi = Smi::Handle(); | |
| 13241 for (intptr_t i = 0; i < intervals.Length() - Code::kInlIntNumEntries; | |
| 13242 i += Code::kInlIntNumEntries) { | |
| 13243 temp_smi ^= intervals.At(i + Code::kInlIntInliningId); | |
| 13244 if (temp_smi.Value() == inlined_id) { | |
| 13245 temp_smi ^= intervals.At(i + Code::kInlIntCallerId); | |
| 13246 return temp_smi.Value(); | |
| 13247 } | |
| 13248 } | 13262 } |
| 13249 return -1; | 13263 const Array& map = Array::Handle(GetInlinedCallerIdMap()); |
| 13264 if (map.IsNull() || (map.Length() == 0)) { |
| 13265 return -1; |
| 13266 } |
| 13267 Smi& smi = Smi::Handle(); |
| 13268 smi ^= map.At(inlined_id); |
| 13269 return smi.Value(); |
| 13250 } | 13270 } |
| 13251 | 13271 |
| 13252 | 13272 |
| 13253 void Code::GetInlinedFunctionsAt( | 13273 void Code::GetInlinedFunctionsAt( |
| 13254 intptr_t offset, GrowableArray<Function*>* fs) const { | 13274 intptr_t offset, GrowableArray<Function*>* fs) const { |
| 13255 fs->Clear(); | 13275 fs->Clear(); |
| 13256 const Array& intervals = Array::Handle(GetInlinedIntervals()); | 13276 const Array& intervals = Array::Handle(GetInlinedIntervals()); |
| 13257 if (intervals.IsNull() || (intervals.Length() == 0)) { | 13277 if (intervals.IsNull() || (intervals.Length() == 0)) { |
| 13258 // E.g., for code stubs. | 13278 // E.g., for code stubs. |
| 13259 return; | 13279 return; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 13274 } | 13294 } |
| 13275 } | 13295 } |
| 13276 } | 13296 } |
| 13277 | 13297 |
| 13278 // Find all functions. | 13298 // Find all functions. |
| 13279 const Array& id_map = Array::Handle(GetInlinedIdToFunction()); | 13299 const Array& id_map = Array::Handle(GetInlinedIdToFunction()); |
| 13280 Smi& temp_smi = Smi::Handle(); | 13300 Smi& temp_smi = Smi::Handle(); |
| 13281 temp_smi ^= intervals.At(found_interval_ix + Code::kInlIntInliningId); | 13301 temp_smi ^= intervals.At(found_interval_ix + Code::kInlIntInliningId); |
| 13282 intptr_t inlining_id = temp_smi.Value(); | 13302 intptr_t inlining_id = temp_smi.Value(); |
| 13283 ASSERT(inlining_id >= 0); | 13303 ASSERT(inlining_id >= 0); |
| 13284 temp_smi ^= intervals.At(found_interval_ix + Code::kInlIntCallerId); | 13304 intptr_t caller_id = GetCallerId(inlining_id); |
| 13285 intptr_t caller_id = temp_smi.Value(); | |
| 13286 while (inlining_id >= 0) { | 13305 while (inlining_id >= 0) { |
| 13287 Function& function = Function::ZoneHandle(); | 13306 Function& function = Function::ZoneHandle(); |
| 13288 function ^= id_map.At(inlining_id); | 13307 function ^= id_map.At(inlining_id); |
| 13289 fs->Add(&function); | 13308 fs->Add(&function); |
| 13290 inlining_id = caller_id; | 13309 inlining_id = caller_id; |
| 13291 caller_id = GetCallerId(inlining_id); | 13310 caller_id = GetCallerId(inlining_id); |
| 13292 } | 13311 } |
| 13293 } | 13312 } |
| 13294 | 13313 |
| 13295 | 13314 |
| 13296 void Code::DumpInlinedIntervals() const { | 13315 void Code::DumpInlinedIntervals() const { |
| 13297 OS::Print("Inlined intervals:\n"); | 13316 LogBlock lb(Isolate::Current()); |
| 13317 ISL_Print("Inlined intervals:\n"); |
| 13298 const Array& intervals = Array::Handle(GetInlinedIntervals()); | 13318 const Array& intervals = Array::Handle(GetInlinedIntervals()); |
| 13299 if (intervals.IsNull() || (intervals.Length() == 0)) return; | 13319 if (intervals.IsNull() || (intervals.Length() == 0)) return; |
| 13300 Smi& start = Smi::Handle(); | 13320 Smi& start = Smi::Handle(); |
| 13301 Smi& inlining_id = Smi::Handle(); | 13321 Smi& inlining_id = Smi::Handle(); |
| 13302 Smi& caller_id = Smi::Handle(); | 13322 GrowableArray<Function*> inlined_functions; |
| 13323 const Function& inliner = Function::Handle(function()); |
| 13303 for (intptr_t i = 0; i < intervals.Length(); i += Code::kInlIntNumEntries) { | 13324 for (intptr_t i = 0; i < intervals.Length(); i += Code::kInlIntNumEntries) { |
| 13304 start ^= intervals.At(i + Code::kInlIntStart); | 13325 start ^= intervals.At(i + Code::kInlIntStart); |
| 13305 ASSERT(!start.IsNull()); | 13326 ASSERT(!start.IsNull()); |
| 13306 if (start.IsNull()) continue; | 13327 if (start.IsNull()) continue; |
| 13307 inlining_id ^= intervals.At(i + Code::kInlIntInliningId); | 13328 inlining_id ^= intervals.At(i + Code::kInlIntInliningId); |
| 13308 caller_id ^= intervals.At(i + Code::kInlIntCallerId); | 13329 ISL_Print(" %" Px " iid: %" Pd " ; ", start.Value(), inlining_id.Value()); |
| 13309 OS::Print(" %" Px " id: %" Pd " caller-id: %" Pd " \n", | 13330 inlined_functions.Clear(); |
| 13310 start.Value(), inlining_id.Value(), caller_id.Value()); | 13331 |
| 13332 ISL_Print("inlined: "); |
| 13333 GetInlinedFunctionsAt(start.Value(), &inlined_functions); |
| 13334 |
| 13335 for (intptr_t j = 0; j < inlined_functions.length(); j++) { |
| 13336 const char* name = inlined_functions[j]->ToQualifiedCString(); |
| 13337 ISL_Print(" %s <-", name); |
| 13338 } |
| 13339 if (inlined_functions[inlined_functions.length() - 1]->raw() != |
| 13340 inliner.raw()) { |
| 13341 ISL_Print(" (ERROR, missing inliner)\n"); |
| 13342 } else { |
| 13343 ISL_Print("\n"); |
| 13344 } |
| 13311 } | 13345 } |
| 13312 OS::Print("Inlined ids:\n"); | 13346 ISL_Print("Inlined ids:\n"); |
| 13313 const Array& id_map = Array::Handle(GetInlinedIdToFunction()); | 13347 const Array& id_map = Array::Handle(GetInlinedIdToFunction()); |
| 13314 Function& function = Function::Handle(); | 13348 Function& function = Function::Handle(); |
| 13315 for (intptr_t i = 0; i < id_map.Length(); i++) { | 13349 for (intptr_t i = 0; i < id_map.Length(); i++) { |
| 13316 function ^= id_map.At(i); | 13350 function ^= id_map.At(i); |
| 13317 if (!function.IsNull()) { | 13351 if (!function.IsNull()) { |
| 13318 OS::Print(" %" Pd ": %s\n", i, function.ToQualifiedCString()); | 13352 ISL_Print(" %" Pd ": %s\n", i, function.ToQualifiedCString()); |
| 13319 } | 13353 } |
| 13320 } | 13354 } |
| 13355 ISL_Print("Caller Inlining Ids:\n"); |
| 13356 const Array& caller_map = Array::Handle(GetInlinedCallerIdMap()); |
| 13357 Smi& smi = Smi::Handle(); |
| 13358 for (intptr_t i = 0; i < caller_map.Length(); i++) { |
| 13359 smi ^= caller_map.At(i); |
| 13360 ISL_Print(" iid: %" Pd " caller iid: %" Pd "\n", i, smi.Value()); |
| 13361 } |
| 13321 } | 13362 } |
| 13322 | 13363 |
| 13323 | 13364 |
| 13324 RawContext* Context::New(intptr_t num_variables, Heap::Space space) { | 13365 RawContext* Context::New(intptr_t num_variables, Heap::Space space) { |
| 13325 ASSERT(num_variables >= 0); | 13366 ASSERT(num_variables >= 0); |
| 13326 ASSERT(Object::context_class() != Class::null()); | 13367 ASSERT(Object::context_class() != Class::null()); |
| 13327 | 13368 |
| 13328 if (num_variables < 0 || num_variables > kMaxElements) { | 13369 if (num_variables < 0 || num_variables > kMaxElements) { |
| 13329 // This should be caught before we reach here. | 13370 // This should be caught before we reach here. |
| 13330 FATAL1("Fatal error in Context::New: invalid num_variables %" Pd "\n", | 13371 FATAL1("Fatal error in Context::New: invalid num_variables %" Pd "\n", |
| (...skipping 7943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21274 return tag_label.ToCString(); | 21315 return tag_label.ToCString(); |
| 21275 } | 21316 } |
| 21276 | 21317 |
| 21277 | 21318 |
| 21278 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21319 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 21279 Instance::PrintJSONImpl(stream, ref); | 21320 Instance::PrintJSONImpl(stream, ref); |
| 21280 } | 21321 } |
| 21281 | 21322 |
| 21282 | 21323 |
| 21283 } // namespace dart | 21324 } // namespace dart |
| OLD | NEW |