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

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

Issue 1109223004: [strong] Disallow implicit conversions for add (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cl feedback Created 5 years, 7 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/code-stubs-hydrogen.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/js-typed-lowering.h" 8 #include "src/compiler/js-typed-lowering.h"
9 #include "src/compiler/linkage.h" 9 #include "src/compiler/linkage.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 } 313 }
314 }; 314 };
315 315
316 316
317 Reduction JSTypedLowering::ReduceJSAdd(Node* node) { 317 Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
318 JSBinopReduction r(this, node); 318 JSBinopReduction r(this, node);
319 if (r.BothInputsAre(Type::Number())) { 319 if (r.BothInputsAre(Type::Number())) {
320 // JSAdd(x:number, y:number) => NumberAdd(x, y) 320 // JSAdd(x:number, y:number) => NumberAdd(x, y)
321 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number()); 321 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number());
322 } 322 }
323 if (r.NeitherInputCanBe(Type::StringOrReceiver())) { 323 if (r.NeitherInputCanBe(Type::StringOrReceiver()) &&
324 !is_strong(OpParameter<LanguageMode>(node))) {
Michael Starzinger 2015/04/30 09:25:56 nit: Please add JSBinopReduction::IsStrong to have
conradw 2015/04/30 09:46:04 Done.
324 // JSAdd(x:-string, y:-string) => NumberAdd(ToNumber(x), ToNumber(y)) 325 // JSAdd(x:-string, y:-string) => NumberAdd(ToNumber(x), ToNumber(y))
325 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); 326 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
326 r.ConvertInputsToNumber(frame_state); 327 r.ConvertInputsToNumber(frame_state);
327 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number()); 328 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number());
328 } 329 }
329 #if 0 330 #if 0
330 // TODO(turbofan): Lowering of StringAdd is disabled for now because: 331 // TODO(turbofan): Lowering of StringAdd is disabled for now because:
331 // a) The inserted ToString operation screws up valueOf vs. toString order. 332 // a) The inserted ToString operation screws up valueOf vs. toString order.
332 // b) Deoptimization at ToString doesn't have corresponding bailout id. 333 // b) Deoptimization at ToString doesn't have corresponding bailout id.
333 // c) Our current StringAddStub is actually non-pure and requires context. 334 // c) Our current StringAddStub is actually non-pure and requires context.
334 if (r.OneInputIs(Type::String())) { 335 if (r.OneInputIs(Type::String()) &&
336 (!is_strong(OpParameter<LanguageMode>(node)) ||
337 r.BothInputsAre(Type::String()))) {
335 // JSAdd(x:string, y:string) => StringAdd(x, y) 338 // JSAdd(x:string, y:string) => StringAdd(x, y)
336 // JSAdd(x:string, y) => StringAdd(x, ToString(y)) 339 // JSAdd(x:string, y) => StringAdd(x, ToString(y))
337 // JSAdd(x, y:string) => StringAdd(ToString(x), y) 340 // JSAdd(x, y:string) => StringAdd(ToString(x), y)
338 r.ConvertInputsToString(); 341 r.ConvertInputsToString();
339 return r.ChangeToPureOperator(simplified()->StringAdd()); 342 return r.ChangeToPureOperator(simplified()->StringAdd());
340 } 343 }
341 #endif 344 #endif
342 return NoChange(); 345 return NoChange();
343 } 346 }
344 347
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 } 1180 }
1178 1181
1179 1182
1180 MachineOperatorBuilder* JSTypedLowering::machine() const { 1183 MachineOperatorBuilder* JSTypedLowering::machine() const {
1181 return jsgraph()->machine(); 1184 return jsgraph()->machine();
1182 } 1185 }
1183 1186
1184 } // namespace compiler 1187 } // namespace compiler
1185 } // namespace internal 1188 } // namespace internal
1186 } // namespace v8 1189 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698