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

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

Issue 9924015: Use the ThreadPool for all isolates and native ports. Previously, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/message.h"
16 #include "vm/message_handler.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 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 1101
1101 1102
1102 DEFINE_RUNTIME_ENTRY(ClosureArgumentMismatch, 0) { 1103 DEFINE_RUNTIME_ENTRY(ClosureArgumentMismatch, 0) {
1103 ASSERT(arguments.Count() == 1104 ASSERT(arguments.Count() ==
1104 kClosureArgumentMismatchRuntimeEntry.argument_count()); 1105 kClosureArgumentMismatchRuntimeEntry.argument_count());
1105 GrowableArray<const Object*> args; 1106 GrowableArray<const Object*> args;
1106 Exceptions::ThrowByType(Exceptions::kClosureArgumentMismatch, args); 1107 Exceptions::ThrowByType(Exceptions::kClosureArgumentMismatch, args);
1107 } 1108 }
1108 1109
1109 1110
1110 static RawInstance* DeserializeMessage(void* data) {
1111 // Create a snapshot object using the buffer.
1112 const Snapshot* snapshot = Snapshot::SetupFromBuffer(data);
1113 ASSERT(snapshot->IsMessageSnapshot());
1114
1115 // Read object back from the snapshot.
1116 SnapshotReader reader(snapshot, Isolate::Current());
1117 Instance& instance = Instance::Handle();
1118 instance ^= reader.ReadObject();
1119 return instance.raw();
1120 }
1121
1122
1123
1124 DEFINE_RUNTIME_ENTRY(StackOverflow, 0) { 1111 DEFINE_RUNTIME_ENTRY(StackOverflow, 0) {
1125 ASSERT(arguments.Count() == 1112 ASSERT(arguments.Count() ==
1126 kStackOverflowRuntimeEntry.argument_count()); 1113 kStackOverflowRuntimeEntry.argument_count());
1127 uword stack_pos = reinterpret_cast<uword>(&arguments); 1114 uword stack_pos = reinterpret_cast<uword>(&arguments);
1128 1115
1129 // If an interrupt happens at the same time as a stack overflow, we 1116 // If an interrupt happens at the same time as a stack overflow, we
1130 // process the stack overflow first. 1117 // process the stack overflow first.
1131 if (stack_pos < isolate->saved_stack_limit()) { 1118 if (stack_pos < isolate->saved_stack_limit()) {
1132 // Use the preallocated stack overflow exception to avoid calling 1119 // Use the preallocated stack overflow exception to avoid calling
1133 // into dart code. 1120 // into dart code.
1134 const Instance& exception = 1121 const Instance& exception =
1135 Instance::Handle(isolate->object_store()->stack_overflow()); 1122 Instance::Handle(isolate->object_store()->stack_overflow());
1136 Exceptions::Throw(exception); 1123 Exceptions::Throw(exception);
1137 UNREACHABLE(); 1124 UNREACHABLE();
1138 } 1125 }
1139 1126
1140 uword interrupt_bits = isolate->GetAndClearInterrupts(); 1127 uword interrupt_bits = isolate->GetAndClearInterrupts();
1141 if (interrupt_bits & Isolate::kMessageInterrupt) { 1128 if (interrupt_bits & Isolate::kMessageInterrupt) {
1142 while (true) { 1129 isolate->message_handler()->HandleOOBMessages();
1143 // TODO(turnidge): This code is duplicated elsewhere. Consolidate.
1144 Message* message =
1145 isolate->message_handler()->queue()->DequeueNoWaitWithPriority(
1146 Message::kOOBPriority);
1147 if (message == NULL) {
1148 // No more OOB messages to handle.
1149 break;
1150 }
1151 const Instance& msg =
1152 Instance::Handle(DeserializeMessage(message->data()));
1153 // For now the only OOB messages are Mirrors messages.
1154 const Object& result = Object::Handle(
1155 DartLibraryCalls::HandleMirrorsMessage(
1156 message->dest_port(), message->reply_port(), msg));
1157 delete message;
1158 if (result.IsError()) {
1159 // TODO(turnidge): Propagating the error is probably wrong here.
1160 Exceptions::PropagateError(result);
1161 }
1162 ASSERT(result.IsNull());
1163 }
1164 } 1130 }
1165 if (interrupt_bits & Isolate::kApiInterrupt) { 1131 if (interrupt_bits & Isolate::kApiInterrupt) {
1166 Dart_IsolateInterruptCallback callback = isolate->InterruptCallback(); 1132 Dart_IsolateInterruptCallback callback = isolate->InterruptCallback();
1167 if (callback) { 1133 if (callback) {
1168 if ((*callback)()) { 1134 if ((*callback)()) {
1169 return; 1135 return;
1170 } else { 1136 } else {
1171 // TODO(turnidge): Unwind the stack. 1137 // TODO(turnidge): Unwind the stack.
1172 UNIMPLEMENTED(); 1138 UNIMPLEMENTED();
1173 } 1139 }
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 } 1379 }
1414 } 1380 }
1415 } 1381 }
1416 // The cache is null terminated, therefore the loop above should never 1382 // The cache is null terminated, therefore the loop above should never
1417 // terminate by itself. 1383 // terminate by itself.
1418 UNREACHABLE(); 1384 UNREACHABLE();
1419 return Code::null(); 1385 return Code::null();
1420 } 1386 }
1421 1387
1422 } // namespace dart 1388 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/isolate.cc ('k') | runtime/vm/dart.h » ('j') | runtime/vm/isolate.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698