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/builtins/builtins-internal.cc

Issue 2752143004: [refactor] Separate generated builtins and C++ builtins into separate files (Closed)
Patch Set: tentative gcmole fix Created 3 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
« no previous file with comments | « src/builtins/builtins-ic-gen.cc ('k') | src/builtins/builtins-internal-gen.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-utils.h" 5 #include "src/builtins/builtins-utils.h"
6 #include "src/builtins/builtins.h" 6 #include "src/builtins/builtins.h"
7 #include "src/code-stub-assembler.h"
8 #include "src/counters.h" 7 #include "src/counters.h"
9 #include "src/interface-descriptors.h" 8 #include "src/interface-descriptors.h"
10 #include "src/macro-assembler.h"
11 #include "src/objects-inl.h" 9 #include "src/objects-inl.h"
12 10
13 namespace v8 { 11 namespace v8 {
14 namespace internal { 12 namespace internal {
15 13
16 BUILTIN(Illegal) { 14 BUILTIN(Illegal) {
17 UNREACHABLE(); 15 UNREACHABLE();
18 return isolate->heap()->undefined_value(); // Make compiler happy. 16 return isolate->heap()->undefined_value(); // Make compiler happy.
19 } 17 }
20 18
(...skipping 14 matching lines...) Expand all
35 THROW_NEW_ERROR_RETURN_FAILURE( 33 THROW_NEW_ERROR_RETURN_FAILURE(
36 isolate, NewTypeError(MessageTemplate::kRestrictedFunctionProperties)); 34 isolate, NewTypeError(MessageTemplate::kRestrictedFunctionProperties));
37 } 35 }
38 36
39 BUILTIN(RestrictedStrictArgumentsPropertiesThrower) { 37 BUILTIN(RestrictedStrictArgumentsPropertiesThrower) {
40 HandleScope scope(isolate); 38 HandleScope scope(isolate);
41 THROW_NEW_ERROR_RETURN_FAILURE( 39 THROW_NEW_ERROR_RETURN_FAILURE(
42 isolate, NewTypeError(MessageTemplate::kStrictPoisonPill)); 40 isolate, NewTypeError(MessageTemplate::kStrictPoisonPill));
43 } 41 }
44 42
45 // -----------------------------------------------------------------------------
46 // Interrupt and stack checks.
47
48 void Builtins::Generate_InterruptCheck(MacroAssembler* masm) {
49 masm->TailCallRuntime(Runtime::kInterrupt);
50 }
51
52 void Builtins::Generate_StackCheck(MacroAssembler* masm) {
53 masm->TailCallRuntime(Runtime::kStackGuard);
54 }
55
56 // -----------------------------------------------------------------------------
57 // TurboFan support builtins.
58
59 TF_BUILTIN(CopyFastSmiOrObjectElements, CodeStubAssembler) {
60 typedef CopyFastSmiOrObjectElementsDescriptor Descriptor;
61
62 Node* object = Parameter(Descriptor::kObject);
63
64 // Load the {object}s elements.
65 Node* source = LoadObjectField(object, JSObject::kElementsOffset);
66
67 ParameterMode mode = OptimalParameterMode();
68 Node* length = TaggedToParameter(LoadFixedArrayBaseLength(source), mode);
69
70 // Check if we can allocate in new space.
71 ElementsKind kind = FAST_ELEMENTS;
72 int max_elements = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(kind);
73 Label if_newspace(this), if_oldspace(this);
74 Branch(UintPtrOrSmiLessThan(length, IntPtrOrSmiConstant(max_elements, mode),
75 mode),
76 &if_newspace, &if_oldspace);
77
78 Bind(&if_newspace);
79 {
80 Node* target = AllocateFixedArray(kind, length, mode);
81 CopyFixedArrayElements(kind, source, target, length, SKIP_WRITE_BARRIER,
82 mode);
83 StoreObjectField(object, JSObject::kElementsOffset, target);
84 Return(target);
85 }
86
87 Bind(&if_oldspace);
88 {
89 Node* target = AllocateFixedArray(kind, length, mode, kPretenured);
90 CopyFixedArrayElements(kind, source, target, length, UPDATE_WRITE_BARRIER,
91 mode);
92 StoreObjectField(object, JSObject::kElementsOffset, target);
93 Return(target);
94 }
95 }
96
97 TF_BUILTIN(GrowFastDoubleElements, CodeStubAssembler) {
98 typedef GrowArrayElementsDescriptor Descriptor;
99
100 Node* object = Parameter(Descriptor::kObject);
101 Node* key = Parameter(Descriptor::kKey);
102 Node* context = Parameter(Descriptor::kContext);
103
104 Label runtime(this, Label::kDeferred);
105 Node* elements = LoadElements(object);
106 elements = TryGrowElementsCapacity(object, elements, FAST_DOUBLE_ELEMENTS,
107 key, &runtime);
108 Return(elements);
109
110 Bind(&runtime);
111 TailCallRuntime(Runtime::kGrowArrayElements, context, object, key);
112 }
113
114 TF_BUILTIN(GrowFastSmiOrObjectElements, CodeStubAssembler) {
115 typedef GrowArrayElementsDescriptor Descriptor;
116
117 Node* object = Parameter(Descriptor::kObject);
118 Node* key = Parameter(Descriptor::kKey);
119 Node* context = Parameter(Descriptor::kContext);
120
121 Label runtime(this, Label::kDeferred);
122 Node* elements = LoadElements(object);
123 elements =
124 TryGrowElementsCapacity(object, elements, FAST_ELEMENTS, key, &runtime);
125 Return(elements);
126
127 Bind(&runtime);
128 TailCallRuntime(Runtime::kGrowArrayElements, context, object, key);
129 }
130
131 TF_BUILTIN(NewUnmappedArgumentsElements, CodeStubAssembler) {
132 typedef NewArgumentsElementsDescriptor Descriptor;
133
134 Node* frame = Parameter(Descriptor::kFrame);
135 Node* length = SmiToWord(Parameter(Descriptor::kLength));
136
137 // Check if we can allocate in new space.
138 ElementsKind kind = FAST_ELEMENTS;
139 int max_elements = FixedArray::GetMaxLengthForNewSpaceAllocation(kind);
140 Label if_newspace(this), if_oldspace(this, Label::kDeferred);
141 Branch(IntPtrLessThan(length, IntPtrConstant(max_elements)), &if_newspace,
142 &if_oldspace);
143
144 Bind(&if_newspace);
145 {
146 // Prefer EmptyFixedArray in case of non-positive {length} (the {length}
147 // can be negative here for rest parameters).
148 Label if_empty(this), if_notempty(this);
149 Branch(IntPtrLessThanOrEqual(length, IntPtrConstant(0)), &if_empty,
150 &if_notempty);
151
152 Bind(&if_empty);
153 Return(EmptyFixedArrayConstant());
154
155 Bind(&if_notempty);
156 {
157 // Allocate a FixedArray in new space.
158 Node* result = AllocateFixedArray(kind, length);
159
160 // Compute the effective {offset} into the {frame}.
161 Node* offset = IntPtrAdd(length, IntPtrConstant(1));
162
163 // Copy the parameters from {frame} (starting at {offset}) to {result}.
164 Variable var_index(this, MachineType::PointerRepresentation());
165 Label loop(this, &var_index), done_loop(this);
166 var_index.Bind(IntPtrConstant(0));
167 Goto(&loop);
168 Bind(&loop);
169 {
170 // Load the current {index}.
171 Node* index = var_index.value();
172
173 // Check if we are done.
174 GotoIf(WordEqual(index, length), &done_loop);
175
176 // Load the parameter at the given {index}.
177 Node* value = Load(MachineType::AnyTagged(), frame,
178 WordShl(IntPtrSub(offset, index),
179 IntPtrConstant(kPointerSizeLog2)));
180
181 // Store the {value} into the {result}.
182 StoreFixedArrayElement(result, index, value, SKIP_WRITE_BARRIER);
183
184 // Continue with next {index}.
185 var_index.Bind(IntPtrAdd(index, IntPtrConstant(1)));
186 Goto(&loop);
187 }
188
189 Bind(&done_loop);
190 Return(result);
191 }
192 }
193
194 Bind(&if_oldspace);
195 {
196 // Allocate in old space (or large object space).
197 TailCallRuntime(Runtime::kNewArgumentsElements, NoContextConstant(),
198 BitcastWordToTagged(frame), SmiFromWord(length));
199 }
200 }
201
202 TF_BUILTIN(ReturnReceiver, CodeStubAssembler) { Return(Parameter(0)); }
203
204 } // namespace internal 43 } // namespace internal
205 } // namespace v8 44 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins-ic-gen.cc ('k') | src/builtins/builtins-internal-gen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698