Chromium Code Reviews| 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/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 749 } | 749 } |
| 750 AllocateRegistersLocally(instr); | 750 AllocateRegistersLocally(instr); |
| 751 } else if (instr->MayThrow() && | 751 } else if (instr->MayThrow() && |
| 752 (CurrentTryIndex() != CatchClauseNode::kInvalidTryIndex)) { | 752 (CurrentTryIndex() != CatchClauseNode::kInvalidTryIndex)) { |
| 753 // Optimized try-block: Sync locals to fixed stack locations. | 753 // Optimized try-block: Sync locals to fixed stack locations. |
| 754 EmitTrySync(instr, CurrentTryIndex()); | 754 EmitTrySync(instr, CurrentTryIndex()); |
| 755 } | 755 } |
| 756 } | 756 } |
| 757 | 757 |
| 758 | 758 |
| 759 void FlowGraphCompiler::EmitTrySyncMove(Address dest, | 759 void FlowGraphCompiler::EmitTrySyncMove(intptr_t dest_offset, |
| 760 Location loc, | 760 Location loc, |
| 761 bool* push_emitted) { | 761 bool* push_emitted) { |
| 762 const Address dest(EBP, dest_offset); | |
| 762 if (loc.IsConstant()) { | 763 if (loc.IsConstant()) { |
| 763 if (!*push_emitted) { | 764 if (!*push_emitted) { |
| 764 __ pushl(EAX); | 765 __ pushl(EAX); |
| 765 *push_emitted = true; | 766 *push_emitted = true; |
| 766 } | 767 } |
| 767 __ LoadObject(EAX, loc.constant()); | 768 __ LoadObject(EAX, loc.constant()); |
| 768 __ movl(dest, EAX); | 769 __ movl(dest, EAX); |
| 769 } else if (loc.IsRegister()) { | 770 } else if (loc.IsRegister()) { |
| 770 if (*push_emitted && loc.reg() == EAX) { | 771 if (*push_emitted && loc.reg() == EAX) { |
| 771 __ movl(EAX, Address(ESP, 0)); | 772 __ movl(EAX, Address(ESP, 0)); |
| 772 __ movl(dest, EAX); | 773 __ movl(dest, EAX); |
| 773 } else { | 774 } else { |
| 774 __ movl(dest, loc.reg()); | 775 __ movl(dest, loc.reg()); |
| 775 } | 776 } |
| 776 } else { | 777 } else { |
| 777 Address src = loc.ToStackSlotAddress(); | 778 Address src = loc.ToStackSlotAddress(); |
| 778 if (!src.Equals(dest)) { | 779 if (!src.Equals(dest)) { |
|
regis
2013/07/17 18:46:45
I guess Equals can remain on Intel, or you compare
zra
2013/07/17 20:40:11
I have left Equals here, but I think this is the o
| |
| 779 if (!*push_emitted) { | 780 if (!*push_emitted) { |
| 780 __ pushl(EAX); | 781 __ pushl(EAX); |
| 781 *push_emitted = true; | 782 *push_emitted = true; |
| 782 } | 783 } |
| 783 __ movl(EAX, src); | 784 __ movl(EAX, src); |
| 784 __ movl(dest, EAX); | 785 __ movl(dest, EAX); |
| 785 } | 786 } |
| 786 } | 787 } |
| 787 } | 788 } |
| 788 | 789 |
| 789 | 790 |
| 790 void FlowGraphCompiler::EmitTrySync(Instruction* instr, intptr_t try_index) { | 791 void FlowGraphCompiler::EmitTrySync(Instruction* instr, intptr_t try_index) { |
| 791 ASSERT(is_optimizing()); | 792 ASSERT(is_optimizing()); |
| 792 Environment* env = instr->env(); | 793 Environment* env = instr->env(); |
| 793 CatchBlockEntryInstr* catch_block = | 794 CatchBlockEntryInstr* catch_block = |
| 794 flow_graph().graph_entry()->GetCatchEntry(try_index); | 795 flow_graph().graph_entry()->GetCatchEntry(try_index); |
| 795 const GrowableArray<Definition*>* idefs = catch_block->initial_definitions(); | 796 const GrowableArray<Definition*>* idefs = catch_block->initial_definitions(); |
| 796 // Parameters. | 797 // Parameters. |
| 797 intptr_t i = 0; | 798 intptr_t i = 0; |
| 798 bool push_emitted = false; | 799 bool push_emitted = false; |
| 799 const intptr_t num_non_copied_params = flow_graph().num_non_copied_params(); | 800 const intptr_t num_non_copied_params = flow_graph().num_non_copied_params(); |
| 800 const intptr_t param_base = | 801 const intptr_t param_base = |
| 801 kParamEndSlotFromFp + num_non_copied_params; | 802 kParamEndSlotFromFp + num_non_copied_params; |
| 802 for (; i < num_non_copied_params; ++i) { | 803 for (; i < num_non_copied_params; ++i) { |
| 803 if ((*idefs)[i]->IsConstant()) continue; // Common constants | 804 if ((*idefs)[i]->IsConstant()) continue; // Common constants |
| 804 Location loc = env->LocationAt(i); | 805 Location loc = env->LocationAt(i); |
| 805 Address dest(EBP, (param_base - i) * kWordSize); | 806 EmitTrySyncMove((param_base - i) * kWordSize, loc, &push_emitted); |
| 806 EmitTrySyncMove(dest, loc, &push_emitted); | |
| 807 } | 807 } |
| 808 | 808 |
| 809 // Process locals. Skip exception_var and stacktrace_var. | 809 // Process locals. Skip exception_var and stacktrace_var. |
| 810 CatchEntryInstr* catch_entry = catch_block->next()->AsCatchEntry(); | 810 CatchEntryInstr* catch_entry = catch_block->next()->AsCatchEntry(); |
| 811 intptr_t local_base = kFirstLocalSlotFromFp + num_non_copied_params; | 811 intptr_t local_base = kFirstLocalSlotFromFp + num_non_copied_params; |
| 812 intptr_t ex_idx = local_base - catch_entry->exception_var().index(); | 812 intptr_t ex_idx = local_base - catch_entry->exception_var().index(); |
| 813 intptr_t st_idx = local_base - catch_entry->stacktrace_var().index(); | 813 intptr_t st_idx = local_base - catch_entry->stacktrace_var().index(); |
| 814 for (; i < flow_graph().variable_count(); ++i) { | 814 for (; i < flow_graph().variable_count(); ++i) { |
| 815 if (i == ex_idx || i == st_idx) continue; | 815 if (i == ex_idx || i == st_idx) continue; |
| 816 if ((*idefs)[i]->IsConstant()) continue; | 816 if ((*idefs)[i]->IsConstant()) continue; |
| 817 Location loc = env->LocationAt(i); | 817 Location loc = env->LocationAt(i); |
| 818 Address dest(EBP, (local_base - i) * kWordSize); | 818 EmitTrySyncMove((local_base - i) * kWordSize, loc, &push_emitted); |
| 819 EmitTrySyncMove(dest, loc, &push_emitted); | |
| 820 // Update safepoint bitmap to indicate that the target location | 819 // Update safepoint bitmap to indicate that the target location |
| 821 // now contains a pointer. | 820 // now contains a pointer. |
| 822 instr->locs()->stack_bitmap()->Set(i - num_non_copied_params, true); | 821 instr->locs()->stack_bitmap()->Set(i - num_non_copied_params, true); |
| 823 } | 822 } |
| 824 if (push_emitted) { | 823 if (push_emitted) { |
| 825 __ popl(EAX); | 824 __ popl(EAX); |
| 826 } | 825 } |
| 827 } | 826 } |
| 828 | 827 |
| 829 | 828 |
| (...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1921 __ movups(reg, Address(ESP, 0)); | 1920 __ movups(reg, Address(ESP, 0)); |
| 1922 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1921 __ addl(ESP, Immediate(kFpuRegisterSize)); |
| 1923 } | 1922 } |
| 1924 | 1923 |
| 1925 | 1924 |
| 1926 #undef __ | 1925 #undef __ |
| 1927 | 1926 |
| 1928 } // namespace dart | 1927 } // namespace dart |
| 1929 | 1928 |
| 1930 #endif // defined TARGET_ARCH_IA32 | 1929 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |