Index: src/x64/macro-assembler-x64.cc |
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc |
index 97e5690c8dcf3a6b0a6c9aae4107ad57ffb89565..d36791c753e05c12cd812d8f4b044c1926dee1d5 100644 |
--- a/src/x64/macro-assembler-x64.cc |
+++ b/src/x64/macro-assembler-x64.cc |
@@ -692,182 +692,6 @@ void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid, |
} |
-static int Offset(ExternalReference ref0, ExternalReference ref1) { |
- int64_t offset = (ref0.address() - ref1.address()); |
- // Check that fits into int. |
- DCHECK(static_cast<int>(offset) == offset); |
- return static_cast<int>(offset); |
-} |
- |
- |
-void MacroAssembler::PrepareCallApiFunction(int arg_stack_space) { |
- EnterApiExitFrame(arg_stack_space); |
-} |
- |
- |
-void MacroAssembler::CallApiFunctionAndReturn( |
- Register function_address, ExternalReference thunk_ref, |
- Register thunk_last_arg, int stack_space, Operand* stack_space_operand, |
- Operand return_value_operand, Operand* context_restore_operand) { |
- Label prologue; |
- Label promote_scheduled_exception; |
- Label exception_handled; |
- Label delete_allocated_handles; |
- Label leave_exit_frame; |
- Label write_back; |
- |
- Factory* factory = isolate()->factory(); |
- ExternalReference next_address = |
- ExternalReference::handle_scope_next_address(isolate()); |
- const int kNextOffset = 0; |
- const int kLimitOffset = Offset( |
- ExternalReference::handle_scope_limit_address(isolate()), |
- next_address); |
- const int kLevelOffset = Offset( |
- ExternalReference::handle_scope_level_address(isolate()), |
- next_address); |
- ExternalReference scheduled_exception_address = |
- ExternalReference::scheduled_exception_address(isolate()); |
- |
- DCHECK(rdx.is(function_address) || r8.is(function_address)); |
- // Allocate HandleScope in callee-save registers. |
- Register prev_next_address_reg = r14; |
- Register prev_limit_reg = rbx; |
- Register base_reg = r15; |
- Move(base_reg, next_address); |
- movp(prev_next_address_reg, Operand(base_reg, kNextOffset)); |
- movp(prev_limit_reg, Operand(base_reg, kLimitOffset)); |
- addl(Operand(base_reg, kLevelOffset), Immediate(1)); |
- |
- if (FLAG_log_timer_events) { |
- FrameScope frame(this, StackFrame::MANUAL); |
- PushSafepointRegisters(); |
- PrepareCallCFunction(1); |
- LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); |
- CallCFunction(ExternalReference::log_enter_external_function(isolate()), 1); |
- PopSafepointRegisters(); |
- } |
- |
- |
- Label profiler_disabled; |
- Label end_profiler_check; |
- Move(rax, ExternalReference::is_profiling_address(isolate())); |
- cmpb(Operand(rax, 0), Immediate(0)); |
- j(zero, &profiler_disabled); |
- |
- // Third parameter is the address of the actual getter function. |
- Move(thunk_last_arg, function_address); |
- Move(rax, thunk_ref); |
- jmp(&end_profiler_check); |
- |
- bind(&profiler_disabled); |
- // Call the api function! |
- Move(rax, function_address); |
- |
- bind(&end_profiler_check); |
- |
- // Call the api function! |
- call(rax); |
- |
- if (FLAG_log_timer_events) { |
- FrameScope frame(this, StackFrame::MANUAL); |
- PushSafepointRegisters(); |
- PrepareCallCFunction(1); |
- LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); |
- CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); |
- PopSafepointRegisters(); |
- } |
- |
- // Load the value from ReturnValue |
- movp(rax, return_value_operand); |
- bind(&prologue); |
- |
- // No more valid handles (the result handle was the last one). Restore |
- // previous handle scope. |
- subl(Operand(base_reg, kLevelOffset), Immediate(1)); |
- movp(Operand(base_reg, kNextOffset), prev_next_address_reg); |
- cmpp(prev_limit_reg, Operand(base_reg, kLimitOffset)); |
- j(not_equal, &delete_allocated_handles); |
- bind(&leave_exit_frame); |
- |
- // Check if the function scheduled an exception. |
- Move(rsi, scheduled_exception_address); |
- Cmp(Operand(rsi, 0), factory->the_hole_value()); |
- j(not_equal, &promote_scheduled_exception); |
- bind(&exception_handled); |
- |
-#if DEBUG |
- // Check if the function returned a valid JavaScript value. |
- Label ok; |
- Register return_value = rax; |
- Register map = rcx; |
- |
- JumpIfSmi(return_value, &ok, Label::kNear); |
- movp(map, FieldOperand(return_value, HeapObject::kMapOffset)); |
- |
- CmpInstanceType(map, LAST_NAME_TYPE); |
- j(below_equal, &ok, Label::kNear); |
- |
- CmpInstanceType(map, FIRST_SPEC_OBJECT_TYPE); |
- j(above_equal, &ok, Label::kNear); |
- |
- CompareRoot(map, Heap::kHeapNumberMapRootIndex); |
- j(equal, &ok, Label::kNear); |
- |
- CompareRoot(return_value, Heap::kUndefinedValueRootIndex); |
- j(equal, &ok, Label::kNear); |
- |
- CompareRoot(return_value, Heap::kTrueValueRootIndex); |
- j(equal, &ok, Label::kNear); |
- |
- CompareRoot(return_value, Heap::kFalseValueRootIndex); |
- j(equal, &ok, Label::kNear); |
- |
- CompareRoot(return_value, Heap::kNullValueRootIndex); |
- j(equal, &ok, Label::kNear); |
- |
- Abort(kAPICallReturnedInvalidObject); |
- |
- bind(&ok); |
-#endif |
- |
- bool restore_context = context_restore_operand != NULL; |
- if (restore_context) { |
- movp(rsi, *context_restore_operand); |
- } |
- if (stack_space_operand != nullptr) { |
- movp(rbx, *stack_space_operand); |
- } |
- LeaveApiExitFrame(!restore_context); |
- if (stack_space_operand != nullptr) { |
- DCHECK_EQ(stack_space, 0); |
- PopReturnAddressTo(rcx); |
- addq(rsp, rbx); |
- jmp(rcx); |
- } else { |
- ret(stack_space * kPointerSize); |
- } |
- |
- bind(&promote_scheduled_exception); |
- { |
- FrameScope frame(this, StackFrame::INTERNAL); |
- CallRuntime(Runtime::kPromoteScheduledException, 0); |
- } |
- jmp(&exception_handled); |
- |
- // HandleScope limit has changed. Delete allocated extensions. |
- bind(&delete_allocated_handles); |
- movp(Operand(base_reg, kLimitOffset), prev_limit_reg); |
- movp(prev_limit_reg, rax); |
- LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); |
- LoadAddress(rax, |
- ExternalReference::delete_handle_scope_extensions(isolate())); |
- call(rax); |
- movp(rax, prev_limit_reg); |
- jmp(&leave_exit_frame); |
-} |
- |
- |
void MacroAssembler::JumpToExternalReference(const ExternalReference& ext, |
int result_size) { |
// Set the entry point and jump to the C entry runtime stub. |