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