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/isolate.h" | 5 #include "vm/isolate.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 | 8 |
9 #include "vm/assert.h" | 9 #include "vm/assert.h" |
10 #include "vm/bigint_store.h" | 10 #include "vm/bigint_store.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 "Count function invocations and report."); | 30 "Count function invocations and report."); |
31 DECLARE_FLAG(bool, generate_gdb_symbols); | 31 DECLARE_FLAG(bool, generate_gdb_symbols); |
32 | 32 |
33 | 33 |
34 Isolate::Isolate() | 34 Isolate::Isolate() |
35 : store_buffer_(), | 35 : store_buffer_(), |
36 message_queue_(NULL), | 36 message_queue_(NULL), |
37 post_message_callback_(NULL), | 37 post_message_callback_(NULL), |
38 close_port_callback_(NULL), | 38 close_port_callback_(NULL), |
39 active_ports_(0), | 39 active_ports_(0), |
40 main_port_(0), | |
siva
2011/11/24 00:52:31
maybe -1 would be better value or we should have a
turnidge
2011/11/29 01:01:31
There is already an assert in PortMap::AllocatePor
| |
40 heap_(NULL), | 41 heap_(NULL), |
41 object_store_(NULL), | 42 object_store_(NULL), |
42 top_resource_(NULL), | 43 top_resource_(NULL), |
43 top_context_(Context::null()), | 44 top_context_(Context::null()), |
44 current_zone_(NULL), | 45 current_zone_(NULL), |
45 #if defined(DEBUG) | 46 #if defined(DEBUG) |
46 no_gc_scope_depth_(0), | 47 no_gc_scope_depth_(0), |
47 no_handle_scope_depth_(0), | 48 no_handle_scope_depth_(0), |
48 top_handle_scope_(NULL), | 49 top_handle_scope_(NULL), |
49 #endif | 50 #endif |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 // Setup the Dart API state. | 119 // Setup the Dart API state. |
119 ApiState* state = new ApiState(); | 120 ApiState* state = new ApiState(); |
120 ASSERT(state != NULL); | 121 ASSERT(state != NULL); |
121 result->set_api_state(state); | 122 result->set_api_state(state); |
122 | 123 |
123 // Initialize stack top and limit in case we are running the isolate in the | 124 // Initialize stack top and limit in case we are running the isolate in the |
124 // main thread. | 125 // main thread. |
125 // TODO(5411455): Need to figure out how to set the stack limit for the | 126 // TODO(5411455): Need to figure out how to set the stack limit for the |
126 // main thread. | 127 // main thread. |
127 result->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(&result)); | 128 result->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(&result)); |
129 result->set_main_port(PortMap::CreatePort()); | |
128 | 130 |
129 return result; | 131 return result; |
130 } | 132 } |
131 | 133 |
132 | 134 |
133 // TODO(5411455): Use flag to override default value and Validate the | 135 // TODO(5411455): Use flag to override default value and Validate the |
134 // stack size by querying OS. | 136 // stack size by querying OS. |
135 uword Isolate::GetSpecifiedStackSize() { | 137 uword Isolate::GetSpecifiedStackSize() { |
136 uword stack_size = Isolate::kDefaultStackSize - Isolate::kStackSizeBuffer; | 138 uword stack_size = Isolate::kDefaultStackSize - Isolate::kStackSizeBuffer; |
137 return stack_size; | 139 return stack_size; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 Dart_IsolateInitCallback Isolate::InitCallback() { | 236 Dart_IsolateInitCallback Isolate::InitCallback() { |
235 return init_callback_; | 237 return init_callback_; |
236 } | 238 } |
237 | 239 |
238 | 240 |
239 void Isolate::StandardRunLoop() { | 241 void Isolate::StandardRunLoop() { |
240 ASSERT(long_jump_base() != NULL); | 242 ASSERT(long_jump_base() != NULL); |
241 ASSERT(post_message_callback() == &StandardPostMessageCallback); | 243 ASSERT(post_message_callback() == &StandardPostMessageCallback); |
242 ASSERT(close_port_callback() == &StandardClosePortCallback); | 244 ASSERT(close_port_callback() == &StandardClosePortCallback); |
243 | 245 |
244 while (active_ports() > 0) { | 246 while (Dart_HasLivePorts()) { |
siva
2011/11/24 00:52:31
Seems pretty expensive to call a dart function fro
turnidge
2011/11/29 01:01:31
Now this uses live_ports() > 0.
| |
245 ASSERT(this == Isolate::Current()); | 247 ASSERT(this == Isolate::Current()); |
246 Zone zone(this); | 248 Zone zone(this); |
247 HandleScope handle_scope(this); | 249 HandleScope handle_scope(this); |
248 | 250 |
249 PortMessage* message = message_queue()->Dequeue(0); | 251 PortMessage* message = message_queue()->Dequeue(0); |
250 if (message != NULL) { | 252 if (message != NULL) { |
251 Dart_Handle result = Dart_HandleMessage( | 253 Dart_Handle result = Dart_HandleMessage( |
252 message->dest_port(), message->reply_port(), message->data()); | 254 message->dest_port(), message->reply_port(), message->data()); |
253 if (Dart_IsError(result)) { | 255 if (Dart_IsError(result)) { |
254 fprintf(stderr, "%s\n", Dart_GetError(result)); | 256 fprintf(stderr, "%s\n", Dart_GetError(result)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 // Visit all objects in the code index table. | 291 // Visit all objects in the code index table. |
290 if (code_index_table() != NULL) { | 292 if (code_index_table() != NULL) { |
291 code_index_table()->VisitObjectPointers(visitor); | 293 code_index_table()->VisitObjectPointers(visitor); |
292 } | 294 } |
293 | 295 |
294 // Visit the top context which is stored in the isolate. | 296 // Visit the top context which is stored in the isolate. |
295 visitor->VisitPointer(reinterpret_cast<RawObject**>(&top_context_)); | 297 visitor->VisitPointer(reinterpret_cast<RawObject**>(&top_context_)); |
296 } | 298 } |
297 | 299 |
298 } // namespace dart | 300 } // namespace dart |
OLD | NEW |