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

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

Issue 1549031: Call to C function support in macro assembler... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 8 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
« no previous file with comments | « src/arm/macro-assembler-arm.h ('k') | src/arm/regexp-macro-assembler-arm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 Label* failure) { 1550 Label* failure) {
1551 int kFlatAsciiStringMask = 1551 int kFlatAsciiStringMask =
1552 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; 1552 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask;
1553 int kFlatAsciiStringTag = ASCII_STRING_TYPE; 1553 int kFlatAsciiStringTag = ASCII_STRING_TYPE;
1554 and_(scratch, type, Operand(kFlatAsciiStringMask)); 1554 and_(scratch, type, Operand(kFlatAsciiStringMask));
1555 cmp(scratch, Operand(kFlatAsciiStringTag)); 1555 cmp(scratch, Operand(kFlatAsciiStringTag));
1556 b(ne, failure); 1556 b(ne, failure);
1557 } 1557 }
1558 1558
1559 1559
1560 void MacroAssembler::PrepareCallCFunction(int num_arguments, Register scratch) {
1561 int frameAlignment = OS::ActivationFrameAlignment();
1562 // Up to four simple arguments are passed in registers r0..r3.
1563 int stack_passed_arguments = (num_arguments <= 4) ? 0 : num_arguments - 4;
1564 if (frameAlignment > kPointerSize) {
1565 // Make stack end at alignment and make room for num_arguments - 4 words
1566 // and the original value of sp.
1567 mov(scratch, sp);
1568 sub(sp, sp, Operand((stack_passed_arguments + 1) * kPointerSize));
1569 ASSERT(IsPowerOf2(frameAlignment));
1570 and_(sp, sp, Operand(-frameAlignment));
1571 str(scratch, MemOperand(sp, stack_passed_arguments * kPointerSize));
1572 } else {
1573 sub(sp, sp, Operand(stack_passed_arguments * kPointerSize));
1574 }
1575 }
1576
1577
1578 void MacroAssembler::CallCFunction(ExternalReference function,
1579 int num_arguments) {
1580 mov(ip, Operand(function));
1581 CallCFunction(ip, num_arguments);
1582 }
1583
1584
1585 void MacroAssembler::CallCFunction(Register function, int num_arguments) {
1586 // Just call directly. The function called cannot cause a GC, or
1587 // allow preemption, so the return address in the link register
1588 // stays correct.
1589 Call(function);
1590 int stack_passed_arguments = (num_arguments <= 4) ? 0 : num_arguments - 4;
1591 if (OS::ActivationFrameAlignment() > kPointerSize) {
1592 ldr(sp, MemOperand(sp, stack_passed_arguments * kPointerSize));
1593 } else {
1594 add(sp, sp, Operand(stack_passed_arguments * sizeof(kPointerSize)));
1595 }
1596 }
1597
1598
1560 #ifdef ENABLE_DEBUGGER_SUPPORT 1599 #ifdef ENABLE_DEBUGGER_SUPPORT
1561 CodePatcher::CodePatcher(byte* address, int instructions) 1600 CodePatcher::CodePatcher(byte* address, int instructions)
1562 : address_(address), 1601 : address_(address),
1563 instructions_(instructions), 1602 instructions_(instructions),
1564 size_(instructions * Assembler::kInstrSize), 1603 size_(instructions * Assembler::kInstrSize),
1565 masm_(address, size_ + Assembler::kGap) { 1604 masm_(address, size_ + Assembler::kGap) {
1566 // Create a new macro assembler pointing to the address of the code to patch. 1605 // Create a new macro assembler pointing to the address of the code to patch.
1567 // The size is adjusted with kGap on order for the assembler to generate size 1606 // The size is adjusted with kGap on order for the assembler to generate size
1568 // bytes of instructions without failing with buffer size constraints. 1607 // bytes of instructions without failing with buffer size constraints.
1569 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 1608 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
(...skipping 15 matching lines...) Expand all
1585 } 1624 }
1586 1625
1587 1626
1588 void CodePatcher::Emit(Address addr) { 1627 void CodePatcher::Emit(Address addr) {
1589 masm()->emit(reinterpret_cast<Instr>(addr)); 1628 masm()->emit(reinterpret_cast<Instr>(addr));
1590 } 1629 }
1591 #endif // ENABLE_DEBUGGER_SUPPORT 1630 #endif // ENABLE_DEBUGGER_SUPPORT
1592 1631
1593 1632
1594 } } // namespace v8::internal 1633 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.h ('k') | src/arm/regexp-macro-assembler-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698