Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/code_index_table.h" | 7 #include "vm/code_index_table.h" |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| 11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
| 12 #include "vm/debugger.h" | 12 #include "vm/debugger.h" |
| 13 #include "vm/exceptions.h" | 13 #include "vm/exceptions.h" |
| 14 #include "vm/ic_data.h" | 14 #include "vm/ic_data.h" |
| 15 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
| 16 #include "vm/message.h" | |
| 16 #include "vm/resolver.h" | 17 #include "vm/resolver.h" |
| 17 #include "vm/runtime_entry.h" | 18 #include "vm/runtime_entry.h" |
| 18 #include "vm/stack_frame.h" | 19 #include "vm/stack_frame.h" |
| 19 #include "vm/verifier.h" | 20 #include "vm/verifier.h" |
| 20 | 21 |
| 21 namespace dart { | 22 namespace dart { |
| 22 | 23 |
| 23 DEFINE_FLAG(bool, inline_cache, true, "enable inline caches"); | 24 DEFINE_FLAG(bool, inline_cache, true, "enable inline caches"); |
| 24 DEFINE_FLAG(bool, trace_deopt, false, "Trace deoptimization"); | 25 DEFINE_FLAG(bool, trace_deopt, false, "Trace deoptimization"); |
| 25 DEFINE_FLAG(bool, trace_ic, false, "trace IC handling"); | 26 DEFINE_FLAG(bool, trace_ic, false, "trace IC handling"); |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 | 870 |
| 870 | 871 |
| 871 DEFINE_RUNTIME_ENTRY(ClosureArgumentMismatch, 0) { | 872 DEFINE_RUNTIME_ENTRY(ClosureArgumentMismatch, 0) { |
| 872 ASSERT(arguments.Count() == | 873 ASSERT(arguments.Count() == |
| 873 kClosureArgumentMismatchRuntimeEntry.argument_count()); | 874 kClosureArgumentMismatchRuntimeEntry.argument_count()); |
| 874 GrowableArray<const Object*> args; | 875 GrowableArray<const Object*> args; |
| 875 Exceptions::ThrowByType(Exceptions::kClosureArgumentMismatch, args); | 876 Exceptions::ThrowByType(Exceptions::kClosureArgumentMismatch, args); |
| 876 } | 877 } |
| 877 | 878 |
| 878 | 879 |
| 880 static RawInstance* DeserializeMessage(void* data) { | |
| 881 // Create a snapshot object using the buffer. | |
| 882 const Snapshot* snapshot = Snapshot::SetupFromBuffer(data); | |
| 883 ASSERT(snapshot->IsMessageSnapshot()); | |
| 884 | |
| 885 // Read object back from the snapshot. | |
| 886 SnapshotReader reader(snapshot, Isolate::Current()); | |
| 887 Instance& instance = Instance::Handle(); | |
| 888 instance ^= reader.ReadObject(); | |
|
siva
2012/02/18 01:25:55
Ditto comment about any object being send in these
| |
| 889 return instance.raw(); | |
| 890 } | |
|
siva
2012/02/18 01:25:55
This function is there in dart_api_impl.cc as well
turnidge
2012/03/07 20:00:14
Agreed. As the next part of the ThreadPool stuff
| |
| 891 | |
| 892 | |
| 893 | |
| 879 DEFINE_RUNTIME_ENTRY(StackOverflow, 0) { | 894 DEFINE_RUNTIME_ENTRY(StackOverflow, 0) { |
| 880 ASSERT(arguments.Count() == | 895 ASSERT(arguments.Count() == |
| 881 kStackOverflowRuntimeEntry.argument_count()); | 896 kStackOverflowRuntimeEntry.argument_count()); |
| 882 uword stack_pos = reinterpret_cast<uword>(&arguments); | 897 uword stack_pos = reinterpret_cast<uword>(&arguments); |
| 883 | 898 |
| 884 // If an interrupt happens at the same time as a stack overflow, we | 899 // If an interrupt happens at the same time as a stack overflow, we |
| 885 // process the stack overflow first. | 900 // process the stack overflow first. |
| 886 if (stack_pos < isolate->saved_stack_limit()) { | 901 if (stack_pos < isolate->saved_stack_limit()) { |
| 887 // Use the preallocated stack overflow exception to avoid calling | 902 // Use the preallocated stack overflow exception to avoid calling |
| 888 // into dart code. | 903 // into dart code. |
| 889 const Instance& exception = | 904 const Instance& exception = |
| 890 Instance::Handle(isolate->object_store()->stack_overflow()); | 905 Instance::Handle(isolate->object_store()->stack_overflow()); |
| 891 Exceptions::Throw(exception); | 906 Exceptions::Throw(exception); |
| 892 UNREACHABLE(); | 907 UNREACHABLE(); |
| 893 } | 908 } |
| 894 | 909 |
| 895 uword interrupt_bits = isolate->GetAndClearInterrupts(); | 910 uword interrupt_bits = isolate->GetAndClearInterrupts(); |
| 896 if (interrupt_bits & Isolate::kMessageInterrupt) { | 911 if (interrupt_bits & Isolate::kMessageInterrupt) { |
| 897 // UNIMPLEMENTED(); | 912 while (true) { |
| 913 Message* message = | |
| 914 isolate->message_handler()->queue()->DequeueNoWaitWithPriority( | |
| 915 Message::kOOBPriority); | |
|
siva
2012/02/18 01:25:55
Can one do a DNS style attack here just bombarding
turnidge
2012/03/07 20:00:14
You can only send OOB messages when you can alread
| |
| 916 if (message == NULL) { | |
| 917 // No more OOB messages to handle. | |
| 918 break; | |
| 919 } | |
| 920 const Instance& msg = | |
| 921 Instance::Handle(DeserializeMessage(message->data())); | |
| 922 // For now the only OOB messages are Mirrors messages. | |
| 923 const Object& result = Object::Handle( | |
| 924 DartLibraryCalls::HandleMirrorsMessage( | |
| 925 message->dest_port(), message->reply_port(), msg)); | |
| 926 delete message; | |
| 927 if (result.IsError()) { | |
| 928 // TODO(turnidge): Propagating the error is probably wrong here. | |
| 929 Exceptions::PropagateError(result); | |
| 930 } | |
| 931 ASSERT(result.IsNull()); | |
| 932 } | |
| 898 } | 933 } |
| 899 if (interrupt_bits & Isolate::kApiInterrupt) { | 934 if (interrupt_bits & Isolate::kApiInterrupt) { |
| 900 Dart_IsolateInterruptCallback callback = isolate->InterruptCallback(); | 935 Dart_IsolateInterruptCallback callback = isolate->InterruptCallback(); |
| 901 if (callback) { | 936 if (callback) { |
| 902 if ((*callback)()) { | 937 if ((*callback)()) { |
| 903 return; | 938 return; |
| 904 } else { | 939 } else { |
| 905 // TODO(turnidge): Unwind the stack. | 940 // TODO(turnidge): Unwind the stack. |
| 906 UNIMPLEMENTED(); | 941 UNIMPLEMENTED(); |
| 907 } | 942 } |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1125 } | 1160 } |
| 1126 } | 1161 } |
| 1127 } | 1162 } |
| 1128 // The cache is null terminated, therefore the loop above should never | 1163 // The cache is null terminated, therefore the loop above should never |
| 1129 // terminate by itself. | 1164 // terminate by itself. |
| 1130 UNREACHABLE(); | 1165 UNREACHABLE(); |
| 1131 return Code::null(); | 1166 return Code::null(); |
| 1132 } | 1167 } |
| 1133 | 1168 |
| 1134 } // namespace dart | 1169 } // namespace dart |
| OLD | NEW |