Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: runtime/vm/object.cc

Issue 188703004: Fix invocation of closures via .call in the VM (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
2258 Function& dispatcher = Function::Handle(); 2259 Function& dispatcher = Function::Handle();
2259 Array& cache = Array::Handle(invocation_dispatcher_cache()); 2260 Array& cache = Array::Handle(invocation_dispatcher_cache());
2260 ASSERT(!cache.IsNull()); 2261 ASSERT(!cache.IsNull());
2261 String& name = String::Handle(); 2262 String& name = String::Handle();
2262 Array& desc = Array::Handle(); 2263 Array& desc = Array::Handle();
2263 intptr_t i = 0; 2264 intptr_t i = 0;
2264 for (; i < cache.Length(); i += kEntrySize) { 2265 for (; i < cache.Length(); i += kEntrySize) {
2265 name ^= cache.At(i + kNameIndex); 2266 name ^= cache.At(i + kNameIndex);
2266 if (name.IsNull()) break; // Reached last entry. 2267 if (name.IsNull()) break; // Reached last entry.
2267 if (!name.Equals(target_name)) continue; 2268 if (!name.Equals(target_name)) continue;
(...skipping 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after
4649 4650
4650 void Function::set_extracted_method_closure(const Function& value) const { 4651 void Function::set_extracted_method_closure(const Function& value) const {
4651 ASSERT(kind() == RawFunction::kMethodExtractor); 4652 ASSERT(kind() == RawFunction::kMethodExtractor);
4652 ASSERT(raw_ptr()->data_ == Object::null()); 4653 ASSERT(raw_ptr()->data_ == Object::null());
4653 set_data(value); 4654 set_data(value);
4654 } 4655 }
4655 4656
4656 4657
4657 RawArray* Function::saved_args_desc() const { 4658 RawArray* Function::saved_args_desc() const {
4658 ASSERT(kind() == RawFunction::kNoSuchMethodDispatcher || 4659 ASSERT(kind() == RawFunction::kNoSuchMethodDispatcher ||
4659 kind() == RawFunction::kInvokeFieldDispatcher); 4660 kind() == RawFunction::kInvokeFieldDispatcher ||
4661 kind() == RawFunction::kInvokeClosureDispatcher);
4660 const Object& obj = Object::Handle(raw_ptr()->data_); 4662 const Object& obj = Object::Handle(raw_ptr()->data_);
4661 ASSERT(obj.IsArray()); 4663 ASSERT(obj.IsArray());
4662 return Array::Cast(obj).raw(); 4664 return Array::Cast(obj).raw();
4663 } 4665 }
4664 4666
4665 4667
4666 void Function::set_saved_args_desc(const Array& value) const { 4668 void Function::set_saved_args_desc(const Array& value) const {
4667 ASSERT(kind() == RawFunction::kNoSuchMethodDispatcher || 4669 ASSERT(kind() == RawFunction::kNoSuchMethodDispatcher ||
4668 kind() == RawFunction::kInvokeFieldDispatcher); 4670 kind() == RawFunction::kInvokeFieldDispatcher ||
4671 kind() == RawFunction::kInvokeClosureDispatcher);
4669 ASSERT(raw_ptr()->data_ == Object::null()); 4672 ASSERT(raw_ptr()->data_ == Object::null());
4670 set_data(value); 4673 set_data(value);
4671 } 4674 }
4672 4675
4673 4676
4674 RawField* Function::saved_static_field() const { 4677 RawField* Function::saved_static_field() const {
4675 ASSERT(kind() == RawFunction::kStaticInitializer); 4678 ASSERT(kind() == RawFunction::kStaticInitializer);
4676 const Object& obj = Object::Handle(raw_ptr()->data_); 4679 const Object& obj = Object::Handle(raw_ptr()->data_);
4677 ASSERT(obj.IsField()); 4680 ASSERT(obj.IsField());
4678 return Field::Cast(obj).raw(); 4681 return Field::Cast(obj).raw();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
4807 break; 4810 break;
4808 case RawFunction::kMethodExtractor: 4811 case RawFunction::kMethodExtractor:
4809 return "kMethodExtractor"; 4812 return "kMethodExtractor";
4810 break; 4813 break;
4811 case RawFunction::kNoSuchMethodDispatcher: 4814 case RawFunction::kNoSuchMethodDispatcher:
4812 return "kNoSuchMethodDispatcher"; 4815 return "kNoSuchMethodDispatcher";
4813 break; 4816 break;
4814 case RawFunction::kInvokeFieldDispatcher: 4817 case RawFunction::kInvokeFieldDispatcher:
4815 return "kInvokeFieldDispatcher"; 4818 return "kInvokeFieldDispatcher";
4816 break; 4819 break;
4820 case RawFunction::kInvokeClosureDispatcher:
4821 return "kInvokeClosureDispatcher";
4822 break;
4817 default: 4823 default:
4818 UNREACHABLE(); 4824 UNREACHABLE();
4819 return NULL; 4825 return NULL;
4820 } 4826 }
4821 } 4827 }
4822 4828
4823 4829
4824 void Function::SetRedirectionType(const Type& type) const { 4830 void Function::SetRedirectionType(const Type& type) const {
4825 ASSERT(IsFactory()); 4831 ASSERT(IsFactory());
4826 Object& obj = Object::Handle(raw_ptr()->data_); 4832 Object& obj = Object::Handle(raw_ptr()->data_);
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
6059 break; 6065 break;
6060 case RawFunction::kMethodExtractor: 6066 case RawFunction::kMethodExtractor:
6061 kind_str = " method-extractor"; 6067 kind_str = " method-extractor";
6062 break; 6068 break;
6063 case RawFunction::kNoSuchMethodDispatcher: 6069 case RawFunction::kNoSuchMethodDispatcher:
6064 kind_str = " no-such-method-dispatcher"; 6070 kind_str = " no-such-method-dispatcher";
6065 break; 6071 break;
6066 case RawFunction::kInvokeFieldDispatcher: 6072 case RawFunction::kInvokeFieldDispatcher:
6067 kind_str = "invoke-field-dispatcher"; 6073 kind_str = "invoke-field-dispatcher";
6068 break; 6074 break;
6075 case RawFunction::kInvokeClosureDispatcher:
6076 kind_str = "invoke-closure-dispatcher";
6077 break;
6069 default: 6078 default:
6070 UNREACHABLE(); 6079 UNREACHABLE();
6071 } 6080 }
6072 const char* kFormat = "Function '%s':%s%s%s%s."; 6081 const char* kFormat = "Function '%s':%s%s%s%s.";
6073 const char* function_name = String::Handle(name()).ToCString(); 6082 const char* function_name = String::Handle(name()).ToCString();
6074 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, 6083 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name,
6075 static_str, abstract_str, kind_str, const_str) + 1; 6084 static_str, abstract_str, kind_str, const_str) + 1;
6076 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 6085 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
6077 OS::SNPrint(chars, len, kFormat, function_name, 6086 OS::SNPrint(chars, len, kFormat, function_name,
6078 static_str, abstract_str, kind_str, const_str); 6087 static_str, abstract_str, kind_str, const_str);
(...skipping 11 matching lines...) Expand all
6090 err ^= cls.EnsureIsFinalized(Isolate::Current()); 6099 err ^= cls.EnsureIsFinalized(Isolate::Current());
6091 ASSERT(err.IsNull()); 6100 ASSERT(err.IsNull());
6092 intptr_t id = -1; 6101 intptr_t id = -1;
6093 const char* selector = NULL; 6102 const char* selector = NULL;
6094 if (IsNonImplicitClosureFunction()) { 6103 if (IsNonImplicitClosureFunction()) {
6095 id = cls.FindClosureIndex(*this); 6104 id = cls.FindClosureIndex(*this);
6096 selector = "closures"; 6105 selector = "closures";
6097 } else if (IsImplicitClosureFunction()) { 6106 } else if (IsImplicitClosureFunction()) {
6098 id = cls.FindImplicitClosureFunctionIndex(*this); 6107 id = cls.FindImplicitClosureFunctionIndex(*this);
6099 selector = "implicit_closures"; 6108 selector = "implicit_closures";
6100 } else if (IsNoSuchMethodDispatcher() || IsInvokeFieldDispatcher()) { 6109 } else if (IsNoSuchMethodDispatcher() ||
6110 IsInvokeFieldDispatcher() ||
6111 IsInvokeClosureDispatcher()) {
6101 id = cls.FindInvocationDispatcherFunctionIndex(*this); 6112 id = cls.FindInvocationDispatcherFunctionIndex(*this);
6102 selector = "dispatchers"; 6113 selector = "dispatchers";
6103 } else { 6114 } else {
6104 id = cls.FindFunctionIndex(*this); 6115 id = cls.FindFunctionIndex(*this);
6105 selector = "functions"; 6116 selector = "functions";
6106 } 6117 }
6107 ASSERT(id >= 0); 6118 ASSERT(id >= 0);
6108 intptr_t cid = cls.id(); 6119 intptr_t cid = cls.id();
6109 JSONObject jsobj(stream); 6120 JSONObject jsobj(stream);
6110 jsobj.AddProperty("type", JSONType(ref)); 6121 jsobj.AddProperty("type", JSONType(ref));
(...skipping 11485 matching lines...) Expand 10 before | Expand all | Expand 10 after
17596 return "_MirrorReference"; 17607 return "_MirrorReference";
17597 } 17608 }
17598 17609
17599 17610
17600 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 17611 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
17601 Instance::PrintToJSONStream(stream, ref); 17612 Instance::PrintToJSONStream(stream, ref);
17602 } 17613 }
17603 17614
17604 17615
17605 } // namespace dart 17616 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698