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

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

Issue 23219002: Add double unary operation (negate). (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
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 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 Definition::kEffect); 1213 Definition::kEffect);
1214 unary_op = new UnarySmiOpInstr(op_kind, new Value(input), call->deopt_id()); 1214 unary_op = new UnarySmiOpInstr(op_kind, new Value(input), call->deopt_id());
1215 } else if ((op_kind == Token::kBIT_NOT) && 1215 } else if ((op_kind == Token::kBIT_NOT) &&
1216 HasOnlySmiOrMint(*call->ic_data()) && 1216 HasOnlySmiOrMint(*call->ic_data()) &&
1217 FlowGraphCompiler::SupportsUnboxedMints()) { 1217 FlowGraphCompiler::SupportsUnboxedMints()) {
1218 unary_op = new UnaryMintOpInstr( 1218 unary_op = new UnaryMintOpInstr(
1219 op_kind, new Value(input), call->deopt_id()); 1219 op_kind, new Value(input), call->deopt_id());
1220 } else if (HasOnlyOneDouble(*call->ic_data()) && 1220 } else if (HasOnlyOneDouble(*call->ic_data()) &&
1221 (op_kind == Token::kNEGATE)) { 1221 (op_kind == Token::kNEGATE)) {
1222 AddReceiverCheck(call); 1222 AddReceiverCheck(call);
1223 ConstantInstr* minus_one = 1223 unary_op = new UnaryDoubleOpInstr(
1224 flow_graph()->GetConstant(Double::ZoneHandle(Double::NewCanonical(-1))); 1224 Token::kNEGATE, new Value(input), call->deopt_id());
1225 unary_op = new BinaryDoubleOpInstr(Token::kMUL, 1225 } else {
1226 new Value(input), 1226 return false;
1227 new Value(minus_one),
1228 call->deopt_id());
1229 } 1227 }
1230 if (unary_op == NULL) return false; 1228 ASSERT(unary_op != NULL);
1231
1232 ReplaceCall(call, unary_op); 1229 ReplaceCall(call, unary_op);
1233 return true; 1230 return true;
1234 } 1231 }
1235 1232
1236 1233
1237 // Using field class 1234 // Using field class
1238 static RawField* GetField(intptr_t class_id, const String& field_name) { 1235 static RawField* GetField(intptr_t class_id, const String& field_name) {
1239 Class& cls = Class::Handle(Isolate::Current()->class_table()->At(class_id)); 1236 Class& cls = Class::Handle(Isolate::Current()->class_table()->At(class_id));
1240 Field& field = Field::Handle(); 1237 Field& field = Field::Handle();
1241 while (!cls.IsNull()) { 1238 while (!cls.IsNull()) {
(...skipping 5107 matching lines...) Expand 10 before | Expand all | Expand 10 after
6349 const Object& value = instr->value()->definition()->constant_value(); 6346 const Object& value = instr->value()->definition()->constant_value();
6350 if (IsNonConstant(value)) { 6347 if (IsNonConstant(value)) {
6351 SetValue(instr, non_constant_); 6348 SetValue(instr, non_constant_);
6352 } else if (IsConstant(value)) { 6349 } else if (IsConstant(value)) {
6353 // TODO(kmillikin): Handle unary operations. 6350 // TODO(kmillikin): Handle unary operations.
6354 SetValue(instr, non_constant_); 6351 SetValue(instr, non_constant_);
6355 } 6352 }
6356 } 6353 }
6357 6354
6358 6355
6356 void ConstantPropagator::VisitUnaryDoubleOp(UnaryDoubleOpInstr* instr) {
6357 const Object& value = instr->value()->definition()->constant_value();
6358 if (IsNonConstant(value)) {
6359 SetValue(instr, non_constant_);
6360 } else if (IsConstant(value)) {
6361 // TODO(kmillikin): Handle unary operations.
6362 SetValue(instr, non_constant_);
6363 }
6364 }
6365
6366
6359 void ConstantPropagator::VisitSmiToDouble(SmiToDoubleInstr* instr) { 6367 void ConstantPropagator::VisitSmiToDouble(SmiToDoubleInstr* instr) {
6360 const Object& value = instr->value()->definition()->constant_value(); 6368 const Object& value = instr->value()->definition()->constant_value();
6361 if (IsConstant(value) && value.IsInteger()) { 6369 if (IsConstant(value) && value.IsInteger()) {
6362 SetValue(instr, Double::Handle( 6370 SetValue(instr, Double::Handle(
6363 Double::New(Integer::Cast(value).AsDoubleValue(), Heap::kOld))); 6371 Double::New(Integer::Cast(value).AsDoubleValue(), Heap::kOld)));
6364 } else if (IsNonConstant(value)) { 6372 } else if (IsNonConstant(value)) {
6365 SetValue(instr, non_constant_); 6373 SetValue(instr, non_constant_);
6366 } 6374 }
6367 } 6375 }
6368 6376
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
7470 } 7478 }
7471 7479
7472 // Insert materializations at environment uses. 7480 // Insert materializations at environment uses.
7473 for (intptr_t i = 0; i < exits.length(); i++) { 7481 for (intptr_t i = 0; i < exits.length(); i++) {
7474 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); 7482 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields);
7475 } 7483 }
7476 } 7484 }
7477 7485
7478 7486
7479 } // namespace dart 7487 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_type_propagator.cc » ('j') | runtime/vm/intermediate_language_mips.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698