| OLD | NEW |
| 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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 void PrepareCallCFunction(int num_arguments, Register scratch); | 473 void PrepareCallCFunction(int num_arguments, Register scratch); |
| 474 | 474 |
| 475 // Calls a C function and cleans up the space for arguments allocated | 475 // Calls a C function and cleans up the space for arguments allocated |
| 476 // by PrepareCallCFunction. The called function is not allowed to trigger a | 476 // by PrepareCallCFunction. The called function is not allowed to trigger a |
| 477 // garbage collection, since that might move the code and invalidate the | 477 // garbage collection, since that might move the code and invalidate the |
| 478 // return address (unless this is somehow accounted for by the called | 478 // return address (unless this is somehow accounted for by the called |
| 479 // function). | 479 // function). |
| 480 void CallCFunction(ExternalReference function, int num_arguments); | 480 void CallCFunction(ExternalReference function, int num_arguments); |
| 481 void CallCFunction(Register function, int num_arguments); | 481 void CallCFunction(Register function, int num_arguments); |
| 482 | 482 |
| 483 void PushHandleScope(Register scratch); | 483 // Prepares stack to put arguments (aligns and so on). Reserves |
| 484 // space for return value if needed (assumes the return value is a handle). |
| 485 // Uses callee-saved esi to restore stack state after call. Arguments must be |
| 486 // stored in ApiParameterOperand(0), ApiParameterOperand(1) etc. |
| 487 void PrepareCallApiFunction(int stack_space, int argc); |
| 484 | 488 |
| 485 // Pops a handle scope using the specified scratch register and | 489 // Tail call an API function (jump). Allocates HandleScope, extracts |
| 486 // ensuring that saved register is left unchanged. | 490 // returned value from handle and propagates exceptions. |
| 487 void PopHandleScope(Register saved, Register scratch); | 491 // Clobbers ebx, esi, edi and caller-save registers. |
| 488 | 492 void CallApiFunctionAndReturn(ApiFunction* function, int argc); |
| 489 // As PopHandleScope, but does not perform a GC. Instead, returns a | |
| 490 // retry after GC failure object if GC is necessary. | |
| 491 Object* TryPopHandleScope(Register saved, Register scratch); | |
| 492 | 493 |
| 493 // Jump to a runtime routine. | 494 // Jump to a runtime routine. |
| 494 void JumpToExternalReference(const ExternalReference& ext); | 495 void JumpToExternalReference(const ExternalReference& ext); |
| 495 | 496 |
| 496 | 497 |
| 497 // --------------------------------------------------------------------------- | 498 // --------------------------------------------------------------------------- |
| 498 // Utilities | 499 // Utilities |
| 499 | 500 |
| 500 void Ret(); | 501 void Ret(); |
| 501 | 502 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 | 633 |
| 633 | 634 |
| 634 // Generate an Operand for loading an indexed field from an object. | 635 // Generate an Operand for loading an indexed field from an object. |
| 635 static inline Operand FieldOperand(Register object, | 636 static inline Operand FieldOperand(Register object, |
| 636 Register index, | 637 Register index, |
| 637 ScaleFactor scale, | 638 ScaleFactor scale, |
| 638 int offset) { | 639 int offset) { |
| 639 return Operand(object, index, scale, offset - kHeapObjectTag); | 640 return Operand(object, index, scale, offset - kHeapObjectTag); |
| 640 } | 641 } |
| 641 | 642 |
| 643 // Generates an Operand for saving parameters after PrepareCallApiFunction. |
| 644 Operand ApiParameterOperand(int index); |
| 645 |
| 642 | 646 |
| 643 #ifdef GENERATED_CODE_COVERAGE | 647 #ifdef GENERATED_CODE_COVERAGE |
| 644 extern void LogGeneratedCodeCoverage(const char* file_line); | 648 extern void LogGeneratedCodeCoverage(const char* file_line); |
| 645 #define CODE_COVERAGE_STRINGIFY(x) #x | 649 #define CODE_COVERAGE_STRINGIFY(x) #x |
| 646 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) | 650 #define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x) |
| 647 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) | 651 #define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__) |
| 648 #define ACCESS_MASM(masm) { \ | 652 #define ACCESS_MASM(masm) { \ |
| 649 byte* ia32_coverage_function = \ | 653 byte* ia32_coverage_function = \ |
| 650 reinterpret_cast<byte*>(FUNCTION_ADDR(LogGeneratedCodeCoverage)); \ | 654 reinterpret_cast<byte*>(FUNCTION_ADDR(LogGeneratedCodeCoverage)); \ |
| 651 masm->pushfd(); \ | 655 masm->pushfd(); \ |
| 652 masm->pushad(); \ | 656 masm->pushad(); \ |
| 653 masm->push(Immediate(reinterpret_cast<int>(&__FILE_LINE__))); \ | 657 masm->push(Immediate(reinterpret_cast<int>(&__FILE_LINE__))); \ |
| 654 masm->call(ia32_coverage_function, RelocInfo::RUNTIME_ENTRY); \ | 658 masm->call(ia32_coverage_function, RelocInfo::RUNTIME_ENTRY); \ |
| 655 masm->pop(eax); \ | 659 masm->pop(eax); \ |
| 656 masm->popad(); \ | 660 masm->popad(); \ |
| 657 masm->popfd(); \ | 661 masm->popfd(); \ |
| 658 } \ | 662 } \ |
| 659 masm-> | 663 masm-> |
| 660 #else | 664 #else |
| 661 #define ACCESS_MASM(masm) masm-> | 665 #define ACCESS_MASM(masm) masm-> |
| 662 #endif | 666 #endif |
| 663 | 667 |
| 664 | 668 |
| 665 } } // namespace v8::internal | 669 } } // namespace v8::internal |
| 666 | 670 |
| 667 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ | 671 #endif // V8_IA32_MACRO_ASSEMBLER_IA32_H_ |
| OLD | NEW |