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

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

Issue 12315087: Hook up simulator (if needed) when calling Dart code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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/code_descriptors_test.cc ('k') | runtime/vm/code_generator_test.cc » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 original_function_name, 1102 original_function_name,
1103 orig_arguments, 1103 orig_arguments,
1104 orig_arguments_desc)); 1104 orig_arguments_desc));
1105 CheckResultError(result); 1105 CheckResultError(result);
1106 arguments.SetReturn(result); 1106 arguments.SetReturn(result);
1107 } 1107 }
1108 1108
1109 1109
1110 // A non-closure object was invoked as a closure, so call the "call" method 1110 // A non-closure object was invoked as a closure, so call the "call" method
1111 // on it. 1111 // on it.
1112 // Arg0: non-closure object. 1112 // Arg0: arguments descriptor.
1113 // Arg1: arguments descriptor. 1113 // Arg1: arguments array, including non-closure object.
1114 // Arg2: arguments array, including non-closure object. 1114 DEFINE_RUNTIME_ENTRY(InvokeNonClosure, 2) {
1115 DEFINE_RUNTIME_ENTRY(InvokeNonClosure, 3) {
1116 ASSERT(arguments.ArgCount() == 1115 ASSERT(arguments.ArgCount() ==
1117 kInvokeNonClosureRuntimeEntry.argument_count()); 1116 kInvokeNonClosureRuntimeEntry.argument_count());
1118 const Instance& instance = Instance::CheckedHandle(arguments.ArgAt(0)); 1117 const Array& args_descriptor = Array::CheckedHandle(arguments.ArgAt(0));
1119 const Array& args_descriptor = Array::CheckedHandle(arguments.ArgAt(1)); 1118 const Array& function_args = Array::CheckedHandle(arguments.ArgAt(1));
1120 const Array& function_args = Array::CheckedHandle(arguments.ArgAt(2));
1121 1119
1122 const Object& result = Object::Handle( 1120 const Object& result = Object::Handle(
1123 DartEntry::InvokeClosure(instance, 1121 DartEntry::InvokeClosure(function_args, args_descriptor));
1124 function_args,
1125 args_descriptor));
1126 CheckResultError(result); 1122 CheckResultError(result);
1127 arguments.SetReturn(result); 1123 arguments.SetReturn(result);
1128 } 1124 }
1129 1125
1130 1126
1131 // An instance call of the form o.f(...) could not be resolved. Check if 1127 // An instance call of the form o.f(...) could not be resolved. Check if
1132 // there is a getter with the same name. If so, invoke it. If the value is 1128 // there is a getter with the same name. If so, invoke it. If the value is
1133 // a closure, invoke it with the given arguments. If the value is a 1129 // a closure, invoke it with the given arguments. If the value is a
1134 // non-closure, attempt to invoke "call" on it. 1130 // non-closure, attempt to invoke "call" on it.
1135 static bool ResolveCallThroughGetter(const Instance& receiver, 1131 static bool ResolveCallThroughGetter(const Instance& receiver,
(...skipping 11 matching lines...) Expand all
1147 getter_name, 1143 getter_name,
1148 kNumArguments, 1144 kNumArguments,
1149 kNumNamedArguments)); 1145 kNumNamedArguments));
1150 if (getter.IsNull() || getter.IsMethodExtractor()) { 1146 if (getter.IsNull() || getter.IsMethodExtractor()) {
1151 return false; 1147 return false;
1152 } 1148 }
1153 1149
1154 // 2. Invoke the getter. 1150 // 2. Invoke the getter.
1155 const Array& args = Array::Handle(Array::New(kNumArguments)); 1151 const Array& args = Array::Handle(Array::New(kNumArguments));
1156 args.SetAt(0, receiver); 1152 args.SetAt(0, receiver);
1157 const Object& value = Object::Handle(DartEntry::InvokeDynamic(getter, args)); 1153 const Object& value = Object::Handle(DartEntry::InvokeFunction(getter, args));
1158 1154
1159 // 3. If the getter threw an exception, treat it as no such method. 1155 // 3. If the getter threw an exception, treat it as no such method.
1160 if (value.IsUnhandledException()) return false; 1156 if (value.IsUnhandledException()) return false;
1161 1157
1162 // 4. If there was some other error, propagate it. 1158 // 4. If there was some other error, propagate it.
1163 CheckResultError(value); 1159 CheckResultError(value);
1164 1160
1165 // 5. Invoke the value as a closure. 1161 // 5. Invoke the value as a closure.
1166 Instance& instance = Instance::Handle(); 1162 Instance& instance = Instance::Handle();
1167 instance ^= value.raw(); 1163 instance ^= value.raw();
1168 arguments.SetAt(0, instance); 1164 arguments.SetAt(0, instance);
1169 *result = DartEntry::InvokeClosure(instance, 1165 *result = DartEntry::InvokeClosure(arguments, arguments_descriptor);
1170 arguments,
1171 arguments_descriptor);
1172 CheckResultError(*result); 1166 CheckResultError(*result);
1173 return true; 1167 return true;
1174 } 1168 }
1175 1169
1176 1170
1177 // The IC miss handler has failed to find a (cacheable) instance function to 1171 // The IC miss handler has failed to find a (cacheable) instance function to
1178 // invoke. Handle three possibilities: 1172 // invoke. Handle three possibilities:
1179 // 1173 //
1180 // 1. If the call was a getter o.f, there may be an instance function with 1174 // 1. If the call was a getter o.f, there may be an instance function with
1181 // the same name. If so, create an implicit closure and return it. 1175 // the same name. If so, create an implicit closure and return it.
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 if (right < 0) { 1723 if (right < 0) {
1730 remainder -= right; 1724 remainder -= right;
1731 } else { 1725 } else {
1732 remainder += right; 1726 remainder += right;
1733 } 1727 }
1734 } 1728 }
1735 return remainder; 1729 return remainder;
1736 } 1730 }
1737 1731
1738 } // namespace dart 1732 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_descriptors_test.cc ('k') | runtime/vm/code_generator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698