OLD | NEW |
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/globals.h" // Needed here to get TARGET_ARCH_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 2565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2576 } | 2576 } |
2577 | 2577 |
2578 | 2578 |
2579 class CheckStackOverflowSlowPath : public SlowPathCode { | 2579 class CheckStackOverflowSlowPath : public SlowPathCode { |
2580 public: | 2580 public: |
2581 explicit CheckStackOverflowSlowPath(CheckStackOverflowInstr* instruction) | 2581 explicit CheckStackOverflowSlowPath(CheckStackOverflowInstr* instruction) |
2582 : instruction_(instruction) { } | 2582 : instruction_(instruction) { } |
2583 | 2583 |
2584 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | 2584 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
2585 if (FLAG_use_osr && osr_entry_label()->IsLinked()) { | 2585 if (FLAG_use_osr && osr_entry_label()->IsLinked()) { |
2586 uword flags_address = Isolate::Current()->stack_overflow_flags_address(); | |
2587 __ Comment("CheckStackOverflowSlowPathOsr"); | 2586 __ Comment("CheckStackOverflowSlowPathOsr"); |
2588 __ Bind(osr_entry_label()); | 2587 __ Bind(osr_entry_label()); |
2589 __ movl(Address::Absolute(flags_address), | 2588 __ movl(Address(THR, Thread::stack_overflow_flags_offset()), |
2590 Immediate(Isolate::kOsrRequest)); | 2589 Immediate(Thread::kOsrRequest)); |
2591 } | 2590 } |
2592 __ Comment("CheckStackOverflowSlowPath"); | 2591 __ Comment("CheckStackOverflowSlowPath"); |
2593 __ Bind(entry_label()); | 2592 __ Bind(entry_label()); |
2594 compiler->SaveLiveRegisters(instruction_->locs()); | 2593 compiler->SaveLiveRegisters(instruction_->locs()); |
2595 // pending_deoptimization_env_ is needed to generate a runtime call that | 2594 // pending_deoptimization_env_ is needed to generate a runtime call that |
2596 // may throw an exception. | 2595 // may throw an exception. |
2597 ASSERT(compiler->pending_deoptimization_env_ == NULL); | 2596 ASSERT(compiler->pending_deoptimization_env_ == NULL); |
2598 Environment* env = compiler->SlowPathEnvironmentFor(instruction_); | 2597 Environment* env = compiler->SlowPathEnvironmentFor(instruction_); |
2599 compiler->pending_deoptimization_env_ = env; | 2598 compiler->pending_deoptimization_env_ = env; |
2600 compiler->GenerateRuntimeCall(instruction_->token_pos(), | 2599 compiler->GenerateRuntimeCall(instruction_->token_pos(), |
(...skipping 21 matching lines...) Expand all Loading... |
2622 private: | 2621 private: |
2623 CheckStackOverflowInstr* instruction_; | 2622 CheckStackOverflowInstr* instruction_; |
2624 Label osr_entry_label_; | 2623 Label osr_entry_label_; |
2625 }; | 2624 }; |
2626 | 2625 |
2627 | 2626 |
2628 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2627 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2629 CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this); | 2628 CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this); |
2630 compiler->AddSlowPathCode(slow_path); | 2629 compiler->AddSlowPathCode(slow_path); |
2631 | 2630 |
2632 if (compiler->is_optimizing()) { | 2631 __ cmpl(ESP, Address(THR, Thread::stack_limit_offset())); |
2633 __ cmpl(ESP, Address::Absolute(Isolate::Current()->stack_limit_address())); | |
2634 } else { | |
2635 Register tmp = locs()->temp(0).reg(); | |
2636 __ LoadIsolate(tmp); | |
2637 __ cmpl(ESP, Address(tmp, Isolate::stack_limit_offset())); | |
2638 } | |
2639 __ j(BELOW_EQUAL, slow_path->entry_label()); | 2632 __ j(BELOW_EQUAL, slow_path->entry_label()); |
2640 if (compiler->CanOSRFunction() && in_loop()) { | 2633 if (compiler->CanOSRFunction() && in_loop()) { |
2641 // In unoptimized code check the usage counter to trigger OSR at loop | 2634 // In unoptimized code check the usage counter to trigger OSR at loop |
2642 // stack checks. Use progressively higher thresholds for more deeply | 2635 // stack checks. Use progressively higher thresholds for more deeply |
2643 // nested loops to attempt to hit outer loops with OSR when possible. | 2636 // nested loops to attempt to hit outer loops with OSR when possible. |
2644 __ LoadObject(EDI, compiler->parsed_function().function()); | 2637 __ LoadObject(EDI, compiler->parsed_function().function()); |
2645 intptr_t threshold = | 2638 intptr_t threshold = |
2646 FLAG_optimization_counter_threshold * (loop_depth() + 1); | 2639 FLAG_optimization_counter_threshold * (loop_depth() + 1); |
2647 __ cmpl(FieldAddress(EDI, Function::usage_counter_offset()), | 2640 __ cmpl(FieldAddress(EDI, Function::usage_counter_offset()), |
2648 Immediate(threshold)); | 2641 Immediate(threshold)); |
(...skipping 4200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6849 __ Drop(1); | 6842 __ Drop(1); |
6850 __ popl(result); | 6843 __ popl(result); |
6851 } | 6844 } |
6852 | 6845 |
6853 | 6846 |
6854 } // namespace dart | 6847 } // namespace dart |
6855 | 6848 |
6856 #undef __ | 6849 #undef __ |
6857 | 6850 |
6858 #endif // defined TARGET_ARCH_IA32 | 6851 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |