| OLD | NEW |
| 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 2170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2181 __ addq(rsp, Immediate(kFastApiCallArguments * kPointerSize)); | 2181 __ addq(rsp, Immediate(kFastApiCallArguments * kPointerSize)); |
| 2182 | 2182 |
| 2183 __ bind(&miss_before_stack_reserved); | 2183 __ bind(&miss_before_stack_reserved); |
| 2184 GenerateMissBranch(); | 2184 GenerateMissBranch(); |
| 2185 | 2185 |
| 2186 // Return the generated code. | 2186 // Return the generated code. |
| 2187 return GetCode(function); | 2187 return GetCode(function); |
| 2188 } | 2188 } |
| 2189 | 2189 |
| 2190 | 2190 |
| 2191 Handle<Code> CallStubCompiler::CompileCallConstant(Handle<Object> object, | 2191 void CallStubCompiler::CompileHandlerFrontend(Handle<Object> object, |
| 2192 Handle<JSObject> holder, | 2192 Handle<JSObject> holder, |
| 2193 Handle<JSFunction> function, | 2193 Handle<String> name, |
| 2194 Handle<String> name, | 2194 CheckType check, |
| 2195 CheckType check) { | 2195 Label* success) { |
| 2196 // ----------- S t a t e ------------- | 2196 // ----------- S t a t e ------------- |
| 2197 // rcx : function name | 2197 // rcx : function name |
| 2198 // rsp[0] : return address | 2198 // rsp[0] : return address |
| 2199 // rsp[8] : argument argc | 2199 // rsp[8] : argument argc |
| 2200 // rsp[16] : argument argc - 1 | 2200 // rsp[16] : argument argc - 1 |
| 2201 // ... | 2201 // ... |
| 2202 // rsp[argc * 8] : argument 1 | 2202 // rsp[argc * 8] : argument 1 |
| 2203 // rsp[(argc + 1) * 8] : argument 0 = receiver | 2203 // rsp[(argc + 1) * 8] : argument 0 = receiver |
| 2204 // ----------------------------------- | 2204 // ----------------------------------- |
| 2205 | |
| 2206 if (HasCustomCallGenerator(function)) { | |
| 2207 Handle<Code> code = CompileCustomCall(object, holder, | |
| 2208 Handle<JSGlobalPropertyCell>::null(), | |
| 2209 function, name); | |
| 2210 // A null handle means bail out to the regular compiler code below. | |
| 2211 if (!code.is_null()) return code; | |
| 2212 } | |
| 2213 | |
| 2214 Label miss; | 2205 Label miss; |
| 2215 GenerateNameCheck(name, &miss); | 2206 GenerateNameCheck(name, &miss); |
| 2216 | 2207 |
| 2217 // Get the receiver from the stack. | 2208 // Get the receiver from the stack. |
| 2218 const int argc = arguments().immediate(); | 2209 const int argc = arguments().immediate(); |
| 2219 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | 2210 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); |
| 2220 | 2211 |
| 2221 // Check that the receiver isn't a smi. | 2212 // Check that the receiver isn't a smi. |
| 2222 if (check != NUMBER_CHECK) { | 2213 if (check != NUMBER_CHECK) { |
| 2223 __ JumpIfSmi(rdx, &miss); | 2214 __ JumpIfSmi(rdx, &miss); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2238 | 2229 |
| 2239 // Patch the receiver on the stack with the global proxy if | 2230 // Patch the receiver on the stack with the global proxy if |
| 2240 // necessary. | 2231 // necessary. |
| 2241 if (object->IsGlobalObject()) { | 2232 if (object->IsGlobalObject()) { |
| 2242 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset)); | 2233 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset)); |
| 2243 __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx); | 2234 __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx); |
| 2244 } | 2235 } |
| 2245 break; | 2236 break; |
| 2246 | 2237 |
| 2247 case STRING_CHECK: | 2238 case STRING_CHECK: |
| 2248 if (function->IsBuiltin() || !function->shared()->is_classic_mode()) { | 2239 // Check that the object is a two-byte string or a symbol. |
| 2249 // Check that the object is a two-byte string or a symbol. | 2240 __ CmpObjectType(rdx, FIRST_NONSTRING_TYPE, rax); |
| 2250 __ CmpObjectType(rdx, FIRST_NONSTRING_TYPE, rax); | 2241 __ j(above_equal, &miss); |
| 2251 __ j(above_equal, &miss); | 2242 // Check that the maps starting from the prototype haven't changed. |
| 2252 // Check that the maps starting from the prototype haven't changed. | 2243 GenerateDirectLoadGlobalFunctionPrototype( |
| 2253 GenerateDirectLoadGlobalFunctionPrototype( | 2244 masm(), Context::STRING_FUNCTION_INDEX, rax, &miss); |
| 2254 masm(), Context::STRING_FUNCTION_INDEX, rax, &miss); | 2245 CheckPrototypes( |
| 2255 CheckPrototypes( | 2246 Handle<JSObject>(JSObject::cast(object->GetPrototype())), |
| 2256 Handle<JSObject>(JSObject::cast(object->GetPrototype())), | 2247 rax, holder, rbx, rdx, rdi, name, &miss); |
| 2257 rax, holder, rbx, rdx, rdi, name, &miss); | |
| 2258 } else { | |
| 2259 // Calling non-strict non-builtins with a value as the receiver | |
| 2260 // requires boxing. | |
| 2261 __ jmp(&miss); | |
| 2262 } | |
| 2263 break; | 2248 break; |
| 2264 | 2249 |
| 2265 case NUMBER_CHECK: | 2250 case NUMBER_CHECK: { |
| 2266 if (function->IsBuiltin() || !function->shared()->is_classic_mode()) { | 2251 Label fast; |
| 2267 Label fast; | 2252 // Check that the object is a smi or a heap number. |
| 2268 // Check that the object is a smi or a heap number. | 2253 __ JumpIfSmi(rdx, &fast); |
| 2269 __ JumpIfSmi(rdx, &fast); | 2254 __ CmpObjectType(rdx, HEAP_NUMBER_TYPE, rax); |
| 2270 __ CmpObjectType(rdx, HEAP_NUMBER_TYPE, rax); | 2255 __ j(not_equal, &miss); |
| 2271 __ j(not_equal, &miss); | 2256 __ bind(&fast); |
| 2272 __ bind(&fast); | 2257 // Check that the maps starting from the prototype haven't changed. |
| 2273 // Check that the maps starting from the prototype haven't changed. | 2258 GenerateDirectLoadGlobalFunctionPrototype( |
| 2274 GenerateDirectLoadGlobalFunctionPrototype( | 2259 masm(), Context::NUMBER_FUNCTION_INDEX, rax, &miss); |
| 2275 masm(), Context::NUMBER_FUNCTION_INDEX, rax, &miss); | 2260 CheckPrototypes( |
| 2276 CheckPrototypes( | 2261 Handle<JSObject>(JSObject::cast(object->GetPrototype())), |
| 2277 Handle<JSObject>(JSObject::cast(object->GetPrototype())), | 2262 rax, holder, rbx, rdx, rdi, name, &miss); |
| 2278 rax, holder, rbx, rdx, rdi, name, &miss); | |
| 2279 } else { | |
| 2280 // Calling non-strict non-builtins with a value as the receiver | |
| 2281 // requires boxing. | |
| 2282 __ jmp(&miss); | |
| 2283 } | |
| 2284 break; | 2263 break; |
| 2285 | 2264 } |
| 2286 case BOOLEAN_CHECK: | 2265 case BOOLEAN_CHECK: { |
| 2287 if (function->IsBuiltin() || !function->shared()->is_classic_mode()) { | 2266 Label fast; |
| 2288 Label fast; | 2267 // Check that the object is a boolean. |
| 2289 // Check that the object is a boolean. | 2268 __ CompareRoot(rdx, Heap::kTrueValueRootIndex); |
| 2290 __ CompareRoot(rdx, Heap::kTrueValueRootIndex); | 2269 __ j(equal, &fast); |
| 2291 __ j(equal, &fast); | 2270 __ CompareRoot(rdx, Heap::kFalseValueRootIndex); |
| 2292 __ CompareRoot(rdx, Heap::kFalseValueRootIndex); | 2271 __ j(not_equal, &miss); |
| 2293 __ j(not_equal, &miss); | 2272 __ bind(&fast); |
| 2294 __ bind(&fast); | 2273 // Check that the maps starting from the prototype haven't changed. |
| 2295 // Check that the maps starting from the prototype haven't changed. | 2274 GenerateDirectLoadGlobalFunctionPrototype( |
| 2296 GenerateDirectLoadGlobalFunctionPrototype( | 2275 masm(), Context::BOOLEAN_FUNCTION_INDEX, rax, &miss); |
| 2297 masm(), Context::BOOLEAN_FUNCTION_INDEX, rax, &miss); | 2276 CheckPrototypes( |
| 2298 CheckPrototypes( | 2277 Handle<JSObject>(JSObject::cast(object->GetPrototype())), |
| 2299 Handle<JSObject>(JSObject::cast(object->GetPrototype())), | 2278 rax, holder, rbx, rdx, rdi, name, &miss); |
| 2300 rax, holder, rbx, rdx, rdi, name, &miss); | |
| 2301 } else { | |
| 2302 // Calling non-strict non-builtins with a value as the receiver | |
| 2303 // requires boxing. | |
| 2304 __ jmp(&miss); | |
| 2305 } | |
| 2306 break; | 2279 break; |
| 2280 } |
| 2307 } | 2281 } |
| 2308 | 2282 |
| 2283 __ jmp(success); |
| 2284 |
| 2285 // Handle call cache miss. |
| 2286 __ bind(&miss); |
| 2287 GenerateMissBranch(); |
| 2288 } |
| 2289 |
| 2290 |
| 2291 void CallStubCompiler::CompileHandlerBackend(Handle<JSFunction> function) { |
| 2309 CallKind call_kind = CallICBase::Contextual::decode(extra_state_) | 2292 CallKind call_kind = CallICBase::Contextual::decode(extra_state_) |
| 2310 ? CALL_AS_FUNCTION | 2293 ? CALL_AS_FUNCTION |
| 2311 : CALL_AS_METHOD; | 2294 : CALL_AS_METHOD; |
| 2312 __ InvokeFunction(function, arguments(), JUMP_FUNCTION, | 2295 __ InvokeFunction(function, arguments(), JUMP_FUNCTION, |
| 2313 NullCallWrapper(), call_kind); | 2296 NullCallWrapper(), call_kind); |
| 2297 } |
| 2314 | 2298 |
| 2315 // Handle call cache miss. | 2299 |
| 2316 __ bind(&miss); | 2300 Handle<Code> CallStubCompiler::CompileCallConstant( |
| 2317 GenerateMissBranch(); | 2301 Handle<Object> object, |
| 2302 Handle<JSObject> holder, |
| 2303 Handle<String> name, |
| 2304 CheckType check, |
| 2305 Handle<JSFunction> function) { |
| 2306 if (HasCustomCallGenerator(function)) { |
| 2307 Handle<Code> code = CompileCustomCall(object, holder, |
| 2308 Handle<JSGlobalPropertyCell>::null(), |
| 2309 function, name); |
| 2310 // A null handle means bail out to the regular compiler code below. |
| 2311 if (!code.is_null()) return code; |
| 2312 } |
| 2313 |
| 2314 Label success; |
| 2315 |
| 2316 CompileHandlerFrontend(object, holder, name, check, &success); |
| 2317 __ bind(&success); |
| 2318 CompileHandlerBackend(function); |
| 2318 | 2319 |
| 2319 // Return the generated code. | 2320 // Return the generated code. |
| 2320 return GetCode(function); | 2321 return GetCode(function); |
| 2321 } | 2322 } |
| 2322 | 2323 |
| 2323 | 2324 |
| 2324 Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object, | 2325 Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object, |
| 2325 Handle<JSObject> holder, | 2326 Handle<JSObject> holder, |
| 2326 Handle<String> name) { | 2327 Handle<String> name) { |
| 2327 // ----------- S t a t e ------------- | 2328 // ----------- S t a t e ------------- |
| (...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3692 __ jmp(ic_slow, RelocInfo::CODE_TARGET); | 3693 __ jmp(ic_slow, RelocInfo::CODE_TARGET); |
| 3693 } | 3694 } |
| 3694 } | 3695 } |
| 3695 | 3696 |
| 3696 | 3697 |
| 3697 #undef __ | 3698 #undef __ |
| 3698 | 3699 |
| 3699 } } // namespace v8::internal | 3700 } } // namespace v8::internal |
| 3700 | 3701 |
| 3701 #endif // V8_TARGET_ARCH_X64 | 3702 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |