| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 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" |
| 11 #include "vm/ast_printer.h" | 11 #include "vm/ast_printer.h" |
| 12 #include "vm/class_finalizer.h" | 12 #include "vm/class_finalizer.h" |
| 13 #include "vm/dart_entry.h" | 13 #include "vm/dart_entry.h" |
| 14 #include "vm/debugger.h" | 14 #include "vm/debugger.h" |
| 15 #include "vm/longjump.h" | 15 #include "vm/longjump.h" |
| 16 #include "vm/object.h" | 16 #include "vm/object.h" |
| 17 #include "vm/object_store.h" | 17 #include "vm/object_store.h" |
| 18 #include "vm/parser.h" | 18 #include "vm/parser.h" |
| 19 #include "vm/resolver.h" | 19 #include "vm/resolver.h" |
| 20 #include "vm/stub_code.h" | 20 #include "vm/stub_code.h" |
| 21 | 21 |
| 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, -1, | 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 | 32 |
| 33 #define __ assembler_-> | 33 #define __ assembler_-> |
| 34 | 34 |
| 35 | 35 |
| 36 // TODO(regis): CodeGeneratorState, CodeGenerator::DescriptorList, and | 36 // TODO(regis): CodeGeneratorState, CodeGenerator::DescriptorList, and |
| 37 // CodeGenerator::HandlerList can probably be moved to code_generator.cc, since | 37 // CodeGenerator::HandlerList can probably be moved to code_generator.cc, since |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // Note that first 13 bytes may be patched with a jump. | 276 // Note that first 13 bytes may be patched with a jump. |
| 277 // TODO(srdjan): Add check that no object is inlined in the first | 277 // TODO(srdjan): Add check that no object is inlined in the first |
| 278 // 13 bytes (length of a jump instruction). | 278 // 13 bytes (length of a jump instruction). |
| 279 void CodeGenerator::GeneratePreEntryCode() { | 279 void CodeGenerator::GeneratePreEntryCode() { |
| 280 // Do not optimize if: | 280 // Do not optimize if: |
| 281 // - we count invocations. | 281 // - we count invocations. |
| 282 // - optimization disabled via negative 'optimization_invocation_threshold; | 282 // - optimization disabled via negative 'optimization_invocation_threshold; |
| 283 // - function is marked as non-optimizable. | 283 // - function is marked as non-optimizable. |
| 284 // - type checks are enabled. | 284 // - type checks are enabled. |
| 285 const bool may_optimize = | 285 const bool may_optimize = |
| 286 false && // TODO(srdjan): Remove once the optimizer is enabled on x64. |
| 286 !FLAG_report_invocation_count && | 287 !FLAG_report_invocation_count && |
| 287 (FLAG_optimization_invocation_threshold >= 0) && | 288 (FLAG_optimization_invocation_threshold >= 0) && |
| 288 !Isolate::Current()->debugger()->IsActive() && | 289 !Isolate::Current()->debugger()->IsActive() && |
| 289 parsed_function_.function().is_optimizable(); | 290 parsed_function_.function().is_optimizable(); |
| 290 // Count invocation and check. | 291 // Count invocation and check. |
| 291 if (FLAG_report_invocation_count || may_optimize) { | 292 if (FLAG_report_invocation_count || may_optimize) { |
| 292 // TODO(turnidge): It would be nice to remove this nop. Right now | 293 // TODO(turnidge): It would be nice to remove this nop. Right now |
| 293 // we need it to make sure the function is still patchable. | 294 // we need it to make sure the function is still patchable. |
| 294 __ nop(8); | 295 __ nop(8); |
| 295 __ nop(5); | 296 __ nop(5); |
| (...skipping 2517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2813 const Error& error = Error::Handle( | 2814 const Error& error = Error::Handle( |
| 2814 Parser::FormatError(script, token_index, "Error", format, args)); | 2815 Parser::FormatError(script, token_index, "Error", format, args)); |
| 2815 va_end(args); | 2816 va_end(args); |
| 2816 Isolate::Current()->long_jump_base()->Jump(1, error); | 2817 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2817 UNREACHABLE(); | 2818 UNREACHABLE(); |
| 2818 } | 2819 } |
| 2819 | 2820 |
| 2820 } // namespace dart | 2821 } // namespace dart |
| 2821 | 2822 |
| 2822 #endif // defined TARGET_ARCH_X64 | 2823 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |