| 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 6800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6811 | 6811 |
| 6812 const Script& script = Script::Handle(this->script()); | 6812 const Script& script = Script::Handle(this->script()); |
| 6813 if (!script.IsNull()) { | 6813 if (!script.IsNull()) { |
| 6814 jsobj.AddProperty("script", script); | 6814 jsobj.AddProperty("script", script); |
| 6815 jsobj.AddProperty("tokenPos", token_pos()); | 6815 jsobj.AddProperty("tokenPos", token_pos()); |
| 6816 jsobj.AddProperty("endTokenPos", end_token_pos()); | 6816 jsobj.AddProperty("endTokenPos", end_token_pos()); |
| 6817 } | 6817 } |
| 6818 } | 6818 } |
| 6819 | 6819 |
| 6820 | 6820 |
| 6821 RawGrowableObjectArray* Function::CollectICsWithSourcePositions() const { |
| 6822 ZoneGrowableArray<const ICData*>* ic_data_array = |
| 6823 new ZoneGrowableArray<const ICData*>(); |
| 6824 RestoreICDataMap(ic_data_array); |
| 6825 const Code& code = Code::Handle(unoptimized_code()); |
| 6826 const PcDescriptors& descriptors = PcDescriptors::Handle( |
| 6827 code.pc_descriptors()); |
| 6828 |
| 6829 const intptr_t begin_pos = token_pos(); |
| 6830 const intptr_t end_pos = end_token_pos(); |
| 6831 |
| 6832 const Script& script = Script::Handle(this->script()); |
| 6833 const GrowableObjectArray& result = |
| 6834 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
| 6835 |
| 6836 PcDescriptors::Iterator iter(descriptors, |
| 6837 RawPcDescriptors::kIcCall | RawPcDescriptors::kUnoptStaticCall); |
| 6838 while (iter.MoveNext()) { |
| 6839 const ICData* ic_data = (*ic_data_array)[iter.DeoptId()]; |
| 6840 if (!ic_data->IsNull()) { |
| 6841 const intptr_t token_pos = iter.TokenPos(); |
| 6842 // Filter out descriptors that do not map to tokens in the source code. |
| 6843 if ((token_pos < begin_pos) || (token_pos > end_pos)) { |
| 6844 continue; |
| 6845 } |
| 6846 |
| 6847 intptr_t line = -1; |
| 6848 intptr_t column = -1; |
| 6849 script.GetTokenLocation(token_pos, &line, &column); |
| 6850 |
| 6851 result.Add(*ic_data); |
| 6852 result.Add(Smi::Handle(Smi::New(line))); |
| 6853 result.Add(Smi::Handle(Smi::New(column))); |
| 6854 } |
| 6855 } |
| 6856 |
| 6857 return result.raw(); |
| 6858 } |
| 6859 |
| 6860 |
| 6821 void ClosureData::set_context_scope(const ContextScope& value) const { | 6861 void ClosureData::set_context_scope(const ContextScope& value) const { |
| 6822 StorePointer(&raw_ptr()->context_scope_, value.raw()); | 6862 StorePointer(&raw_ptr()->context_scope_, value.raw()); |
| 6823 } | 6863 } |
| 6824 | 6864 |
| 6825 | 6865 |
| 6826 void ClosureData::set_implicit_static_closure(const Instance& closure) const { | 6866 void ClosureData::set_implicit_static_closure(const Instance& closure) const { |
| 6827 ASSERT(!closure.IsNull()); | 6867 ASSERT(!closure.IsNull()); |
| 6828 ASSERT(raw_ptr()->closure_ == Instance::null()); | 6868 ASSERT(raw_ptr()->closure_ == Instance::null()); |
| 6829 StorePointer(&raw_ptr()->closure_, closure.raw()); | 6869 StorePointer(&raw_ptr()->closure_, closure.raw()); |
| 6830 } | 6870 } |
| (...skipping 4995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11826 result.WriteSentinel(ic_data); | 11866 result.WriteSentinel(ic_data); |
| 11827 return result.raw(); | 11867 return result.raw(); |
| 11828 } | 11868 } |
| 11829 | 11869 |
| 11830 | 11870 |
| 11831 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const { | 11871 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 11832 Object::PrintJSONImpl(stream, ref); | 11872 Object::PrintJSONImpl(stream, ref); |
| 11833 } | 11873 } |
| 11834 | 11874 |
| 11835 | 11875 |
| 11876 void ICData::PrintToJSONArray(JSONArray* jsarray, |
| 11877 intptr_t line, |
| 11878 intptr_t column) const { |
| 11879 Isolate* isolate = Isolate::Current(); |
| 11880 Class& cls = Class::Handle(); |
| 11881 |
| 11882 JSONObject jsobj(jsarray); |
| 11883 jsobj.AddProperty("name", String::Handle(target_name()).ToCString()); |
| 11884 jsobj.AddProperty("line", line); |
| 11885 jsobj.AddProperty("column", column); |
| 11886 // TODO(rmacnak): Figure out how to stringify DeoptReasons(). |
| 11887 // jsobj.AddProperty("deoptReasons", ...); |
| 11888 |
| 11889 JSONArray cache_entries(&jsobj, "cacheEntries"); |
| 11890 for (intptr_t i = 0; i < NumberOfChecks(); i++) { |
| 11891 intptr_t cid = GetReceiverClassIdAt(i); |
| 11892 cls ^= isolate->class_table()->At(cid); |
| 11893 intptr_t count = GetCountAt(i); |
| 11894 JSONObject cache_entry(&cache_entries); |
| 11895 cache_entry.AddProperty("receiverClass", cls); |
| 11896 cache_entry.AddProperty("count", count); |
| 11897 } |
| 11898 } |
| 11899 |
| 11900 |
| 11836 static Token::Kind RecognizeArithmeticOp(const String& name) { | 11901 static Token::Kind RecognizeArithmeticOp(const String& name) { |
| 11837 ASSERT(name.IsSymbol()); | 11902 ASSERT(name.IsSymbol()); |
| 11838 if (name.raw() == Symbols::Plus().raw()) { | 11903 if (name.raw() == Symbols::Plus().raw()) { |
| 11839 return Token::kADD; | 11904 return Token::kADD; |
| 11840 } else if (name.raw() == Symbols::Minus().raw()) { | 11905 } else if (name.raw() == Symbols::Minus().raw()) { |
| 11841 return Token::kSUB; | 11906 return Token::kSUB; |
| 11842 } else if (name.raw() == Symbols::Star().raw()) { | 11907 } else if (name.raw() == Symbols::Star().raw()) { |
| 11843 return Token::kMUL; | 11908 return Token::kMUL; |
| 11844 } else if (name.raw() == Symbols::Slash().raw()) { | 11909 } else if (name.raw() == Symbols::Slash().raw()) { |
| 11845 return Token::kDIV; | 11910 return Token::kDIV; |
| (...skipping 8768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20614 return tag_label.ToCString(); | 20679 return tag_label.ToCString(); |
| 20615 } | 20680 } |
| 20616 | 20681 |
| 20617 | 20682 |
| 20618 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20683 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20619 Instance::PrintJSONImpl(stream, ref); | 20684 Instance::PrintJSONImpl(stream, ref); |
| 20620 } | 20685 } |
| 20621 | 20686 |
| 20622 | 20687 |
| 20623 } // namespace dart | 20688 } // namespace dart |
| OLD | NEW |