| 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_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 "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 | 72 |
| 73 | 73 |
| 74 // Attempt optimized compilation at return instruction instead of at the entry. | 74 // Attempt optimized compilation at return instruction instead of at the entry. |
| 75 // The entry needs to be patchable, no inlined objects are allowed in the area | 75 // The entry needs to be patchable, no inlined objects are allowed in the area |
| 76 // that will be overwritten by the patch instruction: a jump). | 76 // that will be overwritten by the patch instruction: a jump). |
| 77 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 77 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 78 Register result = locs()->in(0).reg(); | 78 Register result = locs()->in(0).reg(); |
| 79 ASSERT(result == RAX); | 79 ASSERT(result == RAX); |
| 80 #if defined(DEBUG) | 80 #if defined(DEBUG) |
| 81 // TODO(srdjan): Fix for functions with finally clause. | 81 __ Comment("Stack Check"); |
| 82 // A finally clause may leave a previously pushed return value if it | 82 Label done; |
| 83 // has its own return instruction. Method that have finally are currently | 83 const intptr_t fp_sp_dist = |
| 84 // not optimized. | 84 (kFirstLocalSlotFromFp + 1 - compiler->StackSize()) * kWordSize; |
| 85 if (!compiler->HasFinally()) { | 85 ASSERT(fp_sp_dist <= 0); |
| 86 __ Comment("Stack Check"); | 86 __ movq(RDI, RSP); |
| 87 Label done; | 87 __ subq(RDI, RBP); |
| 88 const intptr_t fp_sp_dist = | 88 __ CompareImmediate(RDI, Immediate(fp_sp_dist), PP); |
| 89 (kFirstLocalSlotFromFp + 1 - compiler->StackSize()) * kWordSize; | 89 __ j(EQUAL, &done, Assembler::kNearJump); |
| 90 ASSERT(fp_sp_dist <= 0); | 90 __ int3(); |
| 91 __ movq(RDI, RSP); | 91 __ Bind(&done); |
| 92 __ subq(RDI, RBP); | |
| 93 __ CompareImmediate(RDI, Immediate(fp_sp_dist), PP); | |
| 94 __ j(EQUAL, &done, Assembler::kNearJump); | |
| 95 __ int3(); | |
| 96 __ Bind(&done); | |
| 97 } | |
| 98 #endif | 92 #endif |
| 99 __ LeaveDartFrame(); | 93 __ LeaveDartFrame(); |
| 100 __ ret(); | 94 __ ret(); |
| 101 } | 95 } |
| 102 | 96 |
| 103 | 97 |
| 104 static Condition NegateCondition(Condition condition) { | 98 static Condition NegateCondition(Condition condition) { |
| 105 switch (condition) { | 99 switch (condition) { |
| 106 case EQUAL: return NOT_EQUAL; | 100 case EQUAL: return NOT_EQUAL; |
| 107 case NOT_EQUAL: return EQUAL; | 101 case NOT_EQUAL: return EQUAL; |
| (...skipping 4851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4959 PcDescriptors::kOther, | 4953 PcDescriptors::kOther, |
| 4960 locs()); | 4954 locs()); |
| 4961 __ Drop(2); // Discard type arguments and receiver. | 4955 __ Drop(2); // Discard type arguments and receiver. |
| 4962 } | 4956 } |
| 4963 | 4957 |
| 4964 } // namespace dart | 4958 } // namespace dart |
| 4965 | 4959 |
| 4966 #undef __ | 4960 #undef __ |
| 4967 | 4961 |
| 4968 #endif // defined TARGET_ARCH_X64 | 4962 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |