OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <assert.h> // For assert | 5 #include <assert.h> // For assert |
6 #include <limits.h> // For LONG_MIN, LONG_MAX. | 6 #include <limits.h> // For LONG_MIN, LONG_MAX. |
7 | 7 |
8 #if V8_TARGET_ARCH_PPC | 8 #if V8_TARGET_ARCH_PPC |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 Label* fail) { | 1538 Label* fail) { |
1539 DCHECK(kNotStringTag != 0); | 1539 DCHECK(kNotStringTag != 0); |
1540 | 1540 |
1541 LoadP(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); | 1541 LoadP(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); |
1542 lbz(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); | 1542 lbz(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); |
1543 andi(r0, scratch, Operand(kIsNotStringMask)); | 1543 andi(r0, scratch, Operand(kIsNotStringMask)); |
1544 bne(fail, cr0); | 1544 bne(fail, cr0); |
1545 } | 1545 } |
1546 | 1546 |
1547 | 1547 |
1548 void MacroAssembler::IsObjectNameType(Register object, Register scratch, | |
1549 Label* fail) { | |
1550 LoadP(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); | |
1551 lbz(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); | |
1552 cmpi(scratch, Operand(LAST_NAME_TYPE)); | |
1553 bgt(fail); | |
1554 } | |
1555 | |
1556 | |
1557 void MacroAssembler::MaybeDropFrames() { | 1548 void MacroAssembler::MaybeDropFrames() { |
1558 // Check whether we need to drop frames to restart a function on the stack. | 1549 // Check whether we need to drop frames to restart a function on the stack. |
1559 ExternalReference restart_fp = | 1550 ExternalReference restart_fp = |
1560 ExternalReference::debug_restart_fp_address(isolate()); | 1551 ExternalReference::debug_restart_fp_address(isolate()); |
1561 mov(r4, Operand(restart_fp)); | 1552 mov(r4, Operand(restart_fp)); |
1562 LoadWordArith(r4, MemOperand(r4)); | 1553 LoadWordArith(r4, MemOperand(r4)); |
1563 cmpi(r4, Operand::Zero()); | 1554 cmpi(r4, Operand::Zero()); |
1564 Jump(isolate()->builtins()->FrameDropperTrampoline(), RelocInfo::CODE_TARGET, | 1555 Jump(isolate()->builtins()->FrameDropperTrampoline(), RelocInfo::CODE_TARGET, |
1565 ne); | 1556 ne); |
1566 } | 1557 } |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2083 if (smi_check_type == DO_SMI_CHECK) { | 2074 if (smi_check_type == DO_SMI_CHECK) { |
2084 JumpIfSmi(obj, fail); | 2075 JumpIfSmi(obj, fail); |
2085 } | 2076 } |
2086 LoadP(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); | 2077 LoadP(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); |
2087 LoadRoot(r0, index); | 2078 LoadRoot(r0, index); |
2088 cmp(scratch, r0); | 2079 cmp(scratch, r0); |
2089 bne(fail); | 2080 bne(fail); |
2090 } | 2081 } |
2091 | 2082 |
2092 | 2083 |
2093 void MacroAssembler::DispatchWeakMap(Register obj, Register scratch1, | |
2094 Register scratch2, Handle<WeakCell> cell, | |
2095 Handle<Code> success, | |
2096 SmiCheckType smi_check_type) { | |
2097 Label fail; | |
2098 if (smi_check_type == DO_SMI_CHECK) { | |
2099 JumpIfSmi(obj, &fail); | |
2100 } | |
2101 LoadP(scratch1, FieldMemOperand(obj, HeapObject::kMapOffset)); | |
2102 CmpWeakValue(scratch1, cell, scratch2); | |
2103 Jump(success, RelocInfo::CODE_TARGET, eq); | |
2104 bind(&fail); | |
2105 } | |
2106 | |
2107 | |
2108 void MacroAssembler::CmpWeakValue(Register value, Handle<WeakCell> cell, | |
2109 Register scratch, CRegister cr) { | |
2110 mov(scratch, Operand(cell)); | |
2111 LoadP(scratch, FieldMemOperand(scratch, WeakCell::kValueOffset)); | |
2112 cmp(value, scratch, cr); | |
2113 } | |
2114 | |
2115 | |
2116 void MacroAssembler::GetWeakValue(Register value, Handle<WeakCell> cell) { | 2084 void MacroAssembler::GetWeakValue(Register value, Handle<WeakCell> cell) { |
2117 mov(value, Operand(cell)); | 2085 mov(value, Operand(cell)); |
2118 LoadP(value, FieldMemOperand(value, WeakCell::kValueOffset)); | 2086 LoadP(value, FieldMemOperand(value, WeakCell::kValueOffset)); |
2119 } | 2087 } |
2120 | 2088 |
2121 | 2089 |
2122 void MacroAssembler::LoadWeakValue(Register value, Handle<WeakCell> cell, | 2090 void MacroAssembler::LoadWeakValue(Register value, Handle<WeakCell> cell, |
2123 Label* miss) { | 2091 Label* miss) { |
2124 GetWeakValue(value, cell); | 2092 GetWeakValue(value, cell); |
2125 JumpIfSmi(value, miss); | 2093 JumpIfSmi(value, miss); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2445 } | 2413 } |
2446 } | 2414 } |
2447 | 2415 |
2448 | 2416 |
2449 void MacroAssembler::Assert(Condition cond, BailoutReason reason, | 2417 void MacroAssembler::Assert(Condition cond, BailoutReason reason, |
2450 CRegister cr) { | 2418 CRegister cr) { |
2451 if (emit_debug_code()) Check(cond, reason, cr); | 2419 if (emit_debug_code()) Check(cond, reason, cr); |
2452 } | 2420 } |
2453 | 2421 |
2454 | 2422 |
2455 void MacroAssembler::AssertFastElements(Register elements) { | |
2456 if (emit_debug_code()) { | |
2457 DCHECK(!elements.is(r0)); | |
2458 Label ok; | |
2459 push(elements); | |
2460 LoadP(elements, FieldMemOperand(elements, HeapObject::kMapOffset)); | |
2461 LoadRoot(r0, Heap::kFixedArrayMapRootIndex); | |
2462 cmp(elements, r0); | |
2463 beq(&ok); | |
2464 LoadRoot(r0, Heap::kFixedDoubleArrayMapRootIndex); | |
2465 cmp(elements, r0); | |
2466 beq(&ok); | |
2467 LoadRoot(r0, Heap::kFixedCOWArrayMapRootIndex); | |
2468 cmp(elements, r0); | |
2469 beq(&ok); | |
2470 Abort(kJSObjectWithFastElementsMapHasSlowElements); | |
2471 bind(&ok); | |
2472 pop(elements); | |
2473 } | |
2474 } | |
2475 | |
2476 | 2423 |
2477 void MacroAssembler::Check(Condition cond, BailoutReason reason, CRegister cr) { | 2424 void MacroAssembler::Check(Condition cond, BailoutReason reason, CRegister cr) { |
2478 Label L; | 2425 Label L; |
2479 b(cond, &L, cr); | 2426 b(cond, &L, cr); |
2480 Abort(reason); | 2427 Abort(reason); |
2481 // will not return here | 2428 // will not return here |
2482 bind(&L); | 2429 bind(&L); |
2483 } | 2430 } |
2484 | 2431 |
2485 | 2432 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2616 beq(smi_case, cr0); | 2563 beq(smi_case, cr0); |
2617 } | 2564 } |
2618 | 2565 |
2619 void MacroAssembler::JumpIfEitherSmi(Register reg1, Register reg2, | 2566 void MacroAssembler::JumpIfEitherSmi(Register reg1, Register reg2, |
2620 Label* on_either_smi) { | 2567 Label* on_either_smi) { |
2621 STATIC_ASSERT(kSmiTag == 0); | 2568 STATIC_ASSERT(kSmiTag == 0); |
2622 JumpIfSmi(reg1, on_either_smi); | 2569 JumpIfSmi(reg1, on_either_smi); |
2623 JumpIfSmi(reg2, on_either_smi); | 2570 JumpIfSmi(reg2, on_either_smi); |
2624 } | 2571 } |
2625 | 2572 |
2626 void MacroAssembler::AssertNotNumber(Register object) { | |
2627 if (emit_debug_code()) { | |
2628 STATIC_ASSERT(kSmiTag == 0); | |
2629 TestIfSmi(object, r0); | |
2630 Check(ne, kOperandIsANumber, cr0); | |
2631 push(object); | |
2632 CompareObjectType(object, object, object, HEAP_NUMBER_TYPE); | |
2633 pop(object); | |
2634 Check(ne, kOperandIsANumber); | |
2635 } | |
2636 } | |
2637 | |
2638 void MacroAssembler::AssertNotSmi(Register object) { | 2573 void MacroAssembler::AssertNotSmi(Register object) { |
2639 if (emit_debug_code()) { | 2574 if (emit_debug_code()) { |
2640 STATIC_ASSERT(kSmiTag == 0); | 2575 STATIC_ASSERT(kSmiTag == 0); |
2641 TestIfSmi(object, r0); | 2576 TestIfSmi(object, r0); |
2642 Check(ne, kOperandIsASmi, cr0); | 2577 Check(ne, kOperandIsASmi, cr0); |
2643 } | 2578 } |
2644 } | 2579 } |
2645 | 2580 |
2646 | 2581 |
2647 void MacroAssembler::AssertSmi(Register object) { | 2582 void MacroAssembler::AssertSmi(Register object) { |
2648 if (emit_debug_code()) { | 2583 if (emit_debug_code()) { |
2649 STATIC_ASSERT(kSmiTag == 0); | 2584 STATIC_ASSERT(kSmiTag == 0); |
2650 TestIfSmi(object, r0); | 2585 TestIfSmi(object, r0); |
2651 Check(eq, kOperandIsNotSmi, cr0); | 2586 Check(eq, kOperandIsNotSmi, cr0); |
2652 } | 2587 } |
2653 } | 2588 } |
2654 | 2589 |
2655 | 2590 |
2656 void MacroAssembler::AssertString(Register object) { | |
2657 if (emit_debug_code()) { | |
2658 STATIC_ASSERT(kSmiTag == 0); | |
2659 TestIfSmi(object, r0); | |
2660 Check(ne, kOperandIsASmiAndNotAString, cr0); | |
2661 push(object); | |
2662 LoadP(object, FieldMemOperand(object, HeapObject::kMapOffset)); | |
2663 CompareInstanceType(object, object, FIRST_NONSTRING_TYPE); | |
2664 pop(object); | |
2665 Check(lt, kOperandIsNotAString); | |
2666 } | |
2667 } | |
2668 | |
2669 | |
2670 void MacroAssembler::AssertName(Register object) { | |
2671 if (emit_debug_code()) { | |
2672 STATIC_ASSERT(kSmiTag == 0); | |
2673 TestIfSmi(object, r0); | |
2674 Check(ne, kOperandIsASmiAndNotAName, cr0); | |
2675 push(object); | |
2676 LoadP(object, FieldMemOperand(object, HeapObject::kMapOffset)); | |
2677 CompareInstanceType(object, object, LAST_NAME_TYPE); | |
2678 pop(object); | |
2679 Check(le, kOperandIsNotAName); | |
2680 } | |
2681 } | |
2682 | |
2683 | |
2684 void MacroAssembler::AssertFunction(Register object) { | 2591 void MacroAssembler::AssertFunction(Register object) { |
2685 if (emit_debug_code()) { | 2592 if (emit_debug_code()) { |
2686 STATIC_ASSERT(kSmiTag == 0); | 2593 STATIC_ASSERT(kSmiTag == 0); |
2687 TestIfSmi(object, r0); | 2594 TestIfSmi(object, r0); |
2688 Check(ne, kOperandIsASmiAndNotAFunction, cr0); | 2595 Check(ne, kOperandIsASmiAndNotAFunction, cr0); |
2689 push(object); | 2596 push(object); |
2690 CompareObjectType(object, object, object, JS_FUNCTION_TYPE); | 2597 CompareObjectType(object, object, object, JS_FUNCTION_TYPE); |
2691 pop(object); | 2598 pop(object); |
2692 Check(eq, kOperandIsNotAFunction); | 2599 Check(eq, kOperandIsNotAFunction); |
2693 } | 2600 } |
(...skipping 17 matching lines...) Expand all Loading... |
2711 STATIC_ASSERT(kSmiTag == 0); | 2618 STATIC_ASSERT(kSmiTag == 0); |
2712 TestIfSmi(object, r0); | 2619 TestIfSmi(object, r0); |
2713 Check(ne, kOperandIsASmiAndNotAGeneratorObject, cr0); | 2620 Check(ne, kOperandIsASmiAndNotAGeneratorObject, cr0); |
2714 push(object); | 2621 push(object); |
2715 CompareObjectType(object, object, object, JS_GENERATOR_OBJECT_TYPE); | 2622 CompareObjectType(object, object, object, JS_GENERATOR_OBJECT_TYPE); |
2716 pop(object); | 2623 pop(object); |
2717 Check(eq, kOperandIsNotAGeneratorObject); | 2624 Check(eq, kOperandIsNotAGeneratorObject); |
2718 } | 2625 } |
2719 } | 2626 } |
2720 | 2627 |
2721 void MacroAssembler::AssertReceiver(Register object) { | |
2722 if (emit_debug_code()) { | |
2723 STATIC_ASSERT(kSmiTag == 0); | |
2724 TestIfSmi(object, r0); | |
2725 Check(ne, kOperandIsASmiAndNotAReceiver, cr0); | |
2726 push(object); | |
2727 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); | |
2728 CompareObjectType(object, object, object, FIRST_JS_RECEIVER_TYPE); | |
2729 pop(object); | |
2730 Check(ge, kOperandIsNotAReceiver); | |
2731 } | |
2732 } | |
2733 | |
2734 void MacroAssembler::AssertUndefinedOrAllocationSite(Register object, | 2628 void MacroAssembler::AssertUndefinedOrAllocationSite(Register object, |
2735 Register scratch) { | 2629 Register scratch) { |
2736 if (emit_debug_code()) { | 2630 if (emit_debug_code()) { |
2737 Label done_checking; | 2631 Label done_checking; |
2738 AssertNotSmi(object); | 2632 AssertNotSmi(object); |
2739 CompareRoot(object, Heap::kUndefinedValueRootIndex); | 2633 CompareRoot(object, Heap::kUndefinedValueRootIndex); |
2740 beq(&done_checking); | 2634 beq(&done_checking); |
2741 LoadP(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); | 2635 LoadP(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); |
2742 CompareRoot(scratch, Heap::kAllocationSiteMapRootIndex); | 2636 CompareRoot(scratch, Heap::kAllocationSiteMapRootIndex); |
2743 Assert(eq, kExpectedUndefinedOrCell); | 2637 Assert(eq, kExpectedUndefinedOrCell); |
(...skipping 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4333 } | 4227 } |
4334 if (mag.shift > 0) srawi(result, result, mag.shift); | 4228 if (mag.shift > 0) srawi(result, result, mag.shift); |
4335 ExtractBit(r0, dividend, 31); | 4229 ExtractBit(r0, dividend, 31); |
4336 add(result, result, r0); | 4230 add(result, result, r0); |
4337 } | 4231 } |
4338 | 4232 |
4339 } // namespace internal | 4233 } // namespace internal |
4340 } // namespace v8 | 4234 } // namespace v8 |
4341 | 4235 |
4342 #endif // V8_TARGET_ARCH_PPC | 4236 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |