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

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

Issue 23588002: cleanup api callbacks now that handles are never returned directly (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: nits 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/ia32/macro-assembler-ia32.h ('k') | src/ia32/stub-cache-ia32.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 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 1970
1971 void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid, 1971 void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid,
1972 int num_arguments, 1972 int num_arguments,
1973 int result_size) { 1973 int result_size) {
1974 TailCallExternalReference(ExternalReference(fid, isolate()), 1974 TailCallExternalReference(ExternalReference(fid, isolate()),
1975 num_arguments, 1975 num_arguments,
1976 result_size); 1976 result_size);
1977 } 1977 }
1978 1978
1979 1979
1980 // If true, a Handle<T> returned by value from a function with cdecl calling 1980 Operand ApiParameterOperand(int index) {
1981 // convention will be returned directly as a value of location_ field in a 1981 return Operand(esp, index * kPointerSize);
1982 // register eax.
1983 // If false, it is returned as a pointer to a preallocated by caller memory
1984 // region. Pointer to this region should be passed to a function as an
1985 // implicit first argument.
1986 #if defined(USING_BSD_ABI) || defined(__MINGW32__) || defined(__CYGWIN__)
1987 static const bool kReturnHandlesDirectly = true;
1988 #else
1989 static const bool kReturnHandlesDirectly = false;
1990 #endif
1991
1992
1993 Operand ApiParameterOperand(int index, bool returns_handle) {
1994 int offset = (index +(kReturnHandlesDirectly || !returns_handle ? 0 : 1));
1995 return Operand(esp, offset * kPointerSize);
1996 } 1982 }
1997 1983
1998 1984
1999 void MacroAssembler::PrepareCallApiFunction(int argc, bool returns_handle) { 1985 void MacroAssembler::PrepareCallApiFunction(int argc) {
2000 if (kReturnHandlesDirectly || !returns_handle) { 1986 EnterApiExitFrame(argc);
2001 EnterApiExitFrame(argc); 1987 if (emit_debug_code()) {
2002 // When handles are returned directly we don't have to allocate extra 1988 mov(esi, Immediate(BitCast<int32_t>(kZapValue)));
2003 // space for and pass an out parameter.
2004 if (emit_debug_code()) {
2005 mov(esi, Immediate(BitCast<int32_t>(kZapValue)));
2006 }
2007 } else {
2008 // We allocate two additional slots: return value and pointer to it.
2009 EnterApiExitFrame(argc + 2);
2010
2011 // The argument slots are filled as follows:
2012 //
2013 // n + 1: output slot
2014 // n: arg n
2015 // ...
2016 // 1: arg1
2017 // 0: pointer to the output slot
2018
2019 lea(esi, Operand(esp, (argc + 1) * kPointerSize));
2020 mov(Operand(esp, 0 * kPointerSize), esi);
2021 if (emit_debug_code()) {
2022 mov(Operand(esi, 0), Immediate(0));
2023 }
2024 } 1989 }
2025 } 1990 }
2026 1991
2027 1992
2028 void MacroAssembler::CallApiFunctionAndReturn(Address function_address, 1993 void MacroAssembler::CallApiFunctionAndReturn(Address function_address,
2029 Address thunk_address, 1994 Address thunk_address,
2030 Operand thunk_last_arg, 1995 Operand thunk_last_arg,
2031 int stack_space, 1996 int stack_space,
2032 bool returns_handle,
2033 int return_value_offset) { 1997 int return_value_offset) {
2034 ExternalReference next_address = 1998 ExternalReference next_address =
2035 ExternalReference::handle_scope_next_address(isolate()); 1999 ExternalReference::handle_scope_next_address(isolate());
2036 ExternalReference limit_address = 2000 ExternalReference limit_address =
2037 ExternalReference::handle_scope_limit_address(isolate()); 2001 ExternalReference::handle_scope_limit_address(isolate());
2038 ExternalReference level_address = 2002 ExternalReference level_address =
2039 ExternalReference::handle_scope_level_address(isolate()); 2003 ExternalReference::handle_scope_level_address(isolate());
2040 2004
2041 // Allocate HandleScope in callee-save registers. 2005 // Allocate HandleScope in callee-save registers.
2042 mov(ebx, Operand::StaticVariable(next_address)); 2006 mov(ebx, Operand::StaticVariable(next_address));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 FrameScope frame(this, StackFrame::MANUAL); 2042 FrameScope frame(this, StackFrame::MANUAL);
2079 PushSafepointRegisters(); 2043 PushSafepointRegisters();
2080 PrepareCallCFunction(1, eax); 2044 PrepareCallCFunction(1, eax);
2081 mov(Operand(esp, 0), 2045 mov(Operand(esp, 0),
2082 Immediate(ExternalReference::isolate_address(isolate()))); 2046 Immediate(ExternalReference::isolate_address(isolate())));
2083 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); 2047 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1);
2084 PopSafepointRegisters(); 2048 PopSafepointRegisters();
2085 } 2049 }
2086 2050
2087 Label prologue; 2051 Label prologue;
2088 if (returns_handle) {
2089 if (!kReturnHandlesDirectly) {
2090 // PrepareCallApiFunction saved pointer to the output slot into
2091 // callee-save register esi.
2092 mov(eax, Operand(esi, 0));
2093 }
2094 Label empty_handle;
2095 // Check if the result handle holds 0.
2096 test(eax, eax);
2097 j(zero, &empty_handle);
2098 // It was non-zero. Dereference to get the result value.
2099 mov(eax, Operand(eax, 0));
2100 jmp(&prologue);
2101 bind(&empty_handle);
2102 }
2103 // Load the value from ReturnValue 2052 // Load the value from ReturnValue
2104 mov(eax, Operand(ebp, return_value_offset * kPointerSize)); 2053 mov(eax, Operand(ebp, return_value_offset * kPointerSize));
2105 2054
2106 Label promote_scheduled_exception; 2055 Label promote_scheduled_exception;
2107 Label delete_allocated_handles; 2056 Label delete_allocated_handles;
2108 Label leave_exit_frame; 2057 Label leave_exit_frame;
2109 2058
2110 bind(&prologue); 2059 bind(&prologue);
2111 // No more valid handles (the result handle was the last one). Restore 2060 // No more valid handles (the result handle was the last one). Restore
2112 // previous handle scope. 2061 // previous handle scope.
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
3242 j(greater, &no_memento_available); 3191 j(greater, &no_memento_available);
3243 cmp(MemOperand(scratch_reg, -AllocationMemento::kSize), 3192 cmp(MemOperand(scratch_reg, -AllocationMemento::kSize),
3244 Immediate(Handle<Map>(isolate()->heap()->allocation_memento_map()))); 3193 Immediate(Handle<Map>(isolate()->heap()->allocation_memento_map())));
3245 bind(&no_memento_available); 3194 bind(&no_memento_available);
3246 } 3195 }
3247 3196
3248 3197
3249 } } // namespace v8::internal 3198 } } // namespace v8::internal
3250 3199
3251 #endif // V8_TARGET_ARCH_IA32 3200 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698