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

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

Issue 506933002: Keep track of stack base whenever Dart code is invoked. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/isolate.h" 5 #include "vm/isolate.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "platform/json.h" 9 #include "platform/json.h"
10 #include "vm/code_observers.h" 10 #include "vm/code_observers.h"
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 single_step_(false), 409 single_step_(false),
410 resume_request_(false), 410 resume_request_(false),
411 random_(), 411 random_(),
412 simulator_(NULL), 412 simulator_(NULL),
413 long_jump_base_(NULL), 413 long_jump_base_(NULL),
414 timer_list_(), 414 timer_list_(),
415 deopt_id_(0), 415 deopt_id_(0),
416 mutex_(new Mutex()), 416 mutex_(new Mutex()),
417 stack_limit_(0), 417 stack_limit_(0),
418 saved_stack_limit_(0), 418 saved_stack_limit_(0),
419 stack_base_(0),
419 stack_overflow_flags_(0), 420 stack_overflow_flags_(0),
420 stack_overflow_count_(0), 421 stack_overflow_count_(0),
421 message_handler_(NULL), 422 message_handler_(NULL),
422 spawn_state_(NULL), 423 spawn_state_(NULL),
423 is_runnable_(false), 424 is_runnable_(false),
424 gc_prologue_callback_(NULL), 425 gc_prologue_callback_(NULL),
425 gc_epilogue_callback_(NULL), 426 gc_epilogue_callback_(NULL),
426 defer_finalization_count_(0), 427 defer_finalization_count_(0),
427 deopt_context_(NULL), 428 deopt_context_(NULL),
428 stacktrace_(NULL), 429 stacktrace_(NULL),
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 595
595 // Setup the Dart API state. 596 // Setup the Dart API state.
596 ApiState* state = new ApiState(); 597 ApiState* state = new ApiState();
597 ASSERT(state != NULL); 598 ASSERT(state != NULL);
598 result->set_api_state(state); 599 result->set_api_state(state);
599 600
600 // Initialize stack top and limit in case we are running the isolate in the 601 // Initialize stack top and limit in case we are running the isolate in the
601 // main thread. 602 // main thread.
602 // TODO(5411455): Need to figure out how to set the stack limit for the 603 // TODO(5411455): Need to figure out how to set the stack limit for the
603 // main thread. 604 // main thread.
604 result->SetStackLimitFromCurrentTOS(reinterpret_cast<uword>(&result)); 605 result->SetStackLimitFromStackBase(reinterpret_cast<uword>(&result));
605 result->set_main_port(PortMap::CreatePort(result->message_handler())); 606 result->set_main_port(PortMap::CreatePort(result->message_handler()));
606 result->set_pause_capability(result->random()->NextUInt64()); 607 result->set_pause_capability(result->random()->NextUInt64());
607 result->set_terminate_capability(result->random()->NextUInt64()); 608 result->set_terminate_capability(result->random()->NextUInt64());
608 609
609 result->BuildName(name_prefix); 610 result->BuildName(name_prefix);
610 611
611 result->debugger_ = new Debugger(); 612 result->debugger_ = new Debugger();
612 result->debugger_->Initialize(result); 613 result->debugger_->Initialize(result);
613 if (FLAG_trace_isolates) { 614 if (FLAG_trace_isolates) {
614 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) { 615 if (name_prefix == NULL || strcmp(name_prefix, "vm-isolate") != 0) {
(...skipping 20 matching lines...) Expand all
635 636
636 // TODO(5411455): Use flag to override default value and Validate the 637 // TODO(5411455): Use flag to override default value and Validate the
637 // stack size by querying OS. 638 // stack size by querying OS.
638 uword Isolate::GetSpecifiedStackSize() { 639 uword Isolate::GetSpecifiedStackSize() {
639 ASSERT(Isolate::kStackSizeBuffer < Thread::GetMaxStackSize()); 640 ASSERT(Isolate::kStackSizeBuffer < Thread::GetMaxStackSize());
640 uword stack_size = Thread::GetMaxStackSize() - Isolate::kStackSizeBuffer; 641 uword stack_size = Thread::GetMaxStackSize() - Isolate::kStackSizeBuffer;
641 return stack_size; 642 return stack_size;
642 } 643 }
643 644
644 645
645 void Isolate::SetStackLimitFromCurrentTOS(uword stack_top_value) { 646 void Isolate::SetStackLimitFromStackBase(uword stack_base) {
646 #if defined(USING_SIMULATOR) 647 #if defined(USING_SIMULATOR)
647 // Ignore passed-in native stack top and use Simulator stack top. 648 // Ignore passed-in native stack top and use Simulator stack top.
648 Simulator* sim = Simulator::Current(); // May allocate a simulator. 649 Simulator* sim = Simulator::Current(); // May allocate a simulator.
649 ASSERT(simulator() == sim); // This isolate's simulator is the current one. 650 ASSERT(simulator() == sim); // This isolate's simulator is the current one.
650 stack_top_value = sim->StackTop(); 651 stack_base = sim->StackTop();
651 // The overflow area is accounted for by the simulator. 652 // The overflow area is accounted for by the simulator.
652 #endif 653 #endif
653 SetStackLimit(stack_top_value - GetSpecifiedStackSize()); 654 // Set stack base.
655 stack_base_ = stack_base;
656 // Set stack limit.
657 SetStackLimit(stack_base_ - GetSpecifiedStackSize());
654 } 658 }
655 659
656 660
657 void Isolate::SetStackLimit(uword limit) { 661 void Isolate::SetStackLimit(uword limit) {
658 // The isolate setting the stack limit is not necessarily the isolate which 662 // The isolate setting the stack limit is not necessarily the isolate which
659 // the stack limit is being set on. 663 // the stack limit is being set on.
660 MutexLocker ml(mutex_); 664 MutexLocker ml(mutex_);
661 if (stack_limit_ == saved_stack_limit_) { 665 if (stack_limit_ == saved_stack_limit_) {
662 // No interrupt pending, set stack_limit_ too. 666 // No interrupt pending, set stack_limit_ too.
663 stack_limit_ = limit; 667 stack_limit_ = limit;
664 } 668 }
665 saved_stack_limit_ = limit; 669 saved_stack_limit_ = limit;
666 } 670 }
667 671
668 672
669 bool Isolate::GetStackBounds(uword* lower, uword* upper) { 673 void Isolate::ClearStackLimit() {
674 SetStackLimit(~static_cast<uword>(0));
675 stack_base_ = 0;
676 }
677
678
679 bool Isolate::GetProfilerStackBounds(uword* lower, uword* upper) const {
670 uword stack_lower = stack_limit(); 680 uword stack_lower = stack_limit();
671 if (stack_lower == kUwordMax) { 681 if (stack_lower == kUwordMax) {
672 stack_lower = saved_stack_limit(); 682 stack_lower = saved_stack_limit();
673 } 683 }
674 if (stack_lower == kUwordMax) { 684 if (stack_lower == kUwordMax) {
675 return false; 685 return false;
676 } 686 }
677 uword stack_upper = stack_lower + GetSpecifiedStackSize(); 687 uword stack_upper = stack_lower + GetSpecifiedStackSize();
678 *lower = stack_lower; 688 *lower = stack_lower;
679 *upper = stack_upper; 689 *upper = stack_upper;
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 serialized_message_, serialized_message_len_); 1542 serialized_message_, serialized_message_len_);
1533 } 1543 }
1534 1544
1535 1545
1536 void IsolateSpawnState::Cleanup() { 1546 void IsolateSpawnState::Cleanup() {
1537 SwitchIsolateScope switch_scope(I); 1547 SwitchIsolateScope switch_scope(I);
1538 Dart::ShutdownIsolate(); 1548 Dart::ShutdownIsolate();
1539 } 1549 }
1540 1550
1541 } // namespace dart 1551 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698