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 #if V8_TARGET_ARCH_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
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 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); | 1106 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); |
1107 } | 1107 } |
1108 | 1108 |
1109 | 1109 |
1110 void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) { | 1110 void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) { |
1111 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); | 1111 Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); |
1112 } | 1112 } |
1113 | 1113 |
1114 | 1114 |
1115 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 1115 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
| 1116 // ----------- S t a t e ------------- |
| 1117 // -- a3 : new target (preserved for callee) |
| 1118 // -- a1 : target function (preserved for callee) |
| 1119 // ----------------------------------- |
| 1120 // First lookup code, maybe we don't need to compile! |
| 1121 Label gotta_call_runtime, gotta_call_runtime_no_stack; |
| 1122 Label maybe_call_runtime; |
| 1123 Label try_shared; |
| 1124 Label loop_top, loop_bottom; |
| 1125 |
| 1126 Register closure = a1; |
| 1127 Register new_target = a3; |
| 1128 __ push(new_target); |
| 1129 __ push(closure); |
| 1130 |
| 1131 Register map = a0; |
| 1132 Register index = a2; |
| 1133 __ ld(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 1134 __ ld(map, FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); |
| 1135 __ ld(index, FieldMemOperand(map, FixedArray::kLengthOffset)); |
| 1136 __ Branch(&gotta_call_runtime, lt, index, Operand(Smi::FromInt(2))); |
| 1137 |
| 1138 // Find literals. |
| 1139 // a3 : native context |
| 1140 // a2 : length / index |
| 1141 // a0 : optimized code map |
| 1142 // stack[0] : new target |
| 1143 // stack[4] : closure |
| 1144 Register native_context = a3; |
| 1145 __ ld(native_context, NativeContextMemOperand()); |
| 1146 |
| 1147 __ bind(&loop_top); |
| 1148 Register temp = a1; |
| 1149 Register array_pointer = a5; |
| 1150 |
| 1151 // Does the native context match? |
| 1152 __ SmiScale(at, index, kPointerSizeLog2); |
| 1153 __ Daddu(array_pointer, map, Operand(at)); |
| 1154 __ ld(temp, FieldMemOperand(array_pointer, |
| 1155 SharedFunctionInfo::OffsetToPreviousContext())); |
| 1156 __ ld(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
| 1157 __ Branch(&loop_bottom, ne, temp, Operand(native_context)); |
| 1158 // OSR id set to none? |
| 1159 __ ld(temp, FieldMemOperand(array_pointer, |
| 1160 SharedFunctionInfo::OffsetToPreviousOsrAstId())); |
| 1161 const int bailout_id = BailoutId::None().ToInt(); |
| 1162 __ Branch(&loop_bottom, ne, temp, Operand(Smi::FromInt(bailout_id))); |
| 1163 // Literals available? |
| 1164 __ ld(temp, FieldMemOperand(array_pointer, |
| 1165 SharedFunctionInfo::OffsetToPreviousLiterals())); |
| 1166 __ ld(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
| 1167 __ JumpIfSmi(temp, &gotta_call_runtime); |
| 1168 |
| 1169 // Save the literals in the closure. |
| 1170 __ ld(a4, MemOperand(sp, 0)); |
| 1171 __ sd(temp, FieldMemOperand(a4, JSFunction::kLiteralsOffset)); |
| 1172 __ push(index); |
| 1173 __ RecordWriteField(a4, JSFunction::kLiteralsOffset, temp, index, |
| 1174 kRAHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
| 1175 OMIT_SMI_CHECK); |
| 1176 __ pop(index); |
| 1177 |
| 1178 // Code available? |
| 1179 Register entry = a4; |
| 1180 __ ld(entry, |
| 1181 FieldMemOperand(array_pointer, |
| 1182 SharedFunctionInfo::OffsetToPreviousCachedCode())); |
| 1183 __ ld(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
| 1184 __ JumpIfSmi(entry, &maybe_call_runtime); |
| 1185 |
| 1186 // Found literals and code. Get them into the closure and return. |
| 1187 __ pop(closure); |
| 1188 // Store code entry in the closure. |
| 1189 __ Daddu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1190 |
| 1191 Label install_optimized_code_and_tailcall; |
| 1192 __ bind(&install_optimized_code_and_tailcall); |
| 1193 __ sd(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); |
| 1194 |
| 1195 // Link the closure into the optimized function list. |
| 1196 // a4 : code entry |
| 1197 // a3 : native context |
| 1198 // a1 : closure |
| 1199 __ ld(a5, |
| 1200 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
| 1201 __ sd(a5, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset)); |
| 1202 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, a5, a0, |
| 1203 kRAHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
| 1204 OMIT_SMI_CHECK); |
| 1205 const int function_list_offset = |
| 1206 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); |
| 1207 __ sd(closure, |
| 1208 ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
| 1209 // Save closure before the write barrier. |
| 1210 __ mov(a5, closure); |
| 1211 __ RecordWriteContextSlot(native_context, function_list_offset, closure, a0, |
| 1212 kRAHasNotBeenSaved, kDontSaveFPRegs); |
| 1213 __ mov(closure, a5); |
| 1214 __ pop(new_target); |
| 1215 __ Jump(entry); |
| 1216 |
| 1217 __ bind(&loop_bottom); |
| 1218 __ Dsubu(index, index, |
| 1219 Operand(Smi::FromInt(SharedFunctionInfo::kEntryLength))); |
| 1220 __ Branch(&loop_top, gt, index, Operand(Smi::FromInt(1))); |
| 1221 |
| 1222 // We found neither literals nor code. |
| 1223 __ jmp(&gotta_call_runtime); |
| 1224 |
| 1225 __ bind(&maybe_call_runtime); |
| 1226 __ pop(closure); |
| 1227 |
| 1228 // Last possibility. Check the context free optimized code map entry. |
| 1229 __ ld(entry, FieldMemOperand(map, FixedArray::kHeaderSize)); |
| 1230 __ ld(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
| 1231 __ JumpIfSmi(entry, &try_shared); |
| 1232 |
| 1233 // Store code entry in the closure. |
| 1234 __ Daddu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1235 __ jmp(&install_optimized_code_and_tailcall); |
| 1236 |
| 1237 __ bind(&try_shared); |
| 1238 __ pop(new_target); |
| 1239 // Is the full code valid? |
| 1240 __ ld(entry, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 1241 __ ld(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset)); |
| 1242 __ ld(a5, FieldMemOperand(entry, Code::kFlagsOffset)); |
| 1243 __ And(a5, a5, Operand(Code::KindField::kMask)); |
| 1244 __ dsrl(a5, a5, Code::KindField::kShift); |
| 1245 __ Branch(&gotta_call_runtime_no_stack, eq, a5, Operand(Code::BUILTIN)); |
| 1246 // Yes, install the full code. |
| 1247 __ Daddu(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1248 __ sd(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); |
| 1249 __ Jump(entry); |
| 1250 |
| 1251 __ bind(&gotta_call_runtime); |
| 1252 __ pop(closure); |
| 1253 __ pop(new_target); |
| 1254 __ bind(&gotta_call_runtime_no_stack); |
1116 CallRuntimePassFunction(masm, Runtime::kCompileLazy); | 1255 CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
1117 GenerateTailCallToReturnedCode(masm); | 1256 GenerateTailCallToReturnedCode(masm); |
1118 } | 1257 } |
1119 | 1258 |
1120 | 1259 |
1121 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { | 1260 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
1122 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); | 1261 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); |
1123 GenerateTailCallToReturnedCode(masm); | 1262 GenerateTailCallToReturnedCode(masm); |
1124 } | 1263 } |
1125 | 1264 |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2528 } | 2667 } |
2529 } | 2668 } |
2530 | 2669 |
2531 | 2670 |
2532 #undef __ | 2671 #undef __ |
2533 | 2672 |
2534 } // namespace internal | 2673 } // namespace internal |
2535 } // namespace v8 | 2674 } // namespace v8 |
2536 | 2675 |
2537 #endif // V8_TARGET_ARCH_MIPS64 | 2676 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |