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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/interpreter/interpreter-generator.cc
diff --git a/src/interpreter/interpreter-generator.cc b/src/interpreter/interpreter-generator.cc
index 8f673bb80820ffe6c8c6e19144bc3b2de332f4f3..c826b53314f9372b9068a5d4de9d1f95dadaa75d 100644
--- a/src/interpreter/interpreter-generator.cc
+++ b/src/interpreter/interpreter-generator.cc
@@ -1694,14 +1694,57 @@ void InterpreterGenerator::DoToName(InterpreterAssembler* assembler) {
__ Dispatch();
}
-// ToNumber
+// ToNumber <dst> <slot>
//
// Convert the object referenced by the accumulator to a number.
void InterpreterGenerator::DoToNumber(InterpreterAssembler* assembler) {
Node* object = __ GetAccumulator();
Node* context = __ GetContext();
- Node* result = __ ToNumber(context, object);
- __ StoreRegister(result, __ BytecodeOperandReg(0));
+
+ // Convert the {object} to a Number and collect feedback for the {object}.
+ Variable var_type_feedback(assembler, MachineRepresentation::kTaggedSigned);
+ Variable var_result(assembler, MachineRepresentation::kTagged);
+ Label if_done(assembler), if_objectissmi(assembler),
+ if_objectisnumber(assembler),
+ if_objectisother(assembler, Label::kDeferred);
+
+ __ GotoIf(__ TaggedIsSmi(object), &if_objectissmi);
+ Node* object_map = __ LoadMap(object);
+ __ Branch(__ IsHeapNumberMap(object_map), &if_objectisnumber,
+ &if_objectisother);
+
+ __ Bind(&if_objectissmi);
+ {
+ var_result.Bind(object);
+ var_type_feedback.Bind(
+ __ SmiConstant(BinaryOperationFeedback::kSignedSmall));
+ __ Goto(&if_done);
+ }
+
+ __ Bind(&if_objectisnumber);
+ {
+ var_result.Bind(object);
+ var_type_feedback.Bind(__ SmiConstant(BinaryOperationFeedback::kNumber));
+ __ Goto(&if_done);
+ }
+
+ __ Bind(&if_objectisother);
+ {
+ // Convert the {object} to a Number.
+ Callable callable = CodeFactory::NonNumberToNumber(assembler->isolate());
+ var_result.Bind(__ CallStub(callable, context, object));
+ var_type_feedback.Bind(__ SmiConstant(BinaryOperationFeedback::kAny));
+ __ Goto(&if_done);
+ }
+
+ __ Bind(&if_done);
+ __ StoreRegister(var_result.value(), __ BytecodeOperandReg(0));
+
+ // Record the type feedback collected for {object}.
+ Node* slot_index = __ BytecodeOperandIdx(1);
+ Node* feedback_vector = __ LoadFeedbackVector();
+ __ UpdateFeedback(var_type_feedback.value(), feedback_vector, slot_index);
+
__ Dispatch();
}
« 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