| OLD | NEW |
| 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 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2032 1 << SharedFunctionInfo::kStrictModeBitWithinByte); | 2032 1 << SharedFunctionInfo::kStrictModeBitWithinByte); |
| 2033 __ j(not_equal, cont); | 2033 __ j(not_equal, cont); |
| 2034 | 2034 |
| 2035 // Do not transform the receiver for natives (shared already in ecx). | 2035 // Do not transform the receiver for natives (shared already in ecx). |
| 2036 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kNativeByteOffset), | 2036 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kNativeByteOffset), |
| 2037 1 << SharedFunctionInfo::kNativeBitWithinByte); | 2037 1 << SharedFunctionInfo::kNativeBitWithinByte); |
| 2038 __ j(not_equal, cont); | 2038 __ j(not_equal, cont); |
| 2039 } | 2039 } |
| 2040 | 2040 |
| 2041 | 2041 |
| 2042 static void EmitSlowCase(Isolate* isolate, MacroAssembler* masm, int argc) { | 2042 static void EmitSlowCase(Isolate* isolate, |
| 2043 __ Set(eax, argc); | 2043 MacroAssembler* masm, |
| 2044 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 2044 int argc, |
| 2045 Label* non_function) { |
| 2046 // Check for function proxy. |
| 2047 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); |
| 2048 __ j(not_equal, non_function); |
| 2049 __ pop(ecx); |
| 2050 __ push(edi); // put proxy as additional argument under return address |
| 2051 __ push(ecx); |
| 2052 __ Move(eax, Immediate(argc + 1)); |
| 2053 __ Move(ebx, Immediate(0)); |
| 2054 __ GetBuiltinEntry(edx, Context::CALL_FUNCTION_PROXY_BUILTIN_INDEX); |
| 2055 { |
| 2056 Handle<Code> adaptor = isolate->builtins()->ArgumentsAdaptorTrampoline(); |
| 2057 __ jmp(adaptor, RelocInfo::CODE_TARGET); |
| 2058 } |
| 2059 |
| 2060 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead |
| 2061 // of the original receiver from the call site). |
| 2062 __ bind(non_function); |
| 2063 __ mov(Operand(esp, (argc + 1) * kPointerSize), edi); |
| 2064 __ Move(eax, Immediate(argc)); |
| 2065 __ Move(ebx, Immediate(0)); |
| 2066 __ GetBuiltinEntry(edx, Context::CALL_NON_FUNCTION_BUILTIN_INDEX); |
| 2067 Handle<Code> adaptor = isolate->builtins()->ArgumentsAdaptorTrampoline(); |
| 2068 __ jmp(adaptor, RelocInfo::CODE_TARGET); |
| 2045 } | 2069 } |
| 2046 | 2070 |
| 2047 | 2071 |
| 2048 static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { | 2072 static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { |
| 2049 // Wrap the receiver and patch it back onto the stack. | 2073 // Wrap the receiver and patch it back onto the stack. |
| 2050 { FrameScope frame_scope(masm, StackFrame::INTERNAL); | 2074 { FrameScope frame_scope(masm, StackFrame::INTERNAL); |
| 2051 __ push(edi); | 2075 __ push(edi); |
| 2052 ToObjectStub stub(masm->isolate()); | 2076 ToObjectStub stub(masm->isolate()); |
| 2053 __ CallStub(&stub); | 2077 __ CallStub(&stub); |
| 2054 __ pop(edi); | 2078 __ pop(edi); |
| 2055 } | 2079 } |
| 2056 __ mov(Operand(esp, (argc + 1) * kPointerSize), eax); | 2080 __ mov(Operand(esp, (argc + 1) * kPointerSize), eax); |
| 2057 __ jmp(cont); | 2081 __ jmp(cont); |
| 2058 } | 2082 } |
| 2059 | 2083 |
| 2060 | 2084 |
| 2061 static void CallFunctionNoFeedback(MacroAssembler* masm, | 2085 static void CallFunctionNoFeedback(MacroAssembler* masm, |
| 2062 int argc, bool needs_checks, | 2086 int argc, bool needs_checks, |
| 2063 bool call_as_method) { | 2087 bool call_as_method) { |
| 2064 // edi : the function to call | 2088 // edi : the function to call |
| 2065 Label slow, wrap, cont; | 2089 Label slow, non_function, wrap, cont; |
| 2066 | 2090 |
| 2067 if (needs_checks) { | 2091 if (needs_checks) { |
| 2068 // Check that the function really is a JavaScript function. | 2092 // Check that the function really is a JavaScript function. |
| 2069 __ JumpIfSmi(edi, &slow); | 2093 __ JumpIfSmi(edi, &non_function); |
| 2070 | 2094 |
| 2071 // Goto slow case if we do not have a function. | 2095 // Goto slow case if we do not have a function. |
| 2072 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 2096 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
| 2073 __ j(not_equal, &slow); | 2097 __ j(not_equal, &slow); |
| 2074 } | 2098 } |
| 2075 | 2099 |
| 2076 // Fast-case: Just invoke the function. | 2100 // Fast-case: Just invoke the function. |
| 2077 ParameterCount actual(argc); | 2101 ParameterCount actual(argc); |
| 2078 | 2102 |
| 2079 if (call_as_method) { | 2103 if (call_as_method) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2094 } | 2118 } |
| 2095 | 2119 |
| 2096 __ bind(&cont); | 2120 __ bind(&cont); |
| 2097 } | 2121 } |
| 2098 | 2122 |
| 2099 __ InvokeFunction(edi, actual, JUMP_FUNCTION, NullCallWrapper()); | 2123 __ InvokeFunction(edi, actual, JUMP_FUNCTION, NullCallWrapper()); |
| 2100 | 2124 |
| 2101 if (needs_checks) { | 2125 if (needs_checks) { |
| 2102 // Slow-case: Non-function called. | 2126 // Slow-case: Non-function called. |
| 2103 __ bind(&slow); | 2127 __ bind(&slow); |
| 2104 EmitSlowCase(masm->isolate(), masm, argc); | 2128 // (non_function is bound in EmitSlowCase) |
| 2129 EmitSlowCase(masm->isolate(), masm, argc, &non_function); |
| 2105 } | 2130 } |
| 2106 | 2131 |
| 2107 if (call_as_method) { | 2132 if (call_as_method) { |
| 2108 __ bind(&wrap); | 2133 __ bind(&wrap); |
| 2109 EmitWrapCase(masm, argc, &cont); | 2134 EmitWrapCase(masm, argc, &cont); |
| 2110 } | 2135 } |
| 2111 } | 2136 } |
| 2112 | 2137 |
| 2113 | 2138 |
| 2114 void CallFunctionStub::Generate(MacroAssembler* masm) { | 2139 void CallFunctionStub::Generate(MacroAssembler* masm) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2238 | 2263 |
| 2239 __ mov(ebx, ecx); | 2264 __ mov(ebx, ecx); |
| 2240 __ mov(edx, edi); | 2265 __ mov(edx, edi); |
| 2241 ArrayConstructorStub stub(masm->isolate(), arg_count()); | 2266 ArrayConstructorStub stub(masm->isolate(), arg_count()); |
| 2242 __ TailCallStub(&stub); | 2267 __ TailCallStub(&stub); |
| 2243 | 2268 |
| 2244 __ bind(&miss); | 2269 __ bind(&miss); |
| 2245 GenerateMiss(masm); | 2270 GenerateMiss(masm); |
| 2246 | 2271 |
| 2247 // The slow case, we need this no matter what to complete a call after a miss. | 2272 // The slow case, we need this no matter what to complete a call after a miss. |
| 2248 __ Set(eax, arg_count()); | 2273 CallFunctionNoFeedback(masm, |
| 2249 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 2274 arg_count(), |
| 2275 true, |
| 2276 CallAsMethod()); |
| 2277 |
| 2278 // Unreachable. |
| 2279 __ int3(); |
| 2250 } | 2280 } |
| 2251 | 2281 |
| 2252 | 2282 |
| 2253 void CallICStub::Generate(MacroAssembler* masm) { | 2283 void CallICStub::Generate(MacroAssembler* masm) { |
| 2254 // edi - function | 2284 // edi - function |
| 2255 // edx - slot id | 2285 // edx - slot id |
| 2256 // ebx - vector | 2286 // ebx - vector |
| 2257 Isolate* isolate = masm->isolate(); | 2287 Isolate* isolate = masm->isolate(); |
| 2258 const int with_types_offset = | 2288 const int with_types_offset = |
| 2259 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex); | 2289 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex); |
| 2260 const int generic_offset = | 2290 const int generic_offset = |
| 2261 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex); | 2291 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex); |
| 2262 Label extra_checks_or_miss, slow_start; | 2292 Label extra_checks_or_miss, slow_start; |
| 2263 Label slow, wrap, cont; | 2293 Label slow, non_function, wrap, cont; |
| 2264 Label have_js_function; | 2294 Label have_js_function; |
| 2265 int argc = arg_count(); | 2295 int argc = arg_count(); |
| 2266 ParameterCount actual(argc); | 2296 ParameterCount actual(argc); |
| 2267 | 2297 |
| 2268 // The checks. First, does edi match the recorded monomorphic target? | 2298 // The checks. First, does edi match the recorded monomorphic target? |
| 2269 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, | 2299 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, |
| 2270 FixedArray::kHeaderSize)); | 2300 FixedArray::kHeaderSize)); |
| 2271 | 2301 |
| 2272 // We don't know that we have a weak cell. We might have a private symbol | 2302 // We don't know that we have a weak cell. We might have a private symbol |
| 2273 // or an AllocationSite, but the memory is safe to examine. | 2303 // or an AllocationSite, but the memory is safe to examine. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2306 | 2336 |
| 2307 __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, ecx); | 2337 __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, ecx); |
| 2308 __ j(below, &wrap); | 2338 __ j(below, &wrap); |
| 2309 | 2339 |
| 2310 __ bind(&cont); | 2340 __ bind(&cont); |
| 2311 } | 2341 } |
| 2312 | 2342 |
| 2313 __ InvokeFunction(edi, actual, JUMP_FUNCTION, NullCallWrapper()); | 2343 __ InvokeFunction(edi, actual, JUMP_FUNCTION, NullCallWrapper()); |
| 2314 | 2344 |
| 2315 __ bind(&slow); | 2345 __ bind(&slow); |
| 2316 EmitSlowCase(isolate, masm, argc); | 2346 EmitSlowCase(isolate, masm, argc, &non_function); |
| 2317 | 2347 |
| 2318 if (CallAsMethod()) { | 2348 if (CallAsMethod()) { |
| 2319 __ bind(&wrap); | 2349 __ bind(&wrap); |
| 2320 EmitWrapCase(masm, argc, &cont); | 2350 EmitWrapCase(masm, argc, &cont); |
| 2321 } | 2351 } |
| 2322 | 2352 |
| 2323 __ bind(&extra_checks_or_miss); | 2353 __ bind(&extra_checks_or_miss); |
| 2324 Label uninitialized, miss; | 2354 Label uninitialized, miss; |
| 2325 | 2355 |
| 2326 __ cmp(ecx, Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); | 2356 __ cmp(ecx, Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2387 | 2417 |
| 2388 // We are here because tracing is on or we encountered a MISS case we can't | 2418 // We are here because tracing is on or we encountered a MISS case we can't |
| 2389 // handle here. | 2419 // handle here. |
| 2390 __ bind(&miss); | 2420 __ bind(&miss); |
| 2391 GenerateMiss(masm); | 2421 GenerateMiss(masm); |
| 2392 | 2422 |
| 2393 // the slow case | 2423 // the slow case |
| 2394 __ bind(&slow_start); | 2424 __ bind(&slow_start); |
| 2395 | 2425 |
| 2396 // Check that the function really is a JavaScript function. | 2426 // Check that the function really is a JavaScript function. |
| 2397 __ JumpIfSmi(edi, &slow); | 2427 __ JumpIfSmi(edi, &non_function); |
| 2398 | 2428 |
| 2399 // Goto slow case if we do not have a function. | 2429 // Goto slow case if we do not have a function. |
| 2400 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 2430 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
| 2401 __ j(not_equal, &slow); | 2431 __ j(not_equal, &slow); |
| 2402 __ jmp(&have_js_function); | 2432 __ jmp(&have_js_function); |
| 2403 | 2433 |
| 2404 // Unreachable | 2434 // Unreachable |
| 2405 __ int3(); | 2435 __ int3(); |
| 2406 } | 2436 } |
| 2407 | 2437 |
| (...skipping 3406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5814 Operand(ebp, 7 * kPointerSize), NULL); | 5844 Operand(ebp, 7 * kPointerSize), NULL); |
| 5815 } | 5845 } |
| 5816 | 5846 |
| 5817 | 5847 |
| 5818 #undef __ | 5848 #undef __ |
| 5819 | 5849 |
| 5820 } // namespace internal | 5850 } // namespace internal |
| 5821 } // namespace v8 | 5851 } // namespace v8 |
| 5822 | 5852 |
| 5823 #endif // V8_TARGET_ARCH_IA32 | 5853 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |