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