OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 return TryTailCallStub(&ces); | 1428 return TryTailCallStub(&ces); |
1429 } | 1429 } |
1430 | 1430 |
1431 | 1431 |
1432 void MacroAssembler::InvokePrologue(const ParameterCount& expected, | 1432 void MacroAssembler::InvokePrologue(const ParameterCount& expected, |
1433 const ParameterCount& actual, | 1433 const ParameterCount& actual, |
1434 Handle<Code> code_constant, | 1434 Handle<Code> code_constant, |
1435 const Operand& code_operand, | 1435 const Operand& code_operand, |
1436 NearLabel* done, | 1436 NearLabel* done, |
1437 InvokeFlag flag, | 1437 InvokeFlag flag, |
1438 CallWrapper* call_wrapper) { | 1438 const CallWrapper& call_wrapper) { |
1439 bool definitely_matches = false; | 1439 bool definitely_matches = false; |
1440 Label invoke; | 1440 Label invoke; |
1441 if (expected.is_immediate()) { | 1441 if (expected.is_immediate()) { |
1442 ASSERT(actual.is_immediate()); | 1442 ASSERT(actual.is_immediate()); |
1443 if (expected.immediate() == actual.immediate()) { | 1443 if (expected.immediate() == actual.immediate()) { |
1444 definitely_matches = true; | 1444 definitely_matches = true; |
1445 } else { | 1445 } else { |
1446 mov(eax, actual.immediate()); | 1446 mov(eax, actual.immediate()); |
1447 const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel; | 1447 const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel; |
1448 if (expected.immediate() == sentinel) { | 1448 if (expected.immediate() == sentinel) { |
(...skipping 29 matching lines...) Expand all Loading... |
1478 Handle<Code> adaptor = | 1478 Handle<Code> adaptor = |
1479 isolate()->builtins()->ArgumentsAdaptorTrampoline(); | 1479 isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
1480 if (!code_constant.is_null()) { | 1480 if (!code_constant.is_null()) { |
1481 mov(edx, Immediate(code_constant)); | 1481 mov(edx, Immediate(code_constant)); |
1482 add(Operand(edx), Immediate(Code::kHeaderSize - kHeapObjectTag)); | 1482 add(Operand(edx), Immediate(Code::kHeaderSize - kHeapObjectTag)); |
1483 } else if (!code_operand.is_reg(edx)) { | 1483 } else if (!code_operand.is_reg(edx)) { |
1484 mov(edx, code_operand); | 1484 mov(edx, code_operand); |
1485 } | 1485 } |
1486 | 1486 |
1487 if (flag == CALL_FUNCTION) { | 1487 if (flag == CALL_FUNCTION) { |
1488 if (call_wrapper != NULL) { | 1488 call_wrapper.BeforeCall(CallSize(adaptor, RelocInfo::CODE_TARGET)); |
1489 call_wrapper->BeforeCall(CallSize(adaptor, RelocInfo::CODE_TARGET)); | |
1490 } | |
1491 call(adaptor, RelocInfo::CODE_TARGET); | 1489 call(adaptor, RelocInfo::CODE_TARGET); |
1492 if (call_wrapper != NULL) call_wrapper->AfterCall(); | 1490 call_wrapper.AfterCall(); |
1493 jmp(done); | 1491 jmp(done); |
1494 } else { | 1492 } else { |
1495 jmp(adaptor, RelocInfo::CODE_TARGET); | 1493 jmp(adaptor, RelocInfo::CODE_TARGET); |
1496 } | 1494 } |
1497 bind(&invoke); | 1495 bind(&invoke); |
1498 } | 1496 } |
1499 } | 1497 } |
1500 | 1498 |
1501 | 1499 |
1502 void MacroAssembler::InvokeCode(const Operand& code, | 1500 void MacroAssembler::InvokeCode(const Operand& code, |
1503 const ParameterCount& expected, | 1501 const ParameterCount& expected, |
1504 const ParameterCount& actual, | 1502 const ParameterCount& actual, |
1505 InvokeFlag flag, | 1503 InvokeFlag flag, |
1506 CallWrapper* call_wrapper) { | 1504 const CallWrapper& call_wrapper) { |
1507 NearLabel done; | 1505 NearLabel done; |
1508 InvokePrologue(expected, actual, Handle<Code>::null(), code, | 1506 InvokePrologue(expected, actual, Handle<Code>::null(), code, |
1509 &done, flag, call_wrapper); | 1507 &done, flag, call_wrapper); |
1510 if (flag == CALL_FUNCTION) { | 1508 if (flag == CALL_FUNCTION) { |
1511 if (call_wrapper != NULL) call_wrapper->BeforeCall(CallSize(code)); | 1509 call_wrapper.BeforeCall(CallSize(code)); |
1512 call(code); | 1510 call(code); |
1513 if (call_wrapper != NULL) call_wrapper->AfterCall(); | 1511 call_wrapper.AfterCall(); |
1514 } else { | 1512 } else { |
1515 ASSERT(flag == JUMP_FUNCTION); | 1513 ASSERT(flag == JUMP_FUNCTION); |
1516 jmp(code); | 1514 jmp(code); |
1517 } | 1515 } |
1518 bind(&done); | 1516 bind(&done); |
1519 } | 1517 } |
1520 | 1518 |
1521 | 1519 |
1522 void MacroAssembler::InvokeCode(Handle<Code> code, | 1520 void MacroAssembler::InvokeCode(Handle<Code> code, |
1523 const ParameterCount& expected, | 1521 const ParameterCount& expected, |
1524 const ParameterCount& actual, | 1522 const ParameterCount& actual, |
1525 RelocInfo::Mode rmode, | 1523 RelocInfo::Mode rmode, |
1526 InvokeFlag flag, | 1524 InvokeFlag flag, |
1527 CallWrapper* call_wrapper) { | 1525 const CallWrapper& call_wrapper) { |
1528 NearLabel done; | 1526 NearLabel done; |
1529 Operand dummy(eax); | 1527 Operand dummy(eax); |
1530 InvokePrologue(expected, actual, code, dummy, &done, flag, call_wrapper); | 1528 InvokePrologue(expected, actual, code, dummy, &done, flag, call_wrapper); |
1531 if (flag == CALL_FUNCTION) { | 1529 if (flag == CALL_FUNCTION) { |
1532 if (call_wrapper != NULL) call_wrapper->BeforeCall(CallSize(code, rmode)); | 1530 call_wrapper.BeforeCall(CallSize(code, rmode)); |
1533 call(code, rmode); | 1531 call(code, rmode); |
1534 if (call_wrapper != NULL) call_wrapper->AfterCall(); | 1532 call_wrapper.AfterCall(); |
1535 } else { | 1533 } else { |
1536 ASSERT(flag == JUMP_FUNCTION); | 1534 ASSERT(flag == JUMP_FUNCTION); |
1537 jmp(code, rmode); | 1535 jmp(code, rmode); |
1538 } | 1536 } |
1539 bind(&done); | 1537 bind(&done); |
1540 } | 1538 } |
1541 | 1539 |
1542 | 1540 |
1543 void MacroAssembler::InvokeFunction(Register fun, | 1541 void MacroAssembler::InvokeFunction(Register fun, |
1544 const ParameterCount& actual, | 1542 const ParameterCount& actual, |
1545 InvokeFlag flag, | 1543 InvokeFlag flag, |
1546 CallWrapper* call_wrapper) { | 1544 const CallWrapper& call_wrapper) { |
1547 ASSERT(fun.is(edi)); | 1545 ASSERT(fun.is(edi)); |
1548 mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 1546 mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
1549 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 1547 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
1550 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); | 1548 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); |
1551 SmiUntag(ebx); | 1549 SmiUntag(ebx); |
1552 | 1550 |
1553 ParameterCount expected(ebx); | 1551 ParameterCount expected(ebx); |
1554 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 1552 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), |
1555 expected, actual, flag, call_wrapper); | 1553 expected, actual, flag, call_wrapper); |
1556 } | 1554 } |
1557 | 1555 |
1558 | 1556 |
1559 void MacroAssembler::InvokeFunction(JSFunction* function, | 1557 void MacroAssembler::InvokeFunction(JSFunction* function, |
1560 const ParameterCount& actual, | 1558 const ParameterCount& actual, |
1561 InvokeFlag flag, | 1559 InvokeFlag flag, |
1562 CallWrapper* call_wrapper) { | 1560 const CallWrapper& call_wrapper) { |
1563 ASSERT(function->is_compiled()); | 1561 ASSERT(function->is_compiled()); |
1564 // Get the function and setup the context. | 1562 // Get the function and setup the context. |
1565 mov(edi, Immediate(Handle<JSFunction>(function))); | 1563 mov(edi, Immediate(Handle<JSFunction>(function))); |
1566 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 1564 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
1567 | 1565 |
1568 ParameterCount expected(function->shared()->formal_parameter_count()); | 1566 ParameterCount expected(function->shared()->formal_parameter_count()); |
1569 if (V8::UseCrankshaft()) { | 1567 if (V8::UseCrankshaft()) { |
1570 // TODO(kasperl): For now, we always call indirectly through the | 1568 // TODO(kasperl): For now, we always call indirectly through the |
1571 // code field in the function to allow recompilation to take effect | 1569 // code field in the function to allow recompilation to take effect |
1572 // without changing any of the call sites. | 1570 // without changing any of the call sites. |
1573 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 1571 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), |
1574 expected, actual, flag, call_wrapper); | 1572 expected, actual, flag, call_wrapper); |
1575 } else { | 1573 } else { |
1576 Handle<Code> code(function->code()); | 1574 Handle<Code> code(function->code()); |
1577 InvokeCode(code, expected, actual, RelocInfo::CODE_TARGET, | 1575 InvokeCode(code, expected, actual, RelocInfo::CODE_TARGET, |
1578 flag, call_wrapper); | 1576 flag, call_wrapper); |
1579 } | 1577 } |
1580 } | 1578 } |
1581 | 1579 |
1582 | 1580 |
1583 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, | 1581 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, |
1584 InvokeFlag flag, | 1582 InvokeFlag flag, |
1585 CallWrapper* call_wrapper) { | 1583 const CallWrapper& call_wrapper) { |
1586 // Calls are not allowed in some stubs. | 1584 // Calls are not allowed in some stubs. |
1587 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls()); | 1585 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls()); |
1588 | 1586 |
1589 // Rely on the assertion to check that the number of provided | 1587 // Rely on the assertion to check that the number of provided |
1590 // arguments match the expected number of arguments. Fake a | 1588 // arguments match the expected number of arguments. Fake a |
1591 // parameter count to avoid emitting code to do the check. | 1589 // parameter count to avoid emitting code to do the check. |
1592 ParameterCount expected(0); | 1590 ParameterCount expected(0); |
1593 GetBuiltinFunction(edi, id); | 1591 GetBuiltinFunction(edi, id); |
1594 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 1592 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), |
1595 expected, expected, flag, call_wrapper); | 1593 expected, expected, flag, call_wrapper); |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2038 | 2036 |
2039 // Check that the code was patched as expected. | 2037 // Check that the code was patched as expected. |
2040 ASSERT(masm_.pc_ == address_ + size_); | 2038 ASSERT(masm_.pc_ == address_ + size_); |
2041 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2039 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
2042 } | 2040 } |
2043 | 2041 |
2044 | 2042 |
2045 } } // namespace v8::internal | 2043 } } // namespace v8::internal |
2046 | 2044 |
2047 #endif // V8_TARGET_ARCH_IA32 | 2045 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |