| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 Isolate* isolate, | 354 Isolate* isolate, |
| 355 CodeStubInterfaceDescriptor* descriptor) { | 355 CodeStubInterfaceDescriptor* descriptor) { |
| 356 static Register registers[] = { rdx, rax }; | 356 static Register registers[] = { rdx, rax }; |
| 357 descriptor->register_param_count_ = 2; | 357 descriptor->register_param_count_ = 2; |
| 358 descriptor->register_params_ = registers; | 358 descriptor->register_params_ = registers; |
| 359 descriptor->deoptimization_handler_ = | 359 descriptor->deoptimization_handler_ = |
| 360 Runtime::FunctionForId(Runtime::kStringAdd)->entry; | 360 Runtime::FunctionForId(Runtime::kStringAdd)->entry; |
| 361 } | 361 } |
| 362 | 362 |
| 363 | 363 |
| 364 void CallDescriptors::InitializeForIsolate(Isolate* isolate) { |
| 365 { |
| 366 CallInterfaceDescriptor* descriptor = |
| 367 isolate->call_descriptor(Isolate::ArgumentAdaptorCall); |
| 368 static Register registers[] = { rdi, // JSFunction |
| 369 rsi, // context |
| 370 rax, // actual number of arguments |
| 371 rbx, // expected number of arguments |
| 372 }; |
| 373 static Representation representations[] = { |
| 374 Representation::Tagged(), // JSFunction |
| 375 Representation::Tagged(), // context |
| 376 Representation::Integer32(), // actual number of arguments |
| 377 Representation::Integer32(), // expected number of arguments |
| 378 }; |
| 379 descriptor->register_param_count_ = 4; |
| 380 descriptor->register_params_ = registers; |
| 381 descriptor->param_representations_ = representations; |
| 382 } |
| 383 { |
| 384 CallInterfaceDescriptor* descriptor = |
| 385 isolate->call_descriptor(Isolate::KeyedCall); |
| 386 static Register registers[] = { rsi, // context |
| 387 rcx, // key |
| 388 }; |
| 389 static Representation representations[] = { |
| 390 Representation::Tagged(), // context |
| 391 Representation::Tagged(), // key |
| 392 }; |
| 393 descriptor->register_param_count_ = 2; |
| 394 descriptor->register_params_ = registers; |
| 395 descriptor->param_representations_ = representations; |
| 396 } |
| 397 { |
| 398 CallInterfaceDescriptor* descriptor = |
| 399 isolate->call_descriptor(Isolate::NamedCall); |
| 400 static Register registers[] = { rsi, // context |
| 401 rcx, // name |
| 402 }; |
| 403 static Representation representations[] = { |
| 404 Representation::Tagged(), // context |
| 405 Representation::Tagged(), // name |
| 406 }; |
| 407 descriptor->register_param_count_ = 2; |
| 408 descriptor->register_params_ = registers; |
| 409 descriptor->param_representations_ = representations; |
| 410 } |
| 411 } |
| 412 |
| 413 |
| 364 #define __ ACCESS_MASM(masm) | 414 #define __ ACCESS_MASM(masm) |
| 365 | 415 |
| 366 | 416 |
| 367 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) { | 417 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) { |
| 368 // Update the static counter each time a new code stub is generated. | 418 // Update the static counter each time a new code stub is generated. |
| 369 Isolate* isolate = masm->isolate(); | 419 Isolate* isolate = masm->isolate(); |
| 370 isolate->counters()->code_stubs()->Increment(); | 420 isolate->counters()->code_stubs()->Increment(); |
| 371 | 421 |
| 372 CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor(isolate); | 422 CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor(isolate); |
| 373 int param_count = descriptor->register_param_count_; | 423 int param_count = descriptor->register_param_count_; |
| (...skipping 1983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2357 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); | 2407 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
| 2358 __ j(not_equal, &slow); | 2408 __ j(not_equal, &slow); |
| 2359 | 2409 |
| 2360 if (RecordCallTarget()) { | 2410 if (RecordCallTarget()) { |
| 2361 GenerateRecordCallTarget(masm); | 2411 GenerateRecordCallTarget(masm); |
| 2362 } | 2412 } |
| 2363 | 2413 |
| 2364 // Fast-case: Just invoke the function. | 2414 // Fast-case: Just invoke the function. |
| 2365 ParameterCount actual(argc_); | 2415 ParameterCount actual(argc_); |
| 2366 | 2416 |
| 2367 __ InvokeFunction(rdi, | 2417 __ InvokeFunction(rdi, actual, JUMP_FUNCTION, NullCallWrapper()); |
| 2368 actual, | |
| 2369 JUMP_FUNCTION, | |
| 2370 NullCallWrapper(), | |
| 2371 CALL_AS_FUNCTION); | |
| 2372 | 2418 |
| 2373 // Slow-case: Non-function called. | 2419 // Slow-case: Non-function called. |
| 2374 __ bind(&slow); | 2420 __ bind(&slow); |
| 2375 if (RecordCallTarget()) { | 2421 if (RecordCallTarget()) { |
| 2376 // If there is a call target cache, mark it megamorphic in the | 2422 // If there is a call target cache, mark it megamorphic in the |
| 2377 // non-function case. MegamorphicSentinel is an immortal immovable | 2423 // non-function case. MegamorphicSentinel is an immortal immovable |
| 2378 // object (undefined) so no write barrier is needed. | 2424 // object (undefined) so no write barrier is needed. |
| 2379 __ Move(FieldOperand(rbx, Cell::kValueOffset), | 2425 __ Move(FieldOperand(rbx, Cell::kValueOffset), |
| 2380 TypeFeedbackCells::MegamorphicSentinel(isolate)); | 2426 TypeFeedbackCells::MegamorphicSentinel(isolate)); |
| 2381 } | 2427 } |
| 2382 // Check for function proxy. | 2428 // Check for function proxy. |
| 2383 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); | 2429 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); |
| 2384 __ j(not_equal, &non_function); | 2430 __ j(not_equal, &non_function); |
| 2385 __ PopReturnAddressTo(rcx); | 2431 __ PopReturnAddressTo(rcx); |
| 2386 __ push(rdi); // put proxy as additional argument under return address | 2432 __ push(rdi); // put proxy as additional argument under return address |
| 2387 __ PushReturnAddressFrom(rcx); | 2433 __ PushReturnAddressFrom(rcx); |
| 2388 __ Set(rax, argc_ + 1); | 2434 __ Set(rax, argc_ + 1); |
| 2389 __ Set(rbx, 0); | 2435 __ Set(rbx, 0); |
| 2390 __ SetCallKind(rcx, CALL_AS_FUNCTION); | |
| 2391 __ GetBuiltinEntry(rdx, Builtins::CALL_FUNCTION_PROXY); | 2436 __ GetBuiltinEntry(rdx, Builtins::CALL_FUNCTION_PROXY); |
| 2392 { | 2437 { |
| 2393 Handle<Code> adaptor = | 2438 Handle<Code> adaptor = |
| 2394 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); | 2439 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
| 2395 __ jmp(adaptor, RelocInfo::CODE_TARGET); | 2440 __ jmp(adaptor, RelocInfo::CODE_TARGET); |
| 2396 } | 2441 } |
| 2397 | 2442 |
| 2398 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead | 2443 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead |
| 2399 // of the original receiver from the call site). | 2444 // of the original receiver from the call site). |
| 2400 __ bind(&non_function); | 2445 __ bind(&non_function); |
| 2401 __ movq(args.GetReceiverOperand(), rdi); | 2446 __ movq(args.GetReceiverOperand(), rdi); |
| 2402 __ Set(rax, argc_); | 2447 __ Set(rax, argc_); |
| 2403 __ Set(rbx, 0); | 2448 __ Set(rbx, 0); |
| 2404 __ SetCallKind(rcx, CALL_AS_FUNCTION); | |
| 2405 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); | 2449 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); |
| 2406 Handle<Code> adaptor = | 2450 Handle<Code> adaptor = |
| 2407 isolate->builtins()->ArgumentsAdaptorTrampoline(); | 2451 isolate->builtins()->ArgumentsAdaptorTrampoline(); |
| 2408 __ Jump(adaptor, RelocInfo::CODE_TARGET); | 2452 __ Jump(adaptor, RelocInfo::CODE_TARGET); |
| 2409 } | 2453 } |
| 2410 | 2454 |
| 2411 | 2455 |
| 2412 void CallConstructStub::Generate(MacroAssembler* masm) { | 2456 void CallConstructStub::Generate(MacroAssembler* masm) { |
| 2413 // rax : number of arguments | 2457 // rax : number of arguments |
| 2414 // rbx : cache cell for call target | 2458 // rbx : cache cell for call target |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2441 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); | 2485 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); |
| 2442 __ j(not_equal, &non_function_call); | 2486 __ j(not_equal, &non_function_call); |
| 2443 __ GetBuiltinEntry(rdx, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); | 2487 __ GetBuiltinEntry(rdx, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); |
| 2444 __ jmp(&do_call); | 2488 __ jmp(&do_call); |
| 2445 | 2489 |
| 2446 __ bind(&non_function_call); | 2490 __ bind(&non_function_call); |
| 2447 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | 2491 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
| 2448 __ bind(&do_call); | 2492 __ bind(&do_call); |
| 2449 // Set expected number of arguments to zero (not changing rax). | 2493 // Set expected number of arguments to zero (not changing rax). |
| 2450 __ Set(rbx, 0); | 2494 __ Set(rbx, 0); |
| 2451 __ SetCallKind(rcx, CALL_AS_METHOD); | |
| 2452 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 2495 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
| 2453 RelocInfo::CODE_TARGET); | 2496 RelocInfo::CODE_TARGET); |
| 2454 } | 2497 } |
| 2455 | 2498 |
| 2456 | 2499 |
| 2457 bool CEntryStub::NeedsImmovableCode() { | 2500 bool CEntryStub::NeedsImmovableCode() { |
| 2458 return false; | 2501 return false; |
| 2459 } | 2502 } |
| 2460 | 2503 |
| 2461 | 2504 |
| (...skipping 2642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5104 __ movq(rdi, rax); | 5147 __ movq(rdi, rax); |
| 5105 int parameter_count_offset = | 5148 int parameter_count_offset = |
| 5106 StubFailureTrampolineFrame::kCallerStackParameterCountFrameOffset; | 5149 StubFailureTrampolineFrame::kCallerStackParameterCountFrameOffset; |
| 5107 __ movq(rax, MemOperand(rbp, parameter_count_offset)); | 5150 __ movq(rax, MemOperand(rbp, parameter_count_offset)); |
| 5108 // The parameter count above includes the receiver for the arguments passed to | 5151 // The parameter count above includes the receiver for the arguments passed to |
| 5109 // the deoptimization handler. Subtract the receiver for the parameter count | 5152 // the deoptimization handler. Subtract the receiver for the parameter count |
| 5110 // for the call. | 5153 // for the call. |
| 5111 __ subl(rax, Immediate(1)); | 5154 __ subl(rax, Immediate(1)); |
| 5112 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); | 5155 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); |
| 5113 ParameterCount argument_count(rax); | 5156 ParameterCount argument_count(rax); |
| 5114 __ InvokeFunction( | 5157 __ InvokeFunction(rdi, argument_count, JUMP_FUNCTION, NullCallWrapper()); |
| 5115 rdi, argument_count, JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD); | |
| 5116 } | 5158 } |
| 5117 | 5159 |
| 5118 | 5160 |
| 5119 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { | 5161 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { |
| 5120 if (masm->isolate()->function_entry_hook() != NULL) { | 5162 if (masm->isolate()->function_entry_hook() != NULL) { |
| 5121 ProfileEntryHookStub stub; | 5163 ProfileEntryHookStub stub; |
| 5122 masm->CallStub(&stub); | 5164 masm->CallStub(&stub); |
| 5123 } | 5165 } |
| 5124 } | 5166 } |
| 5125 | 5167 |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5485 __ bind(&fast_elements_case); | 5527 __ bind(&fast_elements_case); |
| 5486 GenerateCase(masm, FAST_ELEMENTS); | 5528 GenerateCase(masm, FAST_ELEMENTS); |
| 5487 } | 5529 } |
| 5488 | 5530 |
| 5489 | 5531 |
| 5490 #undef __ | 5532 #undef __ |
| 5491 | 5533 |
| 5492 } } // namespace v8::internal | 5534 } } // namespace v8::internal |
| 5493 | 5535 |
| 5494 #endif // V8_TARGET_ARCH_X64 | 5536 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |