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

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

Issue 2063073004: [turbofan] Lower to NumberAdd / NumberSubtract if type feedback is Number. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@TurboFan_UnboxHoleyDouble
Patch Set: REBASE and fix. Created 4 years, 6 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 | « no previous file | no next file » | 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/compilation-dependencies.h" 6 #include "src/compilation-dependencies.h"
7 #include "src/compiler/access-builder.h" 7 #include "src/compiler/access-builder.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 397 }
398 } 398 }
399 399
400 400
401 Reduction JSTypedLowering::ReduceJSAdd(Node* node) { 401 Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
402 if (flags() & kDisableBinaryOpReduction) return NoChange(); 402 if (flags() & kDisableBinaryOpReduction) return NoChange();
403 403
404 JSBinopReduction r(this, node); 404 JSBinopReduction r(this, node);
405 405
406 BinaryOperationHints::Hint feedback = r.GetUsableNumberFeedback(); 406 BinaryOperationHints::Hint feedback = r.GetUsableNumberFeedback();
407 if (feedback == BinaryOperationHints::kNumberOrUndefined &&
408 r.BothInputsAre(Type::PlainPrimitive()) &&
409 r.NeitherInputCanBe(Type::StringOrReceiver())) {
410 // JSAdd(x:-string, y:-string) => NumberAdd(ToNumber(x), ToNumber(y))
411 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
412 r.ConvertInputsToNumber(frame_state);
413 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number());
414 }
407 if (feedback != BinaryOperationHints::kAny) { 415 if (feedback != BinaryOperationHints::kAny) {
408 // Lower to the optimistic number binop. 416 // Lower to the optimistic number binop.
409 return r.ChangeToSpeculativeOperator( 417 return r.ChangeToSpeculativeOperator(
410 simplified()->SpeculativeNumberAdd(feedback)); 418 simplified()->SpeculativeNumberAdd(feedback));
411 } 419 }
412 if (r.BothInputsAre(Type::Number())) { 420 if (r.BothInputsAre(Type::Number())) {
413 // JSAdd(x:number, y:number) => NumberAdd(x, y) 421 // JSAdd(x:number, y:number) => NumberAdd(x, y)
414 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); 422 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
415 r.ConvertInputsToNumber(frame_state); 423 r.ConvertInputsToNumber(frame_state);
416 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number()); 424 return r.ChangeToPureOperator(simplified()->NumberAdd(), Type::Number());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 return r.ChangeToPureOperator(simplified()->NumberModulus(), 463 return r.ChangeToPureOperator(simplified()->NumberModulus(),
456 Type::Number()); 464 Type::Number());
457 } 465 }
458 return NoChange(); 466 return NoChange();
459 } 467 }
460 468
461 Reduction JSTypedLowering::ReduceJSSubtract(Node* node) { 469 Reduction JSTypedLowering::ReduceJSSubtract(Node* node) {
462 if (flags() & kDisableBinaryOpReduction) return NoChange(); 470 if (flags() & kDisableBinaryOpReduction) return NoChange();
463 JSBinopReduction r(this, node); 471 JSBinopReduction r(this, node);
464 BinaryOperationHints::Hint feedback = r.GetUsableNumberFeedback(); 472 BinaryOperationHints::Hint feedback = r.GetUsableNumberFeedback();
473 if (feedback == BinaryOperationHints::kNumberOrUndefined &&
474 r.BothInputsAre(Type::PlainPrimitive())) {
475 // JSSubtract(x:plain-primitive, y:plain-primitive)
476 // => NumberSubtract(ToNumber(x), ToNumber(y))
477 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
478 r.ConvertInputsToNumber(frame_state);
479 return r.ChangeToPureOperator(simplified()->NumberSubtract(),
480 Type::Number());
481 }
465 if (feedback != BinaryOperationHints::kAny) { 482 if (feedback != BinaryOperationHints::kAny) {
466 // Lower to the optimistic number binop. 483 // Lower to the optimistic number binop.
467 return r.ChangeToSpeculativeOperator( 484 return r.ChangeToSpeculativeOperator(
468 simplified()->SpeculativeNumberSubtract(feedback)); 485 simplified()->SpeculativeNumberSubtract(feedback));
469 } 486 }
470 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); 487 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
471 r.ConvertInputsToNumber(frame_state); 488 r.ConvertInputsToNumber(frame_state);
472 return r.ChangeToPureOperator(simplified()->NumberSubtract(), Type::Number()); 489 return r.ChangeToPureOperator(simplified()->NumberSubtract(), Type::Number());
473 } 490 }
474 491
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 } 1964 }
1948 1965
1949 1966
1950 CompilationDependencies* JSTypedLowering::dependencies() const { 1967 CompilationDependencies* JSTypedLowering::dependencies() const {
1951 return dependencies_; 1968 return dependencies_;
1952 } 1969 }
1953 1970
1954 } // namespace compiler 1971 } // namespace compiler
1955 } // namespace internal 1972 } // namespace internal
1956 } // namespace v8 1973 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698