| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 // Fall through if bool_register contains null. | 53 // Fall through if bool_register contains null. |
| 54 void FlowGraphCompiler::GenerateBoolToJump(Register bool_register, | 54 void FlowGraphCompiler::GenerateBoolToJump(Register bool_register, |
| 55 Label* is_true, | 55 Label* is_true, |
| 56 Label* is_false) { | 56 Label* is_false) { |
| 57 const Immediate raw_null = | 57 const Immediate raw_null = |
| 58 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 58 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 59 Label fall_through; | 59 Label fall_through; |
| 60 __ cmpq(bool_register, raw_null); | 60 __ cmpq(bool_register, raw_null); |
| 61 __ j(EQUAL, &fall_through, Assembler::kNearJump); | 61 __ j(EQUAL, &fall_through, Assembler::kNearJump); |
| 62 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); | 62 __ CompareObject(bool_register, true_value()); |
| 63 __ CompareObject(bool_register, bool_true); | |
| 64 __ j(EQUAL, is_true); | 63 __ j(EQUAL, is_true); |
| 65 __ jmp(is_false); | 64 __ jmp(is_false); |
| 66 __ Bind(&fall_through); | 65 __ Bind(&fall_through); |
| 67 } | 66 } |
| 68 | 67 |
| 69 | 68 |
| 70 RawSubtypeTestCache* FlowGraphCompiler::GenerateCallSubtypeTestStub( | 69 RawSubtypeTestCache* FlowGraphCompiler::GenerateCallSubtypeTestStub( |
| 71 TypeTestStubKind test_kind, | 70 TypeTestStubKind test_kind, |
| 72 Register instance_reg, | 71 Register instance_reg, |
| 73 Register type_arguments_reg, | 72 Register type_arguments_reg, |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 // - RCX: instantiator or raw_null. | 558 // - RCX: instantiator or raw_null. |
| 560 // Destroys RCX and RDX. | 559 // Destroys RCX and RDX. |
| 561 // Returns: | 560 // Returns: |
| 562 // - true or false in RAX. | 561 // - true or false in RAX. |
| 563 void FlowGraphCompiler::GenerateInstanceOf(intptr_t cid, | 562 void FlowGraphCompiler::GenerateInstanceOf(intptr_t cid, |
| 564 intptr_t token_index, | 563 intptr_t token_index, |
| 565 intptr_t try_index, | 564 intptr_t try_index, |
| 566 const AbstractType& type, | 565 const AbstractType& type, |
| 567 bool negate_result) { | 566 bool negate_result) { |
| 568 ASSERT(type.IsFinalized() && !type.IsMalformed()); | 567 ASSERT(type.IsFinalized() && !type.IsMalformed()); |
| 569 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); | |
| 570 const Bool& bool_false = Bool::ZoneHandle(Bool::False()); | |
| 571 | 568 |
| 572 const Immediate raw_null = | 569 const Immediate raw_null = |
| 573 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 570 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 574 Label is_instance, is_not_instance; | 571 Label is_instance, is_not_instance; |
| 575 __ pushq(RCX); // Store instantiator on stack. | 572 __ pushq(RCX); // Store instantiator on stack. |
| 576 __ pushq(RDX); // Store instantiator type arguments. | 573 __ pushq(RDX); // Store instantiator type arguments. |
| 577 // If type is instantiated and non-parameterized, we can inline code | 574 // If type is instantiated and non-parameterized, we can inline code |
| 578 // checking whether the tested instance is a Smi. | 575 // checking whether the tested instance is a Smi. |
| 579 if (type.IsInstantiated()) { | 576 if (type.IsInstantiated()) { |
| 580 // A null object is only an instance of Object and Dynamic, which has | 577 // A null object is only an instance of Object and Dynamic, which has |
| (...skipping 24 matching lines...) Expand all Loading... |
| 605 __ pushq(RDX); // Instantiator type arguments. | 602 __ pushq(RDX); // Instantiator type arguments. |
| 606 __ LoadObject(RAX, test_cache); | 603 __ LoadObject(RAX, test_cache); |
| 607 __ pushq(RAX); | 604 __ pushq(RAX); |
| 608 GenerateCallRuntime(cid, token_index, try_index, kInstanceofRuntimeEntry); | 605 GenerateCallRuntime(cid, token_index, try_index, kInstanceofRuntimeEntry); |
| 609 // Pop the two parameters supplied to the runtime entry. The result of the | 606 // Pop the two parameters supplied to the runtime entry. The result of the |
| 610 // instanceof runtime call will be left as the result of the operation. | 607 // instanceof runtime call will be left as the result of the operation. |
| 611 __ Drop(7); | 608 __ Drop(7); |
| 612 Label done; | 609 Label done; |
| 613 if (negate_result) { | 610 if (negate_result) { |
| 614 __ popq(RDX); | 611 __ popq(RDX); |
| 615 __ LoadObject(RAX, bool_true); | 612 __ LoadObject(RAX, true_value()); |
| 616 __ cmpq(RDX, RAX); | 613 __ cmpq(RDX, RAX); |
| 617 __ j(NOT_EQUAL, &done, Assembler::kNearJump); | 614 __ j(NOT_EQUAL, &done, Assembler::kNearJump); |
| 618 __ LoadObject(RAX, bool_false); | 615 __ LoadObject(RAX, false_value()); |
| 619 } else { | 616 } else { |
| 620 __ popq(RAX); | 617 __ popq(RAX); |
| 621 } | 618 } |
| 622 __ jmp(&done, Assembler::kNearJump); | 619 __ jmp(&done, Assembler::kNearJump); |
| 623 | 620 |
| 624 __ Bind(&is_not_instance); | 621 __ Bind(&is_not_instance); |
| 625 __ LoadObject(RAX, negate_result ? bool_true : bool_false); | 622 __ LoadObject(RAX, negate_result ? true_value() : false_value()); |
| 626 __ jmp(&done, Assembler::kNearJump); | 623 __ jmp(&done, Assembler::kNearJump); |
| 627 | 624 |
| 628 __ Bind(&is_instance); | 625 __ Bind(&is_instance); |
| 629 __ LoadObject(RAX, negate_result ? bool_false : bool_true); | 626 __ LoadObject(RAX, negate_result ? false_value() : true_value()); |
| 630 __ Bind(&done); | 627 __ Bind(&done); |
| 631 __ popq(RDX); // Remove pushed instantiator type arguments. | 628 __ popq(RDX); // Remove pushed instantiator type arguments. |
| 632 __ popq(RCX); // Remove pushed instantiator. | 629 __ popq(RCX); // Remove pushed instantiator. |
| 633 } | 630 } |
| 634 | 631 |
| 635 | 632 |
| 636 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) { | 633 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) { |
| 637 LocationSummary* locs = instr->locs(); | 634 LocationSummary* locs = instr->locs(); |
| 638 ASSERT(locs != NULL); | 635 ASSERT(locs != NULL); |
| 639 | 636 |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 __ cvtsi2sd(result, temp); | 1026 __ cvtsi2sd(result, temp); |
| 1030 __ Bind(&done); | 1027 __ Bind(&done); |
| 1031 } | 1028 } |
| 1032 | 1029 |
| 1033 | 1030 |
| 1034 #undef __ | 1031 #undef __ |
| 1035 | 1032 |
| 1036 } // namespace dart | 1033 } // namespace dart |
| 1037 | 1034 |
| 1038 #endif // defined TARGET_ARCH_X64 | 1035 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |