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 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 // uses this address to determine whether a frame is interpreted. | 1228 // uses this address to determine whether a frame is interpreted. |
1229 __ mov(r0, | 1229 __ mov(r0, |
1230 Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); | 1230 Operand(masm->isolate()->builtins()->InterpreterEntryTrampoline())); |
1231 __ mtlr(r0); | 1231 __ mtlr(r0); |
1232 | 1232 |
1233 Generate_EnterBytecodeDispatch(masm); | 1233 Generate_EnterBytecodeDispatch(masm); |
1234 } | 1234 } |
1235 | 1235 |
1236 | 1236 |
1237 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 1237 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
| 1238 // ----------- S t a t e ------------- |
| 1239 // -- r6 : new target (preserved for callee) |
| 1240 // -- r4 : target function (preserved for callee) |
| 1241 // ----------------------------------- |
| 1242 // First lookup code, maybe we don't need to compile! |
| 1243 Label gotta_call_runtime; |
| 1244 Label maybe_call_runtime; |
| 1245 Label try_shared; |
| 1246 Label loop_top, loop_bottom; |
| 1247 |
| 1248 Register closure = r4; |
| 1249 Register map = r3; |
| 1250 Register index = r5; |
| 1251 __ LoadP(map, |
| 1252 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 1253 __ LoadP(map, |
| 1254 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); |
| 1255 __ LoadP(index, FieldMemOperand(map, FixedArray::kLengthOffset)); |
| 1256 __ CmpSmiLiteral(index, Smi::FromInt(2), r0); |
| 1257 __ blt(&gotta_call_runtime); |
| 1258 |
| 1259 // Find literals. |
| 1260 // r4 : closure |
| 1261 // r6 : new target |
| 1262 // r3 : optimized code map |
| 1263 // r5 : length / index |
| 1264 // r10 : native context |
| 1265 Register native_context = r10; |
| 1266 __ LoadP(native_context, NativeContextMemOperand()); |
| 1267 |
| 1268 __ bind(&loop_top); |
| 1269 Register array_pointer = r8; |
| 1270 Register temp = r9; |
| 1271 |
| 1272 // Does the native context match? |
| 1273 __ SmiToPtrArrayOffset(array_pointer, index); |
| 1274 __ add(array_pointer, map, array_pointer); |
| 1275 __ LoadP(temp, |
| 1276 FieldMemOperand(array_pointer, |
| 1277 SharedFunctionInfo::OffsetToPreviousContext())); |
| 1278 __ LoadP(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
| 1279 __ cmp(temp, native_context); |
| 1280 __ bne(&loop_bottom); |
| 1281 // OSR id set to none? |
| 1282 __ LoadP(temp, |
| 1283 FieldMemOperand(array_pointer, |
| 1284 SharedFunctionInfo::OffsetToPreviousOsrAstId())); |
| 1285 const int bailout_id = BailoutId::None().ToInt(); |
| 1286 __ CmpSmiLiteral(temp, Smi::FromInt(bailout_id), r0); |
| 1287 __ bne(&loop_bottom); |
| 1288 // Literals available? |
| 1289 __ LoadP(temp, |
| 1290 FieldMemOperand(array_pointer, |
| 1291 SharedFunctionInfo::OffsetToPreviousLiterals())); |
| 1292 __ LoadP(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
| 1293 __ JumpIfSmi(temp, &gotta_call_runtime); |
| 1294 |
| 1295 // Save the literals in the closure. |
| 1296 __ StoreP(temp, FieldMemOperand(closure, JSFunction::kLiteralsOffset), r0); |
| 1297 __ RecordWriteField(closure, JSFunction::kLiteralsOffset, temp, r11, |
| 1298 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
| 1299 OMIT_SMI_CHECK); |
| 1300 |
| 1301 // Code available? |
| 1302 Register entry = r7; |
| 1303 __ LoadP(entry, |
| 1304 FieldMemOperand(array_pointer, |
| 1305 SharedFunctionInfo::OffsetToPreviousCachedCode())); |
| 1306 __ LoadP(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
| 1307 __ JumpIfSmi(entry, &maybe_call_runtime); |
| 1308 |
| 1309 // Found literals and code. Get them into the closure and return. |
| 1310 // Store code entry in the closure. |
| 1311 __ addi(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1312 |
| 1313 Label install_optimized_code_and_tailcall; |
| 1314 __ bind(&install_optimized_code_and_tailcall); |
| 1315 __ StoreP(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset), r0); |
| 1316 __ RecordWriteCodeEntryField(closure, entry, r8); |
| 1317 |
| 1318 // Link the closure into the optimized function list. |
| 1319 // r7 : code entry |
| 1320 // r10: native context |
| 1321 // r4 : closure |
| 1322 __ LoadP( |
| 1323 r8, ContextMemOperand(native_context, Context::OPTIMIZED_FUNCTIONS_LIST)); |
| 1324 __ StoreP(r8, FieldMemOperand(closure, JSFunction::kNextFunctionLinkOffset), |
| 1325 r0); |
| 1326 __ RecordWriteField(closure, JSFunction::kNextFunctionLinkOffset, r8, r3, |
| 1327 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
| 1328 OMIT_SMI_CHECK); |
| 1329 const int function_list_offset = |
| 1330 Context::SlotOffset(Context::OPTIMIZED_FUNCTIONS_LIST); |
| 1331 __ StoreP(closure, ContextMemOperand(native_context, |
| 1332 Context::OPTIMIZED_FUNCTIONS_LIST)); |
| 1333 // Save closure before the write barrier. |
| 1334 __ mr(r8, closure); |
| 1335 __ RecordWriteContextSlot(native_context, function_list_offset, r8, r3, |
| 1336 kLRHasNotBeenSaved, kDontSaveFPRegs); |
| 1337 __ JumpToJSEntry(entry); |
| 1338 |
| 1339 __ bind(&loop_bottom); |
| 1340 __ SubSmiLiteral(index, index, Smi::FromInt(SharedFunctionInfo::kEntryLength), |
| 1341 r0); |
| 1342 __ CmpSmiLiteral(index, Smi::FromInt(1), r0); |
| 1343 __ bgt(&loop_top); |
| 1344 |
| 1345 // We found neither literals nor code. |
| 1346 __ b(&gotta_call_runtime); |
| 1347 |
| 1348 __ bind(&maybe_call_runtime); |
| 1349 |
| 1350 // Last possibility. Check the context free optimized code map entry. |
| 1351 __ LoadP(entry, |
| 1352 FieldMemOperand(map, FixedArray::kHeaderSize + |
| 1353 SharedFunctionInfo::kSharedCodeIndex)); |
| 1354 __ LoadP(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
| 1355 __ JumpIfSmi(entry, &try_shared); |
| 1356 |
| 1357 // Store code entry in the closure. |
| 1358 __ addi(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1359 __ b(&install_optimized_code_and_tailcall); |
| 1360 |
| 1361 __ bind(&try_shared); |
| 1362 // Is the full code valid? |
| 1363 __ LoadP(entry, |
| 1364 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
| 1365 __ LoadP(entry, FieldMemOperand(entry, SharedFunctionInfo::kCodeOffset)); |
| 1366 __ LoadP(r8, FieldMemOperand(entry, Code::kFlagsOffset)); |
| 1367 __ DecodeField<Code::KindField>(r8); |
| 1368 __ cmpi(r8, Operand(Code::BUILTIN)); |
| 1369 __ beq(&gotta_call_runtime); |
| 1370 // Yes, install the full code. |
| 1371 __ addi(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1372 __ StoreP(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset), r0); |
| 1373 __ RecordWriteCodeEntryField(closure, entry, r8); |
| 1374 __ JumpToJSEntry(entry); |
| 1375 |
| 1376 __ bind(&gotta_call_runtime); |
1238 CallRuntimePassFunction(masm, Runtime::kCompileLazy); | 1377 CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
1239 GenerateTailCallToReturnedCode(masm); | 1378 GenerateTailCallToReturnedCode(masm); |
1240 } | 1379 } |
1241 | 1380 |
1242 | 1381 |
1243 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { | 1382 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
1244 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); | 1383 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); |
1245 GenerateTailCallToReturnedCode(masm); | 1384 GenerateTailCallToReturnedCode(masm); |
1246 } | 1385 } |
1247 | 1386 |
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2757 __ bkpt(0); | 2896 __ bkpt(0); |
2758 } | 2897 } |
2759 } | 2898 } |
2760 | 2899 |
2761 | 2900 |
2762 #undef __ | 2901 #undef __ |
2763 } // namespace internal | 2902 } // namespace internal |
2764 } // namespace v8 | 2903 } // namespace v8 |
2765 | 2904 |
2766 #endif // V8_TARGET_ARCH_PPC | 2905 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |