OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 // just copies y and the arguments of the current function on the | 787 // just copies y and the arguments of the current function on the |
788 // stack, as receiver and arguments, and calls x. | 788 // stack, as receiver and arguments, and calls x. |
789 // In the implementation comments, we call x the applicand | 789 // In the implementation comments, we call x the applicand |
790 // and y the receiver. | 790 // and y the receiver. |
791 ASSERT(ArgumentsMode() == LAZY_ARGUMENTS_ALLOCATION); | 791 ASSERT(ArgumentsMode() == LAZY_ARGUMENTS_ALLOCATION); |
792 ASSERT(arguments->IsArguments()); | 792 ASSERT(arguments->IsArguments()); |
793 | 793 |
794 // Load applicand.apply onto the stack. This will usually | 794 // Load applicand.apply onto the stack. This will usually |
795 // give us a megamorphic load site. Not super, but it works. | 795 // give us a megamorphic load site. Not super, but it works. |
796 Load(applicand); | 796 Load(applicand); |
| 797 frame()->Dup(); |
797 Handle<String> name = Factory::LookupAsciiSymbol("apply"); | 798 Handle<String> name = Factory::LookupAsciiSymbol("apply"); |
798 frame()->Push(name); | 799 frame()->Push(name); |
799 Result answer = frame()->CallLoadIC(RelocInfo::CODE_TARGET); | 800 Result answer = frame()->CallLoadIC(RelocInfo::CODE_TARGET); |
800 __ nop(); | 801 __ nop(); |
801 frame()->Push(&answer); | 802 frame()->Push(&answer); |
802 | 803 |
803 // Load the receiver and the existing arguments object onto the | 804 // Load the receiver and the existing arguments object onto the |
804 // expression stack. Avoid allocating the arguments object here. | 805 // expression stack. Avoid allocating the arguments object here. |
805 Load(receiver); | 806 Load(receiver); |
806 LoadFromSlot(scope()->arguments()->var()->slot(), NOT_INSIDE_TYPEOF); | 807 LoadFromSlot(scope()->arguments()->var()->slot(), NOT_INSIDE_TYPEOF); |
(...skipping 4977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5784 LoadGlobal(); | 5785 LoadGlobal(); |
5785 frame_->Push(slot->var()->name()); | 5786 frame_->Push(slot->var()->name()); |
5786 RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF) | 5787 RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF) |
5787 ? RelocInfo::CODE_TARGET | 5788 ? RelocInfo::CODE_TARGET |
5788 : RelocInfo::CODE_TARGET_CONTEXT; | 5789 : RelocInfo::CODE_TARGET_CONTEXT; |
5789 Result answer = frame_->CallLoadIC(mode); | 5790 Result answer = frame_->CallLoadIC(mode); |
5790 // A test rax instruction following the call signals that the inobject | 5791 // A test rax instruction following the call signals that the inobject |
5791 // property case was inlined. Ensure that there is not a test rax | 5792 // property case was inlined. Ensure that there is not a test rax |
5792 // instruction here. | 5793 // instruction here. |
5793 masm_->nop(); | 5794 masm_->nop(); |
5794 // Discard the global object. The result is in answer. | |
5795 frame_->Drop(); | |
5796 return answer; | 5795 return answer; |
5797 } | 5796 } |
5798 | 5797 |
5799 | 5798 |
5800 void CodeGenerator::EmitDynamicLoadFromSlotFastCase(Slot* slot, | 5799 void CodeGenerator::EmitDynamicLoadFromSlotFastCase(Slot* slot, |
5801 TypeofState typeof_state, | 5800 TypeofState typeof_state, |
5802 Result* result, | 5801 Result* result, |
5803 JumpTarget* slow, | 5802 JumpTarget* slow, |
5804 JumpTarget* done) { | 5803 JumpTarget* done) { |
5805 // Generate fast-case code for variables that might be shadowed by | 5804 // Generate fast-case code for variables that might be shadowed by |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6733 | 6732 |
6734 private: | 6733 private: |
6735 Label patch_site_; | 6734 Label patch_site_; |
6736 Register dst_; | 6735 Register dst_; |
6737 Register receiver_; | 6736 Register receiver_; |
6738 Handle<String> name_; | 6737 Handle<String> name_; |
6739 }; | 6738 }; |
6740 | 6739 |
6741 | 6740 |
6742 void DeferredReferenceGetNamedValue::Generate() { | 6741 void DeferredReferenceGetNamedValue::Generate() { |
6743 __ push(receiver_); | 6742 if (!receiver_.is(rax)) { |
| 6743 __ movq(rax, receiver_); |
| 6744 } |
6744 __ Move(rcx, name_); | 6745 __ Move(rcx, name_); |
6745 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); | 6746 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); |
6746 __ Call(ic, RelocInfo::CODE_TARGET); | 6747 __ Call(ic, RelocInfo::CODE_TARGET); |
6747 // The call must be followed by a test rax instruction to indicate | 6748 // The call must be followed by a test rax instruction to indicate |
6748 // that the inobject property case was inlined. | 6749 // that the inobject property case was inlined. |
6749 // | 6750 // |
6750 // Store the delta to the map check instruction here in the test | 6751 // Store the delta to the map check instruction here in the test |
6751 // instruction. Use masm_-> instead of the __ macro since the | 6752 // instruction. Use masm_-> instead of the __ macro since the |
6752 // latter can't return a value. | 6753 // latter can't return a value. |
6753 int delta_to_patch_site = masm_->SizeOfCodeGeneratedSince(patch_site()); | 6754 int delta_to_patch_site = masm_->SizeOfCodeGeneratedSince(patch_site()); |
6754 // Here we use masm_-> instead of the __ macro because this is the | 6755 // Here we use masm_-> instead of the __ macro because this is the |
6755 // instruction that gets patched and coverage code gets in the way. | 6756 // instruction that gets patched and coverage code gets in the way. |
6756 masm_->testl(rax, Immediate(-delta_to_patch_site)); | 6757 masm_->testl(rax, Immediate(-delta_to_patch_site)); |
6757 __ IncrementCounter(&Counters::named_load_inline_miss, 1); | 6758 __ IncrementCounter(&Counters::named_load_inline_miss, 1); |
6758 | 6759 |
6759 if (!dst_.is(rax)) __ movq(dst_, rax); | 6760 if (!dst_.is(rax)) __ movq(dst_, rax); |
6760 __ pop(receiver_); | |
6761 } | 6761 } |
6762 | 6762 |
6763 | 6763 |
6764 void DeferredInlineSmiAdd::Generate() { | 6764 void DeferredInlineSmiAdd::Generate() { |
6765 GenericBinaryOpStub igostub(Token::ADD, overwrite_mode_, NO_SMI_CODE_IN_STUB); | 6765 GenericBinaryOpStub igostub(Token::ADD, overwrite_mode_, NO_SMI_CODE_IN_STUB); |
6766 igostub.GenerateCall(masm_, dst_, value_); | 6766 igostub.GenerateCall(masm_, dst_, value_); |
6767 if (!dst_.is(rax)) __ movq(dst_, rax); | 6767 if (!dst_.is(rax)) __ movq(dst_, rax); |
6768 } | 6768 } |
6769 | 6769 |
6770 | 6770 |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7411 ASSERT(masm()->SizeOfCodeGeneratedSince(deferred->patch_site()) == | 7411 ASSERT(masm()->SizeOfCodeGeneratedSince(deferred->patch_site()) == |
7412 LoadIC::kOffsetToLoadInstruction); | 7412 LoadIC::kOffsetToLoadInstruction); |
7413 // The initial (invalid) offset has to be large enough to force | 7413 // The initial (invalid) offset has to be large enough to force |
7414 // a 32-bit instruction encoding to allow patching with an | 7414 // a 32-bit instruction encoding to allow patching with an |
7415 // arbitrary offset. Use kMaxInt (minus kHeapObjectTag). | 7415 // arbitrary offset. Use kMaxInt (minus kHeapObjectTag). |
7416 int offset = kMaxInt; | 7416 int offset = kMaxInt; |
7417 masm()->movq(result.reg(), FieldOperand(receiver.reg(), offset)); | 7417 masm()->movq(result.reg(), FieldOperand(receiver.reg(), offset)); |
7418 | 7418 |
7419 __ IncrementCounter(&Counters::named_load_inline, 1); | 7419 __ IncrementCounter(&Counters::named_load_inline, 1); |
7420 deferred->BindExit(); | 7420 deferred->BindExit(); |
7421 frame()->Push(&receiver); | |
7422 } | 7421 } |
7423 ASSERT(frame()->height() == original_height); | 7422 ASSERT(frame()->height() == original_height - 1); |
7424 return result; | 7423 return result; |
7425 } | 7424 } |
7426 | 7425 |
7427 | 7426 |
7428 Result CodeGenerator::EmitKeyedLoad() { | 7427 Result CodeGenerator::EmitKeyedLoad() { |
7429 #ifdef DEBUG | 7428 #ifdef DEBUG |
7430 int original_height = frame()->height(); | 7429 int original_height = frame()->height(); |
7431 #endif | 7430 #endif |
7432 Result result; | 7431 Result result; |
7433 // Inline array load code if inside of a loop. We do not know | 7432 // Inline array load code if inside of a loop. We do not know |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7562 ASSERT(slot != NULL); | 7561 ASSERT(slot != NULL); |
7563 cgen_->LoadFromSlotCheckForArguments(slot, NOT_INSIDE_TYPEOF); | 7562 cgen_->LoadFromSlotCheckForArguments(slot, NOT_INSIDE_TYPEOF); |
7564 if (!persist_after_get_) set_unloaded(); | 7563 if (!persist_after_get_) set_unloaded(); |
7565 break; | 7564 break; |
7566 } | 7565 } |
7567 | 7566 |
7568 case NAMED: { | 7567 case NAMED: { |
7569 Variable* var = expression_->AsVariableProxy()->AsVariable(); | 7568 Variable* var = expression_->AsVariableProxy()->AsVariable(); |
7570 bool is_global = var != NULL; | 7569 bool is_global = var != NULL; |
7571 ASSERT(!is_global || var->is_global()); | 7570 ASSERT(!is_global || var->is_global()); |
| 7571 if (persist_after_get_) { |
| 7572 cgen_->frame()->Dup(); |
| 7573 } |
7572 Result result = cgen_->EmitNamedLoad(GetName(), is_global); | 7574 Result result = cgen_->EmitNamedLoad(GetName(), is_global); |
7573 cgen_->frame()->Push(&result); | 7575 cgen_->frame()->Push(&result); |
7574 if (!persist_after_get_) { | 7576 if (!persist_after_get_) { |
7575 cgen_->UnloadReference(this); | 7577 set_unloaded(); |
7576 } | 7578 } |
7577 break; | 7579 break; |
7578 } | 7580 } |
7579 | 7581 |
7580 case KEYED: { | 7582 case KEYED: { |
7581 // A load of a bare identifier (load from global) cannot be keyed. | 7583 // A load of a bare identifier (load from global) cannot be keyed. |
7582 ASSERT(expression_->AsVariableProxy()->AsVariable() == NULL); | 7584 ASSERT(expression_->AsVariableProxy()->AsVariable() == NULL); |
7583 | 7585 |
7584 Result value = cgen_->EmitKeyedLoad(); | 7586 Result value = cgen_->EmitKeyedLoad(); |
7585 cgen_->frame()->Push(&value); | 7587 cgen_->frame()->Push(&value); |
(...skipping 4268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11854 } | 11856 } |
11855 | 11857 |
11856 #endif | 11858 #endif |
11857 | 11859 |
11858 | 11860 |
11859 #undef __ | 11861 #undef __ |
11860 | 11862 |
11861 } } // namespace v8::internal | 11863 } } // namespace v8::internal |
11862 | 11864 |
11863 #endif // V8_TARGET_ARCH_X64 | 11865 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |