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_ARM | 5 #if V8_TARGET_ARCH_ARM |
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 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 // -- r1 : target function (preserved for callee) | 1329 // -- r1 : target function (preserved for callee) |
1330 // ----------------------------------- | 1330 // ----------------------------------- |
1331 // First lookup code, maybe we don't need to compile! | 1331 // First lookup code, maybe we don't need to compile! |
1332 Label gotta_call_runtime, gotta_call_runtime_no_stack; | 1332 Label gotta_call_runtime, gotta_call_runtime_no_stack; |
1333 Label try_shared; | 1333 Label try_shared; |
1334 Label loop_top, loop_bottom; | 1334 Label loop_top, loop_bottom; |
1335 | 1335 |
1336 Register argument_count = r0; | 1336 Register argument_count = r0; |
1337 Register closure = r1; | 1337 Register closure = r1; |
1338 Register new_target = r3; | 1338 Register new_target = r3; |
1339 Register map = argument_count; | |
1340 Register index = r2; | |
1341 | |
1342 // Do we have a valid feedback vector? | |
1343 __ ldr(index, FieldMemOperand(closure, JSFunction::kLiteralsOffset)); | |
1344 __ ldr(index, FieldMemOperand(index, LiteralsArray::kFeedbackVectorOffset)); | |
1345 __ JumpIfRoot(index, Heap::kUndefinedValueRootIndex, | |
1346 &gotta_call_runtime_no_stack); | |
1347 | |
1348 __ push(argument_count); | 1339 __ push(argument_count); |
1349 __ push(new_target); | 1340 __ push(new_target); |
1350 __ push(closure); | 1341 __ push(closure); |
1351 | 1342 |
| 1343 Register map = argument_count; |
| 1344 Register index = r2; |
1352 __ ldr(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1345 __ ldr(map, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
1353 __ ldr(map, | 1346 __ ldr(map, |
1354 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); | 1347 FieldMemOperand(map, SharedFunctionInfo::kOptimizedCodeMapOffset)); |
1355 __ ldr(index, FieldMemOperand(map, FixedArray::kLengthOffset)); | 1348 __ ldr(index, FieldMemOperand(map, FixedArray::kLengthOffset)); |
1356 __ cmp(index, Operand(Smi::FromInt(2))); | 1349 __ cmp(index, Operand(Smi::FromInt(2))); |
1357 __ b(lt, &gotta_call_runtime); | 1350 __ b(lt, &gotta_call_runtime); |
1358 | 1351 |
| 1352 // Find literals. |
1359 // r3 : native context | 1353 // r3 : native context |
1360 // r2 : length / index | 1354 // r2 : length / index |
1361 // r0 : optimized code map | 1355 // r0 : optimized code map |
1362 // stack[0] : new target | 1356 // stack[0] : new target |
1363 // stack[4] : closure | 1357 // stack[4] : closure |
1364 Register native_context = r3; | 1358 Register native_context = r3; |
1365 __ ldr(native_context, NativeContextMemOperand()); | 1359 __ ldr(native_context, NativeContextMemOperand()); |
1366 | 1360 |
1367 __ bind(&loop_top); | 1361 __ bind(&loop_top); |
1368 Register temp = r1; | 1362 Register temp = r1; |
1369 Register array_pointer = r5; | 1363 Register array_pointer = r5; |
1370 | 1364 |
1371 // Does the native context match? | 1365 // Does the native context match? |
1372 __ add(array_pointer, map, Operand::PointerOffsetFromSmiKey(index)); | 1366 __ add(array_pointer, map, Operand::PointerOffsetFromSmiKey(index)); |
1373 __ ldr(temp, FieldMemOperand(array_pointer, | 1367 __ ldr(temp, FieldMemOperand(array_pointer, |
1374 SharedFunctionInfo::kOffsetToPreviousContext)); | 1368 SharedFunctionInfo::kOffsetToPreviousContext)); |
1375 __ ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); | 1369 __ ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
1376 __ cmp(temp, native_context); | 1370 __ cmp(temp, native_context); |
1377 __ b(ne, &loop_bottom); | 1371 __ b(ne, &loop_bottom); |
| 1372 // Literals available? |
| 1373 __ ldr(temp, FieldMemOperand(array_pointer, |
| 1374 SharedFunctionInfo::kOffsetToPreviousLiterals)); |
| 1375 __ ldr(temp, FieldMemOperand(temp, WeakCell::kValueOffset)); |
| 1376 __ JumpIfSmi(temp, &gotta_call_runtime); |
| 1377 |
| 1378 // Save the literals in the closure. |
| 1379 __ ldr(r4, MemOperand(sp, 0)); |
| 1380 __ str(temp, FieldMemOperand(r4, JSFunction::kLiteralsOffset)); |
| 1381 __ push(index); |
| 1382 __ RecordWriteField(r4, JSFunction::kLiteralsOffset, temp, index, |
| 1383 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
| 1384 OMIT_SMI_CHECK); |
| 1385 __ pop(index); |
1378 | 1386 |
1379 // Code available? | 1387 // Code available? |
1380 Register entry = r4; | 1388 Register entry = r4; |
1381 __ ldr(entry, | 1389 __ ldr(entry, |
1382 FieldMemOperand(array_pointer, | 1390 FieldMemOperand(array_pointer, |
1383 SharedFunctionInfo::kOffsetToPreviousCachedCode)); | 1391 SharedFunctionInfo::kOffsetToPreviousCachedCode)); |
1384 __ ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); | 1392 __ ldr(entry, FieldMemOperand(entry, WeakCell::kValueOffset)); |
1385 __ JumpIfSmi(entry, &try_shared); | 1393 __ JumpIfSmi(entry, &try_shared); |
1386 | 1394 |
1387 // Found code. Get it into the closure and return. | 1395 // Found literals and code. Get them into the closure and return. |
1388 __ pop(closure); | 1396 __ pop(closure); |
1389 // Store code entry in the closure. | 1397 // Store code entry in the closure. |
1390 __ add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1398 __ add(entry, entry, Operand(Code::kHeaderSize - kHeapObjectTag)); |
1391 __ str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); | 1399 __ str(entry, FieldMemOperand(closure, JSFunction::kCodeEntryOffset)); |
1392 __ RecordWriteCodeEntryField(closure, entry, r5); | 1400 __ RecordWriteCodeEntryField(closure, entry, r5); |
1393 | 1401 |
1394 // Link the closure into the optimized function list. | 1402 // Link the closure into the optimized function list. |
1395 // r4 : code entry | 1403 // r4 : code entry |
1396 // r3 : native context | 1404 // r3 : native context |
1397 // r1 : closure | 1405 // r1 : closure |
(...skipping 14 matching lines...) Expand all Loading... |
1412 __ mov(closure, r5); | 1420 __ mov(closure, r5); |
1413 __ pop(new_target); | 1421 __ pop(new_target); |
1414 __ pop(argument_count); | 1422 __ pop(argument_count); |
1415 __ Jump(entry); | 1423 __ Jump(entry); |
1416 | 1424 |
1417 __ bind(&loop_bottom); | 1425 __ bind(&loop_bottom); |
1418 __ sub(index, index, Operand(Smi::FromInt(SharedFunctionInfo::kEntryLength))); | 1426 __ sub(index, index, Operand(Smi::FromInt(SharedFunctionInfo::kEntryLength))); |
1419 __ cmp(index, Operand(Smi::FromInt(1))); | 1427 __ cmp(index, Operand(Smi::FromInt(1))); |
1420 __ b(gt, &loop_top); | 1428 __ b(gt, &loop_top); |
1421 | 1429 |
1422 // We found no code. | 1430 // We found neither literals nor code. |
1423 __ jmp(&gotta_call_runtime); | 1431 __ jmp(&gotta_call_runtime); |
1424 | 1432 |
1425 __ bind(&try_shared); | 1433 __ bind(&try_shared); |
1426 __ pop(closure); | 1434 __ pop(closure); |
1427 __ pop(new_target); | 1435 __ pop(new_target); |
1428 __ pop(argument_count); | 1436 __ pop(argument_count); |
1429 __ ldr(entry, | 1437 __ ldr(entry, |
1430 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); | 1438 FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); |
1431 // Is the shared function marked for tier up? | 1439 // Is the shared function marked for tier up? |
1432 __ ldrb(r5, FieldMemOperand(entry, | 1440 __ ldrb(r5, FieldMemOperand(entry, |
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2878 __ bkpt(0); | 2886 __ bkpt(0); |
2879 } | 2887 } |
2880 } | 2888 } |
2881 | 2889 |
2882 #undef __ | 2890 #undef __ |
2883 | 2891 |
2884 } // namespace internal | 2892 } // namespace internal |
2885 } // namespace v8 | 2893 } // namespace v8 |
2886 | 2894 |
2887 #endif // V8_TARGET_ARCH_ARM | 2895 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |