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

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

Issue 2388093003: VM: Make optimized try-catch work in DBC. (Closed)
Patch Set: address comments Created 4 years, 2 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
« no previous file with comments | « runtime/vm/flow_graph_allocator.cc ('k') | runtime/vm/flow_graph_compiler_dbc.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/globals.h" // Needed here to get TARGET_ARCH_XXX. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX.
6 6
7 #include "vm/flow_graph_compiler.h" 7 #include "vm/flow_graph_compiler.h"
8 8
9 #include "vm/bit_vector.h" 9 #include "vm/bit_vector.h"
10 #include "vm/cha.h" 10 #include "vm/cha.h"
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 663
664 // Parameters first. 664 // Parameters first.
665 intptr_t i = 0; 665 intptr_t i = 0;
666 const intptr_t num_non_copied_params = flow_graph().num_non_copied_params(); 666 const intptr_t num_non_copied_params = flow_graph().num_non_copied_params();
667 ParallelMoveInstr* move_instr = new(zone()) ParallelMoveInstr(); 667 ParallelMoveInstr* move_instr = new(zone()) ParallelMoveInstr();
668 for (; i < num_non_copied_params; ++i) { 668 for (; i < num_non_copied_params; ++i) {
669 // Don't sync captured parameters. They are not in the environment. 669 // Don't sync captured parameters. They are not in the environment.
670 if (flow_graph().captured_parameters()->Contains(i)) continue; 670 if (flow_graph().captured_parameters()->Contains(i)) continue;
671 if ((*idefs)[i]->IsConstant()) continue; // Common constants 671 if ((*idefs)[i]->IsConstant()) continue; // Common constants
672 Location src = env->LocationAt(i); 672 Location src = env->LocationAt(i);
673 #if defined(TARGET_ARCH_DBC)
674 intptr_t dest_index = kNumberOfCpuRegisters - 1 - i;
675 Location dest = Location::RegisterLocation(dest_index);
676 // Update safepoint bitmap to indicate that the target location
677 // now contains a pointer. With DBC parameters are copied into
678 // the locals area.
679 instr->locs()->SetStackBit(dest_index);
680 #else
673 intptr_t dest_index = i - num_non_copied_params; 681 intptr_t dest_index = i - num_non_copied_params;
674 Location dest = Location::StackSlot(dest_index); 682 Location dest = Location::StackSlot(dest_index);
683 #endif
675 move_instr->AddMove(dest, src); 684 move_instr->AddMove(dest, src);
676 } 685 }
677 686
678 // Process locals. Skip exception_var and stacktrace_var. 687 // Process locals. Skip exception_var and stacktrace_var.
679 intptr_t local_base = kFirstLocalSlotFromFp + num_non_copied_params; 688 intptr_t local_base = kFirstLocalSlotFromFp + num_non_copied_params;
680 intptr_t ex_idx = local_base - catch_block->exception_var().index(); 689 intptr_t ex_idx = local_base - catch_block->exception_var().index();
681 intptr_t st_idx = local_base - catch_block->stacktrace_var().index(); 690 intptr_t st_idx = local_base - catch_block->stacktrace_var().index();
682 for (; i < flow_graph().variable_count(); ++i) { 691 for (; i < flow_graph().variable_count(); ++i) {
683 // Don't sync captured parameters. They are not in the environment. 692 // Don't sync captured parameters. They are not in the environment.
684 if (flow_graph().captured_parameters()->Contains(i)) continue; 693 if (flow_graph().captured_parameters()->Contains(i)) continue;
685 if (i == ex_idx || i == st_idx) continue; 694 if (i == ex_idx || i == st_idx) continue;
686 if ((*idefs)[i]->IsConstant()) continue; 695 if ((*idefs)[i]->IsConstant()) continue;
687 Location src = env->LocationAt(i); 696 Location src = env->LocationAt(i);
688 ASSERT(!src.IsFpuRegister()); 697 ASSERT(!src.IsFpuRegister());
689 ASSERT(!src.IsDoubleStackSlot()); 698 ASSERT(!src.IsDoubleStackSlot());
699 #if defined(TARGET_ARCH_DBC)
700 intptr_t dest_index = kNumberOfCpuRegisters - 1 - i;
701 Location dest = Location::RegisterLocation(dest_index);
702 #else
690 intptr_t dest_index = i - num_non_copied_params; 703 intptr_t dest_index = i - num_non_copied_params;
691 Location dest = Location::StackSlot(dest_index); 704 Location dest = Location::StackSlot(dest_index);
705 #endif
692 move_instr->AddMove(dest, src); 706 move_instr->AddMove(dest, src);
693 // Update safepoint bitmap to indicate that the target location 707 // Update safepoint bitmap to indicate that the target location
694 // now contains a pointer. 708 // now contains a pointer.
695 instr->locs()->SetStackBit(dest_index); 709 instr->locs()->SetStackBit(dest_index);
696 } 710 }
697 parallel_move_resolver()->EmitNativeCode(move_instr); 711 parallel_move_resolver()->EmitNativeCode(move_instr);
698 } 712 }
699 713
700 714
701 intptr_t FlowGraphCompiler::StackSize() const { 715 intptr_t FlowGraphCompiler::StackSize() const {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 (registers->FpuRegisterCount() * kFpuRegisterSpillFactor); 852 (registers->FpuRegisterCount() * kFpuRegisterSpillFactor);
839 853
840 BitmapBuilder* bitmap = locs->stack_bitmap(); 854 BitmapBuilder* bitmap = locs->stack_bitmap();
841 855
842 // An instruction may have two safepoints in deferred code. The 856 // An instruction may have two safepoints in deferred code. The
843 // call to RecordSafepoint has the side-effect of appending the live 857 // call to RecordSafepoint has the side-effect of appending the live
844 // registers to the bitmap. This is why the second call to RecordSafepoint 858 // registers to the bitmap. This is why the second call to RecordSafepoint
845 // with the same instruction (and same location summary) sees a bitmap that 859 // with the same instruction (and same location summary) sees a bitmap that
846 // is larger that StackSize(). It will never be larger than StackSize() + 860 // is larger that StackSize(). It will never be larger than StackSize() +
847 // live_registers_size. 861 // live_registers_size.
848 ASSERT(bitmap->Length() <= (spill_area_size + live_registers_size));
849 // The first safepoint will grow the bitmap to be the size of 862 // The first safepoint will grow the bitmap to be the size of
850 // spill_area_size but the second safepoint will truncate the bitmap and 863 // spill_area_size but the second safepoint will truncate the bitmap and
851 // append the live registers to it again. The bitmap produced by both calls 864 // append the live registers to it again. The bitmap produced by both calls
852 // will be the same. 865 // will be the same.
866 #if !defined(TARGET_ARCH_DBC)
867 ASSERT(bitmap->Length() <= (spill_area_size + live_registers_size));
853 bitmap->SetLength(spill_area_size); 868 bitmap->SetLength(spill_area_size);
869 #else
870 if (bitmap->Length() <= (spill_area_size + live_registers_size)) {
871 bitmap->SetLength(Utils::Maximum(bitmap->Length(), spill_area_size));
872 }
873 #endif
854 874
855 // Mark the bits in the stack map in the same order we push registers in 875 // Mark the bits in the stack map in the same order we push registers in
856 // slow path code (see FlowGraphCompiler::SaveLiveRegisters). 876 // slow path code (see FlowGraphCompiler::SaveLiveRegisters).
857 // 877 //
858 // Slow path code can have registers at the safepoint. 878 // Slow path code can have registers at the safepoint.
859 if (!locs->always_calls()) { 879 if (!locs->always_calls()) {
860 RegisterSet* regs = locs->live_registers(); 880 RegisterSet* regs = locs->live_registers();
861 if (regs->FpuRegisterCount() > 0) { 881 if (regs->FpuRegisterCount() > 0) {
862 // Denote FPU registers with 0 bits in the stackmap. Based on the 882 // Denote FPU registers with 0 bits in the stackmap. Based on the
863 // assumption that there are normally few live FPU registers, this 883 // assumption that there are normally few live FPU registers, this
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1991 2011
1992 2012
1993 void FlowGraphCompiler::FrameStateClear() { 2013 void FlowGraphCompiler::FrameStateClear() {
1994 ASSERT(!is_optimizing()); 2014 ASSERT(!is_optimizing());
1995 frame_state_.TruncateTo(0); 2015 frame_state_.TruncateTo(0);
1996 } 2016 }
1997 #endif // defined(DEBUG) && !defined(TARGET_ARCH_DBC) 2017 #endif // defined(DEBUG) && !defined(TARGET_ARCH_DBC)
1998 2018
1999 2019
2000 } // namespace dart 2020 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_allocator.cc ('k') | runtime/vm/flow_graph_compiler_dbc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698