Files
sdk/runtime/vm/compiler/compiler_sources.gni
T
Stephen Adams 066962ff60 [vm] Defer removal of bounds checks
Change how `@pragma('vm:unsafe:no-bounds-checks')` works.

Instead of never inserting the bounds check, the bounds check is added to the flow graph with a flag that it should later be removed, `omit_check`. The removal occurs in `RangeAnalysis::EliminateRedundantBoundsChecks`. This ensures that the indexed load is pinned by the check, preventing illegal code motion.

`@pragma('vm:unsafe:no-bounds-checks')` is not a mechanism to allow unsafe access. It means that the access is known to be safe because of invariants not apparent to the compiler. Keeping the bounds check in the flow graph allows range analysis to learn from the bounds constraints and perhaps remove other checks. A test was added for this scenario. I didn't see this in the wild, but I did see one case where a refined range allowed a boxing to be removed.

Bug: #56808
TEST=BoundsCheckElimination_Pragma_learning, BoundsCheckElimination_Pragma_learning_control
Change-Id: I5b3f4470d6c40c988a8a0ee563c765f4f5f9128b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389620
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-10-16 23:10:11 +00:00

223 lines
6.5 KiB
Plaintext

# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
# This file contains all sources (vm and tests) for the compiler pipeline.
# Unit test files need to have a "_test" suffix appended to the name.
compiler_sources = [
"aot/aot_call_specializer.cc",
"aot/aot_call_specializer.h",
"aot/dispatch_table_generator.cc",
"aot/dispatch_table_generator.h",
"aot/precompiler.cc",
"aot/precompiler.h",
"aot/precompiler_tracer.cc",
"aot/precompiler_tracer.h",
"asm_intrinsifier.cc",
"asm_intrinsifier.h",
"asm_intrinsifier_arm.cc",
"asm_intrinsifier_arm64.cc",
"asm_intrinsifier_ia32.cc",
"asm_intrinsifier_riscv.cc",
"asm_intrinsifier_x64.cc",
"assembler/assembler.h",
"assembler/assembler_arm.cc",
"assembler/assembler_arm.h",
"assembler/assembler_arm64.cc",
"assembler/assembler_arm64.h",
"assembler/assembler_base.cc",
"assembler/assembler_base.h",
"assembler/assembler_ia32.cc",
"assembler/assembler_ia32.h",
"assembler/assembler_riscv.cc",
"assembler/assembler_riscv.h",
"assembler/assembler_x64.cc",
"assembler/assembler_x64.h",
"assembler/object_pool_builder.h",
"backend/block_builder.h",
"backend/block_scheduler.cc",
"backend/block_scheduler.h",
"backend/branch_optimizer.cc",
"backend/branch_optimizer.h",
"backend/code_statistics.cc",
"backend/code_statistics.h",
"backend/compile_type.h",
"backend/constant_propagator.cc",
"backend/constant_propagator.h",
"backend/dart_calling_conventions.cc",
"backend/dart_calling_conventions.h",
"backend/evaluator.cc",
"backend/evaluator.h",
"backend/flow_graph.cc",
"backend/flow_graph.h",
"backend/flow_graph_checker.cc",
"backend/flow_graph_checker.h",
"backend/flow_graph_compiler.cc",
"backend/flow_graph_compiler.h",
"backend/flow_graph_compiler_arm.cc",
"backend/flow_graph_compiler_arm64.cc",
"backend/flow_graph_compiler_ia32.cc",
"backend/flow_graph_compiler_riscv.cc",
"backend/flow_graph_compiler_x64.cc",
"backend/il.cc",
"backend/il.h",
"backend/il_arm.cc",
"backend/il_arm64.cc",
"backend/il_ia32.cc",
"backend/il_printer.cc",
"backend/il_printer.h",
"backend/il_riscv.cc",
"backend/il_serializer.cc",
"backend/il_serializer.h",
"backend/il_x64.cc",
"backend/inliner.cc",
"backend/inliner.h",
"backend/linearscan.cc",
"backend/linearscan.h",
"backend/locations.cc",
"backend/locations.h",
"backend/locations_helpers.h",
"backend/locations_helpers_arm.h",
"backend/loops.cc",
"backend/loops.h",
"backend/parallel_move_resolver.cc",
"backend/parallel_move_resolver.h",
"backend/range_analysis.cc",
"backend/range_analysis.h",
"backend/redundancy_elimination.cc",
"backend/redundancy_elimination.h",
"backend/slot.cc",
"backend/slot.h",
"backend/type_propagator.cc",
"backend/type_propagator.h",
"call_specializer.cc",
"call_specializer.h",
"cha.cc",
"cha.h",
"compiler_pass.cc",
"compiler_pass.h",
"compiler_state.cc",
"compiler_state.h",
"compiler_timings.cc",
"compiler_timings.h",
"ffi/abi.cc",
"ffi/abi.h",
"ffi/callback.cc",
"ffi/callback.h",
"ffi/frame_rebase.cc",
"ffi/frame_rebase.h",
"ffi/marshaller.cc",
"ffi/marshaller.h",
"ffi/native_calling_convention.cc",
"ffi/native_calling_convention.h",
"ffi/native_location.cc",
"ffi/native_location.h",
"ffi/native_type.cc",
"ffi/native_type.h",
"ffi/recognized_method.cc",
"ffi/recognized_method.h",
"frontend/base_flow_graph_builder.cc",
"frontend/base_flow_graph_builder.h",
"frontend/constant_reader.cc",
"frontend/constant_reader.h",
"frontend/flow_graph_builder.cc",
"frontend/flow_graph_builder.h",
"frontend/kernel_binary_flowgraph.cc",
"frontend/kernel_binary_flowgraph.h",
"frontend/kernel_fingerprints.cc",
"frontend/kernel_fingerprints.h",
"frontend/kernel_to_il.cc",
"frontend/kernel_to_il.h",
"frontend/kernel_translation_helper.cc",
"frontend/kernel_translation_helper.h",
"frontend/prologue_builder.cc",
"frontend/prologue_builder.h",
"frontend/scope_builder.cc",
"frontend/scope_builder.h",
"graph_intrinsifier.cc",
"graph_intrinsifier.h",
"intrinsifier.cc",
"intrinsifier.h",
"jit/jit_call_specializer.cc",
"jit/jit_call_specializer.h",
"method_recognizer.cc",
"method_recognizer.h",
"recognized_methods_list.h",
"relocation.cc",
"relocation.h",
"stub_code_compiler.cc",
"stub_code_compiler.h",
"stub_code_compiler_arm.cc",
"stub_code_compiler_arm64.cc",
"stub_code_compiler_ia32.cc",
"stub_code_compiler_riscv.cc",
"stub_code_compiler_x64.cc",
"write_barrier_elimination.cc",
"write_barrier_elimination.h",
]
compiler_sources_tests = [
"asm_intrinsifier_test.cc",
"assembler/assembler_arm64_test.cc",
"assembler/assembler_arm_test.cc",
"assembler/assembler_ia32_test.cc",
"assembler/assembler_riscv_test.cc",
"assembler/assembler_test.cc",
"assembler/assembler_x64_test.cc",
"assembler/disassembler_test.cc",
"backend/bce_test.cc",
"backend/constant_propagator_test.cc",
"backend/flow_graph_test.cc",
"backend/il_test.cc",
"backend/il_test_helper.h",
"backend/il_test_helper.cc",
"backend/inliner_test.cc",
"backend/linearscan_test.cc",
"backend/locations_helpers_test.cc",
"backend/loops_test.cc",
"backend/memory_copy_test.cc",
"backend/pragma_unsafe_no_bounds_check_test.cc",
"backend/range_analysis_test.cc",
"backend/reachability_fence_test.cc",
"backend/redundancy_elimination_test.cc",
"backend/slot_test.cc",
"backend/type_propagator_test.cc",
"backend/typed_data_aot_test.cc",
"backend/yield_position_test.cc",
"cha_test.cc",
"relocation_test.cc",
"ffi/native_type_vm_test.cc",
"frontend/kernel_binary_flowgraph_test.cc",
"write_barrier_elimination_test.cc",
]
compiler_api_sources = [
"api/deopt_id.h",
"api/print_filter.cc",
"api/print_filter.h",
"api/type_check_mode.h",
"jit/compiler.cc",
"jit/compiler.h",
"runtime_api.cc",
"runtime_api.h",
]
disassembler_sources = [
"assembler/disassembler.cc",
"assembler/disassembler.h",
"assembler/disassembler_arm.cc",
"assembler/disassembler_arm64.cc",
"assembler/disassembler_kbc.cc",
"assembler/disassembler_kbc.h",
"assembler/disassembler_riscv.cc",
"assembler/disassembler_x86.cc",
]
ffi_sources_tests = [
"ffi/native_calling_convention_test.cc",
"ffi/native_location_test.cc",
"ffi/native_type_test.cc",
"ffi/unit_test_custom_zone.cc",
"ffi/unit_test.cc",
]