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 5469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5480 BranchInstr* branch) { | 5480 BranchInstr* branch) { |
5481 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT); | 5481 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT); |
5482 | 5482 |
5483 BranchLabels labels = compiler->CreateBranchLabels(branch); | 5483 BranchLabels labels = compiler->CreateBranchLabels(branch); |
5484 Condition true_condition = EmitComparisonCode(compiler, labels); | 5484 Condition true_condition = EmitComparisonCode(compiler, labels); |
5485 EmitBranchOnCondition(compiler, true_condition, labels); | 5485 EmitBranchOnCondition(compiler, true_condition, labels); |
5486 } | 5486 } |
5487 | 5487 |
5488 | 5488 |
5489 LocationSummary* ClosureCallInstr::MakeLocationSummary(bool opt) const { | 5489 LocationSummary* ClosureCallInstr::MakeLocationSummary(bool opt) const { |
5490 return MakeCallSummary(); | 5490 const intptr_t kNumInputs = 1; |
| 5491 const intptr_t kNumTemps = 0; |
| 5492 LocationSummary* summary = |
| 5493 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| 5494 summary->set_in(0, Location::RegisterLocation(RAX)); // Function. |
| 5495 summary->set_out(0, Location::RegisterLocation(RAX)); |
| 5496 return summary; |
5491 } | 5497 } |
5492 | 5498 |
5493 | 5499 |
5494 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 5500 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
5495 // Load closure object (first argument) in R13. | 5501 // Arguments descriptor is expected in R10. |
5496 intptr_t argument_count = ArgumentCount(); | 5502 intptr_t argument_count = ArgumentCount(); |
5497 __ movq(R13, Address(RSP, (argument_count - 1) * kWordSize)); | |
5498 | |
5499 // Arguments descriptor is expected in R10. | |
5500 const Array& arguments_descriptor = | 5503 const Array& arguments_descriptor = |
5501 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, | 5504 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, |
5502 argument_names())); | 5505 argument_names())); |
5503 __ LoadObject(R10, arguments_descriptor, PP); | 5506 __ LoadObject(R10, arguments_descriptor, PP); |
5504 | 5507 |
5505 // Load the actual closure function. | 5508 // Function in RAX. |
5506 __ movq(RAX, FieldAddress(R13, Closure::function_offset())); | 5509 ASSERT(locs()->in(0).reg() == RAX); |
5507 | |
5508 // Load closure context in CTX; note that CTX has already been preserved. | |
5509 __ movq(CTX, FieldAddress(R13, Closure::context_offset())); | |
5510 | |
5511 // Load closure function code in RAX. | |
5512 __ movq(RCX, FieldAddress(RAX, Function::code_offset())); | 5510 __ movq(RCX, FieldAddress(RAX, Function::code_offset())); |
5513 | 5511 |
5514 // RAX: Function. | 5512 // RAX: Function. |
5515 // R10: Arguments descriptor array. | 5513 // R10: Arguments descriptor array. |
5516 // RBX: Smi 0 (no IC data; the lazy-compile stub expects a GC-safe value). | 5514 // RBX: Smi 0 (no IC data; the lazy-compile stub expects a GC-safe value). |
5517 __ xorq(RBX, RBX); | 5515 __ xorq(RBX, RBX); |
5518 __ movq(RCX, FieldAddress(RCX, Code::instructions_offset())); | 5516 __ movq(RCX, FieldAddress(RCX, Code::instructions_offset())); |
5519 __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 5517 __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
5520 __ call(RCX); | 5518 __ call(RCX); |
5521 compiler->AddCurrentDescriptor(PcDescriptors::kClosureCall, | 5519 compiler->AddCurrentDescriptor(PcDescriptors::kClosureCall, |
5522 deopt_id(), | 5520 deopt_id(), |
5523 token_pos()); | 5521 token_pos()); |
5524 compiler->RecordSafepoint(locs()); | 5522 compiler->RecordSafepoint(locs()); |
5525 // Marks either the continuation point in unoptimized code or the | 5523 // Marks either the continuation point in unoptimized code or the |
5526 // deoptimization point in optimized code, after call. | 5524 // deoptimization point in optimized code, after call. |
5527 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id()); | 5525 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id()); |
5528 if (compiler->is_optimizing()) { | 5526 if (compiler->is_optimizing()) { |
5529 compiler->AddDeoptIndexAtCall(deopt_id_after, token_pos()); | 5527 compiler->AddDeoptIndexAtCall(deopt_id_after, token_pos(), InputCount()); |
5530 } else { | 5528 } else { |
5531 // Add deoptimization continuation point after the call and before the | 5529 // Add deoptimization continuation point after the call and before the |
5532 // arguments are removed. | 5530 // arguments are removed. |
5533 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, | 5531 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, |
5534 deopt_id_after, | 5532 deopt_id_after, |
5535 token_pos()); | 5533 token_pos()); |
5536 } | 5534 } |
5537 __ Drop(argument_count); | 5535 __ Drop(argument_count); |
5538 } | 5536 } |
5539 | 5537 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5571 PcDescriptors::kOther, | 5569 PcDescriptors::kOther, |
5572 locs()); | 5570 locs()); |
5573 __ Drop(ArgumentCount()); // Discard arguments. | 5571 __ Drop(ArgumentCount()); // Discard arguments. |
5574 } | 5572 } |
5575 | 5573 |
5576 } // namespace dart | 5574 } // namespace dart |
5577 | 5575 |
5578 #undef __ | 5576 #undef __ |
5579 | 5577 |
5580 #endif // defined TARGET_ARCH_X64 | 5578 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |