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

Side by Side Diff: runtime/vm/flow_graph_optimizer.cc

Issue 22999011: Add double unary operation (negate). This is a replica of the destrpyed CL https://chromiumcoderevi… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/flow_graph_type_propagator.cc » ('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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 Definition::kEffect); 1229 Definition::kEffect);
1230 unary_op = new UnarySmiOpInstr(op_kind, new Value(input), call->deopt_id()); 1230 unary_op = new UnarySmiOpInstr(op_kind, new Value(input), call->deopt_id());
1231 } else if ((op_kind == Token::kBIT_NOT) && 1231 } else if ((op_kind == Token::kBIT_NOT) &&
1232 HasOnlySmiOrMint(*call->ic_data()) && 1232 HasOnlySmiOrMint(*call->ic_data()) &&
1233 FlowGraphCompiler::SupportsUnboxedMints()) { 1233 FlowGraphCompiler::SupportsUnboxedMints()) {
1234 unary_op = new UnaryMintOpInstr( 1234 unary_op = new UnaryMintOpInstr(
1235 op_kind, new Value(input), call->deopt_id()); 1235 op_kind, new Value(input), call->deopt_id());
1236 } else if (HasOnlyOneDouble(*call->ic_data()) && 1236 } else if (HasOnlyOneDouble(*call->ic_data()) &&
1237 (op_kind == Token::kNEGATE)) { 1237 (op_kind == Token::kNEGATE)) {
1238 AddReceiverCheck(call); 1238 AddReceiverCheck(call);
1239 ConstantInstr* minus_one = 1239 unary_op = new UnaryDoubleOpInstr(
1240 flow_graph()->GetConstant(Double::ZoneHandle(Double::NewCanonical(-1))); 1240 Token::kNEGATE, new Value(input), call->deopt_id());
1241 unary_op = new BinaryDoubleOpInstr(Token::kMUL, 1241 } else {
1242 new Value(input), 1242 return false;
1243 new Value(minus_one),
1244 call->deopt_id());
1245 } 1243 }
1246 if (unary_op == NULL) return false; 1244 ASSERT(unary_op != NULL);
1247
1248 ReplaceCall(call, unary_op); 1245 ReplaceCall(call, unary_op);
1249 return true; 1246 return true;
1250 } 1247 }
1251 1248
1252 1249
1253 // Using field class 1250 // Using field class
1254 static RawField* GetField(intptr_t class_id, const String& field_name) { 1251 static RawField* GetField(intptr_t class_id, const String& field_name) {
1255 Class& cls = Class::Handle(Isolate::Current()->class_table()->At(class_id)); 1252 Class& cls = Class::Handle(Isolate::Current()->class_table()->At(class_id));
1256 Field& field = Field::Handle(); 1253 Field& field = Field::Handle();
1257 while (!cls.IsNull()) { 1254 while (!cls.IsNull()) {
(...skipping 5107 matching lines...) Expand 10 before | Expand all | Expand 10 after
6365 const Object& value = instr->value()->definition()->constant_value(); 6362 const Object& value = instr->value()->definition()->constant_value();
6366 if (IsNonConstant(value)) { 6363 if (IsNonConstant(value)) {
6367 SetValue(instr, non_constant_); 6364 SetValue(instr, non_constant_);
6368 } else if (IsConstant(value)) { 6365 } else if (IsConstant(value)) {
6369 // TODO(kmillikin): Handle unary operations. 6366 // TODO(kmillikin): Handle unary operations.
6370 SetValue(instr, non_constant_); 6367 SetValue(instr, non_constant_);
6371 } 6368 }
6372 } 6369 }
6373 6370
6374 6371
6372 void ConstantPropagator::VisitUnaryDoubleOp(UnaryDoubleOpInstr* instr) {
6373 const Object& value = instr->value()->definition()->constant_value();
6374 if (IsNonConstant(value)) {
6375 SetValue(instr, non_constant_);
6376 } else if (IsConstant(value)) {
6377 // TODO(kmillikin): Handle unary operations.
6378 SetValue(instr, non_constant_);
6379 }
6380 }
6381
6382
6375 void ConstantPropagator::VisitSmiToDouble(SmiToDoubleInstr* instr) { 6383 void ConstantPropagator::VisitSmiToDouble(SmiToDoubleInstr* instr) {
6376 const Object& value = instr->value()->definition()->constant_value(); 6384 const Object& value = instr->value()->definition()->constant_value();
6377 if (IsConstant(value) && value.IsInteger()) { 6385 if (IsConstant(value) && value.IsInteger()) {
6378 SetValue(instr, Double::Handle( 6386 SetValue(instr, Double::Handle(
6379 Double::New(Integer::Cast(value).AsDoubleValue(), Heap::kOld))); 6387 Double::New(Integer::Cast(value).AsDoubleValue(), Heap::kOld)));
6380 } else if (IsNonConstant(value)) { 6388 } else if (IsNonConstant(value)) {
6381 SetValue(instr, non_constant_); 6389 SetValue(instr, non_constant_);
6382 } 6390 }
6383 } 6391 }
6384 6392
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
7486 } 7494 }
7487 7495
7488 // Insert materializations at environment uses. 7496 // Insert materializations at environment uses.
7489 for (intptr_t i = 0; i < exits.length(); i++) { 7497 for (intptr_t i = 0; i < exits.length(); i++) {
7490 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); 7498 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields);
7491 } 7499 }
7492 } 7500 }
7493 7501
7494 7502
7495 } // namespace dart 7503 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698