| 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 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 mov(r4, Operand(ExternalReference(Runtime::kDebugBreak, isolate()))); | 1082 mov(r4, Operand(ExternalReference(Runtime::kDebugBreak, isolate()))); |
| 1083 CEntryStub ces(isolate(), 1); | 1083 CEntryStub ces(isolate(), 1); |
| 1084 DCHECK(AllowThisStubCall(&ces)); | 1084 DCHECK(AllowThisStubCall(&ces)); |
| 1085 Call(ces.GetCode(), RelocInfo::DEBUG_BREAK); | 1085 Call(ces.GetCode(), RelocInfo::DEBUG_BREAK); |
| 1086 } | 1086 } |
| 1087 | 1087 |
| 1088 | 1088 |
| 1089 void MacroAssembler::PushTryHandler(StackHandler::Kind kind, | 1089 void MacroAssembler::PushTryHandler(StackHandler::Kind kind, |
| 1090 int handler_index) { | 1090 int handler_index) { |
| 1091 // Adjust this code if not the case. | 1091 // Adjust this code if not the case. |
| 1092 STATIC_ASSERT(StackHandlerConstants::kSize == 5 * kPointerSize); | 1092 STATIC_ASSERT(StackHandlerConstants::kSize == 3 * kPointerSize); |
| 1093 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); | 1093 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kPointerSize); |
| 1094 STATIC_ASSERT(StackHandlerConstants::kCodeOffset == 1 * kPointerSize); | 1094 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 1 * kPointerSize); |
| 1095 STATIC_ASSERT(StackHandlerConstants::kStateOffset == 2 * kPointerSize); | 1095 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 2 * kPointerSize); |
| 1096 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); | |
| 1097 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); | |
| 1098 | 1096 |
| 1099 // For the JSEntry handler, we must preserve r1-r7, r0,r8-r15 are available. | 1097 // For the JSEntry handler, we must preserve r1-r7, r0,r8-r12 are available. |
| 1100 // We want the stack to look like | 1098 // We want the stack to look like |
| 1101 // sp -> NextOffset | 1099 // sp -> NextOffset |
| 1102 // CodeObject | |
| 1103 // state | 1100 // state |
| 1104 // context | 1101 // context |
| 1105 // frame pointer | |
| 1106 | 1102 |
| 1107 // Link the current handler as the next handler. | 1103 // Link the current handler as the next handler. |
| 1108 mov(r8, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); | 1104 mov(r8, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); |
| 1109 LoadP(r0, MemOperand(r8)); | 1105 LoadP(r0, MemOperand(r8)); |
| 1110 StorePU(r0, MemOperand(sp, -StackHandlerConstants::kSize)); | 1106 StorePU(r0, MemOperand(sp, -StackHandlerConstants::kSize)); |
| 1111 // Set this new handler as the current one. | 1107 // Set this new handler as the current one. |
| 1112 StoreP(sp, MemOperand(r8)); | 1108 StoreP(sp, MemOperand(r8)); |
| 1113 | 1109 |
| 1114 if (kind == StackHandler::JS_ENTRY) { | |
| 1115 li(r8, Operand::Zero()); // NULL frame pointer. | |
| 1116 StoreP(r8, MemOperand(sp, StackHandlerConstants::kFPOffset)); | |
| 1117 LoadSmiLiteral(r8, Smi::FromInt(0)); // Indicates no context. | |
| 1118 StoreP(r8, MemOperand(sp, StackHandlerConstants::kContextOffset)); | |
| 1119 } else { | |
| 1120 // still not sure if fp is right | |
| 1121 StoreP(fp, MemOperand(sp, StackHandlerConstants::kFPOffset)); | |
| 1122 StoreP(cp, MemOperand(sp, StackHandlerConstants::kContextOffset)); | |
| 1123 } | |
| 1124 unsigned state = StackHandler::IndexField::encode(handler_index) | | 1110 unsigned state = StackHandler::IndexField::encode(handler_index) | |
| 1125 StackHandler::KindField::encode(kind); | 1111 StackHandler::KindField::encode(kind); |
| 1126 LoadIntLiteral(r8, state); | 1112 LoadIntLiteral(r8, state); |
| 1113 |
| 1114 if (kind == StackHandler::JS_ENTRY) { |
| 1115 LoadSmiLiteral(cp, Smi::FromInt(0)); // Indicates no context. |
| 1116 } |
| 1127 StoreP(r8, MemOperand(sp, StackHandlerConstants::kStateOffset)); | 1117 StoreP(r8, MemOperand(sp, StackHandlerConstants::kStateOffset)); |
| 1128 mov(r8, Operand(CodeObject())); | 1118 StoreP(cp, MemOperand(sp, StackHandlerConstants::kContextOffset)); |
| 1129 StoreP(r8, MemOperand(sp, StackHandlerConstants::kCodeOffset)); | |
| 1130 } | 1119 } |
| 1131 | 1120 |
| 1132 | 1121 |
| 1133 void MacroAssembler::PopTryHandler() { | 1122 void MacroAssembler::PopTryHandler() { |
| 1134 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); | 1123 STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); |
| 1135 pop(r4); | 1124 pop(r4); |
| 1136 mov(ip, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); | 1125 mov(ip, Operand(ExternalReference(Isolate::kHandlerAddress, isolate()))); |
| 1137 addi(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize)); | 1126 addi(sp, sp, Operand(StackHandlerConstants::kSize - kPointerSize)); |
| 1138 StoreP(r4, MemOperand(ip)); | 1127 StoreP(r4, MemOperand(ip)); |
| 1139 } | 1128 } |
| 1140 | 1129 |
| 1141 | 1130 |
| 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, | 1131 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, |
| 1244 Register scratch, Label* miss) { | 1132 Register scratch, Label* miss) { |
| 1245 Label same_contexts; | 1133 Label same_contexts; |
| 1246 | 1134 |
| 1247 DCHECK(!holder_reg.is(scratch)); | 1135 DCHECK(!holder_reg.is(scratch)); |
| 1248 DCHECK(!holder_reg.is(ip)); | 1136 DCHECK(!holder_reg.is(ip)); |
| 1249 DCHECK(!scratch.is(ip)); | 1137 DCHECK(!scratch.is(ip)); |
| 1250 | 1138 |
| 1251 // Load current lexical context from the stack frame. | 1139 // Load current lexical context from the stack frame. |
| 1252 LoadP(scratch, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 1140 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)); | 3842 subi(sp, sp, Operand(kDoubleSize)); |
| 3955 stw(src_hi, MemOperand(sp, Register::kExponentOffset)); | 3843 stw(src_hi, MemOperand(sp, Register::kExponentOffset)); |
| 3956 stw(src_lo, MemOperand(sp, Register::kMantissaOffset)); | 3844 stw(src_lo, MemOperand(sp, Register::kMantissaOffset)); |
| 3957 nop(GROUP_ENDING_NOP); // LHS/RAW optimization | 3845 nop(GROUP_ENDING_NOP); // LHS/RAW optimization |
| 3958 lfd(dst, MemOperand(sp)); | 3846 lfd(dst, MemOperand(sp)); |
| 3959 addi(sp, sp, Operand(kDoubleSize)); | 3847 addi(sp, sp, Operand(kDoubleSize)); |
| 3960 } | 3848 } |
| 3961 #endif | 3849 #endif |
| 3962 | 3850 |
| 3963 | 3851 |
| 3852 void MacroAssembler::InsertDoubleLow(DoubleRegister dst, Register src, |
| 3853 Register scratch) { |
| 3854 #if V8_TARGET_ARCH_PPC64 |
| 3855 if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { |
| 3856 mffprd(scratch, dst); |
| 3857 rldimi(scratch, src, 0, 32); |
| 3858 mtfprd(dst, scratch); |
| 3859 return; |
| 3860 } |
| 3861 #endif |
| 3862 |
| 3863 subi(sp, sp, Operand(kDoubleSize)); |
| 3864 stfd(dst, MemOperand(sp)); |
| 3865 stw(src, MemOperand(sp, Register::kMantissaOffset)); |
| 3866 nop(GROUP_ENDING_NOP); // LHS/RAW optimization |
| 3867 lfd(dst, MemOperand(sp)); |
| 3868 addi(sp, sp, Operand(kDoubleSize)); |
| 3869 } |
| 3870 |
| 3871 |
| 3872 void MacroAssembler::InsertDoubleHigh(DoubleRegister dst, Register src, |
| 3873 Register scratch) { |
| 3874 #if V8_TARGET_ARCH_PPC64 |
| 3875 if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { |
| 3876 mffprd(scratch, dst); |
| 3877 rldimi(scratch, src, 32, 0); |
| 3878 mtfprd(dst, scratch); |
| 3879 return; |
| 3880 } |
| 3881 #endif |
| 3882 |
| 3883 subi(sp, sp, Operand(kDoubleSize)); |
| 3884 stfd(dst, MemOperand(sp)); |
| 3885 stw(src, MemOperand(sp, Register::kExponentOffset)); |
| 3886 nop(GROUP_ENDING_NOP); // LHS/RAW optimization |
| 3887 lfd(dst, MemOperand(sp)); |
| 3888 addi(sp, sp, Operand(kDoubleSize)); |
| 3889 } |
| 3890 |
| 3891 |
| 3964 void MacroAssembler::MovDoubleLowToInt(Register dst, DoubleRegister src) { | 3892 void MacroAssembler::MovDoubleLowToInt(Register dst, DoubleRegister src) { |
| 3965 #if V8_TARGET_ARCH_PPC64 | 3893 #if V8_TARGET_ARCH_PPC64 |
| 3966 if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { | 3894 if (CpuFeatures::IsSupported(FPR_GPR_MOV)) { |
| 3967 mffprwz(dst, src); | 3895 mffprwz(dst, src); |
| 3968 return; | 3896 return; |
| 3969 } | 3897 } |
| 3970 #endif | 3898 #endif |
| 3971 | 3899 |
| 3972 subi(sp, sp, Operand(kDoubleSize)); | 3900 subi(sp, sp, Operand(kDoubleSize)); |
| 3973 stfd(src, MemOperand(sp)); | 3901 stfd(src, MemOperand(sp)); |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4614 } | 4542 } |
| 4615 if (mag.shift > 0) srawi(result, result, mag.shift); | 4543 if (mag.shift > 0) srawi(result, result, mag.shift); |
| 4616 ExtractBit(r0, dividend, 31); | 4544 ExtractBit(r0, dividend, 31); |
| 4617 add(result, result, r0); | 4545 add(result, result, r0); |
| 4618 } | 4546 } |
| 4619 | 4547 |
| 4620 } // namespace internal | 4548 } // namespace internal |
| 4621 } // namespace v8 | 4549 } // namespace v8 |
| 4622 | 4550 |
| 4623 #endif // V8_TARGET_ARCH_PPC | 4551 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |