OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
6 | 6 |
7 #if V8_TARGET_ARCH_ARM | 7 #if V8_TARGET_ARCH_ARM |
8 | 8 |
9 #include "src/assembler-inl.h" | 9 #include "src/assembler-inl.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 | 1916 |
1917 Condition MacroAssembler::IsObjectStringType(Register obj, Register type, | 1917 Condition MacroAssembler::IsObjectStringType(Register obj, Register type, |
1918 Condition cond) { | 1918 Condition cond) { |
1919 ldr(type, FieldMemOperand(obj, HeapObject::kMapOffset), cond); | 1919 ldr(type, FieldMemOperand(obj, HeapObject::kMapOffset), cond); |
1920 ldrb(type, FieldMemOperand(type, Map::kInstanceTypeOffset), cond); | 1920 ldrb(type, FieldMemOperand(type, Map::kInstanceTypeOffset), cond); |
1921 tst(type, Operand(kIsNotStringMask), cond); | 1921 tst(type, Operand(kIsNotStringMask), cond); |
1922 DCHECK_EQ(0u, kStringTag); | 1922 DCHECK_EQ(0u, kStringTag); |
1923 return eq; | 1923 return eq; |
1924 } | 1924 } |
1925 | 1925 |
1926 void MacroAssembler::IsObjectNameType(Register object, | |
1927 Register scratch, | |
1928 Label* fail) { | |
1929 ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); | |
1930 ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); | |
1931 cmp(scratch, Operand(LAST_NAME_TYPE)); | |
1932 b(hi, fail); | |
1933 } | |
1934 | |
1935 void MacroAssembler::MaybeDropFrames() { | 1926 void MacroAssembler::MaybeDropFrames() { |
1936 // Check whether we need to drop frames to restart a function on the stack. | 1927 // Check whether we need to drop frames to restart a function on the stack. |
1937 ExternalReference restart_fp = | 1928 ExternalReference restart_fp = |
1938 ExternalReference::debug_restart_fp_address(isolate()); | 1929 ExternalReference::debug_restart_fp_address(isolate()); |
1939 mov(r1, Operand(restart_fp)); | 1930 mov(r1, Operand(restart_fp)); |
1940 ldr(r1, MemOperand(r1)); | 1931 ldr(r1, MemOperand(r1)); |
1941 tst(r1, r1); | 1932 tst(r1, r1); |
1942 Jump(isolate()->builtins()->FrameDropperTrampoline(), RelocInfo::CODE_TARGET, | 1933 Jump(isolate()->builtins()->FrameDropperTrampoline(), RelocInfo::CODE_TARGET, |
1943 ne); | 1934 ne); |
1944 } | 1935 } |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2385 if (smi_check_type == DO_SMI_CHECK) { | 2376 if (smi_check_type == DO_SMI_CHECK) { |
2386 JumpIfSmi(obj, fail); | 2377 JumpIfSmi(obj, fail); |
2387 } | 2378 } |
2388 ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); | 2379 ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); |
2389 LoadRoot(ip, index); | 2380 LoadRoot(ip, index); |
2390 cmp(scratch, ip); | 2381 cmp(scratch, ip); |
2391 b(ne, fail); | 2382 b(ne, fail); |
2392 } | 2383 } |
2393 | 2384 |
2394 | 2385 |
2395 void MacroAssembler::DispatchWeakMap(Register obj, Register scratch1, | |
2396 Register scratch2, Handle<WeakCell> cell, | |
2397 Handle<Code> success, | |
2398 SmiCheckType smi_check_type) { | |
2399 Label fail; | |
2400 if (smi_check_type == DO_SMI_CHECK) { | |
2401 JumpIfSmi(obj, &fail); | |
2402 } | |
2403 ldr(scratch1, FieldMemOperand(obj, HeapObject::kMapOffset)); | |
2404 CmpWeakValue(scratch1, cell, scratch2); | |
2405 Jump(success, RelocInfo::CODE_TARGET, eq); | |
2406 bind(&fail); | |
2407 } | |
2408 | |
2409 | |
2410 void MacroAssembler::CmpWeakValue(Register value, Handle<WeakCell> cell, | |
2411 Register scratch) { | |
2412 mov(scratch, Operand(cell)); | |
2413 ldr(scratch, FieldMemOperand(scratch, WeakCell::kValueOffset)); | |
2414 cmp(value, scratch); | |
2415 } | |
2416 | |
2417 | |
2418 void MacroAssembler::GetWeakValue(Register value, Handle<WeakCell> cell) { | 2386 void MacroAssembler::GetWeakValue(Register value, Handle<WeakCell> cell) { |
2419 mov(value, Operand(cell)); | 2387 mov(value, Operand(cell)); |
2420 ldr(value, FieldMemOperand(value, WeakCell::kValueOffset)); | 2388 ldr(value, FieldMemOperand(value, WeakCell::kValueOffset)); |
2421 } | 2389 } |
2422 | 2390 |
2423 | 2391 |
2424 void MacroAssembler::LoadWeakValue(Register value, Handle<WeakCell> cell, | 2392 void MacroAssembler::LoadWeakValue(Register value, Handle<WeakCell> cell, |
2425 Label* miss) { | 2393 Label* miss) { |
2426 GetWeakValue(value, cell); | 2394 GetWeakValue(value, cell); |
2427 JumpIfSmi(value, miss); | 2395 JumpIfSmi(value, miss); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2708 } | 2676 } |
2709 } | 2677 } |
2710 | 2678 |
2711 | 2679 |
2712 void MacroAssembler::Assert(Condition cond, BailoutReason reason) { | 2680 void MacroAssembler::Assert(Condition cond, BailoutReason reason) { |
2713 if (emit_debug_code()) | 2681 if (emit_debug_code()) |
2714 Check(cond, reason); | 2682 Check(cond, reason); |
2715 } | 2683 } |
2716 | 2684 |
2717 | 2685 |
2718 void MacroAssembler::AssertFastElements(Register elements) { | |
2719 if (emit_debug_code()) { | |
2720 DCHECK(!elements.is(ip)); | |
2721 Label ok; | |
2722 push(elements); | |
2723 ldr(elements, FieldMemOperand(elements, HeapObject::kMapOffset)); | |
2724 LoadRoot(ip, Heap::kFixedArrayMapRootIndex); | |
2725 cmp(elements, ip); | |
2726 b(eq, &ok); | |
2727 LoadRoot(ip, Heap::kFixedDoubleArrayMapRootIndex); | |
2728 cmp(elements, ip); | |
2729 b(eq, &ok); | |
2730 LoadRoot(ip, Heap::kFixedCOWArrayMapRootIndex); | |
2731 cmp(elements, ip); | |
2732 b(eq, &ok); | |
2733 Abort(kJSObjectWithFastElementsMapHasSlowElements); | |
2734 bind(&ok); | |
2735 pop(elements); | |
2736 } | |
2737 } | |
2738 | |
2739 | 2686 |
2740 void MacroAssembler::Check(Condition cond, BailoutReason reason) { | 2687 void MacroAssembler::Check(Condition cond, BailoutReason reason) { |
2741 Label L; | 2688 Label L; |
2742 b(cond, &L); | 2689 b(cond, &L); |
2743 Abort(reason); | 2690 Abort(reason); |
2744 // will not return here | 2691 // will not return here |
2745 bind(&L); | 2692 bind(&L); |
2746 } | 2693 } |
2747 | 2694 |
2748 | 2695 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2900 | 2847 |
2901 void MacroAssembler::JumpIfEitherSmi(Register reg1, | 2848 void MacroAssembler::JumpIfEitherSmi(Register reg1, |
2902 Register reg2, | 2849 Register reg2, |
2903 Label* on_either_smi) { | 2850 Label* on_either_smi) { |
2904 STATIC_ASSERT(kSmiTag == 0); | 2851 STATIC_ASSERT(kSmiTag == 0); |
2905 tst(reg1, Operand(kSmiTagMask)); | 2852 tst(reg1, Operand(kSmiTagMask)); |
2906 tst(reg2, Operand(kSmiTagMask), ne); | 2853 tst(reg2, Operand(kSmiTagMask), ne); |
2907 b(eq, on_either_smi); | 2854 b(eq, on_either_smi); |
2908 } | 2855 } |
2909 | 2856 |
2910 void MacroAssembler::AssertNotNumber(Register object) { | |
2911 if (emit_debug_code()) { | |
2912 STATIC_ASSERT(kSmiTag == 0); | |
2913 tst(object, Operand(kSmiTagMask)); | |
2914 Check(ne, kOperandIsANumber); | |
2915 push(object); | |
2916 CompareObjectType(object, object, object, HEAP_NUMBER_TYPE); | |
2917 pop(object); | |
2918 Check(ne, kOperandIsANumber); | |
2919 } | |
2920 } | |
2921 | |
2922 void MacroAssembler::AssertNotSmi(Register object) { | 2857 void MacroAssembler::AssertNotSmi(Register object) { |
2923 if (emit_debug_code()) { | 2858 if (emit_debug_code()) { |
2924 STATIC_ASSERT(kSmiTag == 0); | 2859 STATIC_ASSERT(kSmiTag == 0); |
2925 tst(object, Operand(kSmiTagMask)); | 2860 tst(object, Operand(kSmiTagMask)); |
2926 Check(ne, kOperandIsASmi); | 2861 Check(ne, kOperandIsASmi); |
2927 } | 2862 } |
2928 } | 2863 } |
2929 | 2864 |
2930 | 2865 |
2931 void MacroAssembler::AssertSmi(Register object) { | 2866 void MacroAssembler::AssertSmi(Register object) { |
2932 if (emit_debug_code()) { | 2867 if (emit_debug_code()) { |
2933 STATIC_ASSERT(kSmiTag == 0); | 2868 STATIC_ASSERT(kSmiTag == 0); |
2934 tst(object, Operand(kSmiTagMask)); | 2869 tst(object, Operand(kSmiTagMask)); |
2935 Check(eq, kOperandIsNotSmi); | 2870 Check(eq, kOperandIsNotSmi); |
2936 } | 2871 } |
2937 } | 2872 } |
2938 | 2873 |
2939 | 2874 |
2940 void MacroAssembler::AssertString(Register object) { | |
2941 if (emit_debug_code()) { | |
2942 STATIC_ASSERT(kSmiTag == 0); | |
2943 tst(object, Operand(kSmiTagMask)); | |
2944 Check(ne, kOperandIsASmiAndNotAString); | |
2945 push(object); | |
2946 ldr(object, FieldMemOperand(object, HeapObject::kMapOffset)); | |
2947 CompareInstanceType(object, object, FIRST_NONSTRING_TYPE); | |
2948 pop(object); | |
2949 Check(lo, kOperandIsNotAString); | |
2950 } | |
2951 } | |
2952 | |
2953 | |
2954 void MacroAssembler::AssertName(Register object) { | |
2955 if (emit_debug_code()) { | |
2956 STATIC_ASSERT(kSmiTag == 0); | |
2957 tst(object, Operand(kSmiTagMask)); | |
2958 Check(ne, kOperandIsASmiAndNotAName); | |
2959 push(object); | |
2960 ldr(object, FieldMemOperand(object, HeapObject::kMapOffset)); | |
2961 CompareInstanceType(object, object, LAST_NAME_TYPE); | |
2962 pop(object); | |
2963 Check(le, kOperandIsNotAName); | |
2964 } | |
2965 } | |
2966 | |
2967 | |
2968 void MacroAssembler::AssertFunction(Register object) { | 2875 void MacroAssembler::AssertFunction(Register object) { |
2969 if (emit_debug_code()) { | 2876 if (emit_debug_code()) { |
2970 STATIC_ASSERT(kSmiTag == 0); | 2877 STATIC_ASSERT(kSmiTag == 0); |
2971 tst(object, Operand(kSmiTagMask)); | 2878 tst(object, Operand(kSmiTagMask)); |
2972 Check(ne, kOperandIsASmiAndNotAFunction); | 2879 Check(ne, kOperandIsASmiAndNotAFunction); |
2973 push(object); | 2880 push(object); |
2974 CompareObjectType(object, object, object, JS_FUNCTION_TYPE); | 2881 CompareObjectType(object, object, object, JS_FUNCTION_TYPE); |
2975 pop(object); | 2882 pop(object); |
2976 Check(eq, kOperandIsNotAFunction); | 2883 Check(eq, kOperandIsNotAFunction); |
2977 } | 2884 } |
(...skipping 17 matching lines...) Expand all Loading... |
2995 STATIC_ASSERT(kSmiTag == 0); | 2902 STATIC_ASSERT(kSmiTag == 0); |
2996 tst(object, Operand(kSmiTagMask)); | 2903 tst(object, Operand(kSmiTagMask)); |
2997 Check(ne, kOperandIsASmiAndNotAGeneratorObject); | 2904 Check(ne, kOperandIsASmiAndNotAGeneratorObject); |
2998 push(object); | 2905 push(object); |
2999 CompareObjectType(object, object, object, JS_GENERATOR_OBJECT_TYPE); | 2906 CompareObjectType(object, object, object, JS_GENERATOR_OBJECT_TYPE); |
3000 pop(object); | 2907 pop(object); |
3001 Check(eq, kOperandIsNotAGeneratorObject); | 2908 Check(eq, kOperandIsNotAGeneratorObject); |
3002 } | 2909 } |
3003 } | 2910 } |
3004 | 2911 |
3005 void MacroAssembler::AssertReceiver(Register object) { | |
3006 if (emit_debug_code()) { | |
3007 STATIC_ASSERT(kSmiTag == 0); | |
3008 tst(object, Operand(kSmiTagMask)); | |
3009 Check(ne, kOperandIsASmiAndNotAReceiver); | |
3010 push(object); | |
3011 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); | |
3012 CompareObjectType(object, object, object, FIRST_JS_RECEIVER_TYPE); | |
3013 pop(object); | |
3014 Check(hs, kOperandIsNotAReceiver); | |
3015 } | |
3016 } | |
3017 | |
3018 | |
3019 void MacroAssembler::AssertUndefinedOrAllocationSite(Register object, | 2912 void MacroAssembler::AssertUndefinedOrAllocationSite(Register object, |
3020 Register scratch) { | 2913 Register scratch) { |
3021 if (emit_debug_code()) { | 2914 if (emit_debug_code()) { |
3022 Label done_checking; | 2915 Label done_checking; |
3023 AssertNotSmi(object); | 2916 AssertNotSmi(object); |
3024 CompareRoot(object, Heap::kUndefinedValueRootIndex); | 2917 CompareRoot(object, Heap::kUndefinedValueRootIndex); |
3025 b(eq, &done_checking); | 2918 b(eq, &done_checking); |
3026 ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); | 2919 ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); |
3027 CompareRoot(scratch, Heap::kAllocationSiteMapRootIndex); | 2920 CompareRoot(scratch, Heap::kAllocationSiteMapRootIndex); |
3028 Assert(eq, kExpectedUndefinedOrCell); | 2921 Assert(eq, kExpectedUndefinedOrCell); |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3884 } | 3777 } |
3885 } | 3778 } |
3886 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); | 3779 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); |
3887 add(result, result, Operand(dividend, LSR, 31)); | 3780 add(result, result, Operand(dividend, LSR, 31)); |
3888 } | 3781 } |
3889 | 3782 |
3890 } // namespace internal | 3783 } // namespace internal |
3891 } // namespace v8 | 3784 } // namespace v8 |
3892 | 3785 |
3893 #endif // V8_TARGET_ARCH_ARM | 3786 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |