Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Side by Side Diff: runtime/vm/intermediate_language_x64.cc

Issue 12776006: Make allocation of Dart parameters and local variables architecture independent. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // that will be overwritten by the patch instruction: a jump). 74 // that will be overwritten by the patch instruction: a jump).
75 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 75 void ReturnInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
76 Register result = locs()->in(0).reg(); 76 Register result = locs()->in(0).reg();
77 ASSERT(result == RAX); 77 ASSERT(result == RAX);
78 #if defined(DEBUG) 78 #if defined(DEBUG)
79 // TODO(srdjan): Fix for functions with finally clause. 79 // TODO(srdjan): Fix for functions with finally clause.
80 // A finally clause may leave a previously pushed return value if it 80 // A finally clause may leave a previously pushed return value if it
81 // has its own return instruction. Method that have finally are currently 81 // has its own return instruction. Method that have finally are currently
82 // not optimized. 82 // not optimized.
83 if (!compiler->HasFinally()) { 83 if (!compiler->HasFinally()) {
84 __ Comment("Stack Check");
84 Label done; 85 Label done;
86 const int sp_fp_dist = compiler->StackSize() + (-kFirstLocalSlotIndex - 1);
85 __ movq(RDI, RBP); 87 __ movq(RDI, RBP);
86 __ subq(RDI, RSP); 88 __ subq(RDI, RSP);
87 // + 1 for Pc marker. 89 __ cmpq(RDI, Immediate(sp_fp_dist * kWordSize));
88 __ cmpq(RDI, Immediate((compiler->StackSize() + 1) * kWordSize));
89 __ j(EQUAL, &done, Assembler::kNearJump); 90 __ j(EQUAL, &done, Assembler::kNearJump);
90 __ int3(); 91 __ int3();
91 __ Bind(&done); 92 __ Bind(&done);
92 } 93 }
93 #endif 94 #endif
94 __ LeaveFrame(); 95 __ LeaveFrame();
95 __ ret(); 96 __ ret();
96 97
97 // Generate 8 bytes of NOPs so that the debugger can patch the 98 // Generate 8 bytes of NOPs so that the debugger can patch the
98 // return pattern with a call to the debug stub. 99 // return pattern with a call to the debug stub.
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 902 void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
902 ASSERT(locs()->temp(0).reg() == RAX); 903 ASSERT(locs()->temp(0).reg() == RAX);
903 ASSERT(locs()->temp(1).reg() == RBX); 904 ASSERT(locs()->temp(1).reg() == RBX);
904 ASSERT(locs()->temp(2).reg() == R10); 905 ASSERT(locs()->temp(2).reg() == R10);
905 Register result = locs()->out().reg(); 906 Register result = locs()->out().reg();
906 907
907 // Push the result place holder initialized to NULL. 908 // Push the result place holder initialized to NULL.
908 __ PushObject(Object::ZoneHandle()); 909 __ PushObject(Object::ZoneHandle());
909 // Pass a pointer to the first argument in RAX. 910 // Pass a pointer to the first argument in RAX.
910 if (!function().HasOptionalParameters()) { 911 if (!function().HasOptionalParameters()) {
911 __ leaq(RAX, Address(RBP, (1 + function().NumParameters()) * kWordSize)); 912 __ leaq(RAX, Address(RBP, (kLastParamSlotIndex +
913 function().NumParameters() - 1) * kWordSize));
912 } else { 914 } else {
913 __ leaq(RAX, 915 __ leaq(RAX,
914 Address(RBP, ParsedFunction::kFirstLocalSlotIndex * kWordSize)); 916 Address(RBP, kFirstLocalSlotIndex * kWordSize));
915 } 917 }
916 __ movq(RBX, Immediate(reinterpret_cast<uword>(native_c_function()))); 918 __ movq(RBX, Immediate(reinterpret_cast<uword>(native_c_function())));
917 __ movq(R10, Immediate(NativeArguments::ComputeArgcTag(function()))); 919 __ movq(R10, Immediate(NativeArguments::ComputeArgcTag(function())));
918 compiler->GenerateCall(token_pos(), 920 compiler->GenerateCall(token_pos(),
919 &StubCode::CallNativeCFunctionLabel(), 921 &StubCode::CallNativeCFunctionLabel(),
920 PcDescriptors::kOther, 922 PcDescriptors::kOther,
921 locs()); 923 locs());
922 __ popq(result); 924 __ popq(result);
923 } 925 }
924 926
(...skipping 2298 matching lines...) Expand 10 before | Expand all | Expand 10 after
3223 PcDescriptors::kOther, 3225 PcDescriptors::kOther,
3224 locs()); 3226 locs());
3225 __ Drop(2); // Discard type arguments and receiver. 3227 __ Drop(2); // Discard type arguments and receiver.
3226 } 3228 }
3227 3229
3228 } // namespace dart 3230 } // namespace dart
3229 3231
3230 #undef __ 3232 #undef __
3231 3233
3232 #endif // defined TARGET_ARCH_X64 3234 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698