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_X87 | 5 #if V8_TARGET_ARCH_X87 |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 } | 1251 } |
1252 | 1252 |
1253 static void IncrementCallCount(MacroAssembler* masm, Register feedback_vector, | 1253 static void IncrementCallCount(MacroAssembler* masm, Register feedback_vector, |
1254 Register slot) { | 1254 Register slot) { |
1255 __ add(FieldOperand(feedback_vector, slot, times_half_pointer_size, | 1255 __ add(FieldOperand(feedback_vector, slot, times_half_pointer_size, |
1256 FixedArray::kHeaderSize + kPointerSize), | 1256 FixedArray::kHeaderSize + kPointerSize), |
1257 Immediate(Smi::FromInt(1))); | 1257 Immediate(Smi::FromInt(1))); |
1258 } | 1258 } |
1259 | 1259 |
1260 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { | 1260 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { |
| 1261 // eax - number of arguments |
1261 // edi - function | 1262 // edi - function |
1262 // edx - slot id | 1263 // edx - slot id |
1263 // ebx - vector | 1264 // ebx - vector |
1264 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); | 1265 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); |
1265 __ cmp(edi, ecx); | 1266 __ cmp(edi, ecx); |
1266 __ j(not_equal, miss); | 1267 __ j(not_equal, miss); |
1267 | 1268 |
1268 __ mov(eax, arg_count()); | |
1269 // Reload ecx. | 1269 // Reload ecx. |
1270 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, | 1270 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, |
1271 FixedArray::kHeaderSize)); | 1271 FixedArray::kHeaderSize)); |
1272 | 1272 |
1273 // Increment the call count for monomorphic function calls. | 1273 // Increment the call count for monomorphic function calls. |
1274 IncrementCallCount(masm, ebx, edx); | 1274 IncrementCallCount(masm, ebx, edx); |
1275 | 1275 |
1276 __ mov(ebx, ecx); | 1276 __ mov(ebx, ecx); |
1277 __ mov(edx, edi); | 1277 __ mov(edx, edi); |
1278 ArrayConstructorStub stub(masm->isolate()); | 1278 ArrayConstructorStub stub(masm->isolate()); |
1279 __ TailCallStub(&stub); | 1279 __ TailCallStub(&stub); |
1280 | 1280 |
1281 // Unreachable. | 1281 // Unreachable. |
1282 } | 1282 } |
1283 | 1283 |
1284 | 1284 |
1285 void CallICStub::Generate(MacroAssembler* masm) { | 1285 void CallICStub::Generate(MacroAssembler* masm) { |
| 1286 // edi - number of arguments |
1286 // edi - function | 1287 // edi - function |
1287 // edx - slot id | 1288 // edx - slot id |
1288 // ebx - vector | 1289 // ebx - vector |
1289 Isolate* isolate = masm->isolate(); | 1290 Isolate* isolate = masm->isolate(); |
1290 Label extra_checks_or_miss, call, call_function, call_count_incremented; | 1291 Label extra_checks_or_miss, call, call_function, call_count_incremented; |
1291 int argc = arg_count(); | |
1292 ParameterCount actual(argc); | |
1293 | 1292 |
1294 // The checks. First, does edi match the recorded monomorphic target? | 1293 // The checks. First, does edi match the recorded monomorphic target? |
1295 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, | 1294 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, |
1296 FixedArray::kHeaderSize)); | 1295 FixedArray::kHeaderSize)); |
1297 | 1296 |
1298 // We don't know that we have a weak cell. We might have a private symbol | 1297 // We don't know that we have a weak cell. We might have a private symbol |
1299 // or an AllocationSite, but the memory is safe to examine. | 1298 // or an AllocationSite, but the memory is safe to examine. |
1300 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to | 1299 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to |
1301 // FixedArray. | 1300 // FixedArray. |
1302 // WeakCell::kValueOffset - contains a JSFunction or Smi(0) | 1301 // WeakCell::kValueOffset - contains a JSFunction or Smi(0) |
(...skipping 11 matching lines...) Expand all Loading... |
1314 | 1313 |
1315 // The compare above could have been a SMI/SMI comparison. Guard against this | 1314 // The compare above could have been a SMI/SMI comparison. Guard against this |
1316 // convincing us that we have a monomorphic JSFunction. | 1315 // convincing us that we have a monomorphic JSFunction. |
1317 __ JumpIfSmi(edi, &extra_checks_or_miss); | 1316 __ JumpIfSmi(edi, &extra_checks_or_miss); |
1318 | 1317 |
1319 __ bind(&call_function); | 1318 __ bind(&call_function); |
1320 | 1319 |
1321 // Increment the call count for monomorphic function calls. | 1320 // Increment the call count for monomorphic function calls. |
1322 IncrementCallCount(masm, ebx, edx); | 1321 IncrementCallCount(masm, ebx, edx); |
1323 | 1322 |
1324 __ Set(eax, argc); | |
1325 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), | 1323 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), |
1326 tail_call_mode()), | 1324 tail_call_mode()), |
1327 RelocInfo::CODE_TARGET); | 1325 RelocInfo::CODE_TARGET); |
1328 | 1326 |
1329 __ bind(&extra_checks_or_miss); | 1327 __ bind(&extra_checks_or_miss); |
1330 Label uninitialized, miss, not_allocation_site; | 1328 Label uninitialized, miss, not_allocation_site; |
1331 | 1329 |
1332 __ cmp(ecx, Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); | 1330 __ cmp(ecx, Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); |
1333 __ j(equal, &call); | 1331 __ j(equal, &call); |
1334 | 1332 |
(...skipping 25 matching lines...) Expand all Loading... |
1360 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), | 1358 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), |
1361 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); | 1359 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); |
1362 | 1360 |
1363 __ bind(&call); | 1361 __ bind(&call); |
1364 | 1362 |
1365 // Increment the call count for megamorphic function calls. | 1363 // Increment the call count for megamorphic function calls. |
1366 IncrementCallCount(masm, ebx, edx); | 1364 IncrementCallCount(masm, ebx, edx); |
1367 | 1365 |
1368 __ bind(&call_count_incremented); | 1366 __ bind(&call_count_incremented); |
1369 | 1367 |
1370 __ Set(eax, argc); | |
1371 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), | 1368 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), |
1372 RelocInfo::CODE_TARGET); | 1369 RelocInfo::CODE_TARGET); |
1373 | 1370 |
1374 __ bind(&uninitialized); | 1371 __ bind(&uninitialized); |
1375 | 1372 |
1376 // We are going monomorphic, provided we actually have a JSFunction. | 1373 // We are going monomorphic, provided we actually have a JSFunction. |
1377 __ JumpIfSmi(edi, &miss); | 1374 __ JumpIfSmi(edi, &miss); |
1378 | 1375 |
1379 // Goto miss case if we do not have a function. | 1376 // Goto miss case if we do not have a function. |
1380 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 1377 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
1381 __ j(not_equal, &miss); | 1378 __ j(not_equal, &miss); |
1382 | 1379 |
1383 // Make sure the function is not the Array() function, which requires special | 1380 // Make sure the function is not the Array() function, which requires special |
1384 // behavior on MISS. | 1381 // behavior on MISS. |
1385 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); | 1382 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); |
1386 __ cmp(edi, ecx); | 1383 __ cmp(edi, ecx); |
1387 __ j(equal, &miss); | 1384 __ j(equal, &miss); |
1388 | 1385 |
1389 // Make sure the function belongs to the same native context. | 1386 // Make sure the function belongs to the same native context. |
1390 __ mov(ecx, FieldOperand(edi, JSFunction::kContextOffset)); | 1387 __ mov(ecx, FieldOperand(edi, JSFunction::kContextOffset)); |
1391 __ mov(ecx, ContextOperand(ecx, Context::NATIVE_CONTEXT_INDEX)); | 1388 __ mov(ecx, ContextOperand(ecx, Context::NATIVE_CONTEXT_INDEX)); |
1392 __ cmp(ecx, NativeContextOperand()); | 1389 __ cmp(ecx, NativeContextOperand()); |
1393 __ j(not_equal, &miss); | 1390 __ j(not_equal, &miss); |
1394 | 1391 |
1395 // Store the function. Use a stub since we need a frame for allocation. | 1392 // Store the function. Use a stub since we need a frame for allocation. |
| 1393 // eax - number of arguments |
1396 // ebx - vector | 1394 // ebx - vector |
1397 // edx - slot | 1395 // edx - slot |
1398 // edi - function | 1396 // edi - function |
1399 { | 1397 { |
1400 FrameScope scope(masm, StackFrame::INTERNAL); | 1398 FrameScope scope(masm, StackFrame::INTERNAL); |
1401 CreateWeakCellStub create_stub(isolate); | 1399 CreateWeakCellStub create_stub(isolate); |
| 1400 __ SmiTag(eax); |
| 1401 __ push(eax); |
1402 __ push(ebx); | 1402 __ push(ebx); |
1403 __ push(edx); | 1403 __ push(edx); |
1404 __ push(edi); | 1404 __ push(edi); |
1405 __ push(esi); | 1405 __ push(esi); |
1406 __ CallStub(&create_stub); | 1406 __ CallStub(&create_stub); |
1407 __ pop(esi); | 1407 __ pop(esi); |
1408 __ pop(edi); | 1408 __ pop(edi); |
1409 __ pop(edx); | 1409 __ pop(edx); |
1410 __ pop(ebx); | 1410 __ pop(ebx); |
| 1411 __ pop(eax); |
| 1412 __ SmiUntag(eax); |
1411 } | 1413 } |
1412 | 1414 |
1413 __ jmp(&call_function); | 1415 __ jmp(&call_function); |
1414 | 1416 |
1415 // We are here because tracing is on or we encountered a MISS case we can't | 1417 // We are here because tracing is on or we encountered a MISS case we can't |
1416 // handle here. | 1418 // handle here. |
1417 __ bind(&miss); | 1419 __ bind(&miss); |
1418 GenerateMiss(masm); | 1420 GenerateMiss(masm); |
1419 | 1421 |
1420 __ jmp(&call_count_incremented); | 1422 __ jmp(&call_count_incremented); |
1421 | 1423 |
1422 // Unreachable | 1424 // Unreachable |
1423 __ int3(); | 1425 __ int3(); |
1424 } | 1426 } |
1425 | 1427 |
1426 | 1428 |
1427 void CallICStub::GenerateMiss(MacroAssembler* masm) { | 1429 void CallICStub::GenerateMiss(MacroAssembler* masm) { |
1428 FrameScope scope(masm, StackFrame::INTERNAL); | 1430 FrameScope scope(masm, StackFrame::INTERNAL); |
1429 | 1431 |
| 1432 // Preserve the number of arguments. |
| 1433 __ SmiTag(eax); |
| 1434 __ push(eax); |
| 1435 |
1430 // Push the function and feedback info. | 1436 // Push the function and feedback info. |
1431 __ push(edi); | 1437 __ push(edi); |
1432 __ push(ebx); | 1438 __ push(ebx); |
1433 __ push(edx); | 1439 __ push(edx); |
1434 | 1440 |
1435 // Call the entry. | 1441 // Call the entry. |
1436 __ CallRuntime(Runtime::kCallIC_Miss); | 1442 __ CallRuntime(Runtime::kCallIC_Miss); |
1437 | 1443 |
1438 // Move result to edi and exit the internal frame. | 1444 // Move result to edi and exit the internal frame. |
1439 __ mov(edi, eax); | 1445 __ mov(edi, eax); |
| 1446 |
| 1447 // Restore number of arguments. |
| 1448 __ pop(eax); |
| 1449 __ SmiUntag(eax); |
1440 } | 1450 } |
1441 | 1451 |
1442 | 1452 |
1443 bool CEntryStub::NeedsImmovableCode() { | 1453 bool CEntryStub::NeedsImmovableCode() { |
1444 return false; | 1454 return false; |
1445 } | 1455 } |
1446 | 1456 |
1447 | 1457 |
1448 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { | 1458 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { |
1449 CEntryStub::GenerateAheadOfTime(isolate); | 1459 CEntryStub::GenerateAheadOfTime(isolate); |
(...skipping 3275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4725 kStackUnwindSpace, nullptr, return_value_operand, | 4735 kStackUnwindSpace, nullptr, return_value_operand, |
4726 NULL); | 4736 NULL); |
4727 } | 4737 } |
4728 | 4738 |
4729 #undef __ | 4739 #undef __ |
4730 | 4740 |
4731 } // namespace internal | 4741 } // namespace internal |
4732 } // namespace v8 | 4742 } // namespace v8 |
4733 | 4743 |
4734 #endif // V8_TARGET_ARCH_X87 | 4744 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |