Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 5674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5685 | 5685 |
| 5686 Label fast_elements_case; | 5686 Label fast_elements_case; |
| 5687 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS)); | 5687 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS)); |
| 5688 GenerateCase(masm, FAST_HOLEY_ELEMENTS); | 5688 GenerateCase(masm, FAST_HOLEY_ELEMENTS); |
| 5689 | 5689 |
| 5690 __ bind(&fast_elements_case); | 5690 __ bind(&fast_elements_case); |
| 5691 GenerateCase(masm, FAST_ELEMENTS); | 5691 GenerateCase(masm, FAST_ELEMENTS); |
| 5692 } | 5692 } |
| 5693 | 5693 |
| 5694 | 5694 |
| 5695 void CallApiFunctionStub::Generate(MacroAssembler* masm) { | |
| 5696 // ----------- S t a t e ------------- | |
| 5697 // -- a0 : callee | |
| 5698 // -- t0 : call_data | |
| 5699 // -- a2 : holder | |
| 5700 // -- a3 : api_function_address | |
| 5701 // -- a1 : thunk_arg | |
| 5702 // -- cp : context | |
| 5703 // -- | |
| 5704 // -- esp[0] : last argument | |
| 5705 // -- ... | |
| 5706 // -- esp[(argc - 1)* 4] : first argument | |
| 5707 // -- esp[argc * 4] : receiver | |
|
Paul Lind
2014/01/28 00:21:13
nit: these should be sp, not esp.
palfia
2014/01/28 01:15:14
Done.
| |
| 5708 // ----------------------------------- | |
| 5709 | |
| 5710 Register callee = a0; | |
| 5711 Register call_data = t0; | |
| 5712 Register holder = a2; | |
| 5713 Register api_function_address = a3; | |
| 5714 Register thunk_arg = a1; | |
| 5715 Register context = cp; | |
| 5716 | |
| 5717 int argc = ArgumentBits::decode(bit_field_); | |
| 5718 bool restore_context = RestoreContextBits::decode(bit_field_); | |
| 5719 bool call_data_undefined = CallDataUndefinedBits::decode(bit_field_); | |
| 5720 | |
| 5721 typedef FunctionCallbackArguments FCA; | |
| 5722 | |
| 5723 STATIC_ASSERT(FCA::kContextSaveIndex == 6); | |
| 5724 STATIC_ASSERT(FCA::kCalleeIndex == 5); | |
| 5725 STATIC_ASSERT(FCA::kDataIndex == 4); | |
| 5726 STATIC_ASSERT(FCA::kReturnValueOffset == 3); | |
| 5727 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); | |
| 5728 STATIC_ASSERT(FCA::kIsolateIndex == 1); | |
| 5729 STATIC_ASSERT(FCA::kHolderIndex == 0); | |
| 5730 STATIC_ASSERT(FCA::kArgsLength == 7); | |
| 5731 | |
| 5732 Isolate* isolate = masm->isolate(); | |
| 5733 | |
| 5734 // context save | |
| 5735 __ push(context); | |
| 5736 // load context from callee | |
| 5737 __ lw(context, FieldMemOperand(callee, JSFunction::kContextOffset)); | |
| 5738 | |
| 5739 // callee | |
| 5740 __ push(callee); | |
| 5741 | |
| 5742 // call data | |
| 5743 __ push(call_data); | |
| 5744 | |
|
Paul Lind
2014/01/28 00:21:13
Suggest you combine push ops where possible. It sa
palfia
2014/01/28 01:15:14
Done.
| |
| 5745 Register scratch = call_data; | |
| 5746 if (!call_data_undefined) { | |
| 5747 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); | |
| 5748 } | |
| 5749 // return value | |
| 5750 __ push(scratch); | |
| 5751 // return value default | |
| 5752 __ push(scratch); | |
|
Paul Lind
2014/01/28 00:21:13
__ Push(scratch, scratch);
palfia
2014/01/28 01:15:14
Done.
| |
| 5753 // isolate | |
| 5754 __ li(scratch, | |
| 5755 Operand(ExternalReference::isolate_address(isolate))); | |
| 5756 __ push(scratch); | |
| 5757 // holder | |
| 5758 __ push(holder); | |
|
Paul Lind
2014/01/28 00:21:13
__ Push(scratch, holder);
palfia
2014/01/28 01:15:14
Done.
| |
| 5759 | |
| 5760 // Prepare arguments. | |
| 5761 __ mov(scratch, sp); | |
| 5762 | |
| 5763 // Allocate the v8::Arguments structure in the arguments' space since | |
| 5764 // it's not controlled by GC. | |
| 5765 const int kApiStackSpace = 4; | |
| 5766 | |
| 5767 FrameScope frame_scope(masm, StackFrame::MANUAL); | |
| 5768 __ EnterExitFrame(false, kApiStackSpace); | |
| 5769 | |
| 5770 ASSERT(!thunk_arg.is(a0) && !api_function_address.is(a0) && !scratch.is(a0)); | |
| 5771 // a0 = FunctionCallbackInfo& | |
| 5772 // Arguments is after the return address. | |
| 5773 __ Addu(a0, sp, Operand(1 * kPointerSize)); | |
| 5774 // FunctionCallbackInfo::implicit_args_ | |
| 5775 __ sw(scratch, MemOperand(a0, 0 * kPointerSize)); | |
| 5776 // FunctionCallbackInfo::values_ | |
| 5777 __ Addu(at, scratch, Operand((FCA::kArgsLength - 1 + argc) * kPointerSize)); | |
| 5778 __ sw(at, MemOperand(a0, 1 * kPointerSize)); | |
| 5779 // FunctionCallbackInfo::length_ = argc | |
| 5780 __ li(at, Operand(argc)); | |
| 5781 __ sw(at, MemOperand(a0, 2 * kPointerSize)); | |
| 5782 // FunctionCallbackInfo::is_construct_call = 0 | |
| 5783 __ sw(zero_reg, MemOperand(a0, 3 * kPointerSize)); | |
| 5784 | |
| 5785 const int kStackUnwindSpace = argc + FCA::kArgsLength + 1; | |
| 5786 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); | |
| 5787 ExternalReference::Type thunk_type = ExternalReference::PROFILING_API_CALL; | |
| 5788 ApiFunction thunk_fun(thunk_address); | |
| 5789 ExternalReference thunk_ref = ExternalReference(&thunk_fun, thunk_type, | |
| 5790 masm->isolate()); | |
| 5791 | |
| 5792 AllowExternalCallThatCantCauseGC scope(masm); | |
| 5793 MemOperand context_restore_operand( | |
| 5794 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); | |
| 5795 MemOperand return_value_operand(fp, | |
| 5796 (2 + FCA::kReturnValueOffset) * kPointerSize); | |
| 5797 | |
| 5798 __ CallApiFunctionAndReturn(api_function_address, | |
| 5799 thunk_ref, | |
| 5800 thunk_arg, | |
| 5801 kStackUnwindSpace, | |
| 5802 return_value_operand, | |
| 5803 restore_context ? | |
| 5804 &context_restore_operand : NULL); | |
| 5805 } | |
| 5806 | |
| 5807 | |
| 5695 #undef __ | 5808 #undef __ |
| 5696 | 5809 |
| 5697 } } // namespace v8::internal | 5810 } } // namespace v8::internal |
| 5698 | 5811 |
| 5699 #endif // V8_TARGET_ARCH_MIPS | 5812 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |