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

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

Issue 23604004: MIPS: cleanup api callbacks now that handles are never returned directly (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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/mips/macro-assembler-mips.h ('k') | src/mips/simulator-mips.cc » ('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 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 3945 matching lines...) Expand 10 before | Expand all | Expand 10 after
3956 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { 3956 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) {
3957 return ref0.address() - ref1.address(); 3957 return ref0.address() - ref1.address();
3958 } 3958 }
3959 3959
3960 3960
3961 void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, 3961 void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function,
3962 Address function_address, 3962 Address function_address,
3963 ExternalReference thunk_ref, 3963 ExternalReference thunk_ref,
3964 Register thunk_last_arg, 3964 Register thunk_last_arg,
3965 int stack_space, 3965 int stack_space,
3966 bool returns_handle,
3967 int return_value_offset_from_fp) { 3966 int return_value_offset_from_fp) {
3968 ExternalReference next_address = 3967 ExternalReference next_address =
3969 ExternalReference::handle_scope_next_address(isolate()); 3968 ExternalReference::handle_scope_next_address(isolate());
3970 const int kNextOffset = 0; 3969 const int kNextOffset = 0;
3971 const int kLimitOffset = AddressOffset( 3970 const int kLimitOffset = AddressOffset(
3972 ExternalReference::handle_scope_limit_address(isolate()), 3971 ExternalReference::handle_scope_limit_address(isolate()),
3973 next_address); 3972 next_address);
3974 const int kLevelOffset = AddressOffset( 3973 const int kLevelOffset = AddressOffset(
3975 ExternalReference::handle_scope_level_address(isolate()), 3974 ExternalReference::handle_scope_level_address(isolate()),
3976 next_address); 3975 next_address);
3977 3976
3978 // Allocate HandleScope in callee-save registers. 3977 // Allocate HandleScope in callee-save registers.
3979 li(s3, Operand(next_address)); 3978 li(s3, Operand(next_address));
3980 lw(s0, MemOperand(s3, kNextOffset)); 3979 lw(s0, MemOperand(s3, kNextOffset));
3981 lw(s1, MemOperand(s3, kLimitOffset)); 3980 lw(s1, MemOperand(s3, kLimitOffset));
3982 lw(s2, MemOperand(s3, kLevelOffset)); 3981 lw(s2, MemOperand(s3, kLevelOffset));
3983 Addu(s2, s2, Operand(1)); 3982 Addu(s2, s2, Operand(1));
3984 sw(s2, MemOperand(s3, kLevelOffset)); 3983 sw(s2, MemOperand(s3, kLevelOffset));
3985 3984
3986 if (FLAG_log_timer_events) { 3985 if (FLAG_log_timer_events) {
3987 FrameScope frame(this, StackFrame::MANUAL); 3986 FrameScope frame(this, StackFrame::MANUAL);
3988 PushSafepointRegisters(); 3987 PushSafepointRegisters();
3989 PrepareCallCFunction(1, a0); 3988 PrepareCallCFunction(1, a0);
3990 li(a0, Operand(ExternalReference::isolate_address(isolate()))); 3989 li(a0, Operand(ExternalReference::isolate_address(isolate())));
3991 CallCFunction(ExternalReference::log_enter_external_function(isolate()), 1); 3990 CallCFunction(ExternalReference::log_enter_external_function(isolate()), 1);
3992 PopSafepointRegisters(); 3991 PopSafepointRegisters();
3993 } 3992 }
3994 3993
3995 // The O32 ABI requires us to pass a pointer in a0 where the returned struct
3996 // (4 bytes) will be placed. This is also built into the Simulator.
3997 // Set up the pointer to the returned value (a0). It was allocated in
3998 // EnterExitFrame.
3999 if (returns_handle) {
4000 addiu(a0, fp, ExitFrameConstants::kStackSpaceOffset);
4001 }
4002
4003 Label profiler_disabled; 3994 Label profiler_disabled;
4004 Label end_profiler_check; 3995 Label end_profiler_check;
4005 bool* is_profiling_flag = 3996 bool* is_profiling_flag =
4006 isolate()->cpu_profiler()->is_profiling_address(); 3997 isolate()->cpu_profiler()->is_profiling_address();
4007 STATIC_ASSERT(sizeof(*is_profiling_flag) == 1); 3998 STATIC_ASSERT(sizeof(*is_profiling_flag) == 1);
4008 li(t9, reinterpret_cast<int32_t>(is_profiling_flag)); 3999 li(t9, reinterpret_cast<int32_t>(is_profiling_flag));
4009 lb(t9, MemOperand(t9, 0)); 4000 lb(t9, MemOperand(t9, 0));
4010 beq(t9, zero_reg, &profiler_disabled); 4001 beq(t9, zero_reg, &profiler_disabled);
4011 4002
4012 // Third parameter is the address of the actual getter function. 4003 // Third parameter is the address of the actual getter function.
(...skipping 19 matching lines...) Expand all
4032 li(a0, Operand(ExternalReference::isolate_address(isolate()))); 4023 li(a0, Operand(ExternalReference::isolate_address(isolate())));
4033 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); 4024 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1);
4034 PopSafepointRegisters(); 4025 PopSafepointRegisters();
4035 } 4026 }
4036 4027
4037 Label promote_scheduled_exception; 4028 Label promote_scheduled_exception;
4038 Label delete_allocated_handles; 4029 Label delete_allocated_handles;
4039 Label leave_exit_frame; 4030 Label leave_exit_frame;
4040 Label return_value_loaded; 4031 Label return_value_loaded;
4041 4032
4042 if (returns_handle) {
4043 Label load_return_value;
4044
4045 // As mentioned above, on MIPS a pointer is returned - we need to
4046 // dereference it to get the actual return value (which is also a pointer).
4047 lw(v0, MemOperand(v0));
4048
4049 Branch(&load_return_value, eq, v0, Operand(zero_reg));
4050 // Dereference returned value.
4051 lw(v0, MemOperand(v0));
4052 Branch(&return_value_loaded);
4053 bind(&load_return_value);
4054 }
4055 // Load value from ReturnValue. 4033 // Load value from ReturnValue.
4056 lw(v0, MemOperand(fp, return_value_offset_from_fp*kPointerSize)); 4034 lw(v0, MemOperand(fp, return_value_offset_from_fp*kPointerSize));
4057 bind(&return_value_loaded); 4035 bind(&return_value_loaded);
4058 4036
4059 // No more valid handles (the result handle was the last one). Restore 4037 // No more valid handles (the result handle was the last one). Restore
4060 // previous handle scope. 4038 // previous handle scope.
4061 sw(s0, MemOperand(s3, kNextOffset)); 4039 sw(s0, MemOperand(s3, kNextOffset));
4062 if (emit_debug_code()) { 4040 if (emit_debug_code()) {
4063 lw(a1, MemOperand(s3, kLevelOffset)); 4041 lw(a1, MemOperand(s3, kLevelOffset));
4064 Check(eq, kUnexpectedLevelAfterReturnFromApiCall, a1, Operand(s2)); 4042 Check(eq, kUnexpectedLevelAfterReturnFromApiCall, a1, Operand(s2));
(...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after
5606 opcode == BGTZL); 5584 opcode == BGTZL);
5607 opcode = (cond == eq) ? BEQ : BNE; 5585 opcode = (cond == eq) ? BEQ : BNE;
5608 instr = (instr & ~kOpcodeMask) | opcode; 5586 instr = (instr & ~kOpcodeMask) | opcode;
5609 masm_.emit(instr); 5587 masm_.emit(instr);
5610 } 5588 }
5611 5589
5612 5590
5613 } } // namespace v8::internal 5591 } } // namespace v8::internal
5614 5592
5615 #endif // V8_TARGET_ARCH_MIPS 5593 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/macro-assembler-mips.h ('k') | src/mips/simulator-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698