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

Side by Side Diff: src/builtins/builtins-internal.cc

Issue 2498073002: [refactoring] Split CodeAssemblerState out of CodeAssembler (Closed)
Patch Set: one more attempt Created 4 years, 1 month 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
« no previous file with comments | « src/builtins/builtins-handler.cc ('k') | src/builtins/builtins-iterator.cc » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/builtins/builtins.h" 5 #include "src/builtins/builtins.h"
6 #include "src/builtins/builtins-utils.h" 6 #include "src/builtins/builtins-utils.h"
7 #include "src/interface-descriptors.h" 7 #include "src/interface-descriptors.h"
8 #include "src/macro-assembler.h" 8 #include "src/macro-assembler.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 void Builtins::Generate_StackCheck(MacroAssembler* masm) { 49 void Builtins::Generate_StackCheck(MacroAssembler* masm) {
50 masm->TailCallRuntime(Runtime::kStackGuard); 50 masm->TailCallRuntime(Runtime::kStackGuard);
51 } 51 }
52 52
53 // ----------------------------------------------------------------------------- 53 // -----------------------------------------------------------------------------
54 // TurboFan support builtins. 54 // TurboFan support builtins.
55 55
56 void Builtins::Generate_CopyFastSmiOrObjectElements( 56 void Builtins::Generate_CopyFastSmiOrObjectElements(
57 CodeStubAssembler* assembler) { 57 compiler::CodeAssemblerState* state) {
58 typedef CodeStubAssembler::Label Label; 58 typedef CodeStubAssembler::Label Label;
59 typedef compiler::Node Node; 59 typedef compiler::Node Node;
60 typedef CopyFastSmiOrObjectElementsDescriptor Descriptor; 60 typedef CopyFastSmiOrObjectElementsDescriptor Descriptor;
61 CodeStubAssembler assembler(state);
61 62
62 Node* object = assembler->Parameter(Descriptor::kObject); 63 Node* object = assembler.Parameter(Descriptor::kObject);
63 64
64 // Load the {object}s elements. 65 // Load the {object}s elements.
65 Node* source = assembler->LoadObjectField(object, JSObject::kElementsOffset); 66 Node* source = assembler.LoadObjectField(object, JSObject::kElementsOffset);
66 67
67 CodeStubAssembler::ParameterMode mode = assembler->OptimalParameterMode(); 68 CodeStubAssembler::ParameterMode mode = assembler.OptimalParameterMode();
68 Node* length = assembler->UntagParameter( 69 Node* length = assembler.UntagParameter(
69 assembler->LoadFixedArrayBaseLength(source), mode); 70 assembler.LoadFixedArrayBaseLength(source), mode);
70 71
71 // Check if we can allocate in new space. 72 // Check if we can allocate in new space.
72 ElementsKind kind = FAST_ELEMENTS; 73 ElementsKind kind = FAST_ELEMENTS;
73 int max_elements = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(kind); 74 int max_elements = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(kind);
74 Label if_newspace(assembler), if_oldspace(assembler); 75 Label if_newspace(&assembler), if_oldspace(&assembler);
75 assembler->Branch( 76 assembler.Branch(
76 assembler->UintPtrLessThan( 77 assembler.UintPtrLessThan(
77 length, assembler->IntPtrOrSmiConstant(max_elements, mode)), 78 length, assembler.IntPtrOrSmiConstant(max_elements, mode)),
78 &if_newspace, &if_oldspace); 79 &if_newspace, &if_oldspace);
79 80
80 assembler->Bind(&if_newspace); 81 assembler.Bind(&if_newspace);
81 { 82 {
82 Node* target = assembler->AllocateFixedArray(kind, length, mode); 83 Node* target = assembler.AllocateFixedArray(kind, length, mode);
83 assembler->CopyFixedArrayElements(kind, source, target, length, 84 assembler.CopyFixedArrayElements(kind, source, target, length,
84 SKIP_WRITE_BARRIER, mode); 85 SKIP_WRITE_BARRIER, mode);
85 assembler->StoreObjectField(object, JSObject::kElementsOffset, target); 86 assembler.StoreObjectField(object, JSObject::kElementsOffset, target);
86 assembler->Return(target); 87 assembler.Return(target);
87 } 88 }
88 89
89 assembler->Bind(&if_oldspace); 90 assembler.Bind(&if_oldspace);
90 { 91 {
91 Node* target = assembler->AllocateFixedArray( 92 Node* target = assembler.AllocateFixedArray(kind, length, mode,
92 kind, length, mode, CodeStubAssembler::kPretenured); 93 CodeStubAssembler::kPretenured);
93 assembler->CopyFixedArrayElements(kind, source, target, length, 94 assembler.CopyFixedArrayElements(kind, source, target, length,
94 UPDATE_WRITE_BARRIER, mode); 95 UPDATE_WRITE_BARRIER, mode);
95 assembler->StoreObjectField(object, JSObject::kElementsOffset, target); 96 assembler.StoreObjectField(object, JSObject::kElementsOffset, target);
96 assembler->Return(target); 97 assembler.Return(target);
97 } 98 }
98 } 99 }
99 100
100 void Builtins::Generate_GrowFastDoubleElements(CodeStubAssembler* assembler) { 101 void Builtins::Generate_GrowFastDoubleElements(
102 compiler::CodeAssemblerState* state) {
101 typedef CodeStubAssembler::Label Label; 103 typedef CodeStubAssembler::Label Label;
102 typedef compiler::Node Node; 104 typedef compiler::Node Node;
103 typedef GrowArrayElementsDescriptor Descriptor; 105 typedef GrowArrayElementsDescriptor Descriptor;
106 CodeStubAssembler assembler(state);
104 107
105 Node* object = assembler->Parameter(Descriptor::kObject); 108 Node* object = assembler.Parameter(Descriptor::kObject);
106 Node* key = assembler->Parameter(Descriptor::kKey); 109 Node* key = assembler.Parameter(Descriptor::kKey);
107 Node* context = assembler->Parameter(Descriptor::kContext); 110 Node* context = assembler.Parameter(Descriptor::kContext);
108 111
109 Label runtime(assembler, CodeStubAssembler::Label::kDeferred); 112 Label runtime(&assembler, CodeStubAssembler::Label::kDeferred);
110 Node* elements = assembler->LoadElements(object); 113 Node* elements = assembler.LoadElements(object);
111 elements = assembler->TryGrowElementsCapacity( 114 elements = assembler.TryGrowElementsCapacity(
112 object, elements, FAST_DOUBLE_ELEMENTS, key, &runtime); 115 object, elements, FAST_DOUBLE_ELEMENTS, key, &runtime);
113 assembler->Return(elements); 116 assembler.Return(elements);
114 117
115 assembler->Bind(&runtime); 118 assembler.Bind(&runtime);
116 assembler->TailCallRuntime(Runtime::kGrowArrayElements, context, object, key); 119 assembler.TailCallRuntime(Runtime::kGrowArrayElements, context, object, key);
117 } 120 }
118 121
119 void Builtins::Generate_GrowFastSmiOrObjectElements( 122 void Builtins::Generate_GrowFastSmiOrObjectElements(
120 CodeStubAssembler* assembler) { 123 compiler::CodeAssemblerState* state) {
121 typedef CodeStubAssembler::Label Label; 124 typedef CodeStubAssembler::Label Label;
122 typedef compiler::Node Node; 125 typedef compiler::Node Node;
123 typedef GrowArrayElementsDescriptor Descriptor; 126 typedef GrowArrayElementsDescriptor Descriptor;
127 CodeStubAssembler assembler(state);
124 128
125 Node* object = assembler->Parameter(Descriptor::kObject); 129 Node* object = assembler.Parameter(Descriptor::kObject);
126 Node* key = assembler->Parameter(Descriptor::kKey); 130 Node* key = assembler.Parameter(Descriptor::kKey);
127 Node* context = assembler->Parameter(Descriptor::kContext); 131 Node* context = assembler.Parameter(Descriptor::kContext);
128 132
129 Label runtime(assembler, CodeStubAssembler::Label::kDeferred); 133 Label runtime(&assembler, CodeStubAssembler::Label::kDeferred);
130 Node* elements = assembler->LoadElements(object); 134 Node* elements = assembler.LoadElements(object);
131 elements = assembler->TryGrowElementsCapacity(object, elements, FAST_ELEMENTS, 135 elements = assembler.TryGrowElementsCapacity(object, elements, FAST_ELEMENTS,
132 key, &runtime); 136 key, &runtime);
133 assembler->Return(elements); 137 assembler.Return(elements);
134 138
135 assembler->Bind(&runtime); 139 assembler.Bind(&runtime);
136 assembler->TailCallRuntime(Runtime::kGrowArrayElements, context, object, key); 140 assembler.TailCallRuntime(Runtime::kGrowArrayElements, context, object, key);
137 } 141 }
138 142
139 } // namespace internal 143 } // namespace internal
140 } // namespace v8 144 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins-handler.cc ('k') | src/builtins/builtins-iterator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698