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

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

Issue 860013002: move CallApiFunctionAndReturn to code-stubs-* (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/mips/code-stubs-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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/division-by-constant.h" 10 #include "src/base/division-by-constant.h"
(...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 2077
2078 void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid, 2078 void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid,
2079 int num_arguments, 2079 int num_arguments,
2080 int result_size) { 2080 int result_size) {
2081 TailCallExternalReference(ExternalReference(fid, isolate()), 2081 TailCallExternalReference(ExternalReference(fid, isolate()),
2082 num_arguments, 2082 num_arguments,
2083 result_size); 2083 result_size);
2084 } 2084 }
2085 2085
2086 2086
2087 Operand ApiParameterOperand(int index) {
2088 return Operand(esp, index * kPointerSize);
2089 }
2090
2091
2092 void MacroAssembler::PrepareCallApiFunction(int argc) {
2093 EnterApiExitFrame(argc);
2094 if (emit_debug_code()) {
2095 mov(esi, Immediate(bit_cast<int32_t>(kZapValue)));
2096 }
2097 }
2098
2099
2100 void MacroAssembler::CallApiFunctionAndReturn(
2101 Register function_address, ExternalReference thunk_ref,
2102 Operand thunk_last_arg, int stack_space, Operand* stack_space_operand,
2103 Operand return_value_operand, Operand* context_restore_operand) {
2104 ExternalReference next_address =
2105 ExternalReference::handle_scope_next_address(isolate());
2106 ExternalReference limit_address =
2107 ExternalReference::handle_scope_limit_address(isolate());
2108 ExternalReference level_address =
2109 ExternalReference::handle_scope_level_address(isolate());
2110
2111 DCHECK(edx.is(function_address));
2112 // Allocate HandleScope in callee-save registers.
2113 mov(ebx, Operand::StaticVariable(next_address));
2114 mov(edi, Operand::StaticVariable(limit_address));
2115 add(Operand::StaticVariable(level_address), Immediate(1));
2116
2117 if (FLAG_log_timer_events) {
2118 FrameScope frame(this, StackFrame::MANUAL);
2119 PushSafepointRegisters();
2120 PrepareCallCFunction(1, eax);
2121 mov(Operand(esp, 0),
2122 Immediate(ExternalReference::isolate_address(isolate())));
2123 CallCFunction(ExternalReference::log_enter_external_function(isolate()), 1);
2124 PopSafepointRegisters();
2125 }
2126
2127
2128 Label profiler_disabled;
2129 Label end_profiler_check;
2130 mov(eax, Immediate(ExternalReference::is_profiling_address(isolate())));
2131 cmpb(Operand(eax, 0), 0);
2132 j(zero, &profiler_disabled);
2133
2134 // Additional parameter is the address of the actual getter function.
2135 mov(thunk_last_arg, function_address);
2136 // Call the api function.
2137 mov(eax, Immediate(thunk_ref));
2138 call(eax);
2139 jmp(&end_profiler_check);
2140
2141 bind(&profiler_disabled);
2142 // Call the api function.
2143 call(function_address);
2144 bind(&end_profiler_check);
2145
2146 if (FLAG_log_timer_events) {
2147 FrameScope frame(this, StackFrame::MANUAL);
2148 PushSafepointRegisters();
2149 PrepareCallCFunction(1, eax);
2150 mov(Operand(esp, 0),
2151 Immediate(ExternalReference::isolate_address(isolate())));
2152 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1);
2153 PopSafepointRegisters();
2154 }
2155
2156 Label prologue;
2157 // Load the value from ReturnValue
2158 mov(eax, return_value_operand);
2159
2160 Label promote_scheduled_exception;
2161 Label exception_handled;
2162 Label delete_allocated_handles;
2163 Label leave_exit_frame;
2164
2165 bind(&prologue);
2166 // No more valid handles (the result handle was the last one). Restore
2167 // previous handle scope.
2168 mov(Operand::StaticVariable(next_address), ebx);
2169 sub(Operand::StaticVariable(level_address), Immediate(1));
2170 Assert(above_equal, kInvalidHandleScopeLevel);
2171 cmp(edi, Operand::StaticVariable(limit_address));
2172 j(not_equal, &delete_allocated_handles);
2173 bind(&leave_exit_frame);
2174
2175 // Check if the function scheduled an exception.
2176 ExternalReference scheduled_exception_address =
2177 ExternalReference::scheduled_exception_address(isolate());
2178 cmp(Operand::StaticVariable(scheduled_exception_address),
2179 Immediate(isolate()->factory()->the_hole_value()));
2180 j(not_equal, &promote_scheduled_exception);
2181 bind(&exception_handled);
2182
2183 #if DEBUG
2184 // Check if the function returned a valid JavaScript value.
2185 Label ok;
2186 Register return_value = eax;
2187 Register map = ecx;
2188
2189 JumpIfSmi(return_value, &ok, Label::kNear);
2190 mov(map, FieldOperand(return_value, HeapObject::kMapOffset));
2191
2192 CmpInstanceType(map, LAST_NAME_TYPE);
2193 j(below_equal, &ok, Label::kNear);
2194
2195 CmpInstanceType(map, FIRST_SPEC_OBJECT_TYPE);
2196 j(above_equal, &ok, Label::kNear);
2197
2198 cmp(map, isolate()->factory()->heap_number_map());
2199 j(equal, &ok, Label::kNear);
2200
2201 cmp(return_value, isolate()->factory()->undefined_value());
2202 j(equal, &ok, Label::kNear);
2203
2204 cmp(return_value, isolate()->factory()->true_value());
2205 j(equal, &ok, Label::kNear);
2206
2207 cmp(return_value, isolate()->factory()->false_value());
2208 j(equal, &ok, Label::kNear);
2209
2210 cmp(return_value, isolate()->factory()->null_value());
2211 j(equal, &ok, Label::kNear);
2212
2213 Abort(kAPICallReturnedInvalidObject);
2214
2215 bind(&ok);
2216 #endif
2217
2218 bool restore_context = context_restore_operand != NULL;
2219 if (restore_context) {
2220 mov(esi, *context_restore_operand);
2221 }
2222 if (stack_space_operand != nullptr) {
2223 mov(ebx, *stack_space_operand);
2224 }
2225 LeaveApiExitFrame(!restore_context);
2226 if (stack_space_operand != nullptr) {
2227 DCHECK_EQ(0, stack_space);
2228 pop(ecx);
2229 add(esp, ebx);
2230 jmp(ecx);
2231 } else {
2232 ret(stack_space * kPointerSize);
2233 }
2234
2235 bind(&promote_scheduled_exception);
2236 {
2237 FrameScope frame(this, StackFrame::INTERNAL);
2238 CallRuntime(Runtime::kPromoteScheduledException, 0);
2239 }
2240 jmp(&exception_handled);
2241
2242 // HandleScope limit has changed. Delete allocated extensions.
2243 ExternalReference delete_extensions =
2244 ExternalReference::delete_handle_scope_extensions(isolate());
2245 bind(&delete_allocated_handles);
2246 mov(Operand::StaticVariable(limit_address), edi);
2247 mov(edi, eax);
2248 mov(Operand(esp, 0),
2249 Immediate(ExternalReference::isolate_address(isolate())));
2250 mov(eax, Immediate(delete_extensions));
2251 call(eax);
2252 mov(eax, edi);
2253 jmp(&leave_exit_frame);
2254 }
2255
2256
2257 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext) { 2087 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext) {
2258 // Set the entry point and jump to the C entry runtime stub. 2088 // Set the entry point and jump to the C entry runtime stub.
2259 mov(ebx, Immediate(ext)); 2089 mov(ebx, Immediate(ext));
2260 CEntryStub ces(isolate(), 1); 2090 CEntryStub ces(isolate(), 1);
2261 jmp(ces.GetCode(), RelocInfo::CODE_TARGET); 2091 jmp(ces.GetCode(), RelocInfo::CODE_TARGET);
2262 } 2092 }
2263 2093
2264 2094
2265 void MacroAssembler::InvokePrologue(const ParameterCount& expected, 2095 void MacroAssembler::InvokePrologue(const ParameterCount& expected,
2266 const ParameterCount& actual, 2096 const ParameterCount& actual,
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
3457 if (mag.shift > 0) sar(edx, mag.shift); 3287 if (mag.shift > 0) sar(edx, mag.shift);
3458 mov(eax, dividend); 3288 mov(eax, dividend);
3459 shr(eax, 31); 3289 shr(eax, 31);
3460 add(edx, eax); 3290 add(edx, eax);
3461 } 3291 }
3462 3292
3463 3293
3464 } } // namespace v8::internal 3294 } } // namespace v8::internal
3465 3295
3466 #endif // V8_TARGET_ARCH_IA32 3296 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/mips/code-stubs-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698