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

Side by Side Diff: src/hydrogen.cc

Issue 6969034: Made the output of the --trace-representation flag a bit more informative and (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 7 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 | « src/hydrogen.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4676 matching lines...) Expand 10 before | Expand all | Expand 10 after
4687 } 4687 }
4688 4688
4689 4689
4690 HInstruction* HGraphBuilder::BuildIncrement(HValue* value, 4690 HInstruction* HGraphBuilder::BuildIncrement(HValue* value,
4691 bool increment, 4691 bool increment,
4692 CountOperation* expr) { 4692 CountOperation* expr) {
4693 HConstant* delta = increment 4693 HConstant* delta = increment
4694 ? graph_->GetConstant1() 4694 ? graph_->GetConstant1()
4695 : graph_->GetConstantMinus1(); 4695 : graph_->GetConstantMinus1();
4696 HInstruction* instr = new(zone()) HAdd(value, delta); 4696 HInstruction* instr = new(zone()) HAdd(value, delta);
4697 Representation rep = ToRepresentation(oracle()->IncrementType(expr)); 4697 TypeInfo info = oracle()->IncrementType(expr);
4698 Representation rep = ToRepresentation(info);
4698 if (rep.IsTagged()) { 4699 if (rep.IsTagged()) {
4699 rep = Representation::Integer32(); 4700 rep = Representation::Integer32();
4700 } 4701 }
4702 TraceRepresentation(expr->op(), info, instr, rep);
4701 AssumeRepresentation(instr, rep); 4703 AssumeRepresentation(instr, rep);
4702 return instr; 4704 return instr;
4703 } 4705 }
4704 4706
4705 4707
4706 void HGraphBuilder::VisitCountOperation(CountOperation* expr) { 4708 void HGraphBuilder::VisitCountOperation(CountOperation* expr) {
4707 ASSERT(!HasStackOverflow()); 4709 ASSERT(!HasStackOverflow());
4708 ASSERT(current_block() != NULL); 4710 ASSERT(current_block() != NULL);
4709 ASSERT(current_block()->HasPredecessor()); 4711 ASSERT(current_block()->HasPredecessor());
4710 Expression* target = expr->expression(); 4712 Expression* target = expr->expression();
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
4863 TypeInfo info = oracle()->BinaryType(expr); 4865 TypeInfo info = oracle()->BinaryType(expr);
4864 HInstruction* instr = BuildBinaryOperation(expr->op(), left, right, info); 4866 HInstruction* instr = BuildBinaryOperation(expr->op(), left, right, info);
4865 // If we hit an uninitialized binary op stub we will get type info 4867 // If we hit an uninitialized binary op stub we will get type info
4866 // for a smi operation. If one of the operands is a constant string 4868 // for a smi operation. If one of the operands is a constant string
4867 // do not generate code assuming it is a smi operation. 4869 // do not generate code assuming it is a smi operation.
4868 if (info.IsSmi() && 4870 if (info.IsSmi() &&
4869 ((left->IsConstant() && HConstant::cast(left)->HasStringValue()) || 4871 ((left->IsConstant() && HConstant::cast(left)->HasStringValue()) ||
4870 (right->IsConstant() && HConstant::cast(right)->HasStringValue()))) { 4872 (right->IsConstant() && HConstant::cast(right)->HasStringValue()))) {
4871 return instr; 4873 return instr;
4872 } 4874 }
4873 if (FLAG_trace_representation) {
4874 PrintF("Info: %s/%s\n", info.ToString(), ToRepresentation(info).Mnemonic());
4875 }
4876 Representation rep = ToRepresentation(info); 4875 Representation rep = ToRepresentation(info);
4877 // We only generate either int32 or generic tagged bitwise operations. 4876 // We only generate either int32 or generic tagged bitwise operations.
4878 if (instr->IsBitwiseBinaryOperation() && rep.IsDouble()) { 4877 if (instr->IsBitwiseBinaryOperation() && rep.IsDouble()) {
4879 rep = Representation::Integer32(); 4878 rep = Representation::Integer32();
4880 } 4879 }
4880 TraceRepresentation(expr->op(), info, instr, rep);
4881 AssumeRepresentation(instr, rep); 4881 AssumeRepresentation(instr, rep);
4882 return instr; 4882 return instr;
4883 } 4883 }
4884 4884
4885 4885
4886 HInstruction* HGraphBuilder::BuildBinaryOperation( 4886 HInstruction* HGraphBuilder::BuildBinaryOperation(
4887 Token::Value op, HValue* left, HValue* right, TypeInfo info) { 4887 Token::Value op, HValue* left, HValue* right, TypeInfo info) {
4888 switch (op) { 4888 switch (op) {
4889 case Token::ADD: 4889 case Token::ADD:
4890 if (info.IsString()) { 4890 if (info.IsString()) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
5039 CHECK_ALIVE(VisitForValue(expr->left())); 5039 CHECK_ALIVE(VisitForValue(expr->left()));
5040 CHECK_ALIVE(VisitForValue(expr->right())); 5040 CHECK_ALIVE(VisitForValue(expr->right()));
5041 HValue* right = Pop(); 5041 HValue* right = Pop();
5042 HValue* left = Pop(); 5042 HValue* left = Pop();
5043 HInstruction* instr = BuildBinaryOperation(expr, left, right); 5043 HInstruction* instr = BuildBinaryOperation(expr, left, right);
5044 instr->set_position(expr->position()); 5044 instr->set_position(expr->position());
5045 ast_context()->ReturnInstruction(instr, expr->id()); 5045 ast_context()->ReturnInstruction(instr, expr->id());
5046 } 5046 }
5047 5047
5048 5048
5049 void HGraphBuilder::AssumeRepresentation(HValue* value, Representation r) { 5049 void HGraphBuilder::TraceRepresentation(Token::Value op,
5050 TypeInfo info,
5051 HValue* value,
5052 Representation rep) {
5053 if (!FLAG_trace_representation) return;
5054 // TODO(svenpanne) Under which circumstances are we actually not flexible?
5055 // At first glance, this looks a bit weird...
5056 bool flexible = value->CheckFlag(HValue::kFlexibleRepresentation);
5057 PrintF("Operation %s has type info %s, %schange representation assumption "
5058 "for %s (ID %d) from %s to %s\n",
5059 Token::Name(op),
5060 info.ToString(),
5061 flexible ? "" : " DO NOT ",
5062 value->Mnemonic(),
5063 graph_->GetMaximumValueID(),
5064 value->representation().Mnemonic(),
5065 rep.Mnemonic());
5066 }
5067
5068
5069 void HGraphBuilder::AssumeRepresentation(HValue* value, Representation rep) {
5050 if (value->CheckFlag(HValue::kFlexibleRepresentation)) { 5070 if (value->CheckFlag(HValue::kFlexibleRepresentation)) {
5051 if (FLAG_trace_representation) { 5071 value->ChangeRepresentation(rep);
5052 PrintF("Assume representation for %s to be %s (%d)\n",
5053 value->Mnemonic(),
5054 r.Mnemonic(),
5055 graph_->GetMaximumValueID());
5056 }
5057 value->ChangeRepresentation(r);
5058 // The representation of the value is dictated by type feedback and 5072 // The representation of the value is dictated by type feedback and
5059 // will not be changed later. 5073 // will not be changed later.
5060 value->ClearFlag(HValue::kFlexibleRepresentation); 5074 value->ClearFlag(HValue::kFlexibleRepresentation);
5061 } else if (FLAG_trace_representation) {
5062 PrintF("No representation assumed\n");
5063 } 5075 }
5064 } 5076 }
5065 5077
5066 5078
5067 Representation HGraphBuilder::ToRepresentation(TypeInfo info) { 5079 Representation HGraphBuilder::ToRepresentation(TypeInfo info) {
5068 if (info.IsSmi()) return Representation::Integer32(); 5080 if (info.IsSmi()) return Representation::Integer32();
5069 if (info.IsInteger32()) return Representation::Integer32(); 5081 if (info.IsInteger32()) return Representation::Integer32();
5070 if (info.IsDouble()) return Representation::Double(); 5082 if (info.IsDouble()) return Representation::Double();
5071 if (info.IsNumber()) return Representation::Double(); 5083 if (info.IsNumber()) return Representation::Double();
5072 return Representation::Tagged(); 5084 return Representation::Tagged();
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
6120 } 6132 }
6121 } 6133 }
6122 6134
6123 #ifdef DEBUG 6135 #ifdef DEBUG
6124 if (graph_ != NULL) graph_->Verify(); 6136 if (graph_ != NULL) graph_->Verify();
6125 if (allocator_ != NULL) allocator_->Verify(); 6137 if (allocator_ != NULL) allocator_->Verify();
6126 #endif 6138 #endif
6127 } 6139 }
6128 6140
6129 } } // namespace v8::internal 6141 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698