| 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/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 locs->set_temp(0, Location::RequiresRegister()); | 52 locs->set_temp(0, Location::RequiresRegister()); |
| 53 return locs; | 53 return locs; |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 57 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 58 Register result = locs()->in(0).reg(); | 58 Register result = locs()->in(0).reg(); |
| 59 Register temp = locs()->temp(0).reg(); | 59 Register temp = locs()->temp(0).reg(); |
| 60 ASSERT(result == RAX); | 60 ASSERT(result == RAX); |
| 61 if (!compiler->is_optimizing()) { | 61 if (!compiler->is_optimizing()) { |
| 62 __ Comment("Check function counter"); |
| 62 // Count only in unoptimized code. | 63 // Count only in unoptimized code. |
| 63 // TODO(srdjan): Replace the counting code with a type feedback | 64 // TODO(srdjan): Replace the counting code with a type feedback |
| 64 // collection and counting stub. | 65 // collection and counting stub. |
| 65 const Function& function = | 66 const Function& function = |
| 66 Function::ZoneHandle(compiler->parsed_function().function().raw()); | 67 Function::ZoneHandle(compiler->parsed_function().function().raw()); |
| 67 __ LoadObject(temp, function); | 68 __ LoadObject(temp, function); |
| 68 __ incq(FieldAddress(temp, Function::usage_counter_offset())); | 69 __ incq(FieldAddress(temp, Function::usage_counter_offset())); |
| 69 if (FlowGraphCompiler::CanOptimize()) { | 70 if (FlowGraphCompiler::CanOptimize()) { |
| 70 // Do not optimize if usage count must be reported. | 71 // Do not optimize if usage count must be reported. |
| 71 __ cmpl(FieldAddress(temp, Function::usage_counter_offset()), | 72 __ cmpq(FieldAddress(temp, Function::usage_counter_offset()), |
| 72 Immediate(FLAG_optimization_counter_threshold)); | 73 Immediate(FLAG_optimization_counter_threshold)); |
| 73 Label not_yet_hot, already_optimized; | 74 Label not_yet_hot, already_optimized; |
| 74 __ j(LESS, ¬_yet_hot, Assembler::kNearJump); | 75 __ j(LESS, ¬_yet_hot, Assembler::kNearJump); |
| 75 __ j(GREATER, &already_optimized, Assembler::kNearJump); | 76 __ j(GREATER, &already_optimized, Assembler::kNearJump); |
| 76 __ pushq(result); // Preserve result. | 77 __ pushq(result); // Preserve result. |
| 77 __ pushq(temp); // Argument for runtime: function to optimize. | 78 __ pushq(temp); // Argument for runtime: function to optimize. |
| 78 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry); | 79 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry); |
| 79 __ popq(temp); // Remove argument. | 80 __ popq(temp); // Remove argument. |
| 80 __ popq(result); // Restore result. | 81 __ popq(result); // Restore result. |
| 81 __ Bind(¬_yet_hot); | 82 __ Bind(¬_yet_hot); |
| (...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2068 kNumArgsChecked); | 2069 kNumArgsChecked); |
| 2069 __ CompareObject(RAX, compiler->bool_true()); | 2070 __ CompareObject(RAX, compiler->bool_true()); |
| 2070 EmitBranchOnCondition(compiler, branch_condition); | 2071 EmitBranchOnCondition(compiler, branch_condition); |
| 2071 } | 2072 } |
| 2072 | 2073 |
| 2073 } // namespace dart | 2074 } // namespace dart |
| 2074 | 2075 |
| 2075 #undef __ | 2076 #undef __ |
| 2076 | 2077 |
| 2077 #endif // defined TARGET_ARCH_X64 | 2078 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |