| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 namespace dart { | 22 namespace dart { |
| 23 | 23 |
| 24 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); | 24 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); |
| 25 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); | 25 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); |
| 26 DEFINE_FLAG(bool, trace_functions, false, "Trace entry of each function."); | 26 DEFINE_FLAG(bool, trace_functions, false, "Trace entry of each function."); |
| 27 DEFINE_FLAG(int, optimization_invocation_threshold, 1000, | 27 DEFINE_FLAG(int, optimization_invocation_threshold, 1000, |
| 28 "number of invocations before a function is optimized, -1 means never."); | 28 "number of invocations before a function is optimized, -1 means never."); |
| 29 DECLARE_FLAG(bool, enable_type_checks); | 29 DECLARE_FLAG(bool, enable_type_checks); |
| 30 DECLARE_FLAG(bool, report_invocation_count); | 30 DECLARE_FLAG(bool, report_invocation_count); |
| 31 DECLARE_FLAG(bool, trace_compiler); | 31 DECLARE_FLAG(bool, trace_compiler); |
| 32 DECLARE_FLAG(bool, debugger); |
| 32 | 33 |
| 33 #define __ assembler_-> | 34 #define __ assembler_-> |
| 34 | 35 |
| 35 | 36 |
| 36 CodeGeneratorState::CodeGeneratorState(CodeGenerator* codegen) | 37 CodeGeneratorState::CodeGeneratorState(CodeGenerator* codegen) |
| 37 : StackResource(Isolate::Current()), | 38 : StackResource(Isolate::Current()), |
| 38 codegen_(codegen), | 39 codegen_(codegen), |
| 39 parent_(codegen->state()) { | 40 parent_(codegen->state()) { |
| 40 if (parent_ != NULL) { | 41 if (parent_ != NULL) { |
| 41 root_node_ = parent_->root_node_; | 42 root_node_ = parent_->root_node_; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 Address::Absolute(Isolate::Current()->stack_limit_address())); | 276 Address::Absolute(Isolate::Current()->stack_limit_address())); |
| 276 __ j(BELOW_EQUAL, &StubCode::StackOverflowLabel()); | 277 __ j(BELOW_EQUAL, &StubCode::StackOverflowLabel()); |
| 277 // Do not optimize if: | 278 // Do not optimize if: |
| 278 // - we count invocations. | 279 // - we count invocations. |
| 279 // - optimization disabled via negative 'optimization_invocation_threshold; | 280 // - optimization disabled via negative 'optimization_invocation_threshold; |
| 280 // - function is marked as non-optimizable. | 281 // - function is marked as non-optimizable. |
| 281 // - type checks are enabled. | 282 // - type checks are enabled. |
| 282 const bool may_optimize = | 283 const bool may_optimize = |
| 283 !FLAG_report_invocation_count && | 284 !FLAG_report_invocation_count && |
| 284 (FLAG_optimization_invocation_threshold >= 0) && | 285 (FLAG_optimization_invocation_threshold >= 0) && |
| 286 !FLAG_debugger && |
| 285 parsed_function_.function().is_optimizable(); | 287 parsed_function_.function().is_optimizable(); |
| 286 // Count invocation and check. | 288 // Count invocation and check. |
| 287 if (FLAG_report_invocation_count || may_optimize) { | 289 if (FLAG_report_invocation_count || may_optimize) { |
| 288 const Function& function = | 290 const Function& function = |
| 289 Function::ZoneHandle(parsed_function_.function().raw()); | 291 Function::ZoneHandle(parsed_function_.function().raw()); |
| 290 __ LoadObject(EAX, function); | 292 __ LoadObject(EAX, function); |
| 291 __ movl(EBX, FieldAddress(EAX, Function::invocation_counter_offset())); | 293 __ movl(EBX, FieldAddress(EAX, Function::invocation_counter_offset())); |
| 292 __ incl(EBX); | 294 __ incl(EBX); |
| 293 if (may_optimize) { | 295 if (may_optimize) { |
| 294 __ cmpl(EBX, Immediate(FLAG_optimization_invocation_threshold)); | 296 __ cmpl(EBX, Immediate(FLAG_optimization_invocation_threshold)); |
| (...skipping 2449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2744 message_buffer, kMessageBufferSize, | 2746 message_buffer, kMessageBufferSize, |
| 2745 format, args); | 2747 format, args); |
| 2746 va_end(args); | 2748 va_end(args); |
| 2747 Isolate::Current()->long_jump_base()->Jump(1, message_buffer); | 2749 Isolate::Current()->long_jump_base()->Jump(1, message_buffer); |
| 2748 UNREACHABLE(); | 2750 UNREACHABLE(); |
| 2749 } | 2751 } |
| 2750 | 2752 |
| 2751 } // namespace dart | 2753 } // namespace dart |
| 2752 | 2754 |
| 2753 #endif // defined TARGET_ARCH_IA32 | 2755 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |