OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/ic/call-optimization.h" | 9 #include "src/ic/call-optimization.h" |
10 #include "src/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
11 #include "src/ic/ic.h" | 11 #include "src/ic/ic.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 #define __ ACCESS_MASM(masm) | 16 #define __ ACCESS_MASM(masm) |
17 | 17 |
| 18 void PropertyHandlerCompiler::PushVectorAndSlot(Register vector, |
| 19 Register slot) { |
| 20 MacroAssembler* masm = this->masm(); |
| 21 __ Push(vector); |
| 22 __ Push(slot); |
| 23 } |
| 24 |
| 25 |
| 26 void PropertyHandlerCompiler::PopVectorAndSlot(Register vector, Register slot) { |
| 27 MacroAssembler* masm = this->masm(); |
| 28 __ Pop(slot); |
| 29 __ Pop(vector); |
| 30 } |
| 31 |
| 32 |
| 33 void PropertyHandlerCompiler::DiscardVectorAndSlot() { |
| 34 MacroAssembler* masm = this->masm(); |
| 35 // Remove vector and slot. |
| 36 __ addp(rsp, Immediate(2 * kPointerSize)); |
| 37 } |
| 38 |
| 39 |
18 void PropertyHandlerCompiler::GenerateDictionaryNegativeLookup( | 40 void PropertyHandlerCompiler::GenerateDictionaryNegativeLookup( |
19 MacroAssembler* masm, Label* miss_label, Register receiver, | 41 MacroAssembler* masm, Label* miss_label, Register receiver, |
20 Handle<Name> name, Register scratch0, Register scratch1) { | 42 Handle<Name> name, Register scratch0, Register scratch1) { |
21 DCHECK(name->IsUniqueName()); | 43 DCHECK(name->IsUniqueName()); |
22 DCHECK(!receiver.is(scratch0)); | 44 DCHECK(!receiver.is(scratch0)); |
23 Counters* counters = masm->isolate()->counters(); | 45 Counters* counters = masm->isolate()->counters(); |
24 __ IncrementCounter(counters->negative_lookups(), 1); | 46 __ IncrementCounter(counters->negative_lookups(), 1); |
25 __ IncrementCounter(counters->negative_lookups_miss(), 1); | 47 __ IncrementCounter(counters->negative_lookups_miss(), 1); |
26 | 48 |
27 __ movp(scratch0, FieldOperand(receiver, HeapObject::kMapOffset)); | 49 __ movp(scratch0, FieldOperand(receiver, HeapObject::kMapOffset)); |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 // Return the register containing the holder. | 490 // Return the register containing the holder. |
469 return reg; | 491 return reg; |
470 } | 492 } |
471 | 493 |
472 | 494 |
473 void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) { | 495 void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) { |
474 if (!miss->is_unused()) { | 496 if (!miss->is_unused()) { |
475 Label success; | 497 Label success; |
476 __ jmp(&success); | 498 __ jmp(&success); |
477 __ bind(miss); | 499 __ bind(miss); |
| 500 if (IC::ICUseVector(kind())) { |
| 501 DCHECK(kind() == Code::LOAD_IC); |
| 502 PopVectorAndSlot(); |
| 503 } |
478 TailCallBuiltin(masm(), MissBuiltin(kind())); | 504 TailCallBuiltin(masm(), MissBuiltin(kind())); |
479 __ bind(&success); | 505 __ bind(&success); |
480 } | 506 } |
481 } | 507 } |
482 | 508 |
483 | 509 |
484 void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) { | 510 void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) { |
485 if (!miss->is_unused()) { | 511 if (!miss->is_unused()) { |
486 Label success; | 512 Label success; |
487 __ jmp(&success); | 513 __ jmp(&success); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 // Save necessary data before invoking an interceptor. | 592 // Save necessary data before invoking an interceptor. |
567 // Requires a frame to make GC aware of pushed pointers. | 593 // Requires a frame to make GC aware of pushed pointers. |
568 { | 594 { |
569 FrameScope frame_scope(masm(), StackFrame::INTERNAL); | 595 FrameScope frame_scope(masm(), StackFrame::INTERNAL); |
570 | 596 |
571 if (must_preserve_receiver_reg) { | 597 if (must_preserve_receiver_reg) { |
572 __ Push(receiver()); | 598 __ Push(receiver()); |
573 } | 599 } |
574 __ Push(holder_reg); | 600 __ Push(holder_reg); |
575 __ Push(this->name()); | 601 __ Push(this->name()); |
| 602 InterceptorVectorSlotPush(holder_reg); |
576 | 603 |
577 // Invoke an interceptor. Note: map checks from receiver to | 604 // Invoke an interceptor. Note: map checks from receiver to |
578 // interceptor's holder has been compiled before (see a caller | 605 // interceptor's holder has been compiled before (see a caller |
579 // of this method.) | 606 // of this method.) |
580 CompileCallLoadPropertyWithInterceptor( | 607 CompileCallLoadPropertyWithInterceptor( |
581 masm(), receiver(), holder_reg, this->name(), holder(), | 608 masm(), receiver(), holder_reg, this->name(), holder(), |
582 IC::kLoadPropertyWithInterceptorOnly); | 609 IC::kLoadPropertyWithInterceptorOnly); |
583 | 610 |
584 // Check if interceptor provided a value for property. If it's | 611 // Check if interceptor provided a value for property. If it's |
585 // the case, return immediately. | 612 // the case, return immediately. |
586 Label interceptor_failed; | 613 Label interceptor_failed; |
587 __ CompareRoot(rax, Heap::kNoInterceptorResultSentinelRootIndex); | 614 __ CompareRoot(rax, Heap::kNoInterceptorResultSentinelRootIndex); |
588 __ j(equal, &interceptor_failed); | 615 __ j(equal, &interceptor_failed); |
589 frame_scope.GenerateLeaveFrame(); | 616 frame_scope.GenerateLeaveFrame(); |
590 __ ret(0); | 617 __ ret(0); |
591 | 618 |
592 __ bind(&interceptor_failed); | 619 __ bind(&interceptor_failed); |
| 620 InterceptorVectorSlotPop(holder_reg); |
593 __ Pop(this->name()); | 621 __ Pop(this->name()); |
594 __ Pop(holder_reg); | 622 __ Pop(holder_reg); |
595 if (must_preserve_receiver_reg) { | 623 if (must_preserve_receiver_reg) { |
596 __ Pop(receiver()); | 624 __ Pop(receiver()); |
597 } | 625 } |
598 | 626 |
599 // Leave the internal frame. | 627 // Leave the internal frame. |
600 } | 628 } |
601 | 629 |
602 GenerateLoadPostInterceptor(it, holder_reg); | 630 GenerateLoadPostInterceptor(it, holder_reg); |
(...skipping 12 matching lines...) Expand all Loading... |
615 ExternalReference ref = ExternalReference( | 643 ExternalReference ref = ExternalReference( |
616 IC_Utility(IC::kLoadPropertyWithInterceptor), isolate()); | 644 IC_Utility(IC::kLoadPropertyWithInterceptor), isolate()); |
617 __ TailCallExternalReference( | 645 __ TailCallExternalReference( |
618 ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1); | 646 ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1); |
619 } | 647 } |
620 | 648 |
621 | 649 |
622 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( | 650 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( |
623 Handle<JSObject> object, Handle<Name> name, | 651 Handle<JSObject> object, Handle<Name> name, |
624 Handle<ExecutableAccessorInfo> callback) { | 652 Handle<ExecutableAccessorInfo> callback) { |
625 Register holder_reg = Frontend(receiver(), name); | 653 Register holder_reg = Frontend(name); |
626 | 654 |
627 __ PopReturnAddressTo(scratch1()); | 655 __ PopReturnAddressTo(scratch1()); |
628 __ Push(receiver()); | 656 __ Push(receiver()); |
629 __ Push(holder_reg); | 657 __ Push(holder_reg); |
630 __ Push(callback); // callback info | 658 __ Push(callback); // callback info |
631 __ Push(name); | 659 __ Push(name); |
632 __ Push(value()); | 660 __ Push(value()); |
633 __ PushReturnAddressFrom(scratch1()); | 661 __ PushReturnAddressFrom(scratch1()); |
634 | 662 |
635 // Do tail-call to the runtime system. | 663 // Do tail-call to the runtime system. |
(...skipping 25 matching lines...) Expand all Loading... |
661 | 689 |
662 | 690 |
663 Register NamedStoreHandlerCompiler::value() { | 691 Register NamedStoreHandlerCompiler::value() { |
664 return StoreDescriptor::ValueRegister(); | 692 return StoreDescriptor::ValueRegister(); |
665 } | 693 } |
666 | 694 |
667 | 695 |
668 Handle<Code> NamedLoadHandlerCompiler::CompileLoadGlobal( | 696 Handle<Code> NamedLoadHandlerCompiler::CompileLoadGlobal( |
669 Handle<PropertyCell> cell, Handle<Name> name, bool is_configurable) { | 697 Handle<PropertyCell> cell, Handle<Name> name, bool is_configurable) { |
670 Label miss; | 698 Label miss; |
| 699 if (IC::ICUseVector(kind())) { |
| 700 PushVectorAndSlot(); |
| 701 } |
671 FrontendHeader(receiver(), name, &miss); | 702 FrontendHeader(receiver(), name, &miss); |
672 | 703 |
673 // Get the value from the cell. | 704 // Get the value from the cell. |
674 Register result = StoreDescriptor::ValueRegister(); | 705 Register result = StoreDescriptor::ValueRegister(); |
675 __ Move(result, cell); | 706 __ Move(result, cell); |
676 __ movp(result, FieldOperand(result, PropertyCell::kValueOffset)); | 707 __ movp(result, FieldOperand(result, PropertyCell::kValueOffset)); |
677 | 708 |
678 // Check for deleted property if property can actually be deleted. | 709 // Check for deleted property if property can actually be deleted. |
679 if (is_configurable) { | 710 if (is_configurable) { |
680 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); | 711 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); |
681 __ j(equal, &miss); | 712 __ j(equal, &miss); |
682 } else if (FLAG_debug_code) { | 713 } else if (FLAG_debug_code) { |
683 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); | 714 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); |
684 __ Check(not_equal, kDontDeleteCellsCannotContainTheHole); | 715 __ Check(not_equal, kDontDeleteCellsCannotContainTheHole); |
685 } | 716 } |
686 | 717 |
687 Counters* counters = isolate()->counters(); | 718 Counters* counters = isolate()->counters(); |
688 __ IncrementCounter(counters->named_load_global_stub(), 1); | 719 __ IncrementCounter(counters->named_load_global_stub(), 1); |
| 720 if (IC::ICUseVector(kind())) { |
| 721 DiscardVectorAndSlot(); |
| 722 } |
689 __ ret(0); | 723 __ ret(0); |
690 | 724 |
691 FrontendFooter(name, &miss); | 725 FrontendFooter(name, &miss); |
692 | 726 |
693 // Return the generated code. | 727 // Return the generated code. |
694 return GetCode(kind(), Code::NORMAL, name); | 728 return GetCode(kind(), Code::NORMAL, name); |
695 } | 729 } |
696 | 730 |
697 | 731 |
698 #undef __ | 732 #undef __ |
699 } | 733 } |
700 } // namespace v8::internal | 734 } // namespace v8::internal |
701 | 735 |
702 #endif // V8_TARGET_ARCH_X64 | 736 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |