| OLD | NEW |
| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 const AbstractType& type, | 345 const AbstractType& type, |
| 346 const AbstractTypeArguments& instantiator_type_arguments, | 346 const AbstractTypeArguments& instantiator_type_arguments, |
| 347 const Bool& result) { | 347 const Bool& result) { |
| 348 DartFrameIterator iterator; | 348 DartFrameIterator iterator; |
| 349 StackFrame* caller_frame = iterator.NextFrame(); | 349 StackFrame* caller_frame = iterator.NextFrame(); |
| 350 ASSERT(caller_frame != NULL); | 350 ASSERT(caller_frame != NULL); |
| 351 | 351 |
| 352 const Type& instance_type = Type::Handle(instance.GetType()); | 352 const Type& instance_type = Type::Handle(instance.GetType()); |
| 353 ASSERT(instance_type.IsInstantiated()); | 353 ASSERT(instance_type.IsInstantiated()); |
| 354 if (type.IsInstantiated()) { | 354 if (type.IsInstantiated()) { |
| 355 OS::PrintErr("%s: '%s' %"Pd" %s '%s' %"Pd" (pc: %#"Px").\n", | 355 OS::PrintErr("%s: '%s' %" Pd " %s '%s' %" Pd " (pc: %#" Px ").\n", |
| 356 message, | 356 message, |
| 357 String::Handle(instance_type.Name()).ToCString(), | 357 String::Handle(instance_type.Name()).ToCString(), |
| 358 Class::Handle(instance_type.type_class()).id(), | 358 Class::Handle(instance_type.type_class()).id(), |
| 359 (result.raw() == Bool::True().raw()) ? "is" : "is !", | 359 (result.raw() == Bool::True().raw()) ? "is" : "is !", |
| 360 String::Handle(type.Name()).ToCString(), | 360 String::Handle(type.Name()).ToCString(), |
| 361 Class::Handle(type.type_class()).id(), | 361 Class::Handle(type.type_class()).id(), |
| 362 caller_frame->pc()); | 362 caller_frame->pc()); |
| 363 } else { | 363 } else { |
| 364 // Instantiate type before printing. | 364 // Instantiate type before printing. |
| 365 Error& malformed_error = Error::Handle(); | 365 Error& malformed_error = Error::Handle(); |
| 366 const AbstractType& instantiated_type = AbstractType::Handle( | 366 const AbstractType& instantiated_type = AbstractType::Handle( |
| 367 type.InstantiateFrom(instantiator_type_arguments, &malformed_error)); | 367 type.InstantiateFrom(instantiator_type_arguments, &malformed_error)); |
| 368 OS::PrintErr("%s: '%s' %s '%s' instantiated from '%s' (pc: %#"Px").\n", | 368 OS::PrintErr("%s: '%s' %s '%s' instantiated from '%s' (pc: %#" Px ").\n", |
| 369 message, | 369 message, |
| 370 String::Handle(instance_type.Name()).ToCString(), | 370 String::Handle(instance_type.Name()).ToCString(), |
| 371 (result.raw() == Bool::True().raw()) ? "is" : "is !", | 371 (result.raw() == Bool::True().raw()) ? "is" : "is !", |
| 372 String::Handle(instantiated_type.Name()).ToCString(), | 372 String::Handle(instantiated_type.Name()).ToCString(), |
| 373 String::Handle(type.Name()).ToCString(), | 373 String::Handle(type.Name()).ToCString(), |
| 374 caller_frame->pc()); | 374 caller_frame->pc()); |
| 375 if (!malformed_error.IsNull()) { | 375 if (!malformed_error.IsNull()) { |
| 376 OS::Print(" malformed error: %s\n", malformed_error.ToErrorCString()); | 376 OS::Print(" malformed error: %s\n", malformed_error.ToErrorCString()); |
| 377 } | 377 } |
| 378 } | 378 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 i, | 481 i, |
| 482 &last_instance_class_id, | 482 &last_instance_class_id, |
| 483 &last_instance_type_arguments, | 483 &last_instance_type_arguments, |
| 484 &last_instantiator_type_arguments, | 484 &last_instantiator_type_arguments, |
| 485 &last_result); | 485 &last_result); |
| 486 if ((last_instance_class_id == instance_class.id()) && | 486 if ((last_instance_class_id == instance_class.id()) && |
| 487 (last_instance_type_arguments.raw() == instance_type_arguments.raw()) && | 487 (last_instance_type_arguments.raw() == instance_type_arguments.raw()) && |
| 488 (last_instantiator_type_arguments.raw() == | 488 (last_instantiator_type_arguments.raw() == |
| 489 instantiator_type_arguments.raw())) { | 489 instantiator_type_arguments.raw())) { |
| 490 if (FLAG_trace_type_checks) { | 490 if (FLAG_trace_type_checks) { |
| 491 OS::PrintErr("%"Pd" ", i); | 491 OS::PrintErr("%" Pd " ", i); |
| 492 if (type_arguments_replaced) { | 492 if (type_arguments_replaced) { |
| 493 PrintTypeCheck("Duplicate cache entry (canonical.)", instance, type, | 493 PrintTypeCheck("Duplicate cache entry (canonical.)", instance, type, |
| 494 instantiator_type_arguments, result); | 494 instantiator_type_arguments, result); |
| 495 } else { | 495 } else { |
| 496 PrintTypeCheck("WARNING Duplicate cache entry", instance, type, | 496 PrintTypeCheck("WARNING Duplicate cache entry", instance, type, |
| 497 instantiator_type_arguments, result); | 497 instantiator_type_arguments, result); |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 // Can occur if we have canonicalized arguments. | 500 // Can occur if we have canonicalized arguments. |
| 501 // TODO(srdjan): Investigate why this assert can fail. | 501 // TODO(srdjan): Investigate why this assert can fail. |
| 502 // ASSERT(type_arguments_replaced); | 502 // ASSERT(type_arguments_replaced); |
| 503 return; | 503 return; |
| 504 } | 504 } |
| 505 } | 505 } |
| 506 if (!instantiator_type_arguments.IsInstantiatedTypeArguments()) { | 506 if (!instantiator_type_arguments.IsInstantiatedTypeArguments()) { |
| 507 new_cache.AddCheck(instance_class.id(), | 507 new_cache.AddCheck(instance_class.id(), |
| 508 instance_type_arguments, | 508 instance_type_arguments, |
| 509 instantiator_type_arguments, | 509 instantiator_type_arguments, |
| 510 result); | 510 result); |
| 511 } | 511 } |
| 512 if (FLAG_trace_type_checks) { | 512 if (FLAG_trace_type_checks) { |
| 513 AbstractType& test_type = AbstractType::Handle(type.raw()); | 513 AbstractType& test_type = AbstractType::Handle(type.raw()); |
| 514 if (!test_type.IsInstantiated()) { | 514 if (!test_type.IsInstantiated()) { |
| 515 Error& malformed_error = Error::Handle(); | 515 Error& malformed_error = Error::Handle(); |
| 516 test_type = type.InstantiateFrom(instantiator_type_arguments, | 516 test_type = type.InstantiateFrom(instantiator_type_arguments, |
| 517 &malformed_error); | 517 &malformed_error); |
| 518 ASSERT(malformed_error.IsNull()); // Malformed types are not optimized. | 518 ASSERT(malformed_error.IsNull()); // Malformed types are not optimized. |
| 519 } | 519 } |
| 520 OS::PrintErr(" Updated test cache %p ix: %"Pd" with " | 520 OS::PrintErr(" Updated test cache %p ix: %" Pd " with " |
| 521 "(cid: %"Pd", type-args: %p, instantiator: %p, result: %s)\n" | 521 "(cid: %" Pd ", type-args: %p, instantiator: %p, result: %s)\n" |
| 522 " instance [class: (%p '%s' cid: %"Pd"), type-args: %p %s]\n" | 522 " instance [class: (%p '%s' cid: %" Pd "), type-args: %p %s]\n" |
| 523 " test-type [class: (%p '%s' cid: %"Pd"), in-type-args: %p %s]\n", | 523 " test-type [class: (%p '%s' cid: %" Pd "), in-type-args: %p %s]\n", |
| 524 new_cache.raw(), | 524 new_cache.raw(), |
| 525 len, | 525 len, |
| 526 | 526 |
| 527 instance_class.id(), | 527 instance_class.id(), |
| 528 instance_type_arguments.raw(), | 528 instance_type_arguments.raw(), |
| 529 instantiator_type_arguments.raw(), | 529 instantiator_type_arguments.raw(), |
| 530 result.ToCString(), | 530 result.ToCString(), |
| 531 | 531 |
| 532 instance_class.raw(), | 532 instance_class.raw(), |
| 533 String::Handle(instance_class.Name()).ToCString(), | 533 String::Handle(instance_class.Name()).ToCString(), |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 } | 732 } |
| 733 const Code& target_code = Code::Handle(target_function.CurrentCode()); | 733 const Code& target_code = Code::Handle(target_function.CurrentCode()); |
| 734 // Before patching verify that we are not repeatedly patching to the same | 734 // Before patching verify that we are not repeatedly patching to the same |
| 735 // target. | 735 // target. |
| 736 ASSERT(target_code.EntryPoint() != | 736 ASSERT(target_code.EntryPoint() != |
| 737 CodePatcher::GetStaticCallTargetAt(caller_frame->pc(), caller_code)); | 737 CodePatcher::GetStaticCallTargetAt(caller_frame->pc(), caller_code)); |
| 738 CodePatcher::PatchStaticCallAt(caller_frame->pc(), caller_code, | 738 CodePatcher::PatchStaticCallAt(caller_frame->pc(), caller_code, |
| 739 target_code.EntryPoint()); | 739 target_code.EntryPoint()); |
| 740 caller_code.SetStaticCallTargetCodeAt(caller_frame->pc(), target_code); | 740 caller_code.SetStaticCallTargetCodeAt(caller_frame->pc(), target_code); |
| 741 if (FLAG_trace_patching) { | 741 if (FLAG_trace_patching) { |
| 742 OS::PrintErr("PatchStaticCall: patching from %#"Px" to '%s' %#"Px"\n", | 742 OS::PrintErr("PatchStaticCall: patching from %#" Px " to '%s' %#" Px "\n", |
| 743 caller_frame->pc(), | 743 caller_frame->pc(), |
| 744 target_function.ToFullyQualifiedCString(), | 744 target_function.ToFullyQualifiedCString(), |
| 745 target_code.EntryPoint()); | 745 target_code.EntryPoint()); |
| 746 } | 746 } |
| 747 arguments.SetReturn(target_code); | 747 arguments.SetReturn(target_code); |
| 748 } | 748 } |
| 749 | 749 |
| 750 | 750 |
| 751 // Resolves and compiles the target function of an instance call, updates | 751 // Resolves and compiles the target function of an instance call, updates |
| 752 // function cache of the receiver's class and returns the compiled code or null. | 752 // function cache of the receiver's class and returns the compiled code or null. |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 ASSERT(caller_frame != NULL); | 892 ASSERT(caller_frame != NULL); |
| 893 if (FLAG_trace_ic_miss_in_optimized) { | 893 if (FLAG_trace_ic_miss_in_optimized) { |
| 894 const Code& caller = Code::Handle(Code::LookupCode(caller_frame->pc())); | 894 const Code& caller = Code::Handle(Code::LookupCode(caller_frame->pc())); |
| 895 if (caller.is_optimized()) { | 895 if (caller.is_optimized()) { |
| 896 OS::PrintErr("IC miss in optimized code; call %s -> %s\n", | 896 OS::PrintErr("IC miss in optimized code; call %s -> %s\n", |
| 897 Function::Handle(caller.function()).ToCString(), | 897 Function::Handle(caller.function()).ToCString(), |
| 898 target_function.ToCString()); | 898 target_function.ToCString()); |
| 899 } | 899 } |
| 900 } | 900 } |
| 901 if (FLAG_trace_ic) { | 901 if (FLAG_trace_ic) { |
| 902 OS::PrintErr("InlineCacheMissHandler %d call at %#"Px"' " | 902 OS::PrintErr("InlineCacheMissHandler %d call at %#" Px "' " |
| 903 "adding <%s> id:%"Pd" -> <%s>\n", | 903 "adding <%s> id:%" Pd " -> <%s>\n", |
| 904 args.length(), | 904 args.length(), |
| 905 caller_frame->pc(), | 905 caller_frame->pc(), |
| 906 Class::Handle(receiver.clazz()).ToCString(), | 906 Class::Handle(receiver.clazz()).ToCString(), |
| 907 receiver.GetClassId(), | 907 receiver.GetClassId(), |
| 908 target_function.ToCString()); | 908 target_function.ToCString()); |
| 909 } | 909 } |
| 910 } | 910 } |
| 911 return target_function.raw(); | 911 return target_function.raw(); |
| 912 } | 912 } |
| 913 | 913 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 } | 1000 } |
| 1001 ASSERT(!target.IsNull() && target.HasCode()); | 1001 ASSERT(!target.IsNull() && target.HasCode()); |
| 1002 GrowableArray<intptr_t> cids(2); | 1002 GrowableArray<intptr_t> cids(2); |
| 1003 cids.Add(arg0.GetClassId()); | 1003 cids.Add(arg0.GetClassId()); |
| 1004 cids.Add(arg1.GetClassId()); | 1004 cids.Add(arg1.GetClassId()); |
| 1005 ic_data.AddCheck(cids, target); | 1005 ic_data.AddCheck(cids, target); |
| 1006 if (FLAG_trace_ic) { | 1006 if (FLAG_trace_ic) { |
| 1007 DartFrameIterator iterator; | 1007 DartFrameIterator iterator; |
| 1008 StackFrame* caller_frame = iterator.NextFrame(); | 1008 StackFrame* caller_frame = iterator.NextFrame(); |
| 1009 ASSERT(caller_frame != NULL); | 1009 ASSERT(caller_frame != NULL); |
| 1010 OS::PrintErr("StaticCallMissHandler at %#"Px" target %s (%"Pd", %"Pd")\n", | 1010 OS::PrintErr("StaticCallMissHandler at %#" Px |
| 1011 caller_frame->pc(), target.ToCString(), cids[0], cids[1]); | 1011 " target %s (%" Pd ", %" Pd ")\n", |
| 1012 caller_frame->pc(), target.ToCString(), cids[0], cids[1]); |
| 1012 } | 1013 } |
| 1013 arguments.SetReturn(target); | 1014 arguments.SetReturn(target); |
| 1014 } | 1015 } |
| 1015 | 1016 |
| 1016 | 1017 |
| 1017 // Handle a miss of a megamorphic cache. | 1018 // Handle a miss of a megamorphic cache. |
| 1018 // Arg0: Receiver. | 1019 // Arg0: Receiver. |
| 1019 // Arg1: ICData object. | 1020 // Arg1: ICData object. |
| 1020 // Arg2: Arguments descriptor array. | 1021 // Arg2: Arguments descriptor array. |
| 1021 | 1022 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 | 1172 |
| 1172 const Function& target_function = | 1173 const Function& target_function = |
| 1173 Function::Handle(receiver_class.GetInvocationDispatcher( | 1174 Function::Handle(receiver_class.GetInvocationDispatcher( |
| 1174 target_name, | 1175 target_name, |
| 1175 arguments_descriptor, | 1176 arguments_descriptor, |
| 1176 RawFunction::kInvokeFieldDispatcher)); | 1177 RawFunction::kInvokeFieldDispatcher)); |
| 1177 // Update IC data. | 1178 // Update IC data. |
| 1178 ASSERT(!target_function.IsNull()); | 1179 ASSERT(!target_function.IsNull()); |
| 1179 ic_data.AddReceiverCheck(receiver.GetClassId(), target_function); | 1180 ic_data.AddReceiverCheck(receiver.GetClassId(), target_function); |
| 1180 if (FLAG_trace_ic) { | 1181 if (FLAG_trace_ic) { |
| 1181 OS::PrintErr("InvokeField IC miss: adding <%s> id:%"Pd" -> <%s>\n", | 1182 OS::PrintErr("InvokeField IC miss: adding <%s> id:%" Pd " -> <%s>\n", |
| 1182 Class::Handle(receiver.clazz()).ToCString(), | 1183 Class::Handle(receiver.clazz()).ToCString(), |
| 1183 receiver.GetClassId(), | 1184 receiver.GetClassId(), |
| 1184 target_function.ToCString()); | 1185 target_function.ToCString()); |
| 1185 } | 1186 } |
| 1186 *result = DartEntry::InvokeFunction(target_function, | 1187 *result = DartEntry::InvokeFunction(target_function, |
| 1187 arguments, | 1188 arguments, |
| 1188 arguments_descriptor); | 1189 arguments_descriptor); |
| 1189 CheckResultError(*result); | 1190 CheckResultError(*result); |
| 1190 return true; | 1191 return true; |
| 1191 } | 1192 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 // Operators calls have two or three arguments tested ([], []=, etc.) | 1249 // Operators calls have two or three arguments tested ([], []=, etc.) |
| 1249 ASSERT(ic_data.num_args_tested() > 1); | 1250 ASSERT(ic_data.num_args_tested() > 1); |
| 1250 GrowableArray<intptr_t> class_ids(ic_data.num_args_tested()); | 1251 GrowableArray<intptr_t> class_ids(ic_data.num_args_tested()); |
| 1251 class_ids.Add(receiver_cid); | 1252 class_ids.Add(receiver_cid); |
| 1252 for (intptr_t i = 1; i < ic_data.num_args_tested(); ++i) { | 1253 for (intptr_t i = 1; i < ic_data.num_args_tested(); ++i) { |
| 1253 class_ids.Add(Object::Handle(args.At(i)).GetClassId()); | 1254 class_ids.Add(Object::Handle(args.At(i)).GetClassId()); |
| 1254 } | 1255 } |
| 1255 ic_data.AddCheck(class_ids, target_function); | 1256 ic_data.AddCheck(class_ids, target_function); |
| 1256 } | 1257 } |
| 1257 if (FLAG_trace_ic) { | 1258 if (FLAG_trace_ic) { |
| 1258 OS::PrintErr("NoSuchMethod IC miss: adding <%s> id:%"Pd" -> <%s>\n", | 1259 OS::PrintErr("NoSuchMethod IC miss: adding <%s> id:%" Pd " -> <%s>\n", |
| 1259 Class::Handle(receiver.clazz()).ToCString(), | 1260 Class::Handle(receiver.clazz()).ToCString(), |
| 1260 receiver_cid, | 1261 receiver_cid, |
| 1261 target_function.ToCString()); | 1262 target_function.ToCString()); |
| 1262 } | 1263 } |
| 1263 result = DartEntry::InvokeFunction(target_function, args, args_descriptor); | 1264 result = DartEntry::InvokeFunction(target_function, args, args_descriptor); |
| 1264 } | 1265 } |
| 1265 CheckResultError(result); | 1266 CheckResultError(result); |
| 1266 arguments.SetReturn(result); | 1267 arguments.SetReturn(result); |
| 1267 } | 1268 } |
| 1268 | 1269 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 | 1362 |
| 1362 if (FLAG_use_osr && (interrupt_bits == 0)) { | 1363 if (FLAG_use_osr && (interrupt_bits == 0)) { |
| 1363 DartFrameIterator iterator; | 1364 DartFrameIterator iterator; |
| 1364 StackFrame* frame = iterator.NextFrame(); | 1365 StackFrame* frame = iterator.NextFrame(); |
| 1365 const Function& function = Function::Handle(frame->LookupDartFunction()); | 1366 const Function& function = Function::Handle(frame->LookupDartFunction()); |
| 1366 ASSERT(!function.IsNull()); | 1367 ASSERT(!function.IsNull()); |
| 1367 if (!CanOptimizeFunction(function, isolate)) return; | 1368 if (!CanOptimizeFunction(function, isolate)) return; |
| 1368 intptr_t osr_id = | 1369 intptr_t osr_id = |
| 1369 Code::Handle(function.unoptimized_code()).GetDeoptIdForOsr(frame->pc()); | 1370 Code::Handle(function.unoptimized_code()).GetDeoptIdForOsr(frame->pc()); |
| 1370 if (FLAG_trace_osr) { | 1371 if (FLAG_trace_osr) { |
| 1371 OS::Print("Attempting OSR for %s at id=%"Pd", count=%"Pd"\n", | 1372 OS::Print("Attempting OSR for %s at id=%" Pd ", count=%" Pd "\n", |
| 1372 function.ToFullyQualifiedCString(), | 1373 function.ToFullyQualifiedCString(), |
| 1373 osr_id, | 1374 osr_id, |
| 1374 function.usage_counter()); | 1375 function.usage_counter()); |
| 1375 } | 1376 } |
| 1376 | 1377 |
| 1377 const Code& original_code = Code::Handle(function.CurrentCode()); | 1378 const Code& original_code = Code::Handle(function.CurrentCode()); |
| 1378 const Error& error = | 1379 const Error& error = |
| 1379 Error::Handle(Compiler::CompileOptimizedFunction(function, osr_id)); | 1380 Error::Handle(Compiler::CompileOptimizedFunction(function, osr_id)); |
| 1380 if (!error.IsNull()) Exceptions::PropagateError(error); | 1381 if (!error.IsNull()) Exceptions::PropagateError(error); |
| 1381 | 1382 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1396 | 1397 |
| 1397 | 1398 |
| 1398 DEFINE_RUNTIME_ENTRY(TraceICCall, 2) { | 1399 DEFINE_RUNTIME_ENTRY(TraceICCall, 2) { |
| 1399 ASSERT(arguments.ArgCount() == | 1400 ASSERT(arguments.ArgCount() == |
| 1400 kTraceICCallRuntimeEntry.argument_count()); | 1401 kTraceICCallRuntimeEntry.argument_count()); |
| 1401 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(0)); | 1402 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(0)); |
| 1402 const Function& function = Function::CheckedHandle(arguments.ArgAt(1)); | 1403 const Function& function = Function::CheckedHandle(arguments.ArgAt(1)); |
| 1403 DartFrameIterator iterator; | 1404 DartFrameIterator iterator; |
| 1404 StackFrame* frame = iterator.NextFrame(); | 1405 StackFrame* frame = iterator.NextFrame(); |
| 1405 ASSERT(frame != NULL); | 1406 ASSERT(frame != NULL); |
| 1406 OS::PrintErr("IC call @%#"Px": ICData: %p cnt:%"Pd" nchecks: %"Pd" %s %s\n", | 1407 OS::PrintErr("IC call @%#" Px ": ICData: %p cnt:%" Pd " nchecks: %" Pd |
| 1408 " %s %s\n", |
| 1407 frame->pc(), | 1409 frame->pc(), |
| 1408 ic_data.raw(), | 1410 ic_data.raw(), |
| 1409 function.usage_counter(), | 1411 function.usage_counter(), |
| 1410 ic_data.NumberOfChecks(), | 1412 ic_data.NumberOfChecks(), |
| 1411 ic_data.is_closure_call() ? "closure" : "", | 1413 ic_data.is_closure_call() ? "closure" : "", |
| 1412 function.ToFullyQualifiedCString()); | 1414 function.ToFullyQualifiedCString()); |
| 1413 } | 1415 } |
| 1414 | 1416 |
| 1415 | 1417 |
| 1416 // This is called from function that needs to be optimized. | 1418 // This is called from function that needs to be optimized. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1457 ASSERT(frame->IsDartFrame()); | 1459 ASSERT(frame->IsDartFrame()); |
| 1458 const Code& caller_code = Code::Handle(frame->LookupDartCode()); | 1460 const Code& caller_code = Code::Handle(frame->LookupDartCode()); |
| 1459 ASSERT(caller_code.is_optimized()); | 1461 ASSERT(caller_code.is_optimized()); |
| 1460 const Function& target_function = Function::Handle( | 1462 const Function& target_function = Function::Handle( |
| 1461 caller_code.GetStaticCallTargetFunctionAt(frame->pc())); | 1463 caller_code.GetStaticCallTargetFunctionAt(frame->pc())); |
| 1462 const Code& target_code = Code::Handle(target_function.CurrentCode()); | 1464 const Code& target_code = Code::Handle(target_function.CurrentCode()); |
| 1463 CodePatcher::PatchStaticCallAt(frame->pc(), caller_code, | 1465 CodePatcher::PatchStaticCallAt(frame->pc(), caller_code, |
| 1464 target_code.EntryPoint()); | 1466 target_code.EntryPoint()); |
| 1465 caller_code.SetStaticCallTargetCodeAt(frame->pc(), target_code); | 1467 caller_code.SetStaticCallTargetCodeAt(frame->pc(), target_code); |
| 1466 if (FLAG_trace_patching) { | 1468 if (FLAG_trace_patching) { |
| 1467 OS::PrintErr("FixCallersTarget: patching from %#"Px" to '%s' %#"Px"\n", | 1469 OS::PrintErr("FixCallersTarget: patching from %#" Px " to '%s' %#" Px "\n", |
| 1468 frame->pc(), | 1470 frame->pc(), |
| 1469 Function::Handle(target_code.function()).ToFullyQualifiedCString(), | 1471 Function::Handle(target_code.function()).ToFullyQualifiedCString(), |
| 1470 target_code.EntryPoint()); | 1472 target_code.EntryPoint()); |
| 1471 } | 1473 } |
| 1472 arguments.SetReturn(target_code); | 1474 arguments.SetReturn(target_code); |
| 1473 } | 1475 } |
| 1474 | 1476 |
| 1475 | 1477 |
| 1476 const char* DeoptReasonToText(intptr_t deopt_id) { | 1478 const char* DeoptReasonToText(intptr_t deopt_id) { |
| 1477 switch (deopt_id) { | 1479 switch (deopt_id) { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 | 1634 |
| 1633 intptr_t deopt_reason = kDeoptUnknown; | 1635 intptr_t deopt_reason = kDeoptUnknown; |
| 1634 const DeoptInfo& deopt_info = DeoptInfo::Handle( | 1636 const DeoptInfo& deopt_info = DeoptInfo::Handle( |
| 1635 optimized_code.GetDeoptInfoAtPc(caller_frame->pc(), &deopt_reason)); | 1637 optimized_code.GetDeoptInfoAtPc(caller_frame->pc(), &deopt_reason)); |
| 1636 ASSERT(!deopt_info.IsNull()); | 1638 ASSERT(!deopt_info.IsNull()); |
| 1637 | 1639 |
| 1638 CopyFrame(optimized_code, *caller_frame); | 1640 CopyFrame(optimized_code, *caller_frame); |
| 1639 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { | 1641 if (FLAG_trace_deoptimization || FLAG_trace_deoptimization_verbose) { |
| 1640 Function& function = Function::Handle(optimized_code.function()); | 1642 Function& function = Function::Handle(optimized_code.function()); |
| 1641 OS::PrintErr( | 1643 OS::PrintErr( |
| 1642 "Deoptimizing (reason %"Pd" '%s') at pc %#"Px" '%s' (count %d)\n", | 1644 "Deoptimizing (reason %" Pd " '%s') at pc %#" Px " '%s' (count %d)\n", |
| 1643 deopt_reason, | 1645 deopt_reason, |
| 1644 DeoptReasonToText(deopt_reason), | 1646 DeoptReasonToText(deopt_reason), |
| 1645 caller_frame->pc(), | 1647 caller_frame->pc(), |
| 1646 function.ToFullyQualifiedCString(), | 1648 function.ToFullyQualifiedCString(), |
| 1647 function.deoptimization_counter()); | 1649 function.deoptimization_counter()); |
| 1648 } | 1650 } |
| 1649 | 1651 |
| 1650 // Compute the stack size of the unoptimized frame. For functions with | 1652 // Compute the stack size of the unoptimized frame. For functions with |
| 1651 // optional arguments the deoptimization info does not describe the | 1653 // optional arguments the deoptimization info does not describe the |
| 1652 // incoming arguments. | 1654 // incoming arguments. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1716 // Populate stack frames. | 1718 // Populate stack frames. |
| 1717 for (intptr_t to_index = frame_size - 1, from_index = len - 1; | 1719 for (intptr_t to_index = frame_size - 1, from_index = len - 1; |
| 1718 to_index >= 0; | 1720 to_index >= 0; |
| 1719 to_index--, from_index--) { | 1721 to_index--, from_index--) { |
| 1720 intptr_t* to_addr = deopt_context.GetToFrameAddressAt(to_index); | 1722 intptr_t* to_addr = deopt_context.GetToFrameAddressAt(to_index); |
| 1721 deopt_instructions[from_index]->Execute(&deopt_context, to_addr); | 1723 deopt_instructions[from_index]->Execute(&deopt_context, to_addr); |
| 1722 } | 1724 } |
| 1723 | 1725 |
| 1724 if (FLAG_trace_deoptimization_verbose) { | 1726 if (FLAG_trace_deoptimization_verbose) { |
| 1725 for (intptr_t i = 0; i < frame_size; i++) { | 1727 for (intptr_t i = 0; i < frame_size; i++) { |
| 1726 OS::PrintErr("*%"Pd". [%"Px"] %#014"Px" [%s]\n", | 1728 OS::PrintErr("*%" Pd ". [%" Px "] %#014" Px " [%s]\n", |
| 1727 i, | 1729 i, |
| 1728 reinterpret_cast<uword>(&start[i]), | 1730 reinterpret_cast<uword>(&start[i]), |
| 1729 start[i], | 1731 start[i], |
| 1730 deopt_instructions[i + (len - frame_size)]->ToCString()); | 1732 deopt_instructions[i + (len - frame_size)]->ToCString()); |
| 1731 } | 1733 } |
| 1732 } | 1734 } |
| 1733 } | 1735 } |
| 1734 | 1736 |
| 1735 | 1737 |
| 1736 // The stack has been adjusted to fit all values for unoptimized frame. | 1738 // The stack has been adjusted to fit all values for unoptimized frame. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1807 StackFrame* top_frame = iterator.NextFrame(); | 1809 StackFrame* top_frame = iterator.NextFrame(); |
| 1808 ASSERT(top_frame != NULL); | 1810 ASSERT(top_frame != NULL); |
| 1809 const Code& code = Code::Handle(top_frame->LookupDartCode()); | 1811 const Code& code = Code::Handle(top_frame->LookupDartCode()); |
| 1810 const Function& top_function = Function::Handle(code.function()); | 1812 const Function& top_function = Function::Handle(code.function()); |
| 1811 const Script& script = Script::Handle(top_function.script()); | 1813 const Script& script = Script::Handle(top_function.script()); |
| 1812 const intptr_t token_pos = code.GetTokenIndexOfPC(top_frame->pc()); | 1814 const intptr_t token_pos = code.GetTokenIndexOfPC(top_frame->pc()); |
| 1813 intptr_t line, column; | 1815 intptr_t line, column; |
| 1814 script.GetTokenLocation(token_pos, &line, &column); | 1816 script.GetTokenLocation(token_pos, &line, &column); |
| 1815 String& line_string = String::Handle(script.GetLine(line)); | 1817 String& line_string = String::Handle(script.GetLine(line)); |
| 1816 OS::PrintErr(" Function: %s\n", top_function.ToFullyQualifiedCString()); | 1818 OS::PrintErr(" Function: %s\n", top_function.ToFullyQualifiedCString()); |
| 1817 OS::PrintErr(" Line %"Pd": '%s'\n", line, line_string.ToCString()); | 1819 OS::PrintErr(" Line %" Pd ": '%s'\n", line, line_string.ToCString()); |
| 1818 OS::PrintErr(" Deopt args: %"Pd"\n", deopt_arguments); | 1820 OS::PrintErr(" Deopt args: %" Pd "\n", deopt_arguments); |
| 1819 } | 1821 } |
| 1820 } | 1822 } |
| 1821 | 1823 |
| 1822 | 1824 |
| 1823 DEFINE_LEAF_RUNTIME_ENTRY(intptr_t, | 1825 DEFINE_LEAF_RUNTIME_ENTRY(intptr_t, |
| 1824 BigintCompare, | 1826 BigintCompare, |
| 1825 2, | 1827 2, |
| 1826 RawBigint* left, | 1828 RawBigint* left, |
| 1827 RawBigint* right) { | 1829 RawBigint* right) { |
| 1828 Isolate* isolate = Isolate::Current(); | 1830 Isolate* isolate = Isolate::Current(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1857 // Arg1: Value that is being stored. | 1859 // Arg1: Value that is being stored. |
| 1858 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { | 1860 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { |
| 1859 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count()); | 1861 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count()); |
| 1860 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); | 1862 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); |
| 1861 const Object& value = Object::Handle(arguments.ArgAt(1)); | 1863 const Object& value = Object::Handle(arguments.ArgAt(1)); |
| 1862 | 1864 |
| 1863 field.UpdateCid(value.GetClassId()); | 1865 field.UpdateCid(value.GetClassId()); |
| 1864 } | 1866 } |
| 1865 | 1867 |
| 1866 } // namespace dart | 1868 } // namespace dart |
| OLD | NEW |