| 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_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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 DECLARE_FLAG(bool, trace_compiler); | 52 DECLARE_FLAG(bool, trace_compiler); |
| 53 DECLARE_FLAG(int, inlining_hotness); | 53 DECLARE_FLAG(int, inlining_hotness); |
| 54 DECLARE_FLAG(int, inlining_size_threshold); | 54 DECLARE_FLAG(int, inlining_size_threshold); |
| 55 DECLARE_FLAG(int, inlining_callee_size_threshold); | 55 DECLARE_FLAG(int, inlining_callee_size_threshold); |
| 56 DECLARE_FLAG(int, inline_getters_setters_smaller_than); | 56 DECLARE_FLAG(int, inline_getters_setters_smaller_than); |
| 57 DECLARE_FLAG(int, inlining_depth_threshold); | 57 DECLARE_FLAG(int, inlining_depth_threshold); |
| 58 DECLARE_FLAG(int, inlining_caller_size_threshold); | 58 DECLARE_FLAG(int, inlining_caller_size_threshold); |
| 59 DECLARE_FLAG(int, inlining_constant_arguments_max_size_threshold); | 59 DECLARE_FLAG(int, inlining_constant_arguments_max_size_threshold); |
| 60 DECLARE_FLAG(int, inlining_constant_arguments_min_size_threshold); | 60 DECLARE_FLAG(int, inlining_constant_arguments_min_size_threshold); |
| 61 | 61 |
| 62 #if !defined(DART_PRECOMPILED_RUNTIME) | |
| 63 static void PrecompilationModeHandler(bool value) { | 62 static void PrecompilationModeHandler(bool value) { |
| 64 if (value) { | 63 if (value) { |
| 65 #if defined(TARGET_ARCH_IA32) | 64 #if defined(TARGET_ARCH_IA32) |
| 66 FATAL("Precompilation not supported on IA32"); | 65 FATAL("Precompilation not supported on IA32"); |
| 67 #endif | 66 #endif |
| 68 | 67 |
| 69 #if defined(PRODUCT) | |
| 70 FATAL("dart_noopt not supported in product mode"); | |
| 71 #else | |
| 72 FLAG_support_debugger = false; | |
| 73 | |
| 74 // Flags affecting compilation only: | 68 // Flags affecting compilation only: |
| 75 // There is no counter feedback in precompilation, so ignore the counter | 69 // There is no counter feedback in precompilation, so ignore the counter |
| 76 // when making inlining decisions. | 70 // when making inlining decisions. |
| 77 FLAG_inlining_hotness = 0; | 71 FLAG_inlining_hotness = 0; |
| 78 // Use smaller thresholds in precompilation as we are compiling everything | 72 // Use smaller thresholds in precompilation as we are compiling everything |
| 79 // with the optimizing compiler instead of only hot functions. | 73 // with the optimizing compiler instead of only hot functions. |
| 80 FLAG_inlining_size_threshold = 5; | 74 FLAG_inlining_size_threshold = 5; |
| 81 FLAG_inline_getters_setters_smaller_than = 5; | 75 FLAG_inline_getters_setters_smaller_than = 5; |
| 82 FLAG_inlining_callee_size_threshold = 20; | 76 FLAG_inlining_callee_size_threshold = 20; |
| 83 FLAG_inlining_depth_threshold = 2; | 77 FLAG_inlining_depth_threshold = 2; |
| 84 FLAG_inlining_caller_size_threshold = 1000; | 78 FLAG_inlining_caller_size_threshold = 1000; |
| 85 FLAG_inlining_constant_arguments_max_size_threshold = 100; | 79 FLAG_inlining_constant_arguments_max_size_threshold = 100; |
| 86 FLAG_inlining_constant_arguments_min_size_threshold = 30; | 80 FLAG_inlining_constant_arguments_min_size_threshold = 30; |
| 87 | 81 |
| 88 FLAG_allow_absolute_addresses = false; | 82 FLAG_allow_absolute_addresses = false; |
| 89 FLAG_always_megamorphic_calls = true; | 83 FLAG_always_megamorphic_calls = true; |
| 90 FLAG_background_compilation = false; | |
| 91 FLAG_collect_code = false; | |
| 92 FLAG_collect_dynamic_function_names = true; | 84 FLAG_collect_dynamic_function_names = true; |
| 93 FLAG_deoptimize_alot = false; // Used in some tests. | |
| 94 FLAG_deoptimize_every = 0; // Used in some tests. | |
| 95 FLAG_emit_edge_counters = false; | |
| 96 FLAG_enable_mirrors = false; | |
| 97 FLAG_fields_may_be_reset = true; | 85 FLAG_fields_may_be_reset = true; |
| 98 FLAG_ic_range_profiling = false; | 86 FLAG_ic_range_profiling = false; |
| 99 FLAG_interpret_irregexp = true; | 87 FLAG_interpret_irregexp = true; |
| 100 FLAG_lazy_dispatchers = false; | 88 FLAG_lazy_dispatchers = false; |
| 101 FLAG_link_natives_lazily = true; | 89 FLAG_link_natives_lazily = true; |
| 102 FLAG_load_deferred_eagerly = true; | |
| 103 FLAG_optimization_counter_threshold = -1; | 90 FLAG_optimization_counter_threshold = -1; |
| 104 FLAG_polymorphic_with_deopt = false; | 91 FLAG_polymorphic_with_deopt = false; |
| 105 FLAG_precompiled_mode = true; | 92 FLAG_precompiled_mode = true; |
| 93 FLAG_reorder_basic_blocks = false; |
| 94 FLAG_use_field_guards = false; |
| 95 FLAG_use_cha_deopt = false; |
| 96 |
| 97 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
| 98 // Set flags affecting runtime accordingly for dart_noopt. |
| 99 FLAG_background_compilation = false; |
| 100 FLAG_collect_code = false; |
| 101 FLAG_support_debugger = false; |
| 102 FLAG_deoptimize_alot = false; // Used in some tests. |
| 103 FLAG_deoptimize_every = 0; // Used in some tests. |
| 104 FLAG_enable_mirrors = false; |
| 105 FLAG_load_deferred_eagerly = true; |
| 106 FLAG_print_stop_message = false; | 106 FLAG_print_stop_message = false; |
| 107 FLAG_use_cha_deopt = false; | |
| 108 FLAG_use_field_guards = false; | |
| 109 FLAG_use_osr = false; | 107 FLAG_use_osr = false; |
| 110 #endif // PRODUCT | 108 #endif |
| 111 } | 109 } |
| 112 } | 110 } |
| 113 | 111 |
| 114 DEFINE_FLAG_HANDLER(PrecompilationModeHandler, | 112 DEFINE_FLAG_HANDLER(PrecompilationModeHandler, |
| 115 precompilation, | 113 precompilation, |
| 116 "Precompilation mode"); | 114 "Precompilation mode"); |
| 117 | 115 |
| 118 #else // DART_PRECOMPILED_RUNTIME | 116 #ifdef DART_PRECOMPILED_RUNTIME |
| 119 | 117 |
| 120 COMPILE_ASSERT(!FLAG_allow_absolute_addresses); | |
| 121 COMPILE_ASSERT(!FLAG_background_compilation); | 118 COMPILE_ASSERT(!FLAG_background_compilation); |
| 122 COMPILE_ASSERT(!FLAG_collect_code); | 119 COMPILE_ASSERT(!FLAG_collect_code); |
| 123 COMPILE_ASSERT(!FLAG_deoptimize_alot); // Used in some tests. | 120 COMPILE_ASSERT(!FLAG_deoptimize_alot); // Used in some tests. |
| 124 COMPILE_ASSERT(!FLAG_emit_edge_counters); | |
| 125 COMPILE_ASSERT(!FLAG_enable_mirrors); | 121 COMPILE_ASSERT(!FLAG_enable_mirrors); |
| 126 COMPILE_ASSERT(!FLAG_ic_range_profiling); | 122 COMPILE_ASSERT(FLAG_precompiled_runtime); |
| 127 COMPILE_ASSERT(!FLAG_lazy_dispatchers); | |
| 128 COMPILE_ASSERT(!FLAG_polymorphic_with_deopt); | |
| 129 COMPILE_ASSERT(!FLAG_print_stop_message); | 123 COMPILE_ASSERT(!FLAG_print_stop_message); |
| 130 COMPILE_ASSERT(!FLAG_use_cha_deopt); | |
| 131 COMPILE_ASSERT(!FLAG_use_field_guards); | |
| 132 COMPILE_ASSERT(!FLAG_use_osr); | 124 COMPILE_ASSERT(!FLAG_use_osr); |
| 133 COMPILE_ASSERT(FLAG_always_megamorphic_calls); | |
| 134 COMPILE_ASSERT(FLAG_collect_dynamic_function_names); | |
| 135 COMPILE_ASSERT(FLAG_deoptimize_every == 0); // Used in some tests. | 125 COMPILE_ASSERT(FLAG_deoptimize_every == 0); // Used in some tests. |
| 136 COMPILE_ASSERT(FLAG_fields_may_be_reset); | |
| 137 COMPILE_ASSERT(FLAG_interpret_irregexp); | |
| 138 COMPILE_ASSERT(FLAG_link_natives_lazily); | |
| 139 COMPILE_ASSERT(FLAG_load_deferred_eagerly); | 126 COMPILE_ASSERT(FLAG_load_deferred_eagerly); |
| 140 COMPILE_ASSERT(FLAG_optimization_counter_threshold == -1); | |
| 141 COMPILE_ASSERT(FLAG_precompiled_mode); | |
| 142 | 127 |
| 143 #endif // DART_PRECOMPILED_RUNTIME | 128 #endif // DART_PRECOMPILED_RUNTIME |
| 144 | 129 |
| 145 | 130 |
| 146 // Assign locations to incoming arguments, i.e., values pushed above spill slots | 131 // Assign locations to incoming arguments, i.e., values pushed above spill slots |
| 147 // with PushArgument. Recursively allocates from outermost to innermost | 132 // with PushArgument. Recursively allocates from outermost to innermost |
| 148 // environment. | 133 // environment. |
| 149 void CompilerDeoptInfo::AllocateIncomingParametersRecursive( | 134 void CompilerDeoptInfo::AllocateIncomingParametersRecursive( |
| 150 Environment* env, | 135 Environment* env, |
| 151 intptr_t* stack_height) { | 136 intptr_t* stack_height) { |
| (...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 BufferFormatter f(buffer, sizeof(buffer)); | 1286 BufferFormatter f(buffer, sizeof(buffer)); |
| 1302 instr->PrintTo(&f); | 1287 instr->PrintTo(&f); |
| 1303 assembler()->Comment("%s", buffer); | 1288 assembler()->Comment("%s", buffer); |
| 1304 #endif | 1289 #endif |
| 1305 } | 1290 } |
| 1306 | 1291 |
| 1307 | 1292 |
| 1308 bool FlowGraphCompiler::NeedsEdgeCounter(TargetEntryInstr* block) { | 1293 bool FlowGraphCompiler::NeedsEdgeCounter(TargetEntryInstr* block) { |
| 1309 // Only emit an edge counter if there is not goto at the end of the block, | 1294 // Only emit an edge counter if there is not goto at the end of the block, |
| 1310 // except for the entry block. | 1295 // except for the entry block. |
| 1311 return (FLAG_emit_edge_counters | 1296 return (FLAG_reorder_basic_blocks |
| 1312 && (!block->last_instruction()->IsGoto() | 1297 && (!block->last_instruction()->IsGoto() |
| 1313 || (block == flow_graph().graph_entry()->normal_entry()))); | 1298 || (block == flow_graph().graph_entry()->normal_entry()))); |
| 1314 } | 1299 } |
| 1315 | 1300 |
| 1316 | 1301 |
| 1317 // Allocate a register that is not explicitly blocked. | 1302 // Allocate a register that is not explicitly blocked. |
| 1318 static Register AllocateFreeRegister(bool* blocked_registers) { | 1303 static Register AllocateFreeRegister(bool* blocked_registers) { |
| 1319 for (intptr_t regno = 0; regno < kNumberOfCpuRegisters; regno++) { | 1304 for (intptr_t regno = 0; regno < kNumberOfCpuRegisters; regno++) { |
| 1320 if (!blocked_registers[regno]) { | 1305 if (!blocked_registers[regno]) { |
| 1321 blocked_registers[regno] = true; | 1306 blocked_registers[regno] = true; |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1939 | 1924 |
| 1940 | 1925 |
| 1941 void FlowGraphCompiler::FrameStateClear() { | 1926 void FlowGraphCompiler::FrameStateClear() { |
| 1942 ASSERT(!is_optimizing()); | 1927 ASSERT(!is_optimizing()); |
| 1943 frame_state_.TruncateTo(0); | 1928 frame_state_.TruncateTo(0); |
| 1944 } | 1929 } |
| 1945 #endif | 1930 #endif |
| 1946 | 1931 |
| 1947 | 1932 |
| 1948 } // namespace dart | 1933 } // namespace dart |
| OLD | NEW |