OLD | NEW |
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/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include "src/bailout-reason.h" | 7 #include "src/bailout-reason.h" |
8 #include "src/crankshaft/hydrogen.h" | 8 #include "src/crankshaft/hydrogen.h" |
9 #include "src/crankshaft/lithium.h" | 9 #include "src/crankshaft/lithium.h" |
10 #include "src/field-index.h" | 10 #include "src/field-index.h" |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 return environment()->Pop(); | 563 return environment()->Pop(); |
564 } | 564 } |
565 | 565 |
566 | 566 |
567 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { | 567 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { |
568 return DoGenerateCode(this); | 568 return DoGenerateCode(this); |
569 } | 569 } |
570 | 570 |
571 | 571 |
572 template <> | 572 template <> |
573 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { | |
574 HValue* undefined = graph()->GetConstantUndefined(); | |
575 HValue* closure = GetParameter(0); | |
576 HValue* literal_index = GetParameter(1); | |
577 | |
578 HValue* literals_array = Add<HLoadNamedField>( | |
579 closure, nullptr, HObjectAccess::ForLiteralsPointer()); | |
580 | |
581 HInstruction* allocation_site = Add<HLoadKeyed>( | |
582 literals_array, literal_index, nullptr, nullptr, FAST_ELEMENTS, | |
583 NEVER_RETURN_HOLE, LiteralsArray::kOffsetToFirstLiteral - kHeapObjectTag); | |
584 | |
585 IfBuilder checker(this); | |
586 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(allocation_site, | |
587 undefined); | |
588 checker.And(); | |
589 | |
590 HObjectAccess access = HObjectAccess::ForAllocationSiteOffset( | |
591 AllocationSite::kTransitionInfoOffset); | |
592 HInstruction* boilerplate = | |
593 Add<HLoadNamedField>(allocation_site, nullptr, access); | |
594 | |
595 int length = casted_stub()->length(); | |
596 if (length == 0) { | |
597 // Empty objects have some slack added to them. | |
598 length = JSObject::kInitialGlobalObjectUnusedPropertiesCount; | |
599 } | |
600 int size = JSObject::kHeaderSize + length * kPointerSize; | |
601 int object_size = size; | |
602 if (FLAG_allocation_site_pretenuring) { | |
603 size += AllocationMemento::kSize; | |
604 } | |
605 | |
606 HValue* boilerplate_map = | |
607 Add<HLoadNamedField>(boilerplate, nullptr, HObjectAccess::ForMap()); | |
608 HValue* boilerplate_size = Add<HLoadNamedField>( | |
609 boilerplate_map, nullptr, HObjectAccess::ForMapInstanceSize()); | |
610 HValue* size_in_words = Add<HConstant>(object_size >> kPointerSizeLog2); | |
611 checker.If<HCompareNumericAndBranch>(boilerplate_size, | |
612 size_in_words, Token::EQ); | |
613 checker.Then(); | |
614 | |
615 HValue* size_in_bytes = Add<HConstant>(size); | |
616 | |
617 HInstruction* object = Add<HAllocate>(size_in_bytes, HType::JSObject(), | |
618 NOT_TENURED, JS_OBJECT_TYPE); | |
619 | |
620 for (int i = 0; i < object_size; i += kPointerSize) { | |
621 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset(i); | |
622 Add<HStoreNamedField>(object, access, | |
623 Add<HLoadNamedField>(boilerplate, nullptr, access)); | |
624 } | |
625 | |
626 DCHECK(FLAG_allocation_site_pretenuring || (size == object_size)); | |
627 if (FLAG_allocation_site_pretenuring) { | |
628 BuildCreateAllocationMemento( | |
629 object, Add<HConstant>(object_size), allocation_site); | |
630 } | |
631 | |
632 environment()->Push(object); | |
633 checker.ElseDeopt(Deoptimizer::kUninitializedBoilerplateInFastClone); | |
634 checker.End(); | |
635 | |
636 return environment()->Pop(); | |
637 } | |
638 | |
639 | |
640 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { | |
641 return DoGenerateCode(this); | |
642 } | |
643 | |
644 | |
645 template <> | |
646 HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() { | 573 HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() { |
647 // This stub is performance sensitive, the generated code must be tuned | 574 // This stub is performance sensitive, the generated code must be tuned |
648 // so that it doesn't build an eager frame. | 575 // so that it doesn't build an eager frame. |
649 info()->MarkMustNotHaveEagerFrame(); | 576 info()->MarkMustNotHaveEagerFrame(); |
650 | 577 |
651 HValue* size = Add<HConstant>(AllocationSite::kSize); | 578 HValue* size = Add<HConstant>(AllocationSite::kSize); |
652 HInstruction* object = Add<HAllocate>(size, HType::JSObject(), TENURED, | 579 HInstruction* object = Add<HAllocate>(size, HType::JSObject(), TENURED, |
653 JS_OBJECT_TYPE); | 580 JS_OBJECT_TYPE); |
654 | 581 |
655 // Store the map | 582 // Store the map |
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2568 return Pop(); | 2495 return Pop(); |
2569 } | 2496 } |
2570 | 2497 |
2571 | 2498 |
2572 Handle<Code> KeyedLoadGenericStub::GenerateCode() { | 2499 Handle<Code> KeyedLoadGenericStub::GenerateCode() { |
2573 return DoGenerateCode(this); | 2500 return DoGenerateCode(this); |
2574 } | 2501 } |
2575 | 2502 |
2576 } // namespace internal | 2503 } // namespace internal |
2577 } // namespace v8 | 2504 } // namespace v8 |
OLD | NEW |