| 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_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/intermediate_language.h" |
| 9 |
| 8 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| 9 #include "vm/locations.h" | 11 #include "vm/locations.h" |
| 10 #include "vm/stub_code.h" | 12 #include "vm/stub_code.h" |
| 11 | 13 |
| 12 #define __ compiler->assembler()-> | 14 #define __ compiler->assembler()-> |
| 13 | 15 |
| 14 namespace dart { | 16 namespace dart { |
| 15 | 17 |
| 16 DECLARE_FLAG(bool, optimization_counter_threshold); | 18 DECLARE_FLAG(int, optimization_counter_threshold); |
| 17 DECLARE_FLAG(bool, trace_functions); | 19 DECLARE_FLAG(bool, trace_functions); |
| 18 | 20 |
| 19 // True iff. the arguments to a call will be properly pushed and can | 21 // True iff. the arguments to a call will be properly pushed and can |
| 20 // be popped after the call. | 22 // be popped after the call. |
| 21 template <typename T> static bool VerifyCallComputation(T* comp) { | 23 template <typename T> static bool VerifyCallComputation(T* comp) { |
| 22 // Argument values should be consecutive temps. | 24 // Argument values should be consecutive temps. |
| 23 // | 25 // |
| 24 // TODO(kmillikin): implement stack height tracking so we can also assert | 26 // TODO(kmillikin): implement stack height tracking so we can also assert |
| 25 // they are on top of the stack. | 27 // they are on top of the stack. |
| 26 intptr_t previous = -1; | 28 intptr_t previous = -1; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 Register temp = locs()->temp(0).reg(); | 69 Register temp = locs()->temp(0).reg(); |
| 68 ASSERT(result == EAX); | 70 ASSERT(result == EAX); |
| 69 if (!compiler->is_optimizing()) { | 71 if (!compiler->is_optimizing()) { |
| 70 // Count only in unoptimized code. | 72 // Count only in unoptimized code. |
| 71 // TODO(srdjan): Replace the counting code with a type feedback | 73 // TODO(srdjan): Replace the counting code with a type feedback |
| 72 // collection and counting stub. | 74 // collection and counting stub. |
| 73 const Function& function = | 75 const Function& function = |
| 74 Function::ZoneHandle(compiler->parsed_function().function().raw()); | 76 Function::ZoneHandle(compiler->parsed_function().function().raw()); |
| 75 __ LoadObject(temp, function); | 77 __ LoadObject(temp, function); |
| 76 __ incl(FieldAddress(temp, Function::usage_counter_offset())); | 78 __ incl(FieldAddress(temp, Function::usage_counter_offset())); |
| 77 /*if (CodeGenerator::CanOptimize()) { | 79 if (CodeGenerator::CanOptimize()) { |
| 78 // Do not optimize if usage count must be reported. | 80 // Do not optimize if usage count must be reported. |
| 79 __ cmpl(FieldAddress(temp, Function::usage_counter_offset()), | 81 __ cmpl(FieldAddress(temp, Function::usage_counter_offset()), |
| 80 Immediate(FLAG_optimization_counter_threshold)); | 82 Immediate(FLAG_optimization_counter_threshold)); |
| 81 Label not_yet_hot; | 83 Label not_yet_hot; |
| 82 __ j(LESS_EQUAL, ¬_yet_hot, Assembler::kNearJump); | 84 __ j(LESS_EQUAL, ¬_yet_hot, Assembler::kNearJump); |
| 83 __ pushl(result); // Preserve result. | 85 __ pushl(result); // Preserve result. |
| 84 __ pushl(temp); // Argument for runtime: function to optimize. | 86 __ pushl(temp); // Argument for runtime: function to optimize. |
| 85 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry); | 87 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry); |
| 86 __ popl(temp); // Remove argument. | 88 __ popl(temp); // Remove argument. |
| 87 __ popl(result); // Restore result. | 89 __ popl(result); // Restore result. |
| 88 __ Bind(¬_yet_hot); | 90 __ Bind(¬_yet_hot); |
| 89 } */ | 91 } |
| 90 } | 92 } |
| 91 if (FLAG_trace_functions) { | 93 if (FLAG_trace_functions) { |
| 92 const Function& function = | 94 const Function& function = |
| 93 Function::ZoneHandle(compiler->parsed_function().function().raw()); | 95 Function::ZoneHandle(compiler->parsed_function().function().raw()); |
| 94 __ LoadObject(temp, function); | 96 __ LoadObject(temp, function); |
| 95 __ pushl(result); // Preserve result. | 97 __ pushl(result); // Preserve result. |
| 96 __ pushl(temp); | 98 __ pushl(temp); |
| 97 compiler->GenerateCallRuntime(AstNode::kNoId, | 99 compiler->GenerateCallRuntime(AstNode::kNoId, |
| 98 0, | 100 0, |
| 99 CatchClauseNode::kInvalidTryIndex, | 101 CatchClauseNode::kInvalidTryIndex, |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 __ movl(locs()->out().reg(), EAX); | 586 __ movl(locs()->out().reg(), EAX); |
| 585 } | 587 } |
| 586 } | 588 } |
| 587 | 589 |
| 588 | 590 |
| 589 } // namespace dart | 591 } // namespace dart |
| 590 | 592 |
| 591 #undef __ | 593 #undef __ |
| 592 | 594 |
| 593 #endif // defined TARGET_ARCH_X64 | 595 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |