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

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

Issue 587203002: ExtendStorageStub added, it is aimed for extending objects backing store when it runs out of space. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/code-stubs.cc ('k') | src/hydrogen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/field-index.h" 8 #include "src/field-index.h"
9 #include "src/hydrogen.h" 9 #include "src/hydrogen.h"
10 #include "src/lithium.h" 10 #include "src/lithium.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return arguments_length_; 56 return arguments_length_;
57 } 57 }
58 CompilationInfo* info() { return &info_; } 58 CompilationInfo* info() { return &info_; }
59 HydrogenCodeStub* stub() { return info_.code_stub(); } 59 HydrogenCodeStub* stub() { return info_.code_stub(); }
60 HContext* context() { return context_; } 60 HContext* context() { return context_; }
61 Isolate* isolate() { return info_.isolate(); } 61 Isolate* isolate() { return info_.isolate(); }
62 62
63 HLoadNamedField* BuildLoadNamedField(HValue* object, 63 HLoadNamedField* BuildLoadNamedField(HValue* object,
64 FieldIndex index); 64 FieldIndex index);
65 void BuildStoreNamedField(HValue* object, HValue* value, FieldIndex index, 65 void BuildStoreNamedField(HValue* object, HValue* value, FieldIndex index,
66 Representation representation); 66 Representation representation,
67 bool transition_to_field);
67 68
68 enum ArgumentClass { 69 enum ArgumentClass {
69 NONE, 70 NONE,
70 SINGLE, 71 SINGLE,
71 MULTIPLE 72 MULTIPLE
72 }; 73 };
73 74
74 HValue* BuildArrayConstructor(ElementsKind kind, 75 HValue* BuildArrayConstructor(ElementsKind kind,
75 AllocationSiteOverrideMode override_mode, 76 AllocationSiteOverrideMode override_mode,
76 ArgumentClass argument_class); 77 ArgumentClass argument_class);
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 return Add<HLoadNamedField>(descriptors, static_cast<HValue*>(NULL), 596 return Add<HLoadNamedField>(descriptors, static_cast<HValue*>(NULL),
596 value_access); 597 value_access);
597 } 598 }
598 599
599 600
600 Handle<Code> LoadConstantStub::GenerateCode() { return DoGenerateCode(this); } 601 Handle<Code> LoadConstantStub::GenerateCode() { return DoGenerateCode(this); }
601 602
602 603
603 void CodeStubGraphBuilderBase::BuildStoreNamedField( 604 void CodeStubGraphBuilderBase::BuildStoreNamedField(
604 HValue* object, HValue* value, FieldIndex index, 605 HValue* object, HValue* value, FieldIndex index,
605 Representation representation) { 606 Representation representation, bool transition_to_field) {
606 DCHECK(!index.is_double() || representation.IsDouble()); 607 DCHECK(!index.is_double() || representation.IsDouble());
607 int offset = index.offset(); 608 int offset = index.offset();
608 HObjectAccess access = 609 HObjectAccess access =
609 index.is_inobject() 610 index.is_inobject()
610 ? HObjectAccess::ForObservableJSObjectOffset(offset, representation) 611 ? HObjectAccess::ForObservableJSObjectOffset(offset, representation)
611 : HObjectAccess::ForBackingStoreOffset(offset, representation); 612 : HObjectAccess::ForBackingStoreOffset(offset, representation);
612 613
613 if (representation.IsDouble()) { 614 if (representation.IsDouble()) {
614 // Load the heap number. 615 HObjectAccess heap_number_access =
615 object = Add<HLoadNamedField>( 616 access.WithRepresentation(Representation::Tagged());
616 object, static_cast<HValue*>(NULL), 617 if (transition_to_field) {
617 access.WithRepresentation(Representation::Tagged())); 618 // The store requires a mutable HeapNumber to be allocated.
618 // Store the double value into it. 619 NoObservableSideEffectsScope no_side_effects(this);
619 access = HObjectAccess::ForHeapNumberValue(); 620 HInstruction* heap_number_size = Add<HConstant>(HeapNumber::kSize);
621
622 // TODO(hpayer): Allocation site pretenuring support.
623 HInstruction* heap_number =
624 Add<HAllocate>(heap_number_size, HType::HeapObject(), NOT_TENURED,
625 MUTABLE_HEAP_NUMBER_TYPE);
626 AddStoreMapConstant(heap_number,
627 isolate()->factory()->mutable_heap_number_map());
628 Add<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(),
629 value);
630 // Store the new mutable heap number into the object.
631 access = heap_number_access;
632 value = heap_number;
633 } else {
634 // Load the heap number.
635 object = Add<HLoadNamedField>(object, static_cast<HValue*>(NULL),
636 heap_number_access);
637 // Store the double value into it.
638 access = HObjectAccess::ForHeapNumberValue();
639 }
620 } else if (representation.IsHeapObject()) { 640 } else if (representation.IsHeapObject()) {
621 BuildCheckHeapObject(value); 641 BuildCheckHeapObject(value);
622 } 642 }
623 643
624 Add<HStoreNamedField>(object, access, value, INITIALIZING_STORE); 644 Add<HStoreNamedField>(object, access, value, INITIALIZING_STORE);
625 } 645 }
626 646
627 647
628 template <> 648 template <>
629 HValue* CodeStubGraphBuilder<StoreFieldStub>::BuildCodeStub() { 649 HValue* CodeStubGraphBuilder<StoreFieldStub>::BuildCodeStub() {
630 BuildStoreNamedField(GetParameter(0), GetParameter(2), casted_stub()->index(), 650 BuildStoreNamedField(GetParameter(0), GetParameter(2), casted_stub()->index(),
631 casted_stub()->representation()); 651 casted_stub()->representation(), false);
632 return GetParameter(2); 652 return GetParameter(2);
633 } 653 }
634 654
635 655
636 Handle<Code> StoreFieldStub::GenerateCode() { return DoGenerateCode(this); } 656 Handle<Code> StoreFieldStub::GenerateCode() { return DoGenerateCode(this); }
637 657
638 658
639 template <> 659 template <>
660 HValue* CodeStubGraphBuilder<ExtendStorageStub>::BuildCodeStub() {
661 HValue* object = GetParameter(ExtendStorageDescriptor::kReceiverIndex);
662 HValue* properties =
663 Add<HLoadNamedField>(object, static_cast<HValue*>(NULL),
664 HObjectAccess::ForPropertiesPointer());
665 HValue* length = AddLoadFixedArrayLength(properties);
666 HValue* delta = Add<HConstant>(static_cast<int32_t>(JSObject::kFieldsAdded));
667 HValue* new_capacity = AddUncasted<HAdd>(length, delta);
668
669 // Grow properties array.
670 ElementsKind kind = FAST_ELEMENTS;
671 Add<HBoundsCheck>(new_capacity,
672 Add<HConstant>((Page::kMaxRegularHeapObjectSize -
673 FixedArray::kHeaderSize) >>
674 ElementsKindToShiftSize(kind)));
675
676 // Reuse this code for properties backing store allocation.
677 HValue* new_properties = BuildAllocateAndInitializeArray(kind, new_capacity);
678
679 BuildCopyProperties(properties, new_properties, length, new_capacity);
680
681 // Store the new value into the "extended" object.
682 Add<HStoreNamedField>(object, HObjectAccess::ForPropertiesPointer(),
683 new_properties);
684
685 BuildStoreNamedField(
686 object, GetParameter(ExtendStorageDescriptor::kValueIndex),
687 casted_stub()->index(), casted_stub()->representation(), true);
688
689 // And finally update the map after the new field is added.
690 Add<HStoreNamedField>(object, HObjectAccess::ForMap(),
691 GetParameter(ExtendStorageDescriptor::kMapIndex));
692
693 return GetParameter(ExtendStorageDescriptor::kValueIndex);
694 }
695
696
697 Handle<Code> ExtendStorageStub::GenerateCode() { return DoGenerateCode(this); }
698
699
700 template <>
640 HValue* CodeStubGraphBuilder<StringLengthStub>::BuildCodeStub() { 701 HValue* CodeStubGraphBuilder<StringLengthStub>::BuildCodeStub() {
641 HValue* string = BuildLoadNamedField(GetParameter(0), 702 HValue* string = BuildLoadNamedField(GetParameter(0),
642 FieldIndex::ForInObjectOffset(JSValue::kValueOffset)); 703 FieldIndex::ForInObjectOffset(JSValue::kValueOffset));
643 return BuildLoadNamedField(string, 704 return BuildLoadNamedField(string,
644 FieldIndex::ForInObjectOffset(String::kLengthOffset)); 705 FieldIndex::ForInObjectOffset(String::kLengthOffset));
645 } 706 }
646 707
647 708
648 Handle<Code> StringLengthStub::GenerateCode() { 709 Handle<Code> StringLengthStub::GenerateCode() {
649 return DoGenerateCode(this); 710 return DoGenerateCode(this);
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 1884
1824 // Probe the stub cache. 1885 // Probe the stub cache.
1825 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( 1886 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags(
1826 Code::ComputeHandlerFlags(Code::LOAD_IC)); 1887 Code::ComputeHandlerFlags(Code::LOAD_IC));
1827 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags); 1888 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags);
1828 1889
1829 // We never continue. 1890 // We never continue.
1830 return graph()->GetConstant0(); 1891 return graph()->GetConstant0();
1831 } 1892 }
1832 } } // namespace v8::internal 1893 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698