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

Side by Side Diff: vm/code_generator.cc

Issue 10828213: Don't hard-code getter prefix in code_generator.cc. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 4 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 | « no previous file | no next file » | 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/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/assembler_macros.h" 7 #include "vm/assembler_macros.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 // Arg1: ic-data. 982 // Arg1: ic-data.
983 // Returns: Closure object or NULL (instance function not found). 983 // Returns: Closure object or NULL (instance function not found).
984 // This is called by the megamorphic stub when it is unable to resolve an 984 // This is called by the megamorphic stub when it is unable to resolve an
985 // instance method. This is done just before the call to noSuchMethod. 985 // instance method. This is done just before the call to noSuchMethod.
986 DEFINE_RUNTIME_ENTRY(ResolveImplicitClosureFunction, 2) { 986 DEFINE_RUNTIME_ENTRY(ResolveImplicitClosureFunction, 2) {
987 ASSERT(arguments.Count() == 987 ASSERT(arguments.Count() ==
988 kResolveImplicitClosureFunctionRuntimeEntry.argument_count()); 988 kResolveImplicitClosureFunctionRuntimeEntry.argument_count());
989 const Instance& receiver = Instance::CheckedHandle(arguments.At(0)); 989 const Instance& receiver = Instance::CheckedHandle(arguments.At(0));
990 const ICData& ic_data = ICData::CheckedHandle(arguments.At(1)); 990 const ICData& ic_data = ICData::CheckedHandle(arguments.At(1));
991 const String& original_function_name = String::Handle(ic_data.target_name()); 991 const String& original_function_name = String::Handle(ic_data.target_name());
992 const String& getter_prefix = String::Handle(String::New("get:"));
993 Closure& closure = Closure::Handle(); 992 Closure& closure = Closure::Handle();
994 if (!original_function_name.StartsWith(getter_prefix)) { 993 if (!Field::IsGetterName(original_function_name)) {
995 // This is not a getter so can't be the case where we are trying to 994 // This is not a getter so can't be the case where we are trying to
996 // create an implicit closure of an instance function. 995 // create an implicit closure of an instance function.
997 arguments.SetReturn(closure); 996 arguments.SetReturn(closure);
998 return; 997 return;
999 } 998 }
1000 const Class& receiver_class = Class::Handle(receiver.clazz()); 999 const Class& receiver_class = Class::Handle(receiver.clazz());
1001 ASSERT(!receiver_class.IsNull()); 1000 ASSERT(!receiver_class.IsNull());
1002 String& func_name = String::Handle(); 1001 String& func_name = String::Handle();
1003 func_name = String::SubString(original_function_name, getter_prefix.Length()); 1002 func_name = Field::NameFromGetter(original_function_name);
1004 func_name = Symbols::New(func_name); 1003 func_name = Symbols::New(func_name);
1005 const Function& function = Function::Handle( 1004 const Function& function = Function::Handle(
1006 LookupDynamicFunction(isolate, receiver_class, func_name)); 1005 LookupDynamicFunction(isolate, receiver_class, func_name));
1007 if (function.IsNull()) { 1006 if (function.IsNull()) {
1008 // There is no function of the same name so can't be the case where 1007 // There is no function of the same name so can't be the case where
1009 // we are trying to create an implicit closure of an instance function. 1008 // we are trying to create an implicit closure of an instance function.
1010 arguments.SetReturn(closure); 1009 arguments.SetReturn(closure);
1011 return; 1010 return;
1012 } 1011 }
1013 Function& implicit_closure_function = 1012 Function& implicit_closure_function =
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 } 1618 }
1620 } 1619 }
1621 } 1620 }
1622 // The cache is null terminated, therefore the loop above should never 1621 // The cache is null terminated, therefore the loop above should never
1623 // terminate by itself. 1622 // terminate by itself.
1624 UNREACHABLE(); 1623 UNREACHABLE();
1625 return Code::null(); 1624 return Code::null();
1626 } 1625 }
1627 1626
1628 } // namespace dart 1627 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698