| 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 2236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2247 const Array& args_desc, | 2247 const Array& args_desc, |
| 2248 RawFunction::Kind kind) const { | 2248 RawFunction::Kind kind) const { |
| 2249 enum { | 2249 enum { |
| 2250 kNameIndex = 0, | 2250 kNameIndex = 0, |
| 2251 kArgsDescIndex, | 2251 kArgsDescIndex, |
| 2252 kFunctionIndex, | 2252 kFunctionIndex, |
| 2253 kEntrySize | 2253 kEntrySize |
| 2254 }; | 2254 }; |
| 2255 | 2255 |
| 2256 ASSERT(kind == RawFunction::kNoSuchMethodDispatcher || | 2256 ASSERT(kind == RawFunction::kNoSuchMethodDispatcher || |
| 2257 kind == RawFunction::kInvokeFieldDispatcher || | 2257 kind == RawFunction::kInvokeFieldDispatcher); |
| 2258 kind == RawFunction::kInvokeClosureDispatcher); | |
| 2259 Function& dispatcher = Function::Handle(); | 2258 Function& dispatcher = Function::Handle(); |
| 2260 Array& cache = Array::Handle(invocation_dispatcher_cache()); | 2259 Array& cache = Array::Handle(invocation_dispatcher_cache()); |
| 2261 ASSERT(!cache.IsNull()); | 2260 ASSERT(!cache.IsNull()); |
| 2262 String& name = String::Handle(); | 2261 String& name = String::Handle(); |
| 2263 Array& desc = Array::Handle(); | 2262 Array& desc = Array::Handle(); |
| 2264 intptr_t i = 0; | 2263 intptr_t i = 0; |
| 2265 for (; i < cache.Length(); i += kEntrySize) { | 2264 for (; i < cache.Length(); i += kEntrySize) { |
| 2266 name ^= cache.At(i + kNameIndex); | 2265 name ^= cache.At(i + kNameIndex); |
| 2267 if (name.IsNull()) break; // Reached last entry. | 2266 if (name.IsNull()) break; // Reached last entry. |
| 2268 if (!name.Equals(target_name)) continue; | 2267 if (!name.Equals(target_name)) continue; |
| (...skipping 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4650 | 4649 |
| 4651 void Function::set_extracted_method_closure(const Function& value) const { | 4650 void Function::set_extracted_method_closure(const Function& value) const { |
| 4652 ASSERT(kind() == RawFunction::kMethodExtractor); | 4651 ASSERT(kind() == RawFunction::kMethodExtractor); |
| 4653 ASSERT(raw_ptr()->data_ == Object::null()); | 4652 ASSERT(raw_ptr()->data_ == Object::null()); |
| 4654 set_data(value); | 4653 set_data(value); |
| 4655 } | 4654 } |
| 4656 | 4655 |
| 4657 | 4656 |
| 4658 RawArray* Function::saved_args_desc() const { | 4657 RawArray* Function::saved_args_desc() const { |
| 4659 ASSERT(kind() == RawFunction::kNoSuchMethodDispatcher || | 4658 ASSERT(kind() == RawFunction::kNoSuchMethodDispatcher || |
| 4660 kind() == RawFunction::kInvokeFieldDispatcher || | 4659 kind() == RawFunction::kInvokeFieldDispatcher); |
| 4661 kind() == RawFunction::kInvokeClosureDispatcher); | |
| 4662 const Object& obj = Object::Handle(raw_ptr()->data_); | 4660 const Object& obj = Object::Handle(raw_ptr()->data_); |
| 4663 ASSERT(obj.IsArray()); | 4661 ASSERT(obj.IsArray()); |
| 4664 return Array::Cast(obj).raw(); | 4662 return Array::Cast(obj).raw(); |
| 4665 } | 4663 } |
| 4666 | 4664 |
| 4667 | 4665 |
| 4668 void Function::set_saved_args_desc(const Array& value) const { | 4666 void Function::set_saved_args_desc(const Array& value) const { |
| 4669 ASSERT(kind() == RawFunction::kNoSuchMethodDispatcher || | 4667 ASSERT(kind() == RawFunction::kNoSuchMethodDispatcher || |
| 4670 kind() == RawFunction::kInvokeFieldDispatcher || | 4668 kind() == RawFunction::kInvokeFieldDispatcher); |
| 4671 kind() == RawFunction::kInvokeClosureDispatcher); | |
| 4672 ASSERT(raw_ptr()->data_ == Object::null()); | 4669 ASSERT(raw_ptr()->data_ == Object::null()); |
| 4673 set_data(value); | 4670 set_data(value); |
| 4674 } | 4671 } |
| 4675 | 4672 |
| 4676 | 4673 |
| 4677 RawField* Function::saved_static_field() const { | 4674 RawField* Function::saved_static_field() const { |
| 4678 ASSERT(kind() == RawFunction::kStaticInitializer); | 4675 ASSERT(kind() == RawFunction::kStaticInitializer); |
| 4679 const Object& obj = Object::Handle(raw_ptr()->data_); | 4676 const Object& obj = Object::Handle(raw_ptr()->data_); |
| 4680 ASSERT(obj.IsField()); | 4677 ASSERT(obj.IsField()); |
| 4681 return Field::Cast(obj).raw(); | 4678 return Field::Cast(obj).raw(); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4810 break; | 4807 break; |
| 4811 case RawFunction::kMethodExtractor: | 4808 case RawFunction::kMethodExtractor: |
| 4812 return "kMethodExtractor"; | 4809 return "kMethodExtractor"; |
| 4813 break; | 4810 break; |
| 4814 case RawFunction::kNoSuchMethodDispatcher: | 4811 case RawFunction::kNoSuchMethodDispatcher: |
| 4815 return "kNoSuchMethodDispatcher"; | 4812 return "kNoSuchMethodDispatcher"; |
| 4816 break; | 4813 break; |
| 4817 case RawFunction::kInvokeFieldDispatcher: | 4814 case RawFunction::kInvokeFieldDispatcher: |
| 4818 return "kInvokeFieldDispatcher"; | 4815 return "kInvokeFieldDispatcher"; |
| 4819 break; | 4816 break; |
| 4820 case RawFunction::kInvokeClosureDispatcher: | |
| 4821 return "kInvokeClosureDispatcher"; | |
| 4822 break; | |
| 4823 default: | 4817 default: |
| 4824 UNREACHABLE(); | 4818 UNREACHABLE(); |
| 4825 return NULL; | 4819 return NULL; |
| 4826 } | 4820 } |
| 4827 } | 4821 } |
| 4828 | 4822 |
| 4829 | 4823 |
| 4830 void Function::SetRedirectionType(const Type& type) const { | 4824 void Function::SetRedirectionType(const Type& type) const { |
| 4831 ASSERT(IsFactory()); | 4825 ASSERT(IsFactory()); |
| 4832 Object& obj = Object::Handle(raw_ptr()->data_); | 4826 Object& obj = Object::Handle(raw_ptr()->data_); |
| (...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6065 break; | 6059 break; |
| 6066 case RawFunction::kMethodExtractor: | 6060 case RawFunction::kMethodExtractor: |
| 6067 kind_str = " method-extractor"; | 6061 kind_str = " method-extractor"; |
| 6068 break; | 6062 break; |
| 6069 case RawFunction::kNoSuchMethodDispatcher: | 6063 case RawFunction::kNoSuchMethodDispatcher: |
| 6070 kind_str = " no-such-method-dispatcher"; | 6064 kind_str = " no-such-method-dispatcher"; |
| 6071 break; | 6065 break; |
| 6072 case RawFunction::kInvokeFieldDispatcher: | 6066 case RawFunction::kInvokeFieldDispatcher: |
| 6073 kind_str = "invoke-field-dispatcher"; | 6067 kind_str = "invoke-field-dispatcher"; |
| 6074 break; | 6068 break; |
| 6075 case RawFunction::kInvokeClosureDispatcher: | |
| 6076 kind_str = "invoke-closure-dispatcher"; | |
| 6077 break; | |
| 6078 default: | 6069 default: |
| 6079 UNREACHABLE(); | 6070 UNREACHABLE(); |
| 6080 } | 6071 } |
| 6081 const char* kFormat = "Function '%s':%s%s%s%s."; | 6072 const char* kFormat = "Function '%s':%s%s%s%s."; |
| 6082 const char* function_name = String::Handle(name()).ToCString(); | 6073 const char* function_name = String::Handle(name()).ToCString(); |
| 6083 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, | 6074 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, |
| 6084 static_str, abstract_str, kind_str, const_str) + 1; | 6075 static_str, abstract_str, kind_str, const_str) + 1; |
| 6085 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 6076 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 6086 OS::SNPrint(chars, len, kFormat, function_name, | 6077 OS::SNPrint(chars, len, kFormat, function_name, |
| 6087 static_str, abstract_str, kind_str, const_str); | 6078 static_str, abstract_str, kind_str, const_str); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 6099 err ^= cls.EnsureIsFinalized(Isolate::Current()); | 6090 err ^= cls.EnsureIsFinalized(Isolate::Current()); |
| 6100 ASSERT(err.IsNull()); | 6091 ASSERT(err.IsNull()); |
| 6101 intptr_t id = -1; | 6092 intptr_t id = -1; |
| 6102 const char* selector = NULL; | 6093 const char* selector = NULL; |
| 6103 if (IsNonImplicitClosureFunction()) { | 6094 if (IsNonImplicitClosureFunction()) { |
| 6104 id = cls.FindClosureIndex(*this); | 6095 id = cls.FindClosureIndex(*this); |
| 6105 selector = "closures"; | 6096 selector = "closures"; |
| 6106 } else if (IsImplicitClosureFunction()) { | 6097 } else if (IsImplicitClosureFunction()) { |
| 6107 id = cls.FindImplicitClosureFunctionIndex(*this); | 6098 id = cls.FindImplicitClosureFunctionIndex(*this); |
| 6108 selector = "implicit_closures"; | 6099 selector = "implicit_closures"; |
| 6109 } else if (IsNoSuchMethodDispatcher() || | 6100 } else if (IsNoSuchMethodDispatcher() || IsInvokeFieldDispatcher()) { |
| 6110 IsInvokeFieldDispatcher() || | |
| 6111 IsInvokeClosureDispatcher()) { | |
| 6112 id = cls.FindInvocationDispatcherFunctionIndex(*this); | 6101 id = cls.FindInvocationDispatcherFunctionIndex(*this); |
| 6113 selector = "dispatchers"; | 6102 selector = "dispatchers"; |
| 6114 } else { | 6103 } else { |
| 6115 id = cls.FindFunctionIndex(*this); | 6104 id = cls.FindFunctionIndex(*this); |
| 6116 selector = "functions"; | 6105 selector = "functions"; |
| 6117 } | 6106 } |
| 6118 ASSERT(id >= 0); | 6107 ASSERT(id >= 0); |
| 6119 intptr_t cid = cls.id(); | 6108 intptr_t cid = cls.id(); |
| 6120 JSONObject jsobj(stream); | 6109 JSONObject jsobj(stream); |
| 6121 jsobj.AddProperty("type", JSONType(ref)); | 6110 jsobj.AddProperty("type", JSONType(ref)); |
| (...skipping 11533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17655 return "_MirrorReference"; | 17644 return "_MirrorReference"; |
| 17656 } | 17645 } |
| 17657 | 17646 |
| 17658 | 17647 |
| 17659 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 17648 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 17660 Instance::PrintToJSONStream(stream, ref); | 17649 Instance::PrintToJSONStream(stream, ref); |
| 17661 } | 17650 } |
| 17662 | 17651 |
| 17663 | 17652 |
| 17664 } // namespace dart | 17653 } // namespace dart |
| OLD | NEW |