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 5396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5407 BranchInstr* branch) { | 5407 BranchInstr* branch) { |
5408 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT); | 5408 ASSERT(kind() == Token::kEQ_STRICT || kind() == Token::kNE_STRICT); |
5409 | 5409 |
5410 BranchLabels labels = compiler->CreateBranchLabels(branch); | 5410 BranchLabels labels = compiler->CreateBranchLabels(branch); |
5411 Condition true_condition = EmitComparisonCode(compiler, labels); | 5411 Condition true_condition = EmitComparisonCode(compiler, labels); |
5412 EmitBranchOnCondition(compiler, true_condition, labels); | 5412 EmitBranchOnCondition(compiler, true_condition, labels); |
5413 } | 5413 } |
5414 | 5414 |
5415 | 5415 |
5416 LocationSummary* ClosureCallInstr::MakeLocationSummary(bool opt) const { | 5416 LocationSummary* ClosureCallInstr::MakeLocationSummary(bool opt) const { |
5417 const intptr_t kNumInputs = 0; | 5417 return MakeCallSummary(); |
5418 const intptr_t kNumTemps = 1; | |
5419 LocationSummary* result = | |
5420 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | |
5421 result->set_out(0, Location::RegisterLocation(RAX)); | |
5422 result->set_temp(0, Location::RegisterLocation(R10)); // Arg. descriptor. | |
5423 return result; | |
5424 } | 5418 } |
5425 | 5419 |
5426 | 5420 |
5427 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 5421 void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
5428 // The arguments to the stub include the closure, as does the arguments | 5422 // Load closure object (first argument) in R13. |
5429 // descriptor. | 5423 intptr_t argument_count = ArgumentCount(); |
5430 Register temp_reg = locs()->temp(0).reg(); | 5424 __ movq(R13, Address(RSP, (argument_count - 1) * kWordSize)); |
5431 int argument_count = ArgumentCount(); | 5425 |
| 5426 // Arguments descriptor is expected in R10. |
5432 const Array& arguments_descriptor = | 5427 const Array& arguments_descriptor = |
5433 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, | 5428 Array::ZoneHandle(ArgumentsDescriptor::New(argument_count, |
5434 argument_names())); | 5429 argument_names())); |
5435 __ LoadObject(temp_reg, arguments_descriptor, PP); | 5430 __ LoadObject(R10, arguments_descriptor, PP); |
5436 ASSERT(temp_reg == R10); | 5431 |
5437 compiler->GenerateDartCall(deopt_id(), | 5432 // Load the actual closure function. |
5438 token_pos(), | 5433 __ movq(RAX, FieldAddress(R13, Closure::function_offset())); |
5439 &StubCode::CallClosureFunctionLabel(), | 5434 |
5440 PcDescriptors::kClosureCall, | 5435 // Load closure context in CTX; note that CTX has already been preserved. |
5441 locs()); | 5436 __ movq(CTX, FieldAddress(R13, Closure::context_offset())); |
| 5437 |
| 5438 // Load closure function code in RAX. |
| 5439 __ movq(RCX, FieldAddress(RAX, Function::code_offset())); |
| 5440 |
| 5441 // RAX: Function. |
| 5442 // R10: Arguments descriptor array. |
| 5443 // RBX: Smi 0 (no IC data; the lazy-compile stub expects a GC-safe value). |
| 5444 __ xorq(RBX, RBX); |
| 5445 __ movq(RCX, FieldAddress(RCX, Code::instructions_offset())); |
| 5446 __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 5447 __ call(RCX); |
| 5448 compiler->AddCurrentDescriptor(PcDescriptors::kClosureCall, |
| 5449 deopt_id(), |
| 5450 token_pos()); |
| 5451 compiler->RecordSafepoint(locs()); |
| 5452 // Marks either the continuation point in unoptimized code or the |
| 5453 // deoptimization point in optimized code, after call. |
| 5454 const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id()); |
| 5455 if (compiler->is_optimizing()) { |
| 5456 compiler->AddDeoptIndexAtCall(deopt_id_after, token_pos()); |
| 5457 } else { |
| 5458 // Add deoptimization continuation point after the call and before the |
| 5459 // arguments are removed. |
| 5460 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, |
| 5461 deopt_id_after, |
| 5462 token_pos()); |
| 5463 } |
5442 __ Drop(argument_count); | 5464 __ Drop(argument_count); |
5443 } | 5465 } |
5444 | 5466 |
5445 | 5467 |
5446 LocationSummary* BooleanNegateInstr::MakeLocationSummary(bool opt) const { | 5468 LocationSummary* BooleanNegateInstr::MakeLocationSummary(bool opt) const { |
5447 return LocationSummary::Make(1, | 5469 return LocationSummary::Make(1, |
5448 Location::RequiresRegister(), | 5470 Location::RequiresRegister(), |
5449 LocationSummary::kNoCall); | 5471 LocationSummary::kNoCall); |
5450 } | 5472 } |
5451 | 5473 |
(...skipping 24 matching lines...) Expand all Loading... |
5476 PcDescriptors::kOther, | 5498 PcDescriptors::kOther, |
5477 locs()); | 5499 locs()); |
5478 __ Drop(ArgumentCount()); // Discard arguments. | 5500 __ Drop(ArgumentCount()); // Discard arguments. |
5479 } | 5501 } |
5480 | 5502 |
5481 } // namespace dart | 5503 } // namespace dart |
5482 | 5504 |
5483 #undef __ | 5505 #undef __ |
5484 | 5506 |
5485 #endif // defined TARGET_ARCH_X64 | 5507 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |