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