| 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 "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 Register result = locs()->in(0).reg(); | 77 Register result = locs()->in(0).reg(); |
| 78 ASSERT(result == RAX); | 78 ASSERT(result == RAX); |
| 79 #if defined(DEBUG) | 79 #if defined(DEBUG) |
| 80 // TODO(srdjan): Fix for functions with finally clause. | 80 // TODO(srdjan): Fix for functions with finally clause. |
| 81 // A finally clause may leave a previously pushed return value if it | 81 // A finally clause may leave a previously pushed return value if it |
| 82 // has its own return instruction. Method that have finally are currently | 82 // has its own return instruction. Method that have finally are currently |
| 83 // not optimized. | 83 // not optimized. |
| 84 if (!compiler->HasFinally()) { | 84 if (!compiler->HasFinally()) { |
| 85 __ Comment("Stack Check"); | 85 __ Comment("Stack Check"); |
| 86 Label done; | 86 Label done; |
| 87 const int sp_fp_dist = compiler->StackSize() + (-kFirstLocalSlotIndex - 1); | 87 const intptr_t fp_sp_dist = |
| 88 __ movq(RDI, RBP); | 88 (kFirstLocalSlotIndex + 1 - compiler->StackSize()) * kWordSize; |
| 89 __ subq(RDI, RSP); | 89 ASSERT(fp_sp_dist <= 0); |
| 90 __ cmpq(RDI, Immediate(sp_fp_dist * kWordSize)); | 90 __ movq(RDI, RSP); |
| 91 __ subq(RDI, RBP); |
| 92 __ cmpq(RDI, Immediate(fp_sp_dist)); |
| 91 __ j(EQUAL, &done, Assembler::kNearJump); | 93 __ j(EQUAL, &done, Assembler::kNearJump); |
| 92 __ int3(); | 94 __ int3(); |
| 93 __ Bind(&done); | 95 __ Bind(&done); |
| 94 } | 96 } |
| 95 #endif | 97 #endif |
| 96 __ LeaveFrame(); | 98 __ LeaveFrame(); |
| 97 __ ret(); | 99 __ ret(); |
| 98 | 100 |
| 99 // Generate 8 bytes of NOPs so that the debugger can patch the | 101 // Generate 8 bytes of NOPs so that the debugger can patch the |
| 100 // return pattern with a call to the debug stub. | 102 // return pattern with a call to the debug stub. |
| (...skipping 1963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 Location::NoLocation(), | 2066 Location::NoLocation(), |
| 2065 LocationSummary::kNoCall); | 2067 LocationSummary::kNoCall); |
| 2066 } | 2068 } |
| 2067 | 2069 |
| 2068 | 2070 |
| 2069 // Restore stack and initialize the two exception variables: | 2071 // Restore stack and initialize the two exception variables: |
| 2070 // exception and stack trace variables. | 2072 // exception and stack trace variables. |
| 2071 void CatchEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2073 void CatchEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2072 // Restore RSP from RBP as we are coming from a throw and the code for | 2074 // Restore RSP from RBP as we are coming from a throw and the code for |
| 2073 // popping arguments has not been run. | 2075 // popping arguments has not been run. |
| 2074 const intptr_t locals_space_size = compiler->StackSize() * kWordSize; | 2076 const intptr_t fp_sp_dist = |
| 2075 ASSERT(locals_space_size >= 0); | 2077 (kFirstLocalSlotIndex + 1 - compiler->StackSize()) * kWordSize; |
| 2076 const intptr_t offset_size = | 2078 ASSERT(fp_sp_dist <= 0); |
| 2077 -locals_space_size + FlowGraphCompiler::kLocalsOffsetFromFP; | 2079 __ leaq(RSP, Address(RBP, fp_sp_dist)); |
| 2078 __ leaq(RSP, Address(RBP, offset_size)); | |
| 2079 | 2080 |
| 2080 ASSERT(!exception_var().is_captured()); | 2081 ASSERT(!exception_var().is_captured()); |
| 2081 ASSERT(!stacktrace_var().is_captured()); | 2082 ASSERT(!stacktrace_var().is_captured()); |
| 2082 __ movq(Address(RBP, exception_var().index() * kWordSize), | 2083 __ movq(Address(RBP, exception_var().index() * kWordSize), |
| 2083 kExceptionObjectReg); | 2084 kExceptionObjectReg); |
| 2084 __ movq(Address(RBP, stacktrace_var().index() * kWordSize), | 2085 __ movq(Address(RBP, stacktrace_var().index() * kWordSize), |
| 2085 kStackTraceObjectReg); | 2086 kStackTraceObjectReg); |
| 2086 } | 2087 } |
| 2087 | 2088 |
| 2088 | 2089 |
| (...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3609 PcDescriptors::kOther, | 3610 PcDescriptors::kOther, |
| 3610 locs()); | 3611 locs()); |
| 3611 __ Drop(2); // Discard type arguments and receiver. | 3612 __ Drop(2); // Discard type arguments and receiver. |
| 3612 } | 3613 } |
| 3613 | 3614 |
| 3614 } // namespace dart | 3615 } // namespace dart |
| 3615 | 3616 |
| 3616 #undef __ | 3617 #undef __ |
| 3617 | 3618 |
| 3618 #endif // defined TARGET_ARCH_X64 | 3619 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |