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

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

Issue 9420038: Heartbeat implementation of dart:mirrors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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
OLDNEW
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/object_store.h" 14 #include "vm/object_store.h"
15 #include "vm/message.h"
15 #include "vm/resolver.h" 16 #include "vm/resolver.h"
16 #include "vm/runtime_entry.h" 17 #include "vm/runtime_entry.h"
17 #include "vm/stack_frame.h" 18 #include "vm/stack_frame.h"
18 #include "vm/verifier.h" 19 #include "vm/verifier.h"
19 20
20 namespace dart { 21 namespace dart {
21 22
22 DEFINE_FLAG(bool, inline_cache, true, "enable inline caches"); 23 DEFINE_FLAG(bool, inline_cache, true, "enable inline caches");
23 DEFINE_FLAG(bool, trace_deopt, false, "Trace deoptimization"); 24 DEFINE_FLAG(bool, trace_deopt, false, "Trace deoptimization");
24 DEFINE_FLAG(bool, trace_ic, false, "trace IC handling"); 25 DEFINE_FLAG(bool, trace_ic, false, "trace IC handling");
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 1121
1121 1122
1122 DEFINE_RUNTIME_ENTRY(ClosureArgumentMismatch, 0) { 1123 DEFINE_RUNTIME_ENTRY(ClosureArgumentMismatch, 0) {
1123 ASSERT(arguments.Count() == 1124 ASSERT(arguments.Count() ==
1124 kClosureArgumentMismatchRuntimeEntry.argument_count()); 1125 kClosureArgumentMismatchRuntimeEntry.argument_count());
1125 GrowableArray<const Object*> args; 1126 GrowableArray<const Object*> args;
1126 Exceptions::ThrowByType(Exceptions::kClosureArgumentMismatch, args); 1127 Exceptions::ThrowByType(Exceptions::kClosureArgumentMismatch, args);
1127 } 1128 }
1128 1129
1129 1130
1131 static RawInstance* DeserializeMessage(void* data) {
1132 // Create a snapshot object using the buffer.
1133 const Snapshot* snapshot = Snapshot::SetupFromBuffer(data);
1134 ASSERT(snapshot->IsMessageSnapshot());
1135
1136 // Read object back from the snapshot.
1137 SnapshotReader reader(snapshot, Isolate::Current());
1138 Instance& instance = Instance::Handle();
1139 instance ^= reader.ReadObject();
1140 return instance.raw();
1141 }
1142
1143
1144
1130 DEFINE_RUNTIME_ENTRY(StackOverflow, 0) { 1145 DEFINE_RUNTIME_ENTRY(StackOverflow, 0) {
1131 ASSERT(arguments.Count() == 1146 ASSERT(arguments.Count() ==
1132 kStackOverflowRuntimeEntry.argument_count()); 1147 kStackOverflowRuntimeEntry.argument_count());
1133 uword stack_pos = reinterpret_cast<uword>(&arguments); 1148 uword stack_pos = reinterpret_cast<uword>(&arguments);
1134 1149
1135 // If an interrupt happens at the same time as a stack overflow, we 1150 // If an interrupt happens at the same time as a stack overflow, we
1136 // process the stack overflow first. 1151 // process the stack overflow first.
1137 if (stack_pos < isolate->saved_stack_limit()) { 1152 if (stack_pos < isolate->saved_stack_limit()) {
1138 // Use the preallocated stack overflow exception to avoid calling 1153 // Use the preallocated stack overflow exception to avoid calling
1139 // into dart code. 1154 // into dart code.
1140 const Instance& exception = 1155 const Instance& exception =
1141 Instance::Handle(isolate->object_store()->stack_overflow()); 1156 Instance::Handle(isolate->object_store()->stack_overflow());
1142 Exceptions::Throw(exception); 1157 Exceptions::Throw(exception);
1143 UNREACHABLE(); 1158 UNREACHABLE();
1144 } 1159 }
1145 1160
1146 uword interrupt_bits = isolate->GetAndClearInterrupts(); 1161 uword interrupt_bits = isolate->GetAndClearInterrupts();
1147 if (interrupt_bits & Isolate::kMessageInterrupt) { 1162 if (interrupt_bits & Isolate::kMessageInterrupt) {
1148 // UNIMPLEMENTED(); 1163 while (true) {
1164 Message* message =
1165 isolate->message_handler()->queue()->DequeueNoWaitWithPriority(
1166 Message::kOOBPriority);
1167 if (message == NULL) {
1168 // No more OOB messages to handle.
1169 break;
1170 }
1171 const Instance& msg =
1172 Instance::Handle(DeserializeMessage(message->data()));
1173 // For now the only OOB messages are Mirrors messages.
1174 const Object& result = Object::Handle(
1175 DartLibraryCalls::HandleMirrorsMessage(
1176 message->dest_port(), message->reply_port(), msg));
1177 delete message;
1178 if (result.IsError()) {
1179 // TODO(turnidge): Propagating the error is probably wrong here.
1180 Exceptions::PropagateError(result);
1181 }
1182 ASSERT(result.IsNull());
1183 }
1149 } 1184 }
1150 if (interrupt_bits & Isolate::kApiInterrupt) { 1185 if (interrupt_bits & Isolate::kApiInterrupt) {
1151 Dart_IsolateInterruptCallback callback = isolate->InterruptCallback(); 1186 Dart_IsolateInterruptCallback callback = isolate->InterruptCallback();
1152 if (callback) { 1187 if (callback) {
1153 if ((*callback)()) { 1188 if ((*callback)()) {
1154 return; 1189 return;
1155 } else { 1190 } else {
1156 // TODO(turnidge): Unwind the stack. 1191 // TODO(turnidge): Unwind the stack.
1157 UNIMPLEMENTED(); 1192 UNIMPLEMENTED();
1158 } 1193 }
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 } 1427 }
1393 } 1428 }
1394 } 1429 }
1395 // The cache is null terminated, therefore the loop above should never 1430 // The cache is null terminated, therefore the loop above should never
1396 // terminate by itself. 1431 // terminate by itself.
1397 UNREACHABLE(); 1432 UNREACHABLE();
1398 return Code::null(); 1433 return Code::null();
1399 } 1434 }
1400 1435
1401 } // namespace dart 1436 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698