| 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 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 namespace v8 { | 38 namespace v8 { |
| 39 namespace internal { | 39 namespace internal { |
| 40 | 40 |
| 41 // ------------------------------------------------------------------------- | 41 // ------------------------------------------------------------------------- |
| 42 // MacroAssembler implementation. | 42 // MacroAssembler implementation. |
| 43 | 43 |
| 44 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) | 44 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) |
| 45 : Assembler(arg_isolate, buffer, size), | 45 : Assembler(arg_isolate, buffer, size), |
| 46 generating_stub_(false), | 46 generating_stub_(false), |
| 47 allow_stub_calls_(true), | 47 allow_stub_calls_(true) { |
| 48 has_frame_(false) { | |
| 49 if (isolate() != NULL) { | 48 if (isolate() != NULL) { |
| 50 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(), | 49 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(), |
| 51 isolate()); | 50 isolate()); |
| 52 } | 51 } |
| 53 } | 52 } |
| 54 | 53 |
| 55 | 54 |
| 56 void MacroAssembler::RecordWriteHelper(Register object, | 55 void MacroAssembler::RecordWriteHelper(Register object, |
| 57 Register addr, | 56 Register addr, |
| 58 Register scratch) { | 57 Register scratch) { |
| (...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 // in initial map. | 1201 // in initial map. |
| 1203 bind(&non_instance); | 1202 bind(&non_instance); |
| 1204 mov(result, FieldOperand(result, Map::kConstructorOffset)); | 1203 mov(result, FieldOperand(result, Map::kConstructorOffset)); |
| 1205 | 1204 |
| 1206 // All done. | 1205 // All done. |
| 1207 bind(&done); | 1206 bind(&done); |
| 1208 } | 1207 } |
| 1209 | 1208 |
| 1210 | 1209 |
| 1211 void MacroAssembler::CallStub(CodeStub* stub, unsigned ast_id) { | 1210 void MacroAssembler::CallStub(CodeStub* stub, unsigned ast_id) { |
| 1212 ASSERT(AllowThisStubCall(stub)); // Calls are not allowed in some stubs. | 1211 ASSERT(allow_stub_calls()); // Calls are not allowed in some stubs. |
| 1213 call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id); | 1212 call(stub->GetCode(), RelocInfo::CODE_TARGET, ast_id); |
| 1214 } | 1213 } |
| 1215 | 1214 |
| 1216 | 1215 |
| 1217 MaybeObject* MacroAssembler::TryCallStub(CodeStub* stub) { | 1216 MaybeObject* MacroAssembler::TryCallStub(CodeStub* stub) { |
| 1218 ASSERT(AllowThisStubCall(stub)); // Calls are not allowed in some stubs. | 1217 ASSERT(allow_stub_calls()); // Calls are not allowed in some stubs. |
| 1219 Object* result; | 1218 Object* result; |
| 1220 { MaybeObject* maybe_result = stub->TryGetCode(); | 1219 { MaybeObject* maybe_result = stub->TryGetCode(); |
| 1221 if (!maybe_result->ToObject(&result)) return maybe_result; | 1220 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1222 } | 1221 } |
| 1223 call(Handle<Code>(Code::cast(result)), RelocInfo::CODE_TARGET); | 1222 call(Handle<Code>(Code::cast(result)), RelocInfo::CODE_TARGET); |
| 1224 return result; | 1223 return result; |
| 1225 } | 1224 } |
| 1226 | 1225 |
| 1227 | 1226 |
| 1228 void MacroAssembler::TailCallStub(CodeStub* stub) { | 1227 void MacroAssembler::TailCallStub(CodeStub* stub) { |
| 1229 ASSERT(stub->CompilingCallsToThisStubIsGCSafe() || allow_stub_calls_); | 1228 ASSERT(allow_stub_calls()); // Calls are not allowed in some stubs. |
| 1230 jmp(stub->GetCode(), RelocInfo::CODE_TARGET); | 1229 jmp(stub->GetCode(), RelocInfo::CODE_TARGET); |
| 1231 } | 1230 } |
| 1232 | 1231 |
| 1233 | 1232 |
| 1234 MaybeObject* MacroAssembler::TryTailCallStub(CodeStub* stub) { | 1233 MaybeObject* MacroAssembler::TryTailCallStub(CodeStub* stub) { |
| 1234 ASSERT(allow_stub_calls()); // Calls are not allowed in some stubs. |
| 1235 Object* result; | 1235 Object* result; |
| 1236 { MaybeObject* maybe_result = stub->TryGetCode(); | 1236 { MaybeObject* maybe_result = stub->TryGetCode(); |
| 1237 if (!maybe_result->ToObject(&result)) return maybe_result; | 1237 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1238 } | 1238 } |
| 1239 jmp(Handle<Code>(Code::cast(result)), RelocInfo::CODE_TARGET); | 1239 jmp(Handle<Code>(Code::cast(result)), RelocInfo::CODE_TARGET); |
| 1240 return result; | 1240 return result; |
| 1241 } | 1241 } |
| 1242 | 1242 |
| 1243 | 1243 |
| 1244 void MacroAssembler::StubReturn(int argc) { | 1244 void MacroAssembler::StubReturn(int argc) { |
| 1245 ASSERT(argc >= 1 && generating_stub()); | 1245 ASSERT(argc >= 1 && generating_stub()); |
| 1246 ret((argc - 1) * kPointerSize); | 1246 ret((argc - 1) * kPointerSize); |
| 1247 } | 1247 } |
| 1248 | 1248 |
| 1249 | 1249 |
| 1250 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) { | |
| 1251 if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false; | |
| 1252 return stub->CompilingCallsToThisStubIsGCSafe() || allow_stub_calls_; | |
| 1253 } | |
| 1254 | |
| 1255 | |
| 1256 void MacroAssembler::IllegalOperation(int num_arguments) { | 1250 void MacroAssembler::IllegalOperation(int num_arguments) { |
| 1257 if (num_arguments > 0) { | 1251 if (num_arguments > 0) { |
| 1258 add(Operand(esp), Immediate(num_arguments * kPointerSize)); | 1252 add(Operand(esp), Immediate(num_arguments * kPointerSize)); |
| 1259 } | 1253 } |
| 1260 mov(eax, Immediate(isolate()->factory()->undefined_value())); | 1254 mov(eax, Immediate(isolate()->factory()->undefined_value())); |
| 1261 } | 1255 } |
| 1262 | 1256 |
| 1263 | 1257 |
| 1264 void MacroAssembler::IndexFromHash(Register hash, Register index) { | 1258 void MacroAssembler::IndexFromHash(Register hash, Register index) { |
| 1265 // The assert checks that the constants for the maximum number of digits | 1259 // The assert checks that the constants for the maximum number of digits |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 } | 1620 } |
| 1627 } | 1621 } |
| 1628 | 1622 |
| 1629 | 1623 |
| 1630 void MacroAssembler::InvokeCode(const Operand& code, | 1624 void MacroAssembler::InvokeCode(const Operand& code, |
| 1631 const ParameterCount& expected, | 1625 const ParameterCount& expected, |
| 1632 const ParameterCount& actual, | 1626 const ParameterCount& actual, |
| 1633 InvokeFlag flag, | 1627 InvokeFlag flag, |
| 1634 const CallWrapper& call_wrapper, | 1628 const CallWrapper& call_wrapper, |
| 1635 CallKind call_kind) { | 1629 CallKind call_kind) { |
| 1636 // You can't call a function without a valid frame. | |
| 1637 ASSERT(flag == JUMP_FUNCTION || has_frame()); | |
| 1638 | |
| 1639 Label done; | 1630 Label done; |
| 1640 InvokePrologue(expected, actual, Handle<Code>::null(), code, | 1631 InvokePrologue(expected, actual, Handle<Code>::null(), code, |
| 1641 &done, flag, Label::kNear, call_wrapper, | 1632 &done, flag, Label::kNear, call_wrapper, |
| 1642 call_kind); | 1633 call_kind); |
| 1643 if (flag == CALL_FUNCTION) { | 1634 if (flag == CALL_FUNCTION) { |
| 1644 call_wrapper.BeforeCall(CallSize(code)); | 1635 call_wrapper.BeforeCall(CallSize(code)); |
| 1645 SetCallKind(ecx, call_kind); | 1636 SetCallKind(ecx, call_kind); |
| 1646 call(code); | 1637 call(code); |
| 1647 call_wrapper.AfterCall(); | 1638 call_wrapper.AfterCall(); |
| 1648 } else { | 1639 } else { |
| 1649 ASSERT(flag == JUMP_FUNCTION); | 1640 ASSERT(flag == JUMP_FUNCTION); |
| 1650 SetCallKind(ecx, call_kind); | 1641 SetCallKind(ecx, call_kind); |
| 1651 jmp(code); | 1642 jmp(code); |
| 1652 } | 1643 } |
| 1653 bind(&done); | 1644 bind(&done); |
| 1654 } | 1645 } |
| 1655 | 1646 |
| 1656 | 1647 |
| 1657 void MacroAssembler::InvokeCode(Handle<Code> code, | 1648 void MacroAssembler::InvokeCode(Handle<Code> code, |
| 1658 const ParameterCount& expected, | 1649 const ParameterCount& expected, |
| 1659 const ParameterCount& actual, | 1650 const ParameterCount& actual, |
| 1660 RelocInfo::Mode rmode, | 1651 RelocInfo::Mode rmode, |
| 1661 InvokeFlag flag, | 1652 InvokeFlag flag, |
| 1662 const CallWrapper& call_wrapper, | 1653 const CallWrapper& call_wrapper, |
| 1663 CallKind call_kind) { | 1654 CallKind call_kind) { |
| 1664 // You can't call a function without a valid frame. | |
| 1665 ASSERT(flag == JUMP_FUNCTION || has_frame()); | |
| 1666 | |
| 1667 Label done; | 1655 Label done; |
| 1668 Operand dummy(eax); | 1656 Operand dummy(eax); |
| 1669 InvokePrologue(expected, actual, code, dummy, &done, flag, Label::kNear, | 1657 InvokePrologue(expected, actual, code, dummy, &done, flag, Label::kNear, |
| 1670 call_wrapper, call_kind); | 1658 call_wrapper, call_kind); |
| 1671 if (flag == CALL_FUNCTION) { | 1659 if (flag == CALL_FUNCTION) { |
| 1672 call_wrapper.BeforeCall(CallSize(code, rmode)); | 1660 call_wrapper.BeforeCall(CallSize(code, rmode)); |
| 1673 SetCallKind(ecx, call_kind); | 1661 SetCallKind(ecx, call_kind); |
| 1674 call(code, rmode); | 1662 call(code, rmode); |
| 1675 call_wrapper.AfterCall(); | 1663 call_wrapper.AfterCall(); |
| 1676 } else { | 1664 } else { |
| 1677 ASSERT(flag == JUMP_FUNCTION); | 1665 ASSERT(flag == JUMP_FUNCTION); |
| 1678 SetCallKind(ecx, call_kind); | 1666 SetCallKind(ecx, call_kind); |
| 1679 jmp(code, rmode); | 1667 jmp(code, rmode); |
| 1680 } | 1668 } |
| 1681 bind(&done); | 1669 bind(&done); |
| 1682 } | 1670 } |
| 1683 | 1671 |
| 1684 | 1672 |
| 1685 void MacroAssembler::InvokeFunction(Register fun, | 1673 void MacroAssembler::InvokeFunction(Register fun, |
| 1686 const ParameterCount& actual, | 1674 const ParameterCount& actual, |
| 1687 InvokeFlag flag, | 1675 InvokeFlag flag, |
| 1688 const CallWrapper& call_wrapper, | 1676 const CallWrapper& call_wrapper, |
| 1689 CallKind call_kind) { | 1677 CallKind call_kind) { |
| 1690 // You can't call a function without a valid frame. | |
| 1691 ASSERT(flag == JUMP_FUNCTION || has_frame()); | |
| 1692 | |
| 1693 ASSERT(fun.is(edi)); | 1678 ASSERT(fun.is(edi)); |
| 1694 mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 1679 mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| 1695 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 1680 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
| 1696 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); | 1681 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 1697 SmiUntag(ebx); | 1682 SmiUntag(ebx); |
| 1698 | 1683 |
| 1699 ParameterCount expected(ebx); | 1684 ParameterCount expected(ebx); |
| 1700 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 1685 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), |
| 1701 expected, actual, flag, call_wrapper, call_kind); | 1686 expected, actual, flag, call_wrapper, call_kind); |
| 1702 } | 1687 } |
| 1703 | 1688 |
| 1704 | 1689 |
| 1705 void MacroAssembler::InvokeFunction(JSFunction* function, | 1690 void MacroAssembler::InvokeFunction(JSFunction* function, |
| 1706 const ParameterCount& actual, | 1691 const ParameterCount& actual, |
| 1707 InvokeFlag flag, | 1692 InvokeFlag flag, |
| 1708 const CallWrapper& call_wrapper, | 1693 const CallWrapper& call_wrapper, |
| 1709 CallKind call_kind) { | 1694 CallKind call_kind) { |
| 1710 // You can't call a function without a valid frame. | |
| 1711 ASSERT(flag == JUMP_FUNCTION || has_frame()); | |
| 1712 | |
| 1713 ASSERT(function->is_compiled()); | 1695 ASSERT(function->is_compiled()); |
| 1714 // Get the function and setup the context. | 1696 // Get the function and setup the context. |
| 1715 mov(edi, Immediate(Handle<JSFunction>(function))); | 1697 mov(edi, Immediate(Handle<JSFunction>(function))); |
| 1716 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 1698 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
| 1717 | 1699 |
| 1718 ParameterCount expected(function->shared()->formal_parameter_count()); | 1700 ParameterCount expected(function->shared()->formal_parameter_count()); |
| 1719 if (V8::UseCrankshaft()) { | 1701 if (V8::UseCrankshaft()) { |
| 1720 // TODO(kasperl): For now, we always call indirectly through the | 1702 // TODO(kasperl): For now, we always call indirectly through the |
| 1721 // code field in the function to allow recompilation to take effect | 1703 // code field in the function to allow recompilation to take effect |
| 1722 // without changing any of the call sites. | 1704 // without changing any of the call sites. |
| 1723 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 1705 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), |
| 1724 expected, actual, flag, call_wrapper, call_kind); | 1706 expected, actual, flag, call_wrapper, call_kind); |
| 1725 } else { | 1707 } else { |
| 1726 Handle<Code> code(function->code()); | 1708 Handle<Code> code(function->code()); |
| 1727 InvokeCode(code, expected, actual, RelocInfo::CODE_TARGET, | 1709 InvokeCode(code, expected, actual, RelocInfo::CODE_TARGET, |
| 1728 flag, call_wrapper, call_kind); | 1710 flag, call_wrapper, call_kind); |
| 1729 } | 1711 } |
| 1730 } | 1712 } |
| 1731 | 1713 |
| 1732 | 1714 |
| 1733 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, | 1715 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, |
| 1734 InvokeFlag flag, | 1716 InvokeFlag flag, |
| 1735 const CallWrapper& call_wrapper) { | 1717 const CallWrapper& call_wrapper) { |
| 1736 // You can't call a builtin without a valid frame. | 1718 // Calls are not allowed in some stubs. |
| 1737 ASSERT(flag == JUMP_FUNCTION || has_frame()); | 1719 ASSERT(flag == JUMP_FUNCTION || allow_stub_calls()); |
| 1738 | 1720 |
| 1739 // Rely on the assertion to check that the number of provided | 1721 // Rely on the assertion to check that the number of provided |
| 1740 // arguments match the expected number of arguments. Fake a | 1722 // arguments match the expected number of arguments. Fake a |
| 1741 // parameter count to avoid emitting code to do the check. | 1723 // parameter count to avoid emitting code to do the check. |
| 1742 ParameterCount expected(0); | 1724 ParameterCount expected(0); |
| 1743 GetBuiltinFunction(edi, id); | 1725 GetBuiltinFunction(edi, id); |
| 1744 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 1726 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), |
| 1745 expected, expected, flag, call_wrapper, CALL_AS_METHOD); | 1727 expected, expected, flag, call_wrapper, CALL_AS_METHOD); |
| 1746 } | 1728 } |
| 1747 | 1729 |
| 1748 | |
| 1749 void MacroAssembler::GetBuiltinFunction(Register target, | 1730 void MacroAssembler::GetBuiltinFunction(Register target, |
| 1750 Builtins::JavaScript id) { | 1731 Builtins::JavaScript id) { |
| 1751 // Load the JavaScript builtin function from the builtins object. | 1732 // Load the JavaScript builtin function from the builtins object. |
| 1752 mov(target, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 1733 mov(target, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 1753 mov(target, FieldOperand(target, GlobalObject::kBuiltinsOffset)); | 1734 mov(target, FieldOperand(target, GlobalObject::kBuiltinsOffset)); |
| 1754 mov(target, FieldOperand(target, | 1735 mov(target, FieldOperand(target, |
| 1755 JSBuiltinsObject::OffsetOfFunctionWithId(id))); | 1736 JSBuiltinsObject::OffsetOfFunctionWithId(id))); |
| 1756 } | 1737 } |
| 1757 | 1738 |
| 1758 | |
| 1759 void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { | 1739 void MacroAssembler::GetBuiltinEntry(Register target, Builtins::JavaScript id) { |
| 1760 ASSERT(!target.is(edi)); | 1740 ASSERT(!target.is(edi)); |
| 1761 // Load the JavaScript builtin function from the builtins object. | 1741 // Load the JavaScript builtin function from the builtins object. |
| 1762 GetBuiltinFunction(edi, id); | 1742 GetBuiltinFunction(edi, id); |
| 1763 // Load the code entry point from the function into the target register. | 1743 // Load the code entry point from the function into the target register. |
| 1764 mov(target, FieldOperand(edi, JSFunction::kCodeEntryOffset)); | 1744 mov(target, FieldOperand(edi, JSFunction::kCodeEntryOffset)); |
| 1765 } | 1745 } |
| 1766 | 1746 |
| 1767 | 1747 |
| 1768 void MacroAssembler::LoadContext(Register dst, int context_chain_length) { | 1748 void MacroAssembler::LoadContext(Register dst, int context_chain_length) { |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 // from the real pointer as a smi. | 1984 // from the real pointer as a smi. |
| 2005 intptr_t p1 = reinterpret_cast<intptr_t>(msg); | 1985 intptr_t p1 = reinterpret_cast<intptr_t>(msg); |
| 2006 intptr_t p0 = (p1 & ~kSmiTagMask) + kSmiTag; | 1986 intptr_t p0 = (p1 & ~kSmiTagMask) + kSmiTag; |
| 2007 ASSERT(reinterpret_cast<Object*>(p0)->IsSmi()); | 1987 ASSERT(reinterpret_cast<Object*>(p0)->IsSmi()); |
| 2008 #ifdef DEBUG | 1988 #ifdef DEBUG |
| 2009 if (msg != NULL) { | 1989 if (msg != NULL) { |
| 2010 RecordComment("Abort message: "); | 1990 RecordComment("Abort message: "); |
| 2011 RecordComment(msg); | 1991 RecordComment(msg); |
| 2012 } | 1992 } |
| 2013 #endif | 1993 #endif |
| 1994 // Disable stub call restrictions to always allow calls to abort. |
| 1995 AllowStubCallsScope allow_scope(this, true); |
| 2014 | 1996 |
| 2015 push(eax); | 1997 push(eax); |
| 2016 push(Immediate(p0)); | 1998 push(Immediate(p0)); |
| 2017 push(Immediate(reinterpret_cast<intptr_t>(Smi::FromInt(p1 - p0)))); | 1999 push(Immediate(reinterpret_cast<intptr_t>(Smi::FromInt(p1 - p0)))); |
| 2018 // Disable stub call restrictions to always allow calls to abort. | 2000 CallRuntime(Runtime::kAbort, 2); |
| 2019 if (!has_frame_) { | |
| 2020 // We don't actually want to generate a pile of code for this, so just | |
| 2021 // claim there is a stack frame, without generating one. | |
| 2022 FrameScope scope(this, StackFrame::NONE); | |
| 2023 CallRuntime(Runtime::kAbort, 2); | |
| 2024 } else { | |
| 2025 CallRuntime(Runtime::kAbort, 2); | |
| 2026 } | |
| 2027 // will not return here | 2001 // will not return here |
| 2028 int3(); | 2002 int3(); |
| 2029 } | 2003 } |
| 2030 | 2004 |
| 2031 | 2005 |
| 2032 void MacroAssembler::LoadInstanceDescriptors(Register map, | 2006 void MacroAssembler::LoadInstanceDescriptors(Register map, |
| 2033 Register descriptors) { | 2007 Register descriptors) { |
| 2034 mov(descriptors, | 2008 mov(descriptors, |
| 2035 FieldOperand(map, Map::kInstanceDescriptorsOrBitField3Offset)); | 2009 FieldOperand(map, Map::kInstanceDescriptorsOrBitField3Offset)); |
| 2036 Label not_smi; | 2010 Label not_smi; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2116 void MacroAssembler::CallCFunction(ExternalReference function, | 2090 void MacroAssembler::CallCFunction(ExternalReference function, |
| 2117 int num_arguments) { | 2091 int num_arguments) { |
| 2118 // Trashing eax is ok as it will be the return value. | 2092 // Trashing eax is ok as it will be the return value. |
| 2119 mov(Operand(eax), Immediate(function)); | 2093 mov(Operand(eax), Immediate(function)); |
| 2120 CallCFunction(eax, num_arguments); | 2094 CallCFunction(eax, num_arguments); |
| 2121 } | 2095 } |
| 2122 | 2096 |
| 2123 | 2097 |
| 2124 void MacroAssembler::CallCFunction(Register function, | 2098 void MacroAssembler::CallCFunction(Register function, |
| 2125 int num_arguments) { | 2099 int num_arguments) { |
| 2126 ASSERT(has_frame()); | |
| 2127 // Check stack alignment. | 2100 // Check stack alignment. |
| 2128 if (emit_debug_code()) { | 2101 if (emit_debug_code()) { |
| 2129 CheckStackAlignment(); | 2102 CheckStackAlignment(); |
| 2130 } | 2103 } |
| 2131 | 2104 |
| 2132 call(Operand(function)); | 2105 call(Operand(function)); |
| 2133 if (OS::ActivationFrameAlignment() != 0) { | 2106 if (OS::ActivationFrameAlignment() != 0) { |
| 2134 mov(esp, Operand(esp, num_arguments * kPointerSize)); | 2107 mov(esp, Operand(esp, num_arguments * kPointerSize)); |
| 2135 } else { | 2108 } else { |
| 2136 add(Operand(esp), Immediate(num_arguments * kPointerSize)); | 2109 add(Operand(esp), Immediate(num_arguments * kPointerSize)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2155 | 2128 |
| 2156 // Check that the code was patched as expected. | 2129 // Check that the code was patched as expected. |
| 2157 ASSERT(masm_.pc_ == address_ + size_); | 2130 ASSERT(masm_.pc_ == address_ + size_); |
| 2158 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2131 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 2159 } | 2132 } |
| 2160 | 2133 |
| 2161 | 2134 |
| 2162 } } // namespace v8::internal | 2135 } } // namespace v8::internal |
| 2163 | 2136 |
| 2164 #endif // V8_TARGET_ARCH_IA32 | 2137 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |