| 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)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 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 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { | 1893 void ParallelMoveResolver::Exchange(const Address& mem1, const Address& mem2) { |
| 1895 ScratchRegisterScope ensure_scratch1(this, kNoRegister); | 1894 ScratchRegisterScope ensure_scratch1(this, kNoRegister); |
| 1896 ScratchRegisterScope ensure_scratch2(this, ensure_scratch1.reg()); | 1895 ScratchRegisterScope ensure_scratch2(this, ensure_scratch1.reg()); |
| 1897 __ movl(ensure_scratch1.reg(), mem1); | 1896 __ movl(ensure_scratch1.reg(), mem1); |
| 1898 __ movl(ensure_scratch2.reg(), mem2); | 1897 __ movl(ensure_scratch2.reg(), mem2); |
| 1899 __ movl(mem2, ensure_scratch1.reg()); | 1898 __ movl(mem2, ensure_scratch1.reg()); |
| 1900 __ movl(mem1, ensure_scratch2.reg()); | 1899 __ movl(mem1, ensure_scratch2.reg()); |
| 1901 } | 1900 } |
| 1902 | 1901 |
| 1903 | 1902 |
| 1903 void ParallelMoveResolver::Exchange(Register reg, intptr_t stack_offset) { |
| 1904 UNREACHABLE(); |
| 1905 } |
| 1906 |
| 1907 |
| 1908 void ParallelMoveResolver::Exchange(intptr_t stack_offset1, |
| 1909 intptr_t stack_offset2) { |
| 1910 UNREACHABLE(); |
| 1911 } |
| 1912 |
| 1913 |
| 1904 void ParallelMoveResolver::SpillScratch(Register reg) { | 1914 void ParallelMoveResolver::SpillScratch(Register reg) { |
| 1905 __ pushl(reg); | 1915 __ pushl(reg); |
| 1906 } | 1916 } |
| 1907 | 1917 |
| 1908 | 1918 |
| 1909 void ParallelMoveResolver::RestoreScratch(Register reg) { | 1919 void ParallelMoveResolver::RestoreScratch(Register reg) { |
| 1910 __ popl(reg); | 1920 __ popl(reg); |
| 1911 } | 1921 } |
| 1912 | 1922 |
| 1913 | 1923 |
| 1914 void ParallelMoveResolver::SpillFpuScratch(FpuRegister reg) { | 1924 void ParallelMoveResolver::SpillFpuScratch(FpuRegister reg) { |
| 1915 __ subl(ESP, Immediate(kFpuRegisterSize)); | 1925 __ subl(ESP, Immediate(kFpuRegisterSize)); |
| 1916 __ movups(Address(ESP, 0), reg); | 1926 __ movups(Address(ESP, 0), reg); |
| 1917 } | 1927 } |
| 1918 | 1928 |
| 1919 | 1929 |
| 1920 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { | 1930 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { |
| 1921 __ movups(reg, Address(ESP, 0)); | 1931 __ movups(reg, Address(ESP, 0)); |
| 1922 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1932 __ addl(ESP, Immediate(kFpuRegisterSize)); |
| 1923 } | 1933 } |
| 1924 | 1934 |
| 1925 | 1935 |
| 1926 #undef __ | 1936 #undef __ |
| 1927 | 1937 |
| 1928 } // namespace dart | 1938 } // namespace dart |
| 1929 | 1939 |
| 1930 #endif // defined TARGET_ARCH_IA32 | 1940 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |