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 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 1253 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
1254 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kConstructStubOffset)); | 1254 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kConstructStubOffset)); |
1255 __ lea(ecx, FieldOperand(ecx, Code::kHeaderSize)); | 1255 __ lea(ecx, FieldOperand(ecx, Code::kHeaderSize)); |
1256 __ jmp(ecx); | 1256 __ jmp(ecx); |
1257 | 1257 |
1258 __ bind(&non_function); | 1258 __ bind(&non_function); |
1259 __ mov(edx, edi); | 1259 __ mov(edx, edi); |
1260 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 1260 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
1261 } | 1261 } |
1262 | 1262 |
| 1263 static void IncrementCallCount(MacroAssembler* masm, Register feedback_vector, |
| 1264 Register slot) { |
| 1265 __ add(FieldOperand(feedback_vector, slot, times_half_pointer_size, |
| 1266 FixedArray::kHeaderSize + kPointerSize), |
| 1267 Immediate(Smi::FromInt(1))); |
| 1268 } |
1263 | 1269 |
1264 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { | 1270 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { |
1265 // edi - function | 1271 // edi - function |
1266 // edx - slot id | 1272 // edx - slot id |
1267 // ebx - vector | 1273 // ebx - vector |
1268 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); | 1274 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); |
1269 __ cmp(edi, ecx); | 1275 __ cmp(edi, ecx); |
1270 __ j(not_equal, miss); | 1276 __ j(not_equal, miss); |
1271 | 1277 |
1272 __ mov(eax, arg_count()); | 1278 __ mov(eax, arg_count()); |
1273 // Reload ecx. | 1279 // Reload ecx. |
1274 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, | 1280 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, |
1275 FixedArray::kHeaderSize)); | 1281 FixedArray::kHeaderSize)); |
1276 | 1282 |
1277 // Increment the call count for monomorphic function calls. | 1283 // Increment the call count for monomorphic function calls. |
1278 __ add(FieldOperand(ebx, edx, times_half_pointer_size, | 1284 IncrementCallCount(masm, ebx, edx); |
1279 FixedArray::kHeaderSize + kPointerSize), | |
1280 Immediate(Smi::FromInt(1))); | |
1281 | 1285 |
1282 __ mov(ebx, ecx); | 1286 __ mov(ebx, ecx); |
1283 __ mov(edx, edi); | 1287 __ mov(edx, edi); |
1284 ArrayConstructorStub stub(masm->isolate(), arg_count()); | 1288 ArrayConstructorStub stub(masm->isolate(), arg_count()); |
1285 __ TailCallStub(&stub); | 1289 __ TailCallStub(&stub); |
1286 | 1290 |
1287 // Unreachable. | 1291 // Unreachable. |
1288 } | 1292 } |
1289 | 1293 |
1290 | 1294 |
1291 void CallICStub::Generate(MacroAssembler* masm) { | 1295 void CallICStub::Generate(MacroAssembler* masm) { |
1292 // edi - function | 1296 // edi - function |
1293 // edx - slot id | 1297 // edx - slot id |
1294 // ebx - vector | 1298 // ebx - vector |
1295 Isolate* isolate = masm->isolate(); | 1299 Isolate* isolate = masm->isolate(); |
1296 Label extra_checks_or_miss, call, call_function; | 1300 Label extra_checks_or_miss, call, call_function, call_count_incremented; |
1297 int argc = arg_count(); | 1301 int argc = arg_count(); |
1298 ParameterCount actual(argc); | 1302 ParameterCount actual(argc); |
1299 | 1303 |
1300 // The checks. First, does edi match the recorded monomorphic target? | 1304 // The checks. First, does edi match the recorded monomorphic target? |
1301 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, | 1305 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, |
1302 FixedArray::kHeaderSize)); | 1306 FixedArray::kHeaderSize)); |
1303 | 1307 |
1304 // We don't know that we have a weak cell. We might have a private symbol | 1308 // We don't know that we have a weak cell. We might have a private symbol |
1305 // or an AllocationSite, but the memory is safe to examine. | 1309 // or an AllocationSite, but the memory is safe to examine. |
1306 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to | 1310 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to |
1307 // FixedArray. | 1311 // FixedArray. |
1308 // WeakCell::kValueOffset - contains a JSFunction or Smi(0) | 1312 // WeakCell::kValueOffset - contains a JSFunction or Smi(0) |
1309 // Symbol::kHashFieldSlot - if the low bit is 1, then the hash is not | 1313 // Symbol::kHashFieldSlot - if the low bit is 1, then the hash is not |
1310 // computed, meaning that it can't appear to be a pointer. If the low bit is | 1314 // computed, meaning that it can't appear to be a pointer. If the low bit is |
1311 // 0, then hash is computed, but the 0 bit prevents the field from appearing | 1315 // 0, then hash is computed, but the 0 bit prevents the field from appearing |
1312 // to be a pointer. | 1316 // to be a pointer. |
1313 STATIC_ASSERT(WeakCell::kSize >= kPointerSize); | 1317 STATIC_ASSERT(WeakCell::kSize >= kPointerSize); |
1314 STATIC_ASSERT(AllocationSite::kTransitionInfoOffset == | 1318 STATIC_ASSERT(AllocationSite::kTransitionInfoOffset == |
1315 WeakCell::kValueOffset && | 1319 WeakCell::kValueOffset && |
1316 WeakCell::kValueOffset == Symbol::kHashFieldSlot); | 1320 WeakCell::kValueOffset == Symbol::kHashFieldSlot); |
1317 | 1321 |
1318 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); | 1322 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); |
1319 __ j(not_equal, &extra_checks_or_miss); | 1323 __ j(not_equal, &extra_checks_or_miss); |
1320 | 1324 |
1321 // The compare above could have been a SMI/SMI comparison. Guard against this | 1325 // The compare above could have been a SMI/SMI comparison. Guard against this |
1322 // convincing us that we have a monomorphic JSFunction. | 1326 // convincing us that we have a monomorphic JSFunction. |
1323 __ JumpIfSmi(edi, &extra_checks_or_miss); | 1327 __ JumpIfSmi(edi, &extra_checks_or_miss); |
1324 | 1328 |
| 1329 __ bind(&call_function); |
| 1330 |
1325 // Increment the call count for monomorphic function calls. | 1331 // Increment the call count for monomorphic function calls. |
1326 __ add(FieldOperand(ebx, edx, times_half_pointer_size, | 1332 IncrementCallCount(masm, ebx, edx); |
1327 FixedArray::kHeaderSize + kPointerSize), | |
1328 Immediate(Smi::FromInt(1))); | |
1329 | 1333 |
1330 __ bind(&call_function); | |
1331 __ Set(eax, argc); | 1334 __ Set(eax, argc); |
1332 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), | 1335 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), |
1333 tail_call_mode()), | 1336 tail_call_mode()), |
1334 RelocInfo::CODE_TARGET); | 1337 RelocInfo::CODE_TARGET); |
1335 | 1338 |
1336 __ bind(&extra_checks_or_miss); | 1339 __ bind(&extra_checks_or_miss); |
1337 Label uninitialized, miss, not_allocation_site; | 1340 Label uninitialized, miss, not_allocation_site; |
1338 | 1341 |
1339 __ cmp(ecx, Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); | 1342 __ cmp(ecx, Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); |
1340 __ j(equal, &call); | 1343 __ j(equal, &call); |
(...skipping 20 matching lines...) Expand all Loading... |
1361 // We are going megamorphic. If the feedback is a JSFunction, it is fine | 1364 // We are going megamorphic. If the feedback is a JSFunction, it is fine |
1362 // to handle it here. More complex cases are dealt with in the runtime. | 1365 // to handle it here. More complex cases are dealt with in the runtime. |
1363 __ AssertNotSmi(ecx); | 1366 __ AssertNotSmi(ecx); |
1364 __ CmpObjectType(ecx, JS_FUNCTION_TYPE, ecx); | 1367 __ CmpObjectType(ecx, JS_FUNCTION_TYPE, ecx); |
1365 __ j(not_equal, &miss); | 1368 __ j(not_equal, &miss); |
1366 __ mov( | 1369 __ mov( |
1367 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), | 1370 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), |
1368 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); | 1371 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); |
1369 | 1372 |
1370 __ bind(&call); | 1373 __ bind(&call); |
| 1374 |
| 1375 // Increment the call count for megamorphic function calls. |
| 1376 IncrementCallCount(masm, ebx, edx); |
| 1377 |
| 1378 __ bind(&call_count_incremented); |
| 1379 |
1371 __ Set(eax, argc); | 1380 __ Set(eax, argc); |
1372 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), | 1381 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), |
1373 RelocInfo::CODE_TARGET); | 1382 RelocInfo::CODE_TARGET); |
1374 | 1383 |
1375 __ bind(&uninitialized); | 1384 __ bind(&uninitialized); |
1376 | 1385 |
1377 // We are going monomorphic, provided we actually have a JSFunction. | 1386 // We are going monomorphic, provided we actually have a JSFunction. |
1378 __ JumpIfSmi(edi, &miss); | 1387 __ JumpIfSmi(edi, &miss); |
1379 | 1388 |
1380 // Goto miss case if we do not have a function. | 1389 // Goto miss case if we do not have a function. |
1381 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 1390 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
1382 __ j(not_equal, &miss); | 1391 __ j(not_equal, &miss); |
1383 | 1392 |
1384 // Make sure the function is not the Array() function, which requires special | 1393 // Make sure the function is not the Array() function, which requires special |
1385 // behavior on MISS. | 1394 // behavior on MISS. |
1386 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); | 1395 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); |
1387 __ cmp(edi, ecx); | 1396 __ cmp(edi, ecx); |
1388 __ j(equal, &miss); | 1397 __ j(equal, &miss); |
1389 | 1398 |
1390 // Make sure the function belongs to the same native context. | 1399 // Make sure the function belongs to the same native context. |
1391 __ mov(ecx, FieldOperand(edi, JSFunction::kContextOffset)); | 1400 __ mov(ecx, FieldOperand(edi, JSFunction::kContextOffset)); |
1392 __ mov(ecx, ContextOperand(ecx, Context::NATIVE_CONTEXT_INDEX)); | 1401 __ mov(ecx, ContextOperand(ecx, Context::NATIVE_CONTEXT_INDEX)); |
1393 __ cmp(ecx, NativeContextOperand()); | 1402 __ cmp(ecx, NativeContextOperand()); |
1394 __ j(not_equal, &miss); | 1403 __ j(not_equal, &miss); |
1395 | 1404 |
1396 // Initialize the call counter. | |
1397 __ mov(FieldOperand(ebx, edx, times_half_pointer_size, | |
1398 FixedArray::kHeaderSize + kPointerSize), | |
1399 Immediate(Smi::FromInt(1))); | |
1400 | |
1401 // Store the function. Use a stub since we need a frame for allocation. | 1405 // Store the function. Use a stub since we need a frame for allocation. |
1402 // ebx - vector | 1406 // ebx - vector |
1403 // edx - slot | 1407 // edx - slot |
1404 // edi - function | 1408 // edi - function |
1405 { | 1409 { |
1406 FrameScope scope(masm, StackFrame::INTERNAL); | 1410 FrameScope scope(masm, StackFrame::INTERNAL); |
1407 CreateWeakCellStub create_stub(isolate); | 1411 CreateWeakCellStub create_stub(isolate); |
| 1412 __ push(ebx); |
| 1413 __ push(edx); |
1408 __ push(edi); | 1414 __ push(edi); |
1409 __ push(esi); | 1415 __ push(esi); |
1410 __ CallStub(&create_stub); | 1416 __ CallStub(&create_stub); |
1411 __ pop(esi); | 1417 __ pop(esi); |
1412 __ pop(edi); | 1418 __ pop(edi); |
| 1419 __ pop(edx); |
| 1420 __ pop(ebx); |
1413 } | 1421 } |
1414 | 1422 |
1415 __ jmp(&call_function); | 1423 __ jmp(&call_function); |
1416 | 1424 |
1417 // We are here because tracing is on or we encountered a MISS case we can't | 1425 // We are here because tracing is on or we encountered a MISS case we can't |
1418 // handle here. | 1426 // handle here. |
1419 __ bind(&miss); | 1427 __ bind(&miss); |
1420 GenerateMiss(masm); | 1428 GenerateMiss(masm); |
1421 | 1429 |
1422 __ jmp(&call); | 1430 __ jmp(&call_count_incremented); |
1423 | 1431 |
1424 // Unreachable | 1432 // Unreachable |
1425 __ int3(); | 1433 __ int3(); |
1426 } | 1434 } |
1427 | 1435 |
1428 | 1436 |
1429 void CallICStub::GenerateMiss(MacroAssembler* masm) { | 1437 void CallICStub::GenerateMiss(MacroAssembler* masm) { |
1430 FrameScope scope(masm, StackFrame::INTERNAL); | 1438 FrameScope scope(masm, StackFrame::INTERNAL); |
1431 | 1439 |
1432 // Push the function and feedback info. | 1440 // Push the function and feedback info. |
(...skipping 3817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5250 kStackUnwindSpace, nullptr, return_value_operand, | 5258 kStackUnwindSpace, nullptr, return_value_operand, |
5251 NULL); | 5259 NULL); |
5252 } | 5260 } |
5253 | 5261 |
5254 #undef __ | 5262 #undef __ |
5255 | 5263 |
5256 } // namespace internal | 5264 } // namespace internal |
5257 } // namespace v8 | 5265 } // namespace v8 |
5258 | 5266 |
5259 #endif // V8_TARGET_ARCH_X87 | 5267 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |