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 #if V8_TARGET_ARCH_PPC | 5 #if V8_TARGET_ARCH_PPC |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { | 1122 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { |
1123 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); | 1123 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); |
1124 } | 1124 } |
1125 | 1125 |
1126 | 1126 |
1127 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { | 1127 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { |
1128 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); | 1128 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); |
1129 } | 1129 } |
1130 | 1130 |
1131 | 1131 |
| 1132 // Clobbers registers {r7, r8, r9, r10}. |
| 1133 void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver, |
| 1134 Register function_template_info, |
| 1135 Label* receiver_check_failed) { |
| 1136 Register signature = r7; |
| 1137 Register map = r8; |
| 1138 Register constructor = r9; |
| 1139 Register scratch = r10; |
| 1140 |
| 1141 __ JumpIfSmi(receiver, receiver_check_failed); |
| 1142 __ CompareObjectType(receiver, map, no_reg, FIRST_JS_OBJECT_TYPE); |
| 1143 __ blt(receiver_check_failed); |
| 1144 |
| 1145 // If there is no signature, return the holder. |
| 1146 __ LoadP(signature, FieldMemOperand(function_template_info, |
| 1147 FunctionTemplateInfo::kSignatureOffset)); |
| 1148 Label receiver_check_passed; |
| 1149 __ JumpIfRoot(signature, Heap::kUndefinedValueRootIndex, |
| 1150 &receiver_check_passed); |
| 1151 |
| 1152 // Walk the prototype chain. |
| 1153 Label prototype_loop_start; |
| 1154 __ bind(&prototype_loop_start); |
| 1155 |
| 1156 // End if the receiver is null or if it's a hidden type. |
| 1157 __ JumpIfRoot(receiver, Heap::kNullValueRootIndex, receiver_check_failed); |
| 1158 __ LoadP(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 1159 __ LoadP(scratch, FieldMemOperand(map, Map::kBitField3Offset)); |
| 1160 __ DecodeField<Map::IsHiddenPrototype>(scratch); |
| 1161 __ cmpi(scratch, Operand::Zero()); |
| 1162 __ bne(receiver_check_failed); |
| 1163 |
| 1164 |
| 1165 // Get the constructor, if any. |
| 1166 __ GetMapConstructor(constructor, map, scratch, scratch); |
| 1167 __ cmpi(scratch, Operand(JS_FUNCTION_TYPE)); |
| 1168 Label next_prototype; |
| 1169 __ bne(&next_prototype); |
| 1170 Register type = constructor; |
| 1171 __ LoadP(type, |
| 1172 FieldMemOperand(constructor, JSFunction::kSharedFunctionInfoOffset)); |
| 1173 __ LoadP(type, |
| 1174 FieldMemOperand(type, SharedFunctionInfo::kFunctionDataOffset)); |
| 1175 |
| 1176 // Loop through the chain of inheriting function templates. |
| 1177 Label function_template_loop; |
| 1178 __ bind(&function_template_loop); |
| 1179 |
| 1180 // If the signatures match, we have a compatible receiver. |
| 1181 __ cmp(signature, type); |
| 1182 __ beq(&receiver_check_passed); |
| 1183 |
| 1184 // If the current type is not a FunctionTemplateInfo, load the next prototype |
| 1185 // in the chain. |
| 1186 __ JumpIfSmi(type, &next_prototype); |
| 1187 __ CompareObjectType(type, scratch, scratch, FUNCTION_TEMPLATE_INFO_TYPE); |
| 1188 __ bne(&next_prototype); |
| 1189 |
| 1190 // Otherwise load the parent function template and iterate. |
| 1191 __ LoadP(type, |
| 1192 FieldMemOperand(type, FunctionTemplateInfo::kParentTemplateOffset)); |
| 1193 __ b(&function_template_loop); |
| 1194 |
| 1195 // Load the next prototype and iterate. |
| 1196 __ bind(&next_prototype); |
| 1197 __ LoadP(receiver, FieldMemOperand(map, Map::kPrototypeOffset)); |
| 1198 __ b(&prototype_loop_start); |
| 1199 |
| 1200 __ bind(&receiver_check_passed); |
| 1201 } |
| 1202 |
| 1203 |
| 1204 void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { |
| 1205 // ----------- S t a t e ------------- |
| 1206 // -- r3 : number of arguments excluding receiver |
| 1207 // -- r4 : callee |
| 1208 // -- lr : return address |
| 1209 // -- sp[0] : last argument |
| 1210 // -- ... |
| 1211 // -- sp[4 * (argc - 1)] : first argument |
| 1212 // -- sp[4 * argc] : receiver |
| 1213 // ----------------------------------- |
| 1214 |
| 1215 // Load the receiver. |
| 1216 __ ShiftLeftImm(r11, r3, Operand(kPointerSizeLog2)); |
| 1217 __ add(r11, sp, r11); |
| 1218 __ LoadP(r5, MemOperand(r11)); |
| 1219 |
| 1220 // Update the receiver if this is a contextual call. |
| 1221 Label set_global_proxy, valid_receiver; |
| 1222 __ JumpIfRoot(r5, Heap::kUndefinedValueRootIndex, &set_global_proxy); |
| 1223 |
| 1224 // Load the FunctionTemplateInfo. |
| 1225 __ bind(&valid_receiver); |
| 1226 __ LoadP(r6, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
| 1227 __ LoadP(r6, FieldMemOperand(r6, SharedFunctionInfo::kFunctionDataOffset)); |
| 1228 |
| 1229 // Do the compatible receiver check. |
| 1230 Label receiver_check_failed; |
| 1231 CompatibleReceiverCheck(masm, r5, r6, &receiver_check_failed); |
| 1232 |
| 1233 // Get the callback offset from the FunctionTemplateInfo, and jump to the |
| 1234 // beginning of the code. |
| 1235 __ LoadP(r6, FieldMemOperand(r6, FunctionTemplateInfo::kCallCodeOffset)); |
| 1236 __ LoadP(r6, FieldMemOperand(r6, CallHandlerInfo::kFastHandlerOffset)); |
| 1237 __ addi(r6, r6, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1238 __ Jump(r6); |
| 1239 |
| 1240 __ bind(&set_global_proxy); |
| 1241 __ LoadGlobalProxy(r5); |
| 1242 __ StoreP(r5, MemOperand(r11)); |
| 1243 __ b(&valid_receiver); |
| 1244 |
| 1245 // Compatible receiver check failed: throw an Illegal Invocation exception. |
| 1246 __ bind(&receiver_check_failed); |
| 1247 // Drop the arguments (including the receiver); |
| 1248 __ addi(r11, r11, Operand(kPointerSize)); |
| 1249 __ StoreP(sp, MemOperand(r11)); |
| 1250 __ TailCallRuntime(Runtime::kThrowIllegalInvocation, 0, 1); |
| 1251 } |
| 1252 |
| 1253 |
1132 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { | 1254 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { |
1133 // Lookup the function in the JavaScript frame. | 1255 // Lookup the function in the JavaScript frame. |
1134 __ LoadP(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1256 __ LoadP(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1135 { | 1257 { |
1136 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1258 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
1137 // Pass function as argument. | 1259 // Pass function as argument. |
1138 __ push(r3); | 1260 __ push(r3); |
1139 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); | 1261 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); |
1140 } | 1262 } |
1141 | 1263 |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1871 __ bkpt(0); | 1993 __ bkpt(0); |
1872 } | 1994 } |
1873 } | 1995 } |
1874 | 1996 |
1875 | 1997 |
1876 #undef __ | 1998 #undef __ |
1877 } // namespace internal | 1999 } // namespace internal |
1878 } // namespace v8 | 2000 } // namespace v8 |
1879 | 2001 |
1880 #endif // V8_TARGET_ARCH_PPC | 2002 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |