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 4725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4736 break; | 4736 break; |
4737 case RawFunction::kMethodExtractor: | 4737 case RawFunction::kMethodExtractor: |
4738 return "kMethodExtractor"; | 4738 return "kMethodExtractor"; |
4739 break; | 4739 break; |
4740 case RawFunction::kNoSuchMethodDispatcher: | 4740 case RawFunction::kNoSuchMethodDispatcher: |
4741 return "kNoSuchMethodDispatcher"; | 4741 return "kNoSuchMethodDispatcher"; |
4742 break; | 4742 break; |
4743 case RawFunction::kInvokeFieldDispatcher: | 4743 case RawFunction::kInvokeFieldDispatcher: |
4744 return "kInvokeFieldDispatcher"; | 4744 return "kInvokeFieldDispatcher"; |
4745 break; | 4745 break; |
| 4746 case RawFunction::kGetFieldClosure: |
| 4747 return "kGetFieldClosure"; |
| 4748 break; |
| 4749 case RawFunction::kSetFieldClosure: |
| 4750 return "kSetFieldClosure"; |
| 4751 break; |
4746 default: | 4752 default: |
4747 UNREACHABLE(); | 4753 UNREACHABLE(); |
4748 return NULL; | 4754 return NULL; |
4749 } | 4755 } |
4750 } | 4756 } |
4751 | 4757 |
4752 | 4758 |
4753 void Function::SetRedirectionType(const Type& type) const { | 4759 void Function::SetRedirectionType(const Type& type) const { |
4754 ASSERT(IsFactory()); | 4760 ASSERT(IsFactory()); |
4755 Object& obj = Object::Handle(raw_ptr()->data_); | 4761 Object& obj = Object::Handle(raw_ptr()->data_); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5028 if (kind() == RawFunction::kConstructor) { | 5034 if (kind() == RawFunction::kConstructor) { |
5029 if (is_static()) { | 5035 if (is_static()) { |
5030 ASSERT(IsFactory()); | 5036 ASSERT(IsFactory()); |
5031 return 1; // Type arguments. | 5037 return 1; // Type arguments. |
5032 } else { | 5038 } else { |
5033 ASSERT(IsConstructor()); | 5039 ASSERT(IsConstructor()); |
5034 return 2; // Instance, phase. | 5040 return 2; // Instance, phase. |
5035 } | 5041 } |
5036 } | 5042 } |
5037 if ((kind() == RawFunction::kClosureFunction) || | 5043 if ((kind() == RawFunction::kClosureFunction) || |
| 5044 (kind() == RawFunction::kGetFieldClosure) || |
| 5045 (kind() == RawFunction::kSetFieldClosure) || |
5038 (kind() == RawFunction::kSignatureFunction)) { | 5046 (kind() == RawFunction::kSignatureFunction)) { |
5039 return 1; // Closure object. | 5047 return 1; // Closure object. |
5040 } | 5048 } |
5041 if (!is_static()) { | 5049 if (!is_static()) { |
5042 // Closure functions defined inside instance (i.e. non-static) functions are | 5050 // Closure functions defined inside instance (i.e. non-static) functions are |
5043 // marked as non-static, but they do not have a receiver. | 5051 // marked as non-static, but they do not have a receiver. |
5044 // Closures are handled above. | 5052 // Closures are handled above. |
5045 ASSERT((kind() != RawFunction::kClosureFunction) && | 5053 ASSERT((kind() != RawFunction::kClosureFunction) && |
| 5054 (kind() != RawFunction::kGetFieldClosure) && |
| 5055 (kind() != RawFunction::kSetFieldClosure) && |
5046 (kind() != RawFunction::kSignatureFunction)); | 5056 (kind() != RawFunction::kSignatureFunction)); |
5047 return 1; // Receiver. | 5057 return 1; // Receiver. |
5048 } | 5058 } |
5049 return 0; // No implicit parameters. | 5059 return 0; // No implicit parameters. |
5050 } | 5060 } |
5051 | 5061 |
5052 | 5062 |
5053 bool Function::AreValidArgumentCounts(intptr_t num_arguments, | 5063 bool Function::AreValidArgumentCounts(intptr_t num_arguments, |
5054 intptr_t num_named_arguments, | 5064 intptr_t num_named_arguments, |
5055 String* error_message) const { | 5065 String* error_message) const { |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5498 result.set_token_pos(token_pos); | 5508 result.set_token_pos(token_pos); |
5499 result.set_end_token_pos(token_pos); | 5509 result.set_end_token_pos(token_pos); |
5500 result.set_num_fixed_parameters(0); | 5510 result.set_num_fixed_parameters(0); |
5501 result.set_num_optional_parameters(0); | 5511 result.set_num_optional_parameters(0); |
5502 result.set_usage_counter(0); | 5512 result.set_usage_counter(0); |
5503 result.set_deoptimization_counter(0); | 5513 result.set_deoptimization_counter(0); |
5504 result.set_optimized_instruction_count(0); | 5514 result.set_optimized_instruction_count(0); |
5505 result.set_optimized_call_site_count(0); | 5515 result.set_optimized_call_site_count(0); |
5506 result.set_is_optimizable(is_native ? false : true); | 5516 result.set_is_optimizable(is_native ? false : true); |
5507 result.set_is_inlinable(true); | 5517 result.set_is_inlinable(true); |
5508 if (kind == RawFunction::kClosureFunction) { | 5518 if ((kind == RawFunction::kClosureFunction) || |
| 5519 (kind == RawFunction::kGetFieldClosure) || |
| 5520 (kind == RawFunction::kSetFieldClosure) ) { |
5509 const ClosureData& data = ClosureData::Handle(ClosureData::New()); | 5521 const ClosureData& data = ClosureData::Handle(ClosureData::New()); |
5510 result.set_data(data); | 5522 result.set_data(data); |
5511 } | 5523 } |
5512 return result.raw(); | 5524 return result.raw(); |
5513 } | 5525 } |
5514 | 5526 |
5515 | 5527 |
5516 RawFunction* Function::Clone(const Class& new_owner) const { | 5528 RawFunction* Function::Clone(const Class& new_owner) const { |
5517 ASSERT(!IsConstructor()); | 5529 ASSERT(!IsConstructor()); |
5518 Function& clone = Function::Handle(); | 5530 Function& clone = Function::Handle(); |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5981 break; | 5993 break; |
5982 case RawFunction::kMethodExtractor: | 5994 case RawFunction::kMethodExtractor: |
5983 kind_str = " method-extractor"; | 5995 kind_str = " method-extractor"; |
5984 break; | 5996 break; |
5985 case RawFunction::kNoSuchMethodDispatcher: | 5997 case RawFunction::kNoSuchMethodDispatcher: |
5986 kind_str = " no-such-method-dispatcher"; | 5998 kind_str = " no-such-method-dispatcher"; |
5987 break; | 5999 break; |
5988 case RawFunction::kInvokeFieldDispatcher: | 6000 case RawFunction::kInvokeFieldDispatcher: |
5989 kind_str = "invoke-field-dispatcher"; | 6001 kind_str = "invoke-field-dispatcher"; |
5990 break; | 6002 break; |
| 6003 case RawFunction::kGetFieldClosure: |
| 6004 kind_str = "get-field-closure"; |
| 6005 break; |
| 6006 case RawFunction::kSetFieldClosure: |
| 6007 kind_str = "set-field-closure"; |
| 6008 break; |
5991 default: | 6009 default: |
5992 UNREACHABLE(); | 6010 UNREACHABLE(); |
5993 } | 6011 } |
5994 const char* kFormat = "Function '%s':%s%s%s%s."; | 6012 const char* kFormat = "Function '%s':%s%s%s%s."; |
5995 const char* function_name = String::Handle(name()).ToCString(); | 6013 const char* function_name = String::Handle(name()).ToCString(); |
5996 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, | 6014 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, |
5997 static_str, abstract_str, kind_str, const_str) + 1; | 6015 static_str, abstract_str, kind_str, const_str) + 1; |
5998 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 6016 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
5999 OS::SNPrint(chars, len, kFormat, function_name, | 6017 OS::SNPrint(chars, len, kFormat, function_name, |
6000 static_str, abstract_str, kind_str, const_str); | 6018 static_str, abstract_str, kind_str, const_str); |
(...skipping 11219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17220 return "_MirrorReference"; | 17238 return "_MirrorReference"; |
17221 } | 17239 } |
17222 | 17240 |
17223 | 17241 |
17224 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 17242 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
17225 Instance::PrintToJSONStream(stream, ref); | 17243 Instance::PrintToJSONStream(stream, ref); |
17226 } | 17244 } |
17227 | 17245 |
17228 | 17246 |
17229 } // namespace dart | 17247 } // namespace dart |
OLD | NEW |