| 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 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #if V8_TARGET_ARCH_PPC | 10 #if V8_TARGET_ARCH_PPC |
| (...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 | 1132 |
| 1133 void MacroAssembler::PopTryHandler() { | 1133 void MacroAssembler::PopTryHandler() { |
| 1134 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | 1134 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); |
| 1135 pop(r4); | 1135 pop(r4); |
| 1136 mov(ip, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); | 1136 mov(ip, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); |
| 1137 addi(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize)); | 1137 addi(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize)); |
| 1138 StoreP(r4, MemOperand(ip)); | 1138 StoreP(r4, MemOperand(ip)); |
| 1139 } | 1139 } |
| 1140 | 1140 |
| 1141 | 1141 |
| 1142 // PPC - make use of ip as a temporary register | |
| 1143 void MacroAssembler::JumpToHandlerEntry() { | |
| 1144 // Compute the handler entry address and jump to it. The handler table is | |
| 1145 // a fixed array of (smi-tagged) code offsets. | |
| 1146 // r3 = exception, r4 = code object, r5 = state. | |
| 1147 LoadP(r6, FieldMemOperand(r4, Code::kHandlerTableOffset)); // Handler table. | |
| 1148 addi(r4, r4, Operand(Code::kHeaderSize - kHeapObjectTag)); // Code start. | |
| 1149 addi(r6, r6, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | |
| 1150 srwi(r5, r5, Operand(StackHandler::kKindWidth)); // Handler index. | |
| 1151 slwi(ip, r5, Operand(kPointerSizeLog2)); | |
| 1152 add(ip, r6, ip); | |
| 1153 LoadP(r5, MemOperand(ip)); // Smi-tagged offset. | |
| 1154 SmiUntag(ip, r5); | |
| 1155 add(ip, r4, ip); | |
| 1156 Jump(ip); | |
| 1157 } | |
| 1158 | |
| 1159 | |
| 1160 void MacroAssembler::Throw(Register value) { | |
| 1161 // Adjust this code if not the case. | |
| 1162 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); | |
| 1163 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | |
| 1164 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); | |
| 1165 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); | |
| 1166 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); | |
| 1167 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); | |
| 1168 Label skip; | |
| 1169 | |
| 1170 // The exception is expected in r3. | |
| 1171 if (!value.is(r3)) { | |
| 1172 mr(r3, value); | |
| 1173 } | |
| 1174 // Drop the stack pointer to the top of the top handler. | |
| 1175 mov(r6, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); | |
| 1176 LoadP(sp, MemOperand(r6)); | |
| 1177 // Restore the next handler. | |
| 1178 pop(r5); | |
| 1179 StoreP(r5, MemOperand(r6)); | |
| 1180 | |
| 1181 // Get the code object (r4) and state (r5). Restore the context and frame | |
| 1182 // pointer. | |
| 1183 pop(r4); | |
| 1184 pop(r5); | |
| 1185 pop(cp); | |
| 1186 pop(fp); | |
| 1187 | |
| 1188 // If the handler is a JS frame, restore the context to the frame. | |
| 1189 // (kind == ENTRY) == (fp == 0) == (cp == 0), so we could test either fp | |
| 1190 // or cp. | |
| 1191 cmpi(cp, Operand::Zero()); | |
| 1192 beq(&skip); | |
| 1193 StoreP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
| 1194 bind(&skip); | |
| 1195 | |
| 1196 JumpToHandlerEntry(); | |
| 1197 } | |
| 1198 | |
| 1199 | |
| 1200 void MacroAssembler::ThrowUncatchable(Register value) { | |
| 1201 // Adjust this code if not the case. | |
| 1202 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); | |
| 1203 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); | |
| 1204 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); | |
| 1205 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); | |
| 1206 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); | |
| 1207 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); | |
| 1208 | |
| 1209 // The exception is expected in r3. | |
| 1210 if (!value.is(r3)) { | |
| 1211 mr(r3, value); | |
| 1212 } | |
| 1213 // Drop the stack pointer to the top of the top stack handler. | |
| 1214 mov(r6, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); | |
| 1215 LoadP(sp, MemOperand(r6)); | |
| 1216 | |
| 1217 // Unwind the handlers until the ENTRY handler is found. | |
| 1218 Label fetch_next, check_kind; | |
| 1219 b(&check_kind); | |
| 1220 bind(&fetch_next); | |
| 1221 LoadP(sp, MemOperand(sp, StackHandlerConstants::kNextOffset)); | |
| 1222 | |
| 1223 bind(&check_kind); | |
| 1224 STATIC_ASSERT(StackHandler::JS_ENTRY == 0); | |
| 1225 LoadP(r5, MemOperand(sp, StackHandlerConstants::kStateOffset)); | |
| 1226 andi(r0, r5, Operand(StackHandler::KindField::kMask)); | |
| 1227 bne(&fetch_next, cr0); | |
| 1228 | |
| 1229 // Set the top handler address to next handler past the top ENTRY handler. | |
| 1230 pop(r5); | |
| 1231 StoreP(r5, MemOperand(r6)); | |
| 1232 // Get the code object (r4) and state (r5). Clear the context and frame | |
| 1233 // pointer (0 was saved in the handler). | |
| 1234 pop(r4); | |
| 1235 pop(r5); | |
| 1236 pop(cp); | |
| 1237 pop(fp); | |
| 1238 | |
| 1239 JumpToHandlerEntry(); | |
| 1240 } | |
| 1241 | |
| 1242 | |
| 1243 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, | 1142 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, |
| 1244 Register scratch, Label* miss) { | 1143 Register scratch, Label* miss) { |
| 1245 Label same_contexts; | 1144 Label same_contexts; |
| 1246 | 1145 |
| 1247 DCHECK(!holder_reg.is(scratch)); | 1146 DCHECK(!holder_reg.is(scratch)); |
| 1248 DCHECK(!holder_reg.is(ip)); | 1147 DCHECK(!holder_reg.is(ip)); |
| 1249 DCHECK(!scratch.is(ip)); | 1148 DCHECK(!scratch.is(ip)); |
| 1250 | 1149 |
| 1251 // Load current lexical context from the stack frame. | 1150 // Load current lexical context from the stack frame. |
| 1252 LoadP(scratch, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 1151 LoadP(scratch, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| (...skipping 2701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3954 subi(sp, sp, Operand(kDoubleSize)); | 3853 subi(sp, sp, Operand(kDoubleSize)); |
| 3955 stw(src_hi, MemOperand(sp, Register::kExponentOffset)); | 3854 stw(src_hi, MemOperand(sp, Register::kExponentOffset)); |
| 3956 stw(src_lo, MemOperand(sp, Register::kMantissaOffset)); | 3855 stw(src_lo, MemOperand(sp, Register::kMantissaOffset)); |
| 3957 nop(GROUP_ENDING_NOP); // LHS/RAW optimization | 3856 nop(GROUP_ENDING_NOP); // LHS/RAW optimization |
| 3958 lfd(dst, MemOperand(sp)); | 3857 lfd(dst, MemOperand(sp)); |
| 3959 addi(sp, sp, Operand(kDoubleSize)); | 3858 addi(sp, sp, Operand(kDoubleSize)); |
| 3960 } | 3859 } |
| 3961 #endif | 3860 #endif |
| 3962 | 3861 |
| 3963 | 3862 |
| 3863 void MacroAssembler::InsertDoubleLow(DoubleRegister dst, Register src, |
| 3864 Register scratch) { |
| 3865 #if V8_TARGET_ARCH_PPC64 |
| 3866 if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { |
| 3867 mffprd(scratch, dst); |
| 3868 rldimi(scratch, src, 0, 32); |
| 3869 mtfprd(dst, scratch); |
| 3870 return; |
| 3871 } |
| 3872 #endif |
| 3873 |
| 3874 subi(sp, sp, Operand(kDoubleSize)); |
| 3875 stfd(dst, MemOperand(sp)); |
| 3876 stw(src, MemOperand(sp, Register::kMantissaOffset)); |
| 3877 nop(GROUP_ENDING_NOP); // LHS/RAW optimization |
| 3878 lfd(dst, MemOperand(sp)); |
| 3879 addi(sp, sp, Operand(kDoubleSize)); |
| 3880 } |
| 3881 |
| 3882 |
| 3883 void MacroAssembler::InsertDoubleHigh(DoubleRegister dst, Register src, |
| 3884 Register scratch) { |
| 3885 #if V8_TARGET_ARCH_PPC64 |
| 3886 if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { |
| 3887 mffprd(scratch, dst); |
| 3888 rldimi(scratch, src, 32, 0); |
| 3889 mtfprd(dst, scratch); |
| 3890 return; |
| 3891 } |
| 3892 #endif |
| 3893 |
| 3894 subi(sp, sp, Operand(kDoubleSize)); |
| 3895 stfd(dst, MemOperand(sp)); |
| 3896 stw(src, MemOperand(sp, Register::kExponentOffset)); |
| 3897 nop(GROUP_ENDING_NOP); // LHS/RAW optimization |
| 3898 lfd(dst, MemOperand(sp)); |
| 3899 addi(sp, sp, Operand(kDoubleSize)); |
| 3900 } |
| 3901 |
| 3902 |
| 3964 void MacroAssembler::MovDoubleLowToInt(Register dst, DoubleRegister src) { | 3903 void MacroAssembler::MovDoubleLowToInt(Register dst, DoubleRegister src) { |
| 3965 #if V8_TARGET_ARCH_PPC64 | 3904 #if V8_TARGET_ARCH_PPC64 |
| 3966 if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { | 3905 if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { |
| 3967 mffprwz(dst, src); | 3906 mffprwz(dst, src); |
| 3968 return; | 3907 return; |
| 3969 } | 3908 } |
| 3970 #endif | 3909 #endif |
| 3971 | 3910 |
| 3972 subi(sp, sp, Operand(kDoubleSize)); | 3911 subi(sp, sp, Operand(kDoubleSize)); |
| 3973 stfd(src, MemOperand(sp)); | 3912 stfd(src, MemOperand(sp)); |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4614 } | 4553 } |
| 4615 if (mag.shift > 0) srawi(result, result, mag.shift); | 4554 if (mag.shift > 0) srawi(result, result, mag.shift); |
| 4616 ExtractBit(r0, dividend, 31); | 4555 ExtractBit(r0, dividend, 31); |
| 4617 add(result, result, r0); | 4556 add(result, result, r0); |
| 4618 } | 4557 } |
| 4619 | 4558 |
| 4620 } // namespace internal | 4559 } // namespace internal |
| 4621 } // namespace v8 | 4560 } // namespace v8 |
| 4622 | 4561 |
| 4623 #endif // V8_TARGET_ARCH_PPC | 4562 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |