| 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 4206 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4217     const Object& obj = Object::Handle(raw_ptr()->data_); | 4217     const Object& obj = Object::Handle(raw_ptr()->data_); | 
| 4218     ASSERT(!obj.IsNull()); | 4218     ASSERT(!obj.IsNull()); | 
| 4219     ClosureData::Cast(obj).set_parent_function(value); | 4219     ClosureData::Cast(obj).set_parent_function(value); | 
| 4220     return; | 4220     return; | 
| 4221   } | 4221   } | 
| 4222   UNREACHABLE(); | 4222   UNREACHABLE(); | 
| 4223 } | 4223 } | 
| 4224 | 4224 | 
| 4225 | 4225 | 
| 4226 RawFunction* Function::implicit_closure_function() const { | 4226 RawFunction* Function::implicit_closure_function() const { | 
| 4227   if (IsClosureFunction() || IsSignatureFunction()) { | 4227   if (IsClosureFunction() || | 
|  | 4228       IsSignatureFunction() || | 
|  | 4229       IsStaticInitializerFunction()) { | 
| 4228     return Function::null(); | 4230     return Function::null(); | 
| 4229   } | 4231   } | 
| 4230   const Object& obj = Object::Handle(raw_ptr()->data_); | 4232   const Object& obj = Object::Handle(raw_ptr()->data_); | 
| 4231   ASSERT(obj.IsNull() || obj.IsFunction()); | 4233   ASSERT(obj.IsNull() || obj.IsFunction()); | 
| 4232   return (obj.IsNull()) ? Function::null() : Function::Cast(obj).raw(); | 4234   return (obj.IsNull()) ? Function::null() : Function::Cast(obj).raw(); | 
| 4233 } | 4235 } | 
| 4234 | 4236 | 
| 4235 | 4237 | 
| 4236 void Function::set_implicit_closure_function(const Function& value) const { | 4238 void Function::set_implicit_closure_function(const Function& value) const { | 
| 4237   ASSERT(!IsClosureFunction() && !IsSignatureFunction()); | 4239   ASSERT(!IsClosureFunction() && !IsSignatureFunction()); | 
| (...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5420                 ToFullyQualifiedCString(), | 5422                 ToFullyQualifiedCString(), | 
| 5421                 fp, | 5423                 fp, | 
| 5422                 SourceFingerprint()); | 5424                 SourceFingerprint()); | 
| 5423       return false; | 5425       return false; | 
| 5424     } | 5426     } | 
| 5425   } | 5427   } | 
| 5426   return true; | 5428   return true; | 
| 5427 } | 5429 } | 
| 5428 | 5430 | 
| 5429 | 5431 | 
|  | 5432 RawFunction* Function::NewStaticInitializer(const String& field_name, | 
|  | 5433                                             const AbstractType& result_type, | 
|  | 5434                                             const Class& cls, | 
|  | 5435                                             intptr_t initializer_pos) { | 
|  | 5436   const String& init_name = | 
|  | 5437       String::Handle(Symbols::New(String::Handle( | 
|  | 5438           String::Concat(Symbols::InitPrefix(), field_name)))); | 
|  | 5439   const Function& init_function = Function::ZoneHandle( | 
|  | 5440       Function::New(init_name, | 
|  | 5441                     RawFunction::kStaticInitializer, | 
|  | 5442                     true,  // static | 
|  | 5443                     false,  // !const | 
|  | 5444                     false,  // !abstract | 
|  | 5445                     false,  // !external | 
|  | 5446                     cls, | 
|  | 5447                     initializer_pos)); | 
|  | 5448   init_function.set_result_type(result_type); | 
|  | 5449   // Static initializer functions are generated by the VM and are therfore | 
|  | 5450   // hidden from the user. Since they are only executed once, we avoid | 
|  | 5451   // optimizing and inlining them. After the field is initialized, the | 
|  | 5452   // optimizing compiler can eliminate the call to the static initializer | 
|  | 5453   // via constant folding. | 
|  | 5454   init_function.set_is_visible(false); | 
|  | 5455   init_function.set_is_optimizable(false); | 
|  | 5456   init_function.set_is_inlinable(false); | 
|  | 5457   return init_function.raw(); | 
|  | 5458 } | 
|  | 5459 | 
|  | 5460 | 
| 5430 const char* Function::ToCString() const { | 5461 const char* Function::ToCString() const { | 
| 5431   const char* static_str = is_static() ? " static" : ""; | 5462   const char* static_str = is_static() ? " static" : ""; | 
| 5432   const char* abstract_str = is_abstract() ? " abstract" : ""; | 5463   const char* abstract_str = is_abstract() ? " abstract" : ""; | 
| 5433   const char* kind_str = NULL; | 5464   const char* kind_str = NULL; | 
| 5434   const char* const_str = is_const() ? " const" : ""; | 5465   const char* const_str = is_const() ? " const" : ""; | 
| 5435   switch (kind()) { | 5466   switch (kind()) { | 
| 5436     case RawFunction::kRegularFunction: | 5467     case RawFunction::kRegularFunction: | 
| 5437     case RawFunction::kClosureFunction: | 5468     case RawFunction::kClosureFunction: | 
| 5438     case RawFunction::kGetterFunction: | 5469     case RawFunction::kGetterFunction: | 
| 5439     case RawFunction::kSetterFunction: | 5470     case RawFunction::kSetterFunction: | 
| 5440       kind_str = ""; | 5471       kind_str = ""; | 
| 5441       break; | 5472       break; | 
| 5442     case RawFunction::kSignatureFunction: | 5473     case RawFunction::kSignatureFunction: | 
| 5443       kind_str = " signature"; | 5474       kind_str = " signature"; | 
| 5444       break; | 5475       break; | 
| 5445     case RawFunction::kConstructor: | 5476     case RawFunction::kConstructor: | 
| 5446       kind_str = is_static() ? " factory" : " constructor"; | 5477       kind_str = is_static() ? " factory" : " constructor"; | 
| 5447       break; | 5478       break; | 
| 5448     case RawFunction::kImplicitGetter: | 5479     case RawFunction::kImplicitGetter: | 
| 5449       kind_str = " getter"; | 5480       kind_str = " getter"; | 
| 5450       break; | 5481       break; | 
| 5451     case RawFunction::kImplicitSetter: | 5482     case RawFunction::kImplicitSetter: | 
| 5452       kind_str = " setter"; | 5483       kind_str = " setter"; | 
| 5453       break; | 5484       break; | 
|  | 5485     case RawFunction::kStaticInitializer: | 
|  | 5486       kind_str = " static-initializer"; | 
|  | 5487       break; | 
| 5454     case RawFunction::kImplicitStaticFinalGetter: | 5488     case RawFunction::kImplicitStaticFinalGetter: | 
| 5455       kind_str = " static-final-getter"; | 5489       kind_str = " static-final-getter"; | 
| 5456       break; | 5490       break; | 
| 5457     case RawFunction::kMethodExtractor: | 5491     case RawFunction::kMethodExtractor: | 
| 5458       kind_str = " method-extractor"; | 5492       kind_str = " method-extractor"; | 
| 5459       break; | 5493       break; | 
| 5460     case RawFunction::kNoSuchMethodDispatcher: | 5494     case RawFunction::kNoSuchMethodDispatcher: | 
| 5461       kind_str = " no-such-method-dispatcher"; | 5495       kind_str = " no-such-method-dispatcher"; | 
| 5462       break; | 5496       break; | 
| 5463     case RawFunction::kInvokeFieldDispatcher: | 5497     case RawFunction::kInvokeFieldDispatcher: | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5515         break; | 5549         break; | 
| 5516       case RawFunction::kNoSuchMethodDispatcher: | 5550       case RawFunction::kNoSuchMethodDispatcher: | 
| 5517         kind_string = "no such method"; | 5551         kind_string = "no such method"; | 
| 5518         break; | 5552         break; | 
| 5519       case RawFunction::kClosureFunction: | 5553       case RawFunction::kClosureFunction: | 
| 5520         kind_string = "closure"; | 5554         kind_string = "closure"; | 
| 5521         break; | 5555         break; | 
| 5522       case RawFunction::kConstructor: | 5556       case RawFunction::kConstructor: | 
| 5523         kind_string = "constructor"; | 5557         kind_string = "constructor"; | 
| 5524         break; | 5558         break; | 
|  | 5559       case RawFunction::kStaticInitializer: | 
|  | 5560         kind_string = "static initializer"; | 
|  | 5561         break; | 
| 5525       case RawFunction::kImplicitStaticFinalGetter: | 5562       case RawFunction::kImplicitStaticFinalGetter: | 
| 5526         kind_string = "static final getter"; | 5563         kind_string = "static final getter"; | 
| 5527         break; | 5564         break; | 
| 5528       default: | 5565       default: | 
| 5529         UNREACHABLE(); | 5566         UNREACHABLE(); | 
| 5530   } | 5567   } | 
| 5531   jsobj.AddProperty("kind", kind_string); | 5568   jsobj.AddProperty("kind", kind_string); | 
| 5532   jsobj.AddProperty("unoptimized_code", Object::Handle(unoptimized_code())); | 5569   jsobj.AddProperty("unoptimized_code", Object::Handle(unoptimized_code())); | 
| 5533   jsobj.AddProperty("usage_counter", usage_counter()); | 5570   jsobj.AddProperty("usage_counter", usage_counter()); | 
| 5534   jsobj.AddProperty("optimized_call_site_count", optimized_call_site_count()); | 5571   jsobj.AddProperty("optimized_call_site_count", optimized_call_site_count()); | 
| (...skipping 10062 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 15597   return "_MirrorReference"; | 15634   return "_MirrorReference"; | 
| 15598 } | 15635 } | 
| 15599 | 15636 | 
| 15600 | 15637 | 
| 15601 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15638 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 
| 15602   JSONObject jsobj(stream); | 15639   JSONObject jsobj(stream); | 
| 15603 } | 15640 } | 
| 15604 | 15641 | 
| 15605 | 15642 | 
| 15606 }  // namespace dart | 15643 }  // namespace dart | 
| OLD | NEW | 
|---|