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/code_patcher.h" | 9 #include "vm/code_patcher.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 | 670 |
671 // Result of an invoke may be an unhandled exception, in which case we | 671 // Result of an invoke may be an unhandled exception, in which case we |
672 // rethrow it. | 672 // rethrow it. |
673 static void CheckResultError(const Object& result) { | 673 static void CheckResultError(const Object& result) { |
674 if (result.IsError()) { | 674 if (result.IsError()) { |
675 Exceptions::PropagateError(Error::Cast(result)); | 675 Exceptions::PropagateError(Error::Cast(result)); |
676 } | 676 } |
677 } | 677 } |
678 | 678 |
679 | 679 |
| 680 #if !defined(TARGET_ARCH_DBC) |
680 // Gets called from debug stub when code reaches a breakpoint | 681 // Gets called from debug stub when code reaches a breakpoint |
681 // set on a runtime stub call. | 682 // set on a runtime stub call. |
682 DEFINE_RUNTIME_ENTRY(BreakpointRuntimeHandler, 0) { | 683 DEFINE_RUNTIME_ENTRY(BreakpointRuntimeHandler, 0) { |
683 if (!FLAG_support_debugger) { | 684 if (!FLAG_support_debugger) { |
684 UNREACHABLE(); | 685 UNREACHABLE(); |
685 return; | 686 return; |
686 } | 687 } |
687 DartFrameIterator iterator; | 688 DartFrameIterator iterator; |
688 StackFrame* caller_frame = iterator.NextFrame(); | 689 StackFrame* caller_frame = iterator.NextFrame(); |
689 ASSERT(caller_frame != NULL); | 690 ASSERT(caller_frame != NULL); |
690 const Code& orig_stub = Code::Handle( | 691 const Code& orig_stub = Code::Handle( |
691 isolate->debugger()->GetPatchedStubAddress(caller_frame->pc())); | 692 isolate->debugger()->GetPatchedStubAddress(caller_frame->pc())); |
692 const Error& error = Error::Handle(isolate->debugger()->SignalBpReached()); | 693 const Error& error = Error::Handle(isolate->debugger()->SignalBpReached()); |
693 if (!error.IsNull()) { | 694 if (!error.IsNull()) { |
694 Exceptions::PropagateError(error); | 695 Exceptions::PropagateError(error); |
695 UNREACHABLE(); | 696 UNREACHABLE(); |
696 } | 697 } |
697 arguments.SetReturn(orig_stub); | 698 arguments.SetReturn(orig_stub); |
698 } | 699 } |
| 700 #else |
| 701 // Gets called from the simulator when the breakpoint is reached. |
| 702 DEFINE_RUNTIME_ENTRY(BreakpointRuntimeHandler, 0) { |
| 703 if (!FLAG_support_debugger) { |
| 704 UNREACHABLE(); |
| 705 return; |
| 706 } |
| 707 const Error& error = Error::Handle(isolate->debugger()->SignalBpReached()); |
| 708 if (!error.IsNull()) { |
| 709 Exceptions::PropagateError(error); |
| 710 UNREACHABLE(); |
| 711 } |
| 712 } |
| 713 #endif // !defined(TARGET_ARCH_DBC) |
699 | 714 |
700 | 715 |
701 DEFINE_RUNTIME_ENTRY(SingleStepHandler, 0) { | 716 DEFINE_RUNTIME_ENTRY(SingleStepHandler, 0) { |
702 if (!FLAG_support_debugger) { | 717 if (!FLAG_support_debugger) { |
703 UNREACHABLE(); | 718 UNREACHABLE(); |
704 return; | 719 return; |
705 } | 720 } |
706 const Error& error = | 721 const Error& error = |
707 Error::Handle(isolate->debugger()->DebuggerStepCallback()); | 722 Error::Handle(isolate->debugger()->DebuggerStepCallback()); |
708 if (!error.IsNull()) { | 723 if (!error.IsNull()) { |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 arguments.SetReturn(target); | 986 arguments.SetReturn(target); |
972 } | 987 } |
973 | 988 |
974 | 989 |
975 // Handle a miss of a megamorphic cache. | 990 // Handle a miss of a megamorphic cache. |
976 // Arg0: Receiver. | 991 // Arg0: Receiver. |
977 // Arg1: ICData or MegamorphicCache. | 992 // Arg1: ICData or MegamorphicCache. |
978 // Arg2: Arguments descriptor array. | 993 // Arg2: Arguments descriptor array. |
979 // Returns: target function to call. | 994 // Returns: target function to call. |
980 DEFINE_RUNTIME_ENTRY(MegamorphicCacheMissHandler, 3) { | 995 DEFINE_RUNTIME_ENTRY(MegamorphicCacheMissHandler, 3) { |
| 996 // DBC does not use megamorphic calls right now. |
| 997 #if !defined(TARGET_ARCH_DBC) |
981 const Instance& receiver = Instance::CheckedHandle(zone, arguments.ArgAt(0)); | 998 const Instance& receiver = Instance::CheckedHandle(zone, arguments.ArgAt(0)); |
982 const Object& ic_data_or_cache = Object::Handle(zone, arguments.ArgAt(1)); | 999 const Object& ic_data_or_cache = Object::Handle(zone, arguments.ArgAt(1)); |
983 const Array& descriptor = Array::CheckedHandle(zone, arguments.ArgAt(2)); | 1000 const Array& descriptor = Array::CheckedHandle(zone, arguments.ArgAt(2)); |
984 String& name = String::Handle(zone); | 1001 String& name = String::Handle(zone); |
985 if (ic_data_or_cache.IsICData()) { | 1002 if (ic_data_or_cache.IsICData()) { |
986 name = ICData::Cast(ic_data_or_cache).target_name(); | 1003 name = ICData::Cast(ic_data_or_cache).target_name(); |
987 } else { | 1004 } else { |
988 ASSERT(ic_data_or_cache.IsMegamorphicCache()); | 1005 ASSERT(ic_data_or_cache.IsMegamorphicCache()); |
989 name = MegamorphicCache::Cast(ic_data_or_cache).target_name(); | 1006 name = MegamorphicCache::Cast(ic_data_or_cache).target_name(); |
990 } | 1007 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 code, ic_data, cache, stub); | 1045 code, ic_data, cache, stub); |
1029 } | 1046 } |
1030 } else { | 1047 } else { |
1031 const MegamorphicCache& cache = MegamorphicCache::Cast(ic_data_or_cache); | 1048 const MegamorphicCache& cache = MegamorphicCache::Cast(ic_data_or_cache); |
1032 // Insert function found into cache and return it. | 1049 // Insert function found into cache and return it. |
1033 cache.EnsureCapacity(); | 1050 cache.EnsureCapacity(); |
1034 const Smi& class_id = Smi::Handle(zone, Smi::New(cls.id())); | 1051 const Smi& class_id = Smi::Handle(zone, Smi::New(cls.id())); |
1035 cache.Insert(class_id, target_function); | 1052 cache.Insert(class_id, target_function); |
1036 } | 1053 } |
1037 arguments.SetReturn(target_function); | 1054 arguments.SetReturn(target_function); |
| 1055 #else |
| 1056 UNREACHABLE(); |
| 1057 #endif // !defined(TARGET_ARCH_DBC) |
1038 } | 1058 } |
1039 | 1059 |
1040 | 1060 |
1041 // Invoke appropriate noSuchMethod or closure from getter. | 1061 // Invoke appropriate noSuchMethod or closure from getter. |
1042 // Arg0: receiver | 1062 // Arg0: receiver |
1043 // Arg1: ICData or MegamorphicCache | 1063 // Arg1: ICData or MegamorphicCache |
1044 // Arg2: arguments descriptor array | 1064 // Arg2: arguments descriptor array |
1045 // Arg3: arguments array | 1065 // Arg3: arguments array |
1046 DEFINE_RUNTIME_ENTRY(InvokeNoSuchMethodDispatcher, 4) { | 1066 DEFINE_RUNTIME_ENTRY(InvokeNoSuchMethodDispatcher, 4) { |
1047 ASSERT(!FLAG_lazy_dispatchers); | 1067 ASSERT(!FLAG_lazy_dispatchers); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 } | 1290 } |
1271 function.set_usage_counter(INT_MIN); | 1291 function.set_usage_counter(INT_MIN); |
1272 return false; | 1292 return false; |
1273 } | 1293 } |
1274 return true; | 1294 return true; |
1275 } | 1295 } |
1276 | 1296 |
1277 | 1297 |
1278 DEFINE_RUNTIME_ENTRY(StackOverflow, 0) { | 1298 DEFINE_RUNTIME_ENTRY(StackOverflow, 0) { |
1279 #if defined(USING_SIMULATOR) | 1299 #if defined(USING_SIMULATOR) |
1280 uword stack_pos = Simulator::Current()->get_register(SPREG); | 1300 uword stack_pos = Simulator::Current()->get_sp(); |
1281 #else | 1301 #else |
1282 uword stack_pos = Isolate::GetCurrentStackPointer(); | 1302 uword stack_pos = Isolate::GetCurrentStackPointer(); |
1283 #endif | 1303 #endif |
1284 // Always clear the stack overflow flags. They are meant for this | 1304 // Always clear the stack overflow flags. They are meant for this |
1285 // particular stack overflow runtime call and are not meant to | 1305 // particular stack overflow runtime call and are not meant to |
1286 // persist. | 1306 // persist. |
1287 uword stack_overflow_flags = isolate->GetAndClearStackOverflowFlags(); | 1307 uword stack_overflow_flags = isolate->GetAndClearStackOverflowFlags(); |
1288 | 1308 |
1289 // If an interrupt happens at the same time as a stack overflow, we | 1309 // If an interrupt happens at the same time as a stack overflow, we |
1290 // process the stack overflow now and leave the interrupt for next | 1310 // process the stack overflow now and leave the interrupt for next |
1291 // time. | 1311 // time. |
1292 if (stack_pos < isolate->saved_stack_limit()) { | 1312 if (IsCalleeFrameOf(isolate->saved_stack_limit(), stack_pos)) { |
1293 // Use the preallocated stack overflow exception to avoid calling | 1313 // Use the preallocated stack overflow exception to avoid calling |
1294 // into dart code. | 1314 // into dart code. |
1295 const Instance& exception = | 1315 const Instance& exception = |
1296 Instance::Handle(isolate->object_store()->stack_overflow()); | 1316 Instance::Handle(isolate->object_store()->stack_overflow()); |
1297 Exceptions::Throw(thread, exception); | 1317 Exceptions::Throw(thread, exception); |
1298 UNREACHABLE(); | 1318 UNREACHABLE(); |
1299 } | 1319 } |
1300 | 1320 |
1301 // The following code is used to stress test deoptimization and | 1321 // The following code is used to stress test deoptimization and |
1302 // debugger stack tracing. | 1322 // debugger stack tracing. |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1892 const intptr_t elm_size = old_data.ElementSizeInBytes(); | 1912 const intptr_t elm_size = old_data.ElementSizeInBytes(); |
1893 const TypedData& new_data = | 1913 const TypedData& new_data = |
1894 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); | 1914 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); |
1895 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); | 1915 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); |
1896 typed_data_cell.SetAt(0, new_data); | 1916 typed_data_cell.SetAt(0, new_data); |
1897 arguments.SetReturn(new_data); | 1917 arguments.SetReturn(new_data); |
1898 } | 1918 } |
1899 | 1919 |
1900 | 1920 |
1901 } // namespace dart | 1921 } // namespace dart |
OLD | NEW |