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

Side by Side Diff: src/interpreter/interpreter-generator.cc

Issue 2804813003: [turbofan] Collect and use type feedback on ToNumber. (Closed)
Patch Set: Address Michis feedback. Created 3 years, 8 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
OLDNEW
1 // Copyright 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 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/interpreter/interpreter-generator.h" 5 #include "src/interpreter/interpreter-generator.h"
6 6
7 #include <array> 7 #include <array>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "src/builtins/builtins-arguments-gen.h" 10 #include "src/builtins/builtins-arguments-gen.h"
(...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 // 1687 //
1688 // Convert the object referenced by the accumulator to a name. 1688 // Convert the object referenced by the accumulator to a name.
1689 void InterpreterGenerator::DoToName(InterpreterAssembler* assembler) { 1689 void InterpreterGenerator::DoToName(InterpreterAssembler* assembler) {
1690 Node* object = __ GetAccumulator(); 1690 Node* object = __ GetAccumulator();
1691 Node* context = __ GetContext(); 1691 Node* context = __ GetContext();
1692 Node* result = __ ToName(context, object); 1692 Node* result = __ ToName(context, object);
1693 __ StoreRegister(result, __ BytecodeOperandReg(0)); 1693 __ StoreRegister(result, __ BytecodeOperandReg(0));
1694 __ Dispatch(); 1694 __ Dispatch();
1695 } 1695 }
1696 1696
1697 // ToNumber 1697 // ToNumber <dst> <slot>
1698 // 1698 //
1699 // Convert the object referenced by the accumulator to a number. 1699 // Convert the object referenced by the accumulator to a number.
1700 void InterpreterGenerator::DoToNumber(InterpreterAssembler* assembler) { 1700 void InterpreterGenerator::DoToNumber(InterpreterAssembler* assembler) {
1701 Node* object = __ GetAccumulator(); 1701 Node* object = __ GetAccumulator();
1702 Node* context = __ GetContext(); 1702 Node* context = __ GetContext();
1703 Node* result = __ ToNumber(context, object); 1703
1704 __ StoreRegister(result, __ BytecodeOperandReg(0)); 1704 // Convert the {object} to a Number and collect feedback for the {object}.
1705 Variable var_type_feedback(assembler, MachineRepresentation::kTaggedSigned);
1706 Variable var_result(assembler, MachineRepresentation::kTagged);
1707 Label if_done(assembler), if_objectissmi(assembler),
1708 if_objectisnumber(assembler),
1709 if_objectisother(assembler, Label::kDeferred);
1710
1711 __ GotoIf(__ TaggedIsSmi(object), &if_objectissmi);
1712 Node* object_map = __ LoadMap(object);
1713 __ Branch(__ IsHeapNumberMap(object_map), &if_objectisnumber,
1714 &if_objectisother);
1715
1716 __ Bind(&if_objectissmi);
1717 {
1718 var_result.Bind(object);
1719 var_type_feedback.Bind(
1720 __ SmiConstant(BinaryOperationFeedback::kSignedSmall));
1721 __ Goto(&if_done);
1722 }
1723
1724 __ Bind(&if_objectisnumber);
1725 {
1726 var_result.Bind(object);
1727 var_type_feedback.Bind(__ SmiConstant(BinaryOperationFeedback::kNumber));
1728 __ Goto(&if_done);
1729 }
1730
1731 __ Bind(&if_objectisother);
1732 {
1733 // Convert the {object} to a Number.
1734 Callable callable = CodeFactory::NonNumberToNumber(assembler->isolate());
1735 var_result.Bind(__ CallStub(callable, context, object));
1736 var_type_feedback.Bind(__ SmiConstant(BinaryOperationFeedback::kAny));
1737 __ Goto(&if_done);
1738 }
1739
1740 __ Bind(&if_done);
1741 __ StoreRegister(var_result.value(), __ BytecodeOperandReg(0));
1742
1743 // Record the type feedback collected for {object}.
1744 Node* slot_index = __ BytecodeOperandIdx(1);
1745 Node* feedback_vector = __ LoadFeedbackVector();
1746 __ UpdateFeedback(var_type_feedback.value(), feedback_vector, slot_index);
1747
1705 __ Dispatch(); 1748 __ Dispatch();
1706 } 1749 }
1707 1750
1708 // ToObject 1751 // ToObject
1709 // 1752 //
1710 // Convert the object referenced by the accumulator to a JSReceiver. 1753 // Convert the object referenced by the accumulator to a JSReceiver.
1711 void InterpreterGenerator::DoToObject(InterpreterAssembler* assembler) { 1754 void InterpreterGenerator::DoToObject(InterpreterAssembler* assembler) {
1712 Node* result = BuildUnaryOp(CodeFactory::ToObject(isolate_), assembler); 1755 Node* result = BuildUnaryOp(CodeFactory::ToObject(isolate_), assembler);
1713 __ StoreRegister(result, __ BytecodeOperandReg(0)); 1756 __ StoreRegister(result, __ BytecodeOperandReg(0));
1714 __ Dispatch(); 1757 __ Dispatch();
(...skipping 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after
3596 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 3639 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
3597 __ SmiTag(new_state)); 3640 __ SmiTag(new_state));
3598 __ SetAccumulator(old_state); 3641 __ SetAccumulator(old_state);
3599 3642
3600 __ Dispatch(); 3643 __ Dispatch();
3601 } 3644 }
3602 3645
3603 } // namespace interpreter 3646 } // namespace interpreter
3604 } // namespace internal 3647 } // namespace internal
3605 } // namespace v8 3648 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | test/cctest/interpreter/bytecode_expectations/AssignmentsInBinaryExpression.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698