Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 975463002: Implement subclassing Arrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added tests Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 4610 matching lines...) Expand 10 before | Expand all | Expand 10 after
4621 } else if (argument_count() == MORE_THAN_ONE) { 4621 } else if (argument_count() == MORE_THAN_ONE) {
4622 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode); 4622 CreateArrayDispatch<ArrayNArgumentsConstructorStub>(masm, mode);
4623 } else { 4623 } else {
4624 UNREACHABLE(); 4624 UNREACHABLE();
4625 } 4625 }
4626 } 4626 }
4627 4627
4628 4628
4629 void ArrayConstructorStub::Generate(MacroAssembler* masm) { 4629 void ArrayConstructorStub::Generate(MacroAssembler* masm) {
4630 // ----------- S t a t e ------------- 4630 // ----------- S t a t e -------------
4631 // -- eax : argc (only if argument_count() == ANY) 4631 // -- eax : argc (only if argument_count() is ANY or MORE_THAN_ONE)
4632 // -- ebx : AllocationSite or undefined 4632 // -- ebx : AllocationSite or undefined
4633 // -- edi : constructor 4633 // -- edi : constructor
4634 // -- edx : Original constructor 4634 // -- edx : Original constructor
4635 // -- esp[0] : return address 4635 // -- esp[0] : return address
4636 // -- esp[4] : last argument 4636 // -- esp[4] : last argument
4637 // ----------------------------------- 4637 // -----------------------------------
4638 if (FLAG_debug_code) { 4638 if (FLAG_debug_code) {
4639 // The array construct code is only set for the global and natives 4639 // The array construct code is only set for the global and natives
4640 // builtin Array functions which always have maps. 4640 // builtin Array functions which always have maps.
4641 4641
(...skipping 13 matching lines...) Expand all
4655 4655
4656 __ cmp(edx, edi); 4656 __ cmp(edx, edi);
4657 __ j(not_equal, &subclassing); 4657 __ j(not_equal, &subclassing);
4658 4658
4659 Label no_info; 4659 Label no_info;
4660 // If the feedback vector is the undefined value call an array constructor 4660 // If the feedback vector is the undefined value call an array constructor
4661 // that doesn't use AllocationSites. 4661 // that doesn't use AllocationSites.
4662 __ cmp(ebx, isolate()->factory()->undefined_value()); 4662 __ cmp(ebx, isolate()->factory()->undefined_value());
4663 __ j(equal, &no_info); 4663 __ j(equal, &no_info);
4664 4664
4665 __ cmp(edx, edi);
4666 __ j(not_equal, &subclassing);
4667
4668 // Only look at the lower 16 bits of the transition info. 4665 // Only look at the lower 16 bits of the transition info.
4669 __ mov(edx, FieldOperand(ebx, AllocationSite::kTransitionInfoOffset)); 4666 __ mov(edx, FieldOperand(ebx, AllocationSite::kTransitionInfoOffset));
4670 __ SmiUntag(edx); 4667 __ SmiUntag(edx);
4671 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0); 4668 STATIC_ASSERT(AllocationSite::ElementsKindBits::kShift == 0);
4672 __ and_(edx, Immediate(AllocationSite::ElementsKindBits::kMask)); 4669 __ and_(edx, Immediate(AllocationSite::ElementsKindBits::kMask));
4673 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE); 4670 GenerateDispatchToArrayStub(masm, DONT_OVERRIDE);
4674 4671
4675 __ bind(&no_info); 4672 __ bind(&no_info);
4676 GenerateDispatchToArrayStub(masm, DISABLE_ALLOCATION_SITES); 4673 GenerateDispatchToArrayStub(masm, DISABLE_ALLOCATION_SITES);
4677 4674
4675 // Subclassing.
4678 __ bind(&subclassing); 4676 __ bind(&subclassing);
4679 __ TailCallRuntime(Runtime::kThrowArrayNotSubclassableError, 0, 1); 4677 __ pop(ecx); // return address.
4678 __ push(edi);
4679 __ push(edx);
4680
4681 // Adjust argc.
4682 switch (argument_count()) {
4683 case ANY:
4684 case MORE_THAN_ONE:
4685 __ add(eax, Immediate(2));
4686 break;
4687 case NONE:
4688 __ mov(eax, Immediate(2));
4689 break;
4690 case ONE:
4691 __ mov(eax, Immediate(3));
4692 break;
4693 }
4694
4695 __ push(ecx);
4696 __ JumpToExternalReference(
4697 ExternalReference(Runtime::kArrayConstructorWithSubclassing, isolate()));
4680 } 4698 }
4681 4699
4682 4700
4683 void InternalArrayConstructorStub::GenerateCase( 4701 void InternalArrayConstructorStub::GenerateCase(
4684 MacroAssembler* masm, ElementsKind kind) { 4702 MacroAssembler* masm, ElementsKind kind) {
4685 Label not_zero_case, not_one_case; 4703 Label not_zero_case, not_one_case;
4686 Label normal_sequence; 4704 Label normal_sequence;
4687 4705
4688 __ test(eax, eax); 4706 __ test(eax, eax);
4689 __ j(not_zero, &not_zero_case); 4707 __ j(not_zero, &not_zero_case);
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
5151 ApiParameterOperand(2), kStackSpace, nullptr, 5169 ApiParameterOperand(2), kStackSpace, nullptr,
5152 Operand(ebp, 7 * kPointerSize), NULL); 5170 Operand(ebp, 7 * kPointerSize), NULL);
5153 } 5171 }
5154 5172
5155 5173
5156 #undef __ 5174 #undef __
5157 5175
5158 } } // namespace v8::internal 5176 } } // namespace v8::internal
5159 5177
5160 #endif // V8_TARGET_ARCH_IA32 5178 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698