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

Side by Side Diff: src/compiler/bytecode-graph-builder.cc

Issue 2250513005: [interpreter] Record type feedback in the handlers for Inc and Dec. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added tests. Created 4 years, 4 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/bytecode-graph-builder.h ('k') | src/interpreter/interpreter.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/bytecode-graph-builder.h" 5 #include "src/compiler/bytecode-graph-builder.h"
6 6
7 #include "src/compiler/bytecode-branch-analysis.h" 7 #include "src/compiler/bytecode-branch-analysis.h"
8 #include "src/compiler/linkage.h" 8 #include "src/compiler/linkage.h"
9 #include "src/compiler/operator-properties.h" 9 #include "src/compiler/operator-properties.h"
10 #include "src/interpreter/bytecodes.h" 10 #include "src/interpreter/bytecodes.h"
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(1)); 1208 feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(1));
1209 DCHECK_EQ(FeedbackVectorSlotKind::GENERAL, feedback_vector()->GetKind(slot)); 1209 DCHECK_EQ(FeedbackVectorSlotKind::GENERAL, feedback_vector()->GetKind(slot));
1210 Object* feedback = feedback_vector()->Get(slot); 1210 Object* feedback = feedback_vector()->Get(slot);
1211 BinaryOperationHint hint = BinaryOperationHint::kAny; 1211 BinaryOperationHint hint = BinaryOperationHint::kAny;
1212 if (feedback->IsSmi()) { 1212 if (feedback->IsSmi()) {
1213 hint = BinaryOperationHintFromFeedback((Smi::cast(feedback))->value()); 1213 hint = BinaryOperationHintFromFeedback((Smi::cast(feedback))->value());
1214 } 1214 }
1215 return hint; 1215 return hint;
1216 } 1216 }
1217 1217
1218 BinaryOperationHint BytecodeGraphBuilder::GetBinaryOperationHintForIncDec() {
1219 FeedbackVectorSlot slot =
1220 feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(0));
1221 DCHECK_EQ(FeedbackVectorSlotKind::GENERAL, feedback_vector()->GetKind(slot));
1222 Object* feedback = feedback_vector()->Get(slot);
1223 BinaryOperationHint hint = BinaryOperationHint::kAny;
1224 if (feedback->IsSmi()) {
1225 hint = BinaryOperationHintFromFeedback((Smi::cast(feedback))->value());
1226 }
1227 return hint;
1228 }
1229
1218 void BytecodeGraphBuilder::VisitAdd() { 1230 void BytecodeGraphBuilder::VisitAdd() {
1219 BuildBinaryOp(javascript()->Add(GetBinaryOperationHint())); 1231 BuildBinaryOp(javascript()->Add(GetBinaryOperationHint()));
1220 } 1232 }
1221 1233
1222 void BytecodeGraphBuilder::VisitSub() { 1234 void BytecodeGraphBuilder::VisitSub() {
1223 BuildBinaryOp(javascript()->Subtract(GetBinaryOperationHint())); 1235 BuildBinaryOp(javascript()->Subtract(GetBinaryOperationHint()));
1224 } 1236 }
1225 1237
1226 void BytecodeGraphBuilder::VisitMul() { 1238 void BytecodeGraphBuilder::VisitMul() {
1227 BuildBinaryOp(javascript()->Multiply(GetBinaryOperationHint())); 1239 BuildBinaryOp(javascript()->Multiply(GetBinaryOperationHint()));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 1307
1296 void BytecodeGraphBuilder::VisitShiftRightSmi() { 1308 void BytecodeGraphBuilder::VisitShiftRightSmi() {
1297 BinaryOperationHint hint = BinaryOperationHint::kAny; 1309 BinaryOperationHint hint = BinaryOperationHint::kAny;
1298 BuildBinaryOpWithImmediate(javascript()->ShiftRight(hint)); 1310 BuildBinaryOpWithImmediate(javascript()->ShiftRight(hint));
1299 } 1311 }
1300 1312
1301 void BytecodeGraphBuilder::VisitInc() { 1313 void BytecodeGraphBuilder::VisitInc() {
1302 FrameStateBeforeAndAfter states(this); 1314 FrameStateBeforeAndAfter states(this);
1303 // Note: Use subtract -1 here instead of add 1 to ensure we always convert to 1315 // Note: Use subtract -1 here instead of add 1 to ensure we always convert to
1304 // a number, not a string. 1316 // a number, not a string.
1305 const Operator* js_op = javascript()->Subtract(BinaryOperationHint::kAny); 1317 const Operator* js_op =
1318 javascript()->Subtract(GetBinaryOperationHintForIncDec());
1306 Node* node = NewNode(js_op, environment()->LookupAccumulator(), 1319 Node* node = NewNode(js_op, environment()->LookupAccumulator(),
1307 jsgraph()->Constant(-1.0)); 1320 jsgraph()->Constant(-1));
1308 environment()->BindAccumulator(node, &states); 1321 environment()->BindAccumulator(node, &states);
1309 } 1322 }
1310 1323
1311 void BytecodeGraphBuilder::VisitDec() { 1324 void BytecodeGraphBuilder::VisitDec() {
1312 FrameStateBeforeAndAfter states(this); 1325 FrameStateBeforeAndAfter states(this);
1313 const Operator* js_op = javascript()->Subtract(BinaryOperationHint::kAny); 1326 const Operator* js_op =
1327 javascript()->Subtract(GetBinaryOperationHintForIncDec());
1314 Node* node = NewNode(js_op, environment()->LookupAccumulator(), 1328 Node* node = NewNode(js_op, environment()->LookupAccumulator(),
1315 jsgraph()->OneConstant()); 1329 jsgraph()->OneConstant());
1316 environment()->BindAccumulator(node, &states); 1330 environment()->BindAccumulator(node, &states);
1317 } 1331 }
1318 1332
1319 void BytecodeGraphBuilder::VisitLogicalNot() { 1333 void BytecodeGraphBuilder::VisitLogicalNot() {
1320 Node* value = environment()->LookupAccumulator(); 1334 Node* value = environment()->LookupAccumulator();
1321 Node* node = NewNode(common()->Select(MachineRepresentation::kTagged), value, 1335 Node* node = NewNode(common()->Select(MachineRepresentation::kTagged), value,
1322 jsgraph()->FalseConstant(), jsgraph()->TrueConstant()); 1336 jsgraph()->FalseConstant(), jsgraph()->TrueConstant());
1323 environment()->BindAccumulator(node); 1337 environment()->BindAccumulator(node);
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1916 // Phi does not exist yet, introduce one. 1930 // Phi does not exist yet, introduce one.
1917 value = NewPhi(inputs, value, control); 1931 value = NewPhi(inputs, value, control);
1918 value->ReplaceInput(inputs - 1, other); 1932 value->ReplaceInput(inputs - 1, other);
1919 } 1933 }
1920 return value; 1934 return value;
1921 } 1935 }
1922 1936
1923 } // namespace compiler 1937 } // namespace compiler
1924 } // namespace internal 1938 } // namespace internal
1925 } // namespace v8 1939 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/bytecode-graph-builder.h ('k') | src/interpreter/interpreter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698