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

Side by Side Diff: src/compiler/js-intrinsic-lowering.cc

Issue 2126453002: [intrinsic] Drop the %_ValueOf intrinsic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix noi18n build (narf) Created 4 years, 5 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/compiler/js-intrinsic-lowering.h ('k') | src/crankshaft/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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/compiler/js-intrinsic-lowering.h" 5 #include "src/compiler/js-intrinsic-lowering.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/compiler/access-builder.h" 10 #include "src/compiler/access-builder.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 case Runtime::kInlineIsArray: 43 case Runtime::kInlineIsArray:
44 return ReduceIsInstanceType(node, JS_ARRAY_TYPE); 44 return ReduceIsInstanceType(node, JS_ARRAY_TYPE);
45 case Runtime::kInlineIsTypedArray: 45 case Runtime::kInlineIsTypedArray:
46 return ReduceIsInstanceType(node, JS_TYPED_ARRAY_TYPE); 46 return ReduceIsInstanceType(node, JS_TYPED_ARRAY_TYPE);
47 case Runtime::kInlineIsRegExp: 47 case Runtime::kInlineIsRegExp:
48 return ReduceIsInstanceType(node, JS_REGEXP_TYPE); 48 return ReduceIsInstanceType(node, JS_REGEXP_TYPE);
49 case Runtime::kInlineIsJSReceiver: 49 case Runtime::kInlineIsJSReceiver:
50 return ReduceIsJSReceiver(node); 50 return ReduceIsJSReceiver(node);
51 case Runtime::kInlineIsSmi: 51 case Runtime::kInlineIsSmi:
52 return ReduceIsSmi(node); 52 return ReduceIsSmi(node);
53 case Runtime::kInlineValueOf:
54 return ReduceValueOf(node);
55 case Runtime::kInlineFixedArrayGet: 53 case Runtime::kInlineFixedArrayGet:
56 return ReduceFixedArrayGet(node); 54 return ReduceFixedArrayGet(node);
57 case Runtime::kInlineFixedArraySet: 55 case Runtime::kInlineFixedArraySet:
58 return ReduceFixedArraySet(node); 56 return ReduceFixedArraySet(node);
59 case Runtime::kInlineRegExpConstructResult: 57 case Runtime::kInlineRegExpConstructResult:
60 return ReduceRegExpConstructResult(node); 58 return ReduceRegExpConstructResult(node);
61 case Runtime::kInlineRegExpExec: 59 case Runtime::kInlineRegExpExec:
62 return ReduceRegExpExec(node); 60 return ReduceRegExpExec(node);
63 case Runtime::kInlineRegExpFlags: 61 case Runtime::kInlineRegExpFlags:
64 return ReduceRegExpFlags(node); 62 return ReduceRegExpFlags(node);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 Reduction JSIntrinsicLowering::ReduceIsJSReceiver(Node* node) { 195 Reduction JSIntrinsicLowering::ReduceIsJSReceiver(Node* node) {
198 return Change(node, simplified()->ObjectIsReceiver()); 196 return Change(node, simplified()->ObjectIsReceiver());
199 } 197 }
200 198
201 199
202 Reduction JSIntrinsicLowering::ReduceIsSmi(Node* node) { 200 Reduction JSIntrinsicLowering::ReduceIsSmi(Node* node) {
203 return Change(node, simplified()->ObjectIsSmi()); 201 return Change(node, simplified()->ObjectIsSmi());
204 } 202 }
205 203
206 204
207 Reduction JSIntrinsicLowering::ReduceValueOf(Node* node) {
208 // if (%_IsSmi(value)) {
209 // return value;
210 // } else if (%_GetInstanceType(%_GetMap(value)) == JS_VALUE_TYPE) {
211 // return %_GetValue(value);
212 // } else {
213 // return value;
214 // }
215 const Operator* const merge_op = common()->Merge(2);
216 const Operator* const ephi_op = common()->EffectPhi(2);
217 const Operator* const phi_op =
218 common()->Phi(MachineRepresentation::kTagged, 2);
219
220 Node* value = NodeProperties::GetValueInput(node, 0);
221 Node* effect = NodeProperties::GetEffectInput(node);
222 Node* control = NodeProperties::GetControlInput(node);
223
224 Node* check0 = graph()->NewNode(simplified()->ObjectIsSmi(), value);
225 Node* branch0 = graph()->NewNode(common()->Branch(), check0, control);
226
227 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
228 Node* etrue0 = effect;
229 Node* vtrue0 = value;
230
231 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0);
232 Node* efalse0;
233 Node* vfalse0;
234 {
235 Node* check1 = graph()->NewNode(
236 machine()->Word32Equal(),
237 graph()->NewNode(
238 simplified()->LoadField(AccessBuilder::ForMapInstanceType()),
239 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()),
240 value, effect, if_false0),
241 effect, if_false0),
242 jsgraph()->Int32Constant(JS_VALUE_TYPE));
243 Node* branch1 = graph()->NewNode(common()->Branch(), check1, if_false0);
244
245 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
246 Node* etrue1 =
247 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForValue()),
248 value, effect, if_true1);
249 Node* vtrue1 = etrue1;
250
251 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
252 Node* efalse1 = effect;
253 Node* vfalse1 = value;
254
255 Node* merge1 = graph()->NewNode(merge_op, if_true1, if_false1);
256 efalse0 = graph()->NewNode(ephi_op, etrue1, efalse1, merge1);
257 vfalse0 = graph()->NewNode(phi_op, vtrue1, vfalse1, merge1);
258 }
259
260 Node* merge0 = graph()->NewNode(merge_op, if_true0, if_false0);
261
262 // Replace all effect uses of {node} with the {ephi0}.
263 Node* ephi0 = graph()->NewNode(ephi_op, etrue0, efalse0, merge0);
264 ReplaceWithValue(node, node, ephi0);
265
266 // Turn the {node} into a Phi.
267 return Change(node, phi_op, vtrue0, vfalse0, merge0);
268 }
269
270
271 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op) { 205 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op) {
272 // Replace all effect uses of {node} with the effect dependency. 206 // Replace all effect uses of {node} with the effect dependency.
273 RelaxEffectsAndControls(node); 207 RelaxEffectsAndControls(node);
274 // Remove the inputs corresponding to context, effect and control. 208 // Remove the inputs corresponding to context, effect and control.
275 NodeProperties::RemoveNonValueInputs(node); 209 NodeProperties::RemoveNonValueInputs(node);
276 // Finally update the operator to the new one. 210 // Finally update the operator to the new one.
277 NodeProperties::ChangeOp(node, op); 211 NodeProperties::ChangeOp(node, op);
278 return Changed(node); 212 return Changed(node);
279 } 213 }
280 214
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 413 }
480 414
481 415
482 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { 416 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const {
483 return jsgraph()->simplified(); 417 return jsgraph()->simplified();
484 } 418 }
485 419
486 } // namespace compiler 420 } // namespace compiler
487 } // namespace internal 421 } // namespace internal
488 } // namespace v8 422 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-intrinsic-lowering.h ('k') | src/crankshaft/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698