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 "lib/error.h" | 10 #include "lib/error.h" |
(...skipping 2564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2575 __ testq(value, Immediate(kSmiTagMask)); | 2575 __ testq(value, Immediate(kSmiTagMask)); |
2576 __ j(NOT_ZERO, deopt); | 2576 __ j(NOT_ZERO, deopt); |
2577 } | 2577 } |
2578 | 2578 |
2579 | 2579 |
2580 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const { | 2580 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const { |
2581 const intptr_t kNumInputs = 2; | 2581 const intptr_t kNumInputs = 2; |
2582 const intptr_t kNumTemps = 0; | 2582 const intptr_t kNumTemps = 0; |
2583 LocationSummary* locs = | 2583 LocationSummary* locs = |
2584 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 2584 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
2585 locs->set_in(0, Location::RegisterOrSmiConstant(array())); | 2585 locs->set_in(0, Location::RegisterOrSmiConstant(length())); |
2586 locs->set_in(1, Location::RegisterOrSmiConstant(index())); | 2586 locs->set_in(1, Location::RegisterOrSmiConstant(index())); |
2587 return locs; | 2587 return locs; |
2588 } | 2588 } |
2589 | 2589 |
2590 | 2590 |
2591 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2591 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
2592 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2592 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
2593 kDeoptCheckArrayBound); | 2593 kDeoptCheckArrayBound); |
2594 if (locs()->in(0).IsConstant() && locs()->in(1).IsConstant()) { | 2594 if (locs()->in(0).IsConstant() && locs()->in(1).IsConstant()) { |
2595 // Unconditionally deoptimize for constant bounds checks because they | 2595 // Unconditionally deoptimize for constant bounds checks because they |
2596 // only occur only when index is out-of-bounds. | 2596 // only occur only when index is out-of-bounds. |
2597 __ jmp(deopt); | 2597 __ jmp(deopt); |
2598 return; | 2598 return; |
2599 } | 2599 } |
2600 | 2600 |
2601 | |
2602 intptr_t length_offset = LengthOffsetFor(array_type()); | |
2603 if (locs()->in(1).IsConstant()) { | 2601 if (locs()->in(1).IsConstant()) { |
2604 Register receiver = locs()->in(0).reg(); | 2602 Register length = locs()->in(0).reg(); |
2605 const Object& constant = locs()->in(1).constant(); | 2603 const Object& constant = locs()->in(1).constant(); |
2606 ASSERT(constant.IsSmi()); | 2604 ASSERT(constant.IsSmi()); |
2607 const int64_t imm = | 2605 const int64_t imm = |
2608 reinterpret_cast<int64_t>(constant.raw()); | 2606 reinterpret_cast<int64_t>(constant.raw()); |
2609 __ cmpq(FieldAddress(receiver, length_offset), Immediate(imm)); | 2607 __ cmpq(length, Immediate(imm)); |
2610 __ j(BELOW_EQUAL, deopt); | 2608 __ j(BELOW_EQUAL, deopt); |
2611 } else if (locs()->in(0).IsConstant()) { | 2609 } else if (locs()->in(0).IsConstant()) { |
2612 ASSERT(locs()->in(0).constant().IsArray() || | 2610 ASSERT(locs()->in(0).constant().IsSmi()); |
2613 locs()->in(0).constant().IsString()); | 2611 const Smi& smi_const = Smi::Cast(locs()->in(0).constant()); |
2614 intptr_t length = locs()->in(0).constant().IsArray() | |
2615 ? Array::Cast(locs()->in(0).constant()).Length() | |
2616 : String::Cast(locs()->in(0).constant()).Length(); | |
2617 Register index = locs()->in(1).reg(); | 2612 Register index = locs()->in(1).reg(); |
2618 __ cmpq(index, | 2613 __ cmpq(index, Immediate(reinterpret_cast<int64_t>(smi_const.raw()))); |
2619 Immediate(reinterpret_cast<int64_t>(Smi::New(length)))); | |
2620 __ j(ABOVE_EQUAL, deopt); | 2614 __ j(ABOVE_EQUAL, deopt); |
2621 } else { | 2615 } else { |
2622 Register receiver = locs()->in(0).reg(); | 2616 Register length = locs()->in(0).reg(); |
2623 Register index = locs()->in(1).reg(); | 2617 Register index = locs()->in(1).reg(); |
2624 __ cmpq(index, FieldAddress(receiver, length_offset)); | 2618 __ cmpq(index, length); |
2625 __ j(ABOVE_EQUAL, deopt); | 2619 __ j(ABOVE_EQUAL, deopt); |
2626 } | 2620 } |
2627 } | 2621 } |
2628 | 2622 |
2629 | 2623 |
2630 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const { | 2624 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const { |
2631 UNIMPLEMENTED(); | 2625 UNIMPLEMENTED(); |
2632 return NULL; | 2626 return NULL; |
2633 } | 2627 } |
2634 | 2628 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2992 PcDescriptors::kOther, | 2986 PcDescriptors::kOther, |
2993 locs()); | 2987 locs()); |
2994 __ Drop(2); // Discard type arguments and receiver. | 2988 __ Drop(2); // Discard type arguments and receiver. |
2995 } | 2989 } |
2996 | 2990 |
2997 } // namespace dart | 2991 } // namespace dart |
2998 | 2992 |
2999 #undef __ | 2993 #undef __ |
3000 | 2994 |
3001 #endif // defined TARGET_ARCH_X64 | 2995 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |