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 2469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2480 __ jmp(slow_path->entry_label()); | 2480 __ jmp(slow_path->entry_label()); |
2481 } | 2481 } |
2482 __ Bind(slow_path->exit_label()); | 2482 __ Bind(slow_path->exit_label()); |
2483 } | 2483 } |
2484 | 2484 |
2485 | 2485 |
2486 static void EmitJavascriptOverflowCheck(FlowGraphCompiler* compiler, | 2486 static void EmitJavascriptOverflowCheck(FlowGraphCompiler* compiler, |
2487 Range* range, | 2487 Range* range, |
2488 Label* overflow, | 2488 Label* overflow, |
2489 Register result) { | 2489 Register result) { |
2490 if (!range->IsWithin(-0x20000000000000LL, 0x20000000000000LL)) { | 2490 if (!RangeUtils::IsWithin(range, -0x20000000000000LL, 0x20000000000000LL)) { |
2491 ASSERT(overflow != NULL); | 2491 ASSERT(overflow != NULL); |
2492 // TODO(zra): This can be tightened to one compare/branch using: | 2492 // TODO(zra): This can be tightened to one compare/branch using: |
2493 // overflow = (result + 2^52) > 2^53 with an unsigned comparison. | 2493 // overflow = (result + 2^52) > 2^53 with an unsigned comparison. |
2494 __ CompareImmediate(result, Immediate(-0x20000000000000LL), PP); | 2494 __ CompareImmediate(result, Immediate(-0x20000000000000LL), PP); |
2495 __ j(LESS, overflow); | 2495 __ j(LESS, overflow); |
2496 __ CompareImmediate(result, Immediate(0x20000000000000LL), PP); | 2496 __ CompareImmediate(result, Immediate(0x20000000000000LL), PP); |
2497 __ j(GREATER, overflow); | 2497 __ j(GREATER, overflow); |
2498 } | 2498 } |
2499 } | 2499 } |
2500 | 2500 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2554 const Object& obj = shift_left->left()->BoundConstant(); | 2554 const Object& obj = shift_left->left()->BoundConstant(); |
2555 if (obj.IsSmi()) { | 2555 if (obj.IsSmi()) { |
2556 const intptr_t left_int = Smi::Cast(obj).Value(); | 2556 const intptr_t left_int = Smi::Cast(obj).Value(); |
2557 if (left_int == 0) { | 2557 if (left_int == 0) { |
2558 __ CompareImmediate(right, Immediate(0), PP); | 2558 __ CompareImmediate(right, Immediate(0), PP); |
2559 __ j(NEGATIVE, deopt); | 2559 __ j(NEGATIVE, deopt); |
2560 return; | 2560 return; |
2561 } | 2561 } |
2562 const intptr_t max_right = kSmiBits - Utils::HighestBit(left_int); | 2562 const intptr_t max_right = kSmiBits - Utils::HighestBit(left_int); |
2563 const bool right_needs_check = | 2563 const bool right_needs_check = |
2564 (right_range == NULL) || | 2564 !RangeUtils::IsWithin(right_range, 0, max_right - 1); |
2565 !right_range->IsWithin(0, max_right - 1); | |
2566 if (right_needs_check) { | 2565 if (right_needs_check) { |
2567 __ CompareImmediate(right, | 2566 __ CompareImmediate(right, |
2568 Immediate(reinterpret_cast<int64_t>(Smi::New(max_right))), PP); | 2567 Immediate(reinterpret_cast<int64_t>(Smi::New(max_right))), PP); |
2569 __ j(ABOVE_EQUAL, deopt); | 2568 __ j(ABOVE_EQUAL, deopt); |
2570 } | 2569 } |
2571 __ SmiUntag(right); | 2570 __ SmiUntag(right); |
2572 __ shlq(left, right); | 2571 __ shlq(left, right); |
2573 } | 2572 } |
2574 if (FLAG_throw_on_javascript_int_overflow) { | 2573 if (FLAG_throw_on_javascript_int_overflow) { |
2575 EmitJavascriptOverflowCheck(compiler, shift_left->range(), deopt, result); | 2574 EmitJavascriptOverflowCheck(compiler, shift_left->range(), deopt, result); |
2576 } | 2575 } |
2577 return; | 2576 return; |
2578 } | 2577 } |
2579 | 2578 |
2580 const bool right_needs_check = | 2579 const bool right_needs_check = |
2581 (right_range == NULL) || !right_range->IsWithin(0, (Smi::kBits - 1)); | 2580 !RangeUtils::IsWithin(right_range, 0, (Smi::kBits - 1)); |
2582 ASSERT(right == RCX); // Count must be in RCX | 2581 ASSERT(right == RCX); // Count must be in RCX |
2583 if (is_truncating) { | 2582 if (is_truncating) { |
2584 if (right_needs_check) { | 2583 if (right_needs_check) { |
2585 const bool right_may_be_negative = | 2584 const bool right_may_be_negative = |
2586 (right_range == NULL) || !right_range->IsPositive(); | 2585 (right_range == NULL) || !right_range->IsPositive(); |
2587 if (right_may_be_negative) { | 2586 if (right_may_be_negative) { |
2588 ASSERT(shift_left->CanDeoptimize()); | 2587 ASSERT(shift_left->CanDeoptimize()); |
2589 __ CompareImmediate(right, Immediate(0), PP); | 2588 __ CompareImmediate(right, Immediate(0), PP); |
2590 __ j(NEGATIVE, deopt); | 2589 __ j(NEGATIVE, deopt); |
2591 } | 2590 } |
(...skipping 3247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5839 __ movq(R10, Immediate(kInvalidObjectPointer)); | 5838 __ movq(R10, Immediate(kInvalidObjectPointer)); |
5840 __ movq(RBX, Immediate(kInvalidObjectPointer)); | 5839 __ movq(RBX, Immediate(kInvalidObjectPointer)); |
5841 #endif | 5840 #endif |
5842 } | 5841 } |
5843 | 5842 |
5844 } // namespace dart | 5843 } // namespace dart |
5845 | 5844 |
5846 #undef __ | 5845 #undef __ |
5847 | 5846 |
5848 #endif // defined TARGET_ARCH_X64 | 5847 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |