| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 Isolate* isolate, | 357 Isolate* isolate, |
| 358 CodeStubInterfaceDescriptor* descriptor) { | 358 CodeStubInterfaceDescriptor* descriptor) { |
| 359 static Register registers[] = { edx, eax }; | 359 static Register registers[] = { edx, eax }; |
| 360 descriptor->register_param_count_ = 2; | 360 descriptor->register_param_count_ = 2; |
| 361 descriptor->register_params_ = registers; | 361 descriptor->register_params_ = registers; |
| 362 descriptor->deoptimization_handler_ = | 362 descriptor->deoptimization_handler_ = |
| 363 Runtime::FunctionForId(Runtime::kStringAdd)->entry; | 363 Runtime::FunctionForId(Runtime::kStringAdd)->entry; |
| 364 } | 364 } |
| 365 | 365 |
| 366 | 366 |
| 367 void CallDescriptors::InitializeForIsolate(Isolate* isolate) { |
| 368 { |
| 369 CallInterfaceDescriptor* descriptor = |
| 370 isolate->call_descriptor(Isolate::ArgumentAdaptorCall); |
| 371 static Register registers[] = { edi, // JSFunction |
| 372 esi, // context |
| 373 eax, // actual number of arguments |
| 374 ebx, // expected number of arguments |
| 375 }; |
| 376 static Representation representations[] = { |
| 377 Representation::Tagged(), // JSFunction |
| 378 Representation::Tagged(), // context |
| 379 Representation::Integer32(), // actual number of arguments |
| 380 Representation::Integer32(), // expected number of arguments |
| 381 }; |
| 382 descriptor->register_param_count_ = 4; |
| 383 descriptor->register_params_ = registers; |
| 384 descriptor->param_representations_ = representations; |
| 385 } |
| 386 { |
| 387 CallInterfaceDescriptor* descriptor = |
| 388 isolate->call_descriptor(Isolate::KeyedCall); |
| 389 static Register registers[] = { esi, // context |
| 390 ecx, // key |
| 391 }; |
| 392 static Representation representations[] = { |
| 393 Representation::Tagged(), // context |
| 394 Representation::Tagged(), // key |
| 395 }; |
| 396 descriptor->register_param_count_ = 2; |
| 397 descriptor->register_params_ = registers; |
| 398 descriptor->param_representations_ = representations; |
| 399 } |
| 400 { |
| 401 CallInterfaceDescriptor* descriptor = |
| 402 isolate->call_descriptor(Isolate::NamedCall); |
| 403 static Register registers[] = { esi, // context |
| 404 ecx, // name |
| 405 }; |
| 406 static Representation representations[] = { |
| 407 Representation::Tagged(), // context |
| 408 Representation::Tagged(), // name |
| 409 }; |
| 410 descriptor->register_param_count_ = 2; |
| 411 descriptor->register_params_ = registers; |
| 412 descriptor->param_representations_ = representations; |
| 413 } |
| 414 } |
| 415 |
| 416 |
| 367 #define __ ACCESS_MASM(masm) | 417 #define __ ACCESS_MASM(masm) |
| 368 | 418 |
| 369 | 419 |
| 370 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) { | 420 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) { |
| 371 // Update the static counter each time a new code stub is generated. | 421 // Update the static counter each time a new code stub is generated. |
| 372 Isolate* isolate = masm->isolate(); | 422 Isolate* isolate = masm->isolate(); |
| 373 isolate->counters()->code_stubs()->Increment(); | 423 isolate->counters()->code_stubs()->Increment(); |
| 374 | 424 |
| 375 CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor(isolate); | 425 CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor(isolate); |
| 376 int param_count = descriptor->register_param_count_; | 426 int param_count = descriptor->register_param_count_; |
| (...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2524 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 2574 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
| 2525 __ j(not_equal, &slow); | 2575 __ j(not_equal, &slow); |
| 2526 | 2576 |
| 2527 if (RecordCallTarget()) { | 2577 if (RecordCallTarget()) { |
| 2528 GenerateRecordCallTarget(masm); | 2578 GenerateRecordCallTarget(masm); |
| 2529 } | 2579 } |
| 2530 | 2580 |
| 2531 // Fast-case: Just invoke the function. | 2581 // Fast-case: Just invoke the function. |
| 2532 ParameterCount actual(argc_); | 2582 ParameterCount actual(argc_); |
| 2533 | 2583 |
| 2534 __ InvokeFunction(edi, | 2584 __ InvokeFunction(edi, actual, JUMP_FUNCTION, NullCallWrapper()); |
| 2535 actual, | |
| 2536 JUMP_FUNCTION, | |
| 2537 NullCallWrapper(), | |
| 2538 CALL_AS_FUNCTION); | |
| 2539 | 2585 |
| 2540 // Slow-case: Non-function called. | 2586 // Slow-case: Non-function called. |
| 2541 __ bind(&slow); | 2587 __ bind(&slow); |
| 2542 if (RecordCallTarget()) { | 2588 if (RecordCallTarget()) { |
| 2543 // If there is a call target cache, mark it megamorphic in the | 2589 // If there is a call target cache, mark it megamorphic in the |
| 2544 // non-function case. MegamorphicSentinel is an immortal immovable | 2590 // non-function case. MegamorphicSentinel is an immortal immovable |
| 2545 // object (undefined) so no write barrier is needed. | 2591 // object (undefined) so no write barrier is needed. |
| 2546 __ mov(FieldOperand(ebx, Cell::kValueOffset), | 2592 __ mov(FieldOperand(ebx, Cell::kValueOffset), |
| 2547 Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); | 2593 Immediate(TypeFeedbackCells::MegamorphicSentinel(isolate))); |
| 2548 } | 2594 } |
| 2549 // Check for function proxy. | 2595 // Check for function proxy. |
| 2550 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); | 2596 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); |
| 2551 __ j(not_equal, &non_function); | 2597 __ j(not_equal, &non_function); |
| 2552 __ pop(ecx); | 2598 __ pop(ecx); |
| 2553 __ push(edi); // put proxy as additional argument under return address | 2599 __ push(edi); // put proxy as additional argument under return address |
| 2554 __ push(ecx); | 2600 __ push(ecx); |
| 2555 __ Set(eax, Immediate(argc_ + 1)); | 2601 __ Set(eax, Immediate(argc_ + 1)); |
| 2556 __ Set(ebx, Immediate(0)); | 2602 __ Set(ebx, Immediate(0)); |
| 2557 __ SetCallKind(ecx, CALL_AS_FUNCTION); | |
| 2558 __ GetBuiltinEntry(edx, Builtins::CALL_FUNCTION_PROXY); | 2603 __ GetBuiltinEntry(edx, Builtins::CALL_FUNCTION_PROXY); |
| 2559 { | 2604 { |
| 2560 Handle<Code> adaptor = isolate->builtins()->ArgumentsAdaptorTrampoline(); | 2605 Handle<Code> adaptor = isolate->builtins()->ArgumentsAdaptorTrampoline(); |
| 2561 __ jmp(adaptor, RelocInfo::CODE_TARGET); | 2606 __ jmp(adaptor, RelocInfo::CODE_TARGET); |
| 2562 } | 2607 } |
| 2563 | 2608 |
| 2564 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead | 2609 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead |
| 2565 // of the original receiver from the call site). | 2610 // of the original receiver from the call site). |
| 2566 __ bind(&non_function); | 2611 __ bind(&non_function); |
| 2567 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), edi); | 2612 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), edi); |
| 2568 __ Set(eax, Immediate(argc_)); | 2613 __ Set(eax, Immediate(argc_)); |
| 2569 __ Set(ebx, Immediate(0)); | 2614 __ Set(ebx, Immediate(0)); |
| 2570 __ SetCallKind(ecx, CALL_AS_FUNCTION); | |
| 2571 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); | 2615 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); |
| 2572 Handle<Code> adaptor = isolate->builtins()->ArgumentsAdaptorTrampoline(); | 2616 Handle<Code> adaptor = isolate->builtins()->ArgumentsAdaptorTrampoline(); |
| 2573 __ jmp(adaptor, RelocInfo::CODE_TARGET); | 2617 __ jmp(adaptor, RelocInfo::CODE_TARGET); |
| 2574 } | 2618 } |
| 2575 | 2619 |
| 2576 | 2620 |
| 2577 void CallConstructStub::Generate(MacroAssembler* masm) { | 2621 void CallConstructStub::Generate(MacroAssembler* masm) { |
| 2578 // eax : number of arguments | 2622 // eax : number of arguments |
| 2579 // ebx : cache cell for call target | 2623 // ebx : cache cell for call target |
| 2580 // edi : constructor function | 2624 // edi : constructor function |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2608 __ GetBuiltinEntry(edx, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); | 2652 __ GetBuiltinEntry(edx, Builtins::CALL_FUNCTION_PROXY_AS_CONSTRUCTOR); |
| 2609 __ jmp(&do_call); | 2653 __ jmp(&do_call); |
| 2610 | 2654 |
| 2611 __ bind(&non_function_call); | 2655 __ bind(&non_function_call); |
| 2612 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); | 2656 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
| 2613 __ bind(&do_call); | 2657 __ bind(&do_call); |
| 2614 // Set expected number of arguments to zero (not changing eax). | 2658 // Set expected number of arguments to zero (not changing eax). |
| 2615 __ Set(ebx, Immediate(0)); | 2659 __ Set(ebx, Immediate(0)); |
| 2616 Handle<Code> arguments_adaptor = | 2660 Handle<Code> arguments_adaptor = |
| 2617 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); | 2661 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
| 2618 __ SetCallKind(ecx, CALL_AS_METHOD); | |
| 2619 __ jmp(arguments_adaptor, RelocInfo::CODE_TARGET); | 2662 __ jmp(arguments_adaptor, RelocInfo::CODE_TARGET); |
| 2620 } | 2663 } |
| 2621 | 2664 |
| 2622 | 2665 |
| 2623 bool CEntryStub::NeedsImmovableCode() { | 2666 bool CEntryStub::NeedsImmovableCode() { |
| 2624 return false; | 2667 return false; |
| 2625 } | 2668 } |
| 2626 | 2669 |
| 2627 | 2670 |
| 2628 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { | 2671 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { |
| (...skipping 2678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5307 __ mov(edi, eax); | 5350 __ mov(edi, eax); |
| 5308 int parameter_count_offset = | 5351 int parameter_count_offset = |
| 5309 StubFailureTrampolineFrame::kCallerStackParameterCountFrameOffset; | 5352 StubFailureTrampolineFrame::kCallerStackParameterCountFrameOffset; |
| 5310 __ mov(eax, MemOperand(ebp, parameter_count_offset)); | 5353 __ mov(eax, MemOperand(ebp, parameter_count_offset)); |
| 5311 // The parameter count above includes the receiver for the arguments passed to | 5354 // The parameter count above includes the receiver for the arguments passed to |
| 5312 // the deoptimization handler. Subtract the receiver for the parameter count | 5355 // the deoptimization handler. Subtract the receiver for the parameter count |
| 5313 // for the call. | 5356 // for the call. |
| 5314 __ sub(eax, Immediate(1)); | 5357 __ sub(eax, Immediate(1)); |
| 5315 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); | 5358 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); |
| 5316 ParameterCount argument_count(eax); | 5359 ParameterCount argument_count(eax); |
| 5317 __ InvokeFunction( | 5360 __ InvokeFunction(edi, argument_count, JUMP_FUNCTION, NullCallWrapper()); |
| 5318 edi, argument_count, JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD); | |
| 5319 } | 5361 } |
| 5320 | 5362 |
| 5321 | 5363 |
| 5322 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { | 5364 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { |
| 5323 if (masm->isolate()->function_entry_hook() != NULL) { | 5365 if (masm->isolate()->function_entry_hook() != NULL) { |
| 5324 ProfileEntryHookStub stub; | 5366 ProfileEntryHookStub stub; |
| 5325 masm->CallStub(&stub); | 5367 masm->CallStub(&stub); |
| 5326 } | 5368 } |
| 5327 } | 5369 } |
| 5328 | 5370 |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5677 __ bind(&fast_elements_case); | 5719 __ bind(&fast_elements_case); |
| 5678 GenerateCase(masm, FAST_ELEMENTS); | 5720 GenerateCase(masm, FAST_ELEMENTS); |
| 5679 } | 5721 } |
| 5680 | 5722 |
| 5681 | 5723 |
| 5682 #undef __ | 5724 #undef __ |
| 5683 | 5725 |
| 5684 } } // namespace v8::internal | 5726 } } // namespace v8::internal |
| 5685 | 5727 |
| 5686 #endif // V8_TARGET_ARCH_IA32 | 5728 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |