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

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

Issue 17074003: Back out r24266 to investigate dartium test failure. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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/class_finalizer.cc ('k') | runtime/vm/debugger.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.h" 7 #include "vm/assembler.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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 const GrowableArray<const Instance*>& args, 871 const GrowableArray<const Instance*>& args,
872 const ICData& ic_data, 872 const ICData& ic_data,
873 const Array& args_descriptor_array) { 873 const Array& args_descriptor_array) {
874 const Instance& receiver = *args[0]; 874 const Instance& receiver = *args[0];
875 const Code& target_code = 875 const Code& target_code =
876 Code::Handle(ResolveCompileInstanceCallTarget(receiver, ic_data)); 876 Code::Handle(ResolveCompileInstanceCallTarget(receiver, ic_data));
877 if (target_code.IsNull()) { 877 if (target_code.IsNull()) {
878 // Let the megamorphic stub handle special cases: NoSuchMethod, 878 // Let the megamorphic stub handle special cases: NoSuchMethod,
879 // closure calls. 879 // closure calls.
880 if (FLAG_trace_ic) { 880 if (FLAG_trace_ic) {
881 OS::PrintErr("InlineCacheMissHandler NULL code for %s receiver: %s\n", 881 OS::PrintErr("InlineCacheMissHandler NULL code for receiver: %s\n",
882 String::Handle(ic_data.target_name()).ToCString(), 882 receiver.ToCString());
883 receiver.ToCString());
884 } 883 }
885 return Function::null(); 884 return Function::null();
886 } 885 }
887 const Function& target_function = 886 const Function& target_function =
888 Function::Handle(target_code.function()); 887 Function::Handle(target_code.function());
889 ASSERT(!target_function.IsNull()); 888 ASSERT(!target_function.IsNull());
890 if (args.length() == 1) { 889 if (args.length() == 1) {
891 ic_data.AddReceiverCheck(args[0]->GetClassId(), target_function); 890 ic_data.AddReceiverCheck(args[0]->GetClassId(), target_function);
892 } else { 891 } else {
893 GrowableArray<intptr_t> class_ids(args.length()); 892 GrowableArray<intptr_t> class_ids(args.length());
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 Object* result) { 1147 Object* result) {
1149 // 1. Check if there is a getter with the same name. 1148 // 1. Check if there is a getter with the same name.
1150 const String& getter_name = String::Handle(Field::GetterName(target_name)); 1149 const String& getter_name = String::Handle(Field::GetterName(target_name));
1151 const int kNumArguments = 1; 1150 const int kNumArguments = 1;
1152 const int kNumNamedArguments = 0; 1151 const int kNumNamedArguments = 0;
1153 const Function& getter = Function::Handle( 1152 const Function& getter = Function::Handle(
1154 Resolver::ResolveDynamicForReceiverClass(receiver_class, 1153 Resolver::ResolveDynamicForReceiverClass(receiver_class,
1155 getter_name, 1154 getter_name,
1156 kNumArguments, 1155 kNumArguments,
1157 kNumNamedArguments)); 1156 kNumNamedArguments));
1158 if (getter.IsNull() || 1157 if (getter.IsNull() || getter.IsMethodExtractor()) {
1159 getter.IsMethodExtractor() ||
1160 getter.IsNoSuchMethodDispatcher()) {
1161 return false; 1158 return false;
1162 } 1159 }
1163 1160
1164 // 2. Invoke the getter. 1161 // 2. Invoke the getter.
1165 const Array& args = Array::Handle(Array::New(kNumArguments)); 1162 const Array& args = Array::Handle(Array::New(kNumArguments));
1166 args.SetAt(0, receiver); 1163 args.SetAt(0, receiver);
1167 const Object& value = Object::Handle(DartEntry::InvokeFunction(getter, args)); 1164 const Object& value = Object::Handle(DartEntry::InvokeFunction(getter, args));
1168 1165
1169 // 3. If the getter threw an exception, treat it as no such method. 1166 // 3. If the getter threw an exception, treat it as no such method.
1170 if (value.IsUnhandledException()) return false; 1167 if (value.IsUnhandledException()) return false;
1171 1168
1172 // 4. If there was some other error, propagate it. 1169 // 4. If there was some other error, propagate it.
1173 CheckResultError(value); 1170 CheckResultError(value);
1174 1171
1175 // 5. Invoke the value as a closure. 1172 // 5. Invoke the value as a closure.
1176 Instance& instance = Instance::Handle(); 1173 Instance& instance = Instance::Handle();
1177 instance ^= value.raw(); 1174 instance ^= value.raw();
1178 arguments.SetAt(0, instance); 1175 arguments.SetAt(0, instance);
1179 *result = DartEntry::InvokeClosure(arguments, arguments_descriptor); 1176 *result = DartEntry::InvokeClosure(arguments, arguments_descriptor);
1180 CheckResultError(*result); 1177 CheckResultError(*result);
1181 return true; 1178 return true;
1182 } 1179 }
1183 1180
1184 1181
1185 // Create a method for noSuchMethod invocation and attach it to the receiver
1186 // class.
1187 static RawFunction* CreateNoSuchMethodDispatcher(
1188 const String& target_name,
1189 const Class& receiver_class,
1190 const Array& arguments_descriptor) {
1191 Function& invocation = Function::Handle(
1192 Function::New(String::Handle(Symbols::New(target_name)),
1193 RawFunction::kNoSuchMethodDispatcher,
1194 false, // Not static.
1195 false, // Not const.
1196 false, // Not abstract.
1197 false, // Not external.
1198 receiver_class,
1199 0)); // No token position.
1200
1201 // Initialize signature: receiver is a single fixed parameter.
1202 const intptr_t kNumParameters = 1;
1203 invocation.set_num_fixed_parameters(kNumParameters);
1204 invocation.SetNumOptionalParameters(0, 0);
1205 invocation.set_parameter_types(Array::Handle(Array::New(kNumParameters,
1206 Heap::kOld)));
1207 invocation.set_parameter_names(Array::Handle(Array::New(kNumParameters,
1208 Heap::kOld)));
1209 invocation.SetParameterTypeAt(0, Type::Handle(Type::DynamicType()));
1210 invocation.SetParameterNameAt(0, Symbols::This());
1211 invocation.set_result_type(Type::Handle(Type::DynamicType()));
1212 invocation.set_is_visible(false); // Not visible in stack trace.
1213
1214 receiver_class.AddFunction(invocation);
1215
1216 return invocation.raw();
1217 }
1218
1219
1220 // The IC miss handler has failed to find a (cacheable) instance function to 1182 // The IC miss handler has failed to find a (cacheable) instance function to
1221 // invoke. Handle three possibilities: 1183 // invoke. Handle three possibilities:
1222 // 1184 //
1223 // 1. If the call was a getter o.f, there may be an instance function with 1185 // 1. If the call was a getter o.f, there may be an instance function with
1224 // the same name. If so, create an implicit closure and return it. 1186 // the same name. If so, create an implicit closure and return it.
1225 // 1187 //
1226 // 2. If the call was an instance call o.f(...), there may be a getter with 1188 // 2. If the call was an instance call o.f(...), there may be a getter with
1227 // the same name. If so, invoke it. If the value is a closure, invoke 1189 // the same name. If so, invoke it. If the value is a closure, invoke
1228 // it with the given arguments. If the value is a non-closure, attempt 1190 // it with the given arguments. If the value is a non-closure, attempt
1229 // to invoke "call" on it. 1191 // to invoke "call" on it.
(...skipping 14 matching lines...) Expand all
1244 } 1206 }
1245 const String& target_name = String::Handle(ic_data.target_name()); 1207 const String& target_name = String::Handle(ic_data.target_name());
1246 1208
1247 Object& result = Object::Handle(); 1209 Object& result = Object::Handle();
1248 if (!ResolveCallThroughGetter(receiver, 1210 if (!ResolveCallThroughGetter(receiver,
1249 receiver_class, 1211 receiver_class,
1250 target_name, 1212 target_name,
1251 args_descriptor, 1213 args_descriptor,
1252 args, 1214 args,
1253 &result)) { 1215 &result)) {
1254 ArgumentsDescriptor desc(args_descriptor); 1216 result = DartEntry::InvokeNoSuchMethod(receiver,
1255 // TODO(fschneider): Handle multiple arguments. 1217 target_name,
1256 if ((desc.Count() == 1) && (desc.PositionalCount() == 1)) { 1218 args,
1257 // Create Function for noSuchMethodInvocation and add it to the class. 1219 args_descriptor);
1258 Function& target_function = Function::Handle();
1259 target_function ^= CreateNoSuchMethodDispatcher(target_name,
1260 receiver_class,
1261 args_descriptor);
1262
1263 // Update IC data.
1264 ASSERT(!target_function.IsNull());
1265 ic_data.AddReceiverCheck(receiver.GetClassId(), target_function);
1266 if (FLAG_trace_ic) {
1267 OS::PrintErr("NoSuchMethod IC miss: adding <%s> id:%"Pd" -> <%s>\n",
1268 Class::Handle(receiver.clazz()).ToCString(),
1269 receiver.GetClassId(),
1270 target_function.ToCString());
1271 }
1272 result =
1273 DartEntry::InvokeFunction(target_function, args, args_descriptor);
1274 } else {
1275 result = DartEntry::InvokeNoSuchMethod(receiver,
1276 target_name,
1277 args,
1278 args_descriptor);
1279 }
1280 } 1220 }
1281 CheckResultError(result); 1221 CheckResultError(result);
1282 arguments.SetReturn(result); 1222 arguments.SetReturn(result);
1283 } 1223 }
1284 1224
1285 1225
1286 static bool CanOptimizeFunction(const Function& function, Isolate* isolate) { 1226 static bool CanOptimizeFunction(const Function& function, Isolate* isolate) {
1287 const intptr_t kLowInvocationCount = -100000000; 1227 const intptr_t kLowInvocationCount = -100000000;
1288 if (isolate->debugger()->HasBreakpoint(function)) { 1228 if (isolate->debugger()->HasBreakpoint(function)) {
1289 // We cannot set breakpoints in optimized code, so do not optimize 1229 // We cannot set breakpoints in optimized code, so do not optimize
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 // Arg1: Value that is being stored. 1803 // Arg1: Value that is being stored.
1864 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { 1804 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) {
1865 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count()); 1805 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count());
1866 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); 1806 const Field& field = Field::CheckedHandle(arguments.ArgAt(0));
1867 const Object& value = Object::Handle(arguments.ArgAt(1)); 1807 const Object& value = Object::Handle(arguments.ArgAt(1));
1868 1808
1869 field.UpdateCid(value.GetClassId()); 1809 field.UpdateCid(value.GetClassId());
1870 } 1810 }
1871 1811
1872 } // namespace dart 1812 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/debugger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698