Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 7039036: Fix calls of strict mode function with an implicit receiver. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix presubmit Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 1505
1506 MaybeObject* MacroAssembler::TryJumpToExternalReference( 1506 MaybeObject* MacroAssembler::TryJumpToExternalReference(
1507 const ExternalReference& ext) { 1507 const ExternalReference& ext) {
1508 // Set the entry point and jump to the C entry runtime stub. 1508 // Set the entry point and jump to the C entry runtime stub.
1509 mov(ebx, Immediate(ext)); 1509 mov(ebx, Immediate(ext));
1510 CEntryStub ces(1); 1510 CEntryStub ces(1);
1511 return TryTailCallStub(&ces); 1511 return TryTailCallStub(&ces);
1512 } 1512 }
1513 1513
1514 1514
1515 void MacroAssembler::SetReceiverType(Register dst, ReceiverType type) {
Kevin Millikin (Chromium) 2011/05/18 15:57:23 I'm not sure it helps to have the register as an a
Mads Ager (chromium) 2011/05/23 16:31:34 The point was exactly to make it clear at the call
1516 if (type == IMPLICIT_RECEIVER) {
1517 // Set to some non-zero smi by updating the least significant
1518 // byte.
1519 mov_b(Operand(dst), 1 << kSmiTagSize);
1520 } else {
1521 // Set to smi zero by clearing the register.
1522 xor_(dst, Operand(dst));
1523 }
1524 }
1525
1526
1515 void MacroAssembler::InvokePrologue(const ParameterCount& expected, 1527 void MacroAssembler::InvokePrologue(const ParameterCount& expected,
1516 const ParameterCount& actual, 1528 const ParameterCount& actual,
1517 Handle<Code> code_constant, 1529 Handle<Code> code_constant,
1518 const Operand& code_operand, 1530 const Operand& code_operand,
1519 Label* done, 1531 Label* done,
1520 InvokeFlag flag, 1532 InvokeFlag flag,
1521 Label::Distance done_near, 1533 Label::Distance done_near,
1522 const CallWrapper& call_wrapper) { 1534 const CallWrapper& call_wrapper,
1535 ReceiverType receiver_type) {
1523 bool definitely_matches = false; 1536 bool definitely_matches = false;
1524 Label invoke; 1537 Label invoke;
1525 if (expected.is_immediate()) { 1538 if (expected.is_immediate()) {
1526 ASSERT(actual.is_immediate()); 1539 ASSERT(actual.is_immediate());
1527 if (expected.immediate() == actual.immediate()) { 1540 if (expected.immediate() == actual.immediate()) {
1528 definitely_matches = true; 1541 definitely_matches = true;
1529 } else { 1542 } else {
1530 mov(eax, actual.immediate()); 1543 mov(eax, actual.immediate());
1531 const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel; 1544 const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel;
1532 if (expected.immediate() == sentinel) { 1545 if (expected.immediate() == sentinel) {
(...skipping 30 matching lines...) Expand all
1563 isolate()->builtins()->ArgumentsAdaptorTrampoline(); 1576 isolate()->builtins()->ArgumentsAdaptorTrampoline();
1564 if (!code_constant.is_null()) { 1577 if (!code_constant.is_null()) {
1565 mov(edx, Immediate(code_constant)); 1578 mov(edx, Immediate(code_constant));
1566 add(Operand(edx), Immediate(Code::kHeaderSize - kHeapObjectTag)); 1579 add(Operand(edx), Immediate(Code::kHeaderSize - kHeapObjectTag));
1567 } else if (!code_operand.is_reg(edx)) { 1580 } else if (!code_operand.is_reg(edx)) {
1568 mov(edx, code_operand); 1581 mov(edx, code_operand);
1569 } 1582 }
1570 1583
1571 if (flag == CALL_FUNCTION) { 1584 if (flag == CALL_FUNCTION) {
1572 call_wrapper.BeforeCall(CallSize(adaptor, RelocInfo::CODE_TARGET)); 1585 call_wrapper.BeforeCall(CallSize(adaptor, RelocInfo::CODE_TARGET));
1586 SetReceiverType(ecx, receiver_type);
1573 call(adaptor, RelocInfo::CODE_TARGET); 1587 call(adaptor, RelocInfo::CODE_TARGET);
1574 call_wrapper.AfterCall(); 1588 call_wrapper.AfterCall();
1575 jmp(done, done_near); 1589 jmp(done, done_near);
1576 } else { 1590 } else {
1591 SetReceiverType(ecx, receiver_type);
1577 jmp(adaptor, RelocInfo::CODE_TARGET); 1592 jmp(adaptor, RelocInfo::CODE_TARGET);
1578 } 1593 }
1579 bind(&invoke); 1594 bind(&invoke);
1580 } 1595 }
1581 } 1596 }
1582 1597
1583 1598
1584 void MacroAssembler::InvokeCode(const Operand& code, 1599 void MacroAssembler::InvokeCode(const Operand& code,
1585 const ParameterCount& expected, 1600 const ParameterCount& expected,
1586 const ParameterCount& actual, 1601 const ParameterCount& actual,
1587 InvokeFlag flag, 1602 InvokeFlag flag,
1588 const CallWrapper& call_wrapper) { 1603 const CallWrapper& call_wrapper,
1604 ReceiverType receiver_type) {
1589 Label done; 1605 Label done;
1590 InvokePrologue(expected, actual, Handle<Code>::null(), code, 1606 InvokePrologue(expected, actual, Handle<Code>::null(), code,
1591 &done, flag, Label::kNear, call_wrapper); 1607 &done, flag, Label::kNear, call_wrapper,
1608 receiver_type);
1592 if (flag == CALL_FUNCTION) { 1609 if (flag == CALL_FUNCTION) {
1593 call_wrapper.BeforeCall(CallSize(code)); 1610 call_wrapper.BeforeCall(CallSize(code));
1611 SetReceiverType(ecx, receiver_type);
1594 call(code); 1612 call(code);
1595 call_wrapper.AfterCall(); 1613 call_wrapper.AfterCall();
1596 } else { 1614 } else {
1597 ASSERT(flag == JUMP_FUNCTION); 1615 ASSERT(flag == JUMP_FUNCTION);
1616 SetReceiverType(ecx, receiver_type);
1598 jmp(code); 1617 jmp(code);
1599 } 1618 }
1600 bind(&done); 1619 bind(&done);
1601 } 1620 }
1602 1621
1603 1622
1604 void MacroAssembler::InvokeCode(Handle<Code> code, 1623 void MacroAssembler::InvokeCode(Handle<Code> code,
1605 const ParameterCount& expected, 1624 const ParameterCount& expected,
1606 const ParameterCount& actual, 1625 const ParameterCount& actual,
1607 RelocInfo::Mode rmode, 1626 RelocInfo::Mode rmode,
1608 InvokeFlag flag, 1627 InvokeFlag flag,
1609 const CallWrapper& call_wrapper) { 1628 const CallWrapper& call_wrapper,
1629 ReceiverType receiver_type) {
1610 Label done; 1630 Label done;
1611 Operand dummy(eax); 1631 Operand dummy(eax);
1612 InvokePrologue(expected, actual, code, dummy, &done, flag, Label::kNear, 1632 InvokePrologue(expected, actual, code, dummy, &done, flag, Label::kNear,
1613 call_wrapper); 1633 call_wrapper);
1614 if (flag == CALL_FUNCTION) { 1634 if (flag == CALL_FUNCTION) {
1615 call_wrapper.BeforeCall(CallSize(code, rmode)); 1635 call_wrapper.BeforeCall(CallSize(code, rmode));
1636 SetReceiverType(ecx, receiver_type);
1616 call(code, rmode); 1637 call(code, rmode);
1617 call_wrapper.AfterCall(); 1638 call_wrapper.AfterCall();
1618 } else { 1639 } else {
1619 ASSERT(flag == JUMP_FUNCTION); 1640 ASSERT(flag == JUMP_FUNCTION);
1641 SetReceiverType(ecx, receiver_type);
1620 jmp(code, rmode); 1642 jmp(code, rmode);
1621 } 1643 }
1622 bind(&done); 1644 bind(&done);
1623 } 1645 }
1624 1646
1625 1647
1626 void MacroAssembler::InvokeFunction(Register fun, 1648 void MacroAssembler::InvokeFunction(Register fun,
1627 const ParameterCount& actual, 1649 const ParameterCount& actual,
1628 InvokeFlag flag, 1650 InvokeFlag flag,
1629 const CallWrapper& call_wrapper) { 1651 const CallWrapper& call_wrapper,
1652 ReceiverType receiver_type) {
1630 ASSERT(fun.is(edi)); 1653 ASSERT(fun.is(edi));
1631 mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 1654 mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
1632 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); 1655 mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
1633 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); 1656 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset));
1634 SmiUntag(ebx); 1657 SmiUntag(ebx);
1635 1658
1636 ParameterCount expected(ebx); 1659 ParameterCount expected(ebx);
1637 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), 1660 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset),
1638 expected, actual, flag, call_wrapper); 1661 expected, actual, flag, call_wrapper, receiver_type);
1639 } 1662 }
1640 1663
1641 1664
1642 void MacroAssembler::InvokeFunction(JSFunction* function, 1665 void MacroAssembler::InvokeFunction(JSFunction* function,
1643 const ParameterCount& actual, 1666 const ParameterCount& actual,
1644 InvokeFlag flag, 1667 InvokeFlag flag,
1645 const CallWrapper& call_wrapper) { 1668 const CallWrapper& call_wrapper) {
1646 ASSERT(function->is_compiled()); 1669 ASSERT(function->is_compiled());
1647 // Get the function and setup the context. 1670 // Get the function and setup the context.
1648 mov(edi, Immediate(Handle<JSFunction>(function))); 1671 mov(edi, Immediate(Handle<JSFunction>(function)));
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 2091
2069 // Check that the code was patched as expected. 2092 // Check that the code was patched as expected.
2070 ASSERT(masm_.pc_ == address_ + size_); 2093 ASSERT(masm_.pc_ == address_ + size_);
2071 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 2094 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
2072 } 2095 }
2073 2096
2074 2097
2075 } } // namespace v8::internal 2098 } } // namespace v8::internal
2076 2099
2077 #endif // V8_TARGET_ARCH_IA32 2100 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698