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 49203002: Improvements in positions handling in optimizing compiler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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 | src/hydrogen-instructions.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 8101 matching lines...) Expand 10 before | Expand all | Expand 10 after
8112 set_current_block(join_block); 8112 set_current_block(join_block);
8113 // We did not materialize any value in the predecessor environments, 8113 // We did not materialize any value in the predecessor environments,
8114 // so there is no need to handle it here. 8114 // so there is no need to handle it here.
8115 } 8115 }
8116 } 8116 }
8117 8117
8118 8118
8119 void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) { 8119 void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) {
8120 CHECK_ALIVE(VisitForValue(expr->left())); 8120 CHECK_ALIVE(VisitForValue(expr->left()));
8121 CHECK_ALIVE(VisitForValue(expr->right())); 8121 CHECK_ALIVE(VisitForValue(expr->right()));
8122 if (!FLAG_emit_opt_code_positions) SetSourcePosition(expr->position()); 8122 SetSourcePosition(expr->position());
8123 HValue* right = Pop(); 8123 HValue* right = Pop();
8124 HValue* left = Pop(); 8124 HValue* left = Pop();
8125 HInstruction* instr = BuildBinaryOperation(expr, left, right); 8125 HInstruction* instr = BuildBinaryOperation(expr, left, right);
8126 if (FLAG_emit_opt_code_positions && instr->IsBinaryOperation()) {
8127 HBinaryOperation::cast(instr)->SetOperandPositions(
8128 zone(), expr->left()->position(), expr->right()->position());
8129 }
8126 return ast_context()->ReturnInstruction(instr, expr->id()); 8130 return ast_context()->ReturnInstruction(instr, expr->id());
8127 } 8131 }
8128 8132
8129 8133
8130 void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr, 8134 void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr,
8131 Expression* sub_expr, 8135 Expression* sub_expr,
8132 Handle<String> check) { 8136 Handle<String> check) {
8133 CHECK_ALIVE(VisitForTypeOf(sub_expr)); 8137 CHECK_ALIVE(VisitForTypeOf(sub_expr));
8134 if (!FLAG_emit_opt_code_positions) SetSourcePosition(expr->position()); 8138 SetSourcePosition(expr->position());
8135 HValue* value = Pop(); 8139 HValue* value = Pop();
8136 HTypeofIsAndBranch* instr = new(zone()) HTypeofIsAndBranch(value, check); 8140 HTypeofIsAndBranch* instr = new(zone()) HTypeofIsAndBranch(value, check);
8137 return ast_context()->ReturnControl(instr, expr->id()); 8141 return ast_context()->ReturnControl(instr, expr->id());
8138 } 8142 }
8139 8143
8140 8144
8141 static bool IsLiteralCompareBool(Isolate* isolate, 8145 static bool IsLiteralCompareBool(Isolate* isolate,
8142 HValue* left, 8146 HValue* left,
8143 Token::Value op, 8147 Token::Value op,
8144 HValue* right) { 8148 HValue* right) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
8187 Handle<Type> left_type = expr->left()->bounds().lower; 8191 Handle<Type> left_type = expr->left()->bounds().lower;
8188 Handle<Type> right_type = expr->right()->bounds().lower; 8192 Handle<Type> right_type = expr->right()->bounds().lower;
8189 Handle<Type> combined_type = expr->combined_type(); 8193 Handle<Type> combined_type = expr->combined_type();
8190 Representation combined_rep = Representation::FromType(combined_type); 8194 Representation combined_rep = Representation::FromType(combined_type);
8191 Representation left_rep = Representation::FromType(left_type); 8195 Representation left_rep = Representation::FromType(left_type);
8192 Representation right_rep = Representation::FromType(right_type); 8196 Representation right_rep = Representation::FromType(right_type);
8193 8197
8194 CHECK_ALIVE(VisitForValue(expr->left())); 8198 CHECK_ALIVE(VisitForValue(expr->left()));
8195 CHECK_ALIVE(VisitForValue(expr->right())); 8199 CHECK_ALIVE(VisitForValue(expr->right()));
8196 8200
8201 if (FLAG_emit_opt_code_positions) SetSourcePosition(expr->position());
8202
8197 HValue* context = environment()->context(); 8203 HValue* context = environment()->context();
8198 HValue* right = Pop(); 8204 HValue* right = Pop();
8199 HValue* left = Pop(); 8205 HValue* left = Pop();
8200 Token::Value op = expr->op(); 8206 Token::Value op = expr->op();
8201 8207
8202 if (IsLiteralCompareBool(isolate(), left, op, right)) { 8208 if (IsLiteralCompareBool(isolate(), left, op, right)) {
8203 HCompareObjectEqAndBranch* result = 8209 HCompareObjectEqAndBranch* result =
8204 New<HCompareObjectEqAndBranch>(left, right); 8210 New<HCompareObjectEqAndBranch>(left, right);
8205 return ast_context()->ReturnControl(result, expr->id()); 8211 return ast_context()->ReturnControl(result, expr->id());
8206 } 8212 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
8266 switch (op) { 8272 switch (op) {
8267 case Token::EQ: 8273 case Token::EQ:
8268 case Token::EQ_STRICT: { 8274 case Token::EQ_STRICT: {
8269 // Can we get away with map check and not instance type check? 8275 // Can we get away with map check and not instance type check?
8270 if (combined_type->IsClass()) { 8276 if (combined_type->IsClass()) {
8271 Handle<Map> map = combined_type->AsClass(); 8277 Handle<Map> map = combined_type->AsClass();
8272 AddCheckMap(left, map); 8278 AddCheckMap(left, map);
8273 AddCheckMap(right, map); 8279 AddCheckMap(right, map);
8274 HCompareObjectEqAndBranch* result = 8280 HCompareObjectEqAndBranch* result =
8275 New<HCompareObjectEqAndBranch>(left, right); 8281 New<HCompareObjectEqAndBranch>(left, right);
8282 if (FLAG_emit_opt_code_positions) {
8283 result->set_operand_position(zone(), 0, expr->left()->position());
8284 result->set_operand_position(zone(), 1, expr->right()->position());
8285 }
8276 return ast_context()->ReturnControl(result, expr->id()); 8286 return ast_context()->ReturnControl(result, expr->id());
8277 } else { 8287 } else {
8278 BuildCheckHeapObject(left); 8288 BuildCheckHeapObject(left);
8279 AddInstruction(HCheckInstanceType::NewIsSpecObject(left, zone())); 8289 AddInstruction(HCheckInstanceType::NewIsSpecObject(left, zone()));
8280 BuildCheckHeapObject(right); 8290 BuildCheckHeapObject(right);
8281 AddInstruction(HCheckInstanceType::NewIsSpecObject(right, zone())); 8291 AddInstruction(HCheckInstanceType::NewIsSpecObject(right, zone()));
8282 HCompareObjectEqAndBranch* result = 8292 HCompareObjectEqAndBranch* result =
8283 New<HCompareObjectEqAndBranch>(left, right); 8293 New<HCompareObjectEqAndBranch>(left, right);
8284 return ast_context()->ReturnControl(result, expr->id()); 8294 return ast_context()->ReturnControl(result, expr->id());
8285 } 8295 }
(...skipping 22 matching lines...) Expand all
8308 if (combined_rep.IsTagged() || combined_rep.IsNone()) { 8318 if (combined_rep.IsTagged() || combined_rep.IsNone()) {
8309 HCompareGeneric* result = 8319 HCompareGeneric* result =
8310 new(zone()) HCompareGeneric(context, left, right, op); 8320 new(zone()) HCompareGeneric(context, left, right, op);
8311 result->set_observed_input_representation(1, left_rep); 8321 result->set_observed_input_representation(1, left_rep);
8312 result->set_observed_input_representation(2, right_rep); 8322 result->set_observed_input_representation(2, right_rep);
8313 return ast_context()->ReturnInstruction(result, expr->id()); 8323 return ast_context()->ReturnInstruction(result, expr->id());
8314 } else { 8324 } else {
8315 HCompareNumericAndBranch* result = 8325 HCompareNumericAndBranch* result =
8316 New<HCompareNumericAndBranch>(left, right, op); 8326 New<HCompareNumericAndBranch>(left, right, op);
8317 result->set_observed_input_representation(left_rep, right_rep); 8327 result->set_observed_input_representation(left_rep, right_rep);
8328 if (FLAG_emit_opt_code_positions) {
8329 result->SetOperandPositions(zone(),
8330 expr->left()->position(),
8331 expr->right()->position());
8332 }
8318 return ast_context()->ReturnControl(result, expr->id()); 8333 return ast_context()->ReturnControl(result, expr->id());
8319 } 8334 }
8320 } 8335 }
8321 } 8336 }
8322 8337
8323 8338
8324 void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr, 8339 void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr,
8325 Expression* sub_expr, 8340 Expression* sub_expr,
8326 NilValue nil) { 8341 NilValue nil) {
8327 ASSERT(!HasStackOverflow()); 8342 ASSERT(!HasStackOverflow());
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after
9645 trace_.Add(" "); 9660 trace_.Add(" ");
9646 phi->PrintTo(&trace_); 9661 phi->PrintTo(&trace_);
9647 trace_.Add("\n"); 9662 trace_.Add("\n");
9648 } 9663 }
9649 } 9664 }
9650 9665
9651 { 9666 {
9652 Tag HIR_tag(this, "HIR"); 9667 Tag HIR_tag(this, "HIR");
9653 for (HInstructionIterator it(current); !it.Done(); it.Advance()) { 9668 for (HInstructionIterator it(current); !it.Done(); it.Advance()) {
9654 HInstruction* instruction = it.Current(); 9669 HInstruction* instruction = it.Current();
9655 int bci = 0; 9670 int bci = FLAG_emit_opt_code_positions && instruction->has_position() ?
9671 instruction->position() : 0;
9656 int uses = instruction->UseCount(); 9672 int uses = instruction->UseCount();
9657 PrintIndent(); 9673 PrintIndent();
9658 trace_.Add("%d %d ", bci, uses); 9674 trace_.Add("%d %d ", bci, uses);
9659 instruction->PrintNameTo(&trace_); 9675 instruction->PrintNameTo(&trace_);
9660 trace_.Add(" "); 9676 trace_.Add(" ");
9661 instruction->PrintTo(&trace_); 9677 instruction->PrintTo(&trace_);
9662 trace_.Add(" <|@\n"); 9678 trace_.Add(" <|@\n");
9663 } 9679 }
9664 } 9680 }
9665 9681
9666 9682
9667 if (chunk != NULL) { 9683 if (chunk != NULL) {
9668 Tag LIR_tag(this, "LIR"); 9684 Tag LIR_tag(this, "LIR");
9669 int first_index = current->first_instruction_index(); 9685 int first_index = current->first_instruction_index();
9670 int last_index = current->last_instruction_index(); 9686 int last_index = current->last_instruction_index();
9671 if (first_index != -1 && last_index != -1) { 9687 if (first_index != -1 && last_index != -1) {
9672 const ZoneList<LInstruction*>* instructions = chunk->instructions(); 9688 const ZoneList<LInstruction*>* instructions = chunk->instructions();
9673 for (int i = first_index; i <= last_index; ++i) { 9689 for (int i = first_index; i <= last_index; ++i) {
9674 LInstruction* linstr = instructions->at(i); 9690 LInstruction* linstr = instructions->at(i);
9675 if (linstr != NULL) { 9691 if (linstr != NULL) {
9676 PrintIndent(); 9692 PrintIndent();
9677 trace_.Add("%d ", 9693 trace_.Add("%d ",
9678 LifetimePosition::FromInstructionIndex(i).Value()); 9694 LifetimePosition::FromInstructionIndex(i).Value());
9679 linstr->PrintTo(&trace_); 9695 linstr->PrintTo(&trace_);
9696 trace_.Add(" [hir:");
9697 linstr->hydrogen_value()->PrintNameTo(&trace_);
9698 trace_.Add("]");
9680 trace_.Add(" <|@\n"); 9699 trace_.Add(" <|@\n");
9681 } 9700 }
9682 } 9701 }
9683 } 9702 }
9684 } 9703 }
9685 } 9704 }
9686 } 9705 }
9687 9706
9688 9707
9689 void HTracer::TraceLiveRanges(const char* name, LAllocator* allocator) { 9708 void HTracer::TraceLiveRanges(const char* name, LAllocator* allocator) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
9848 if (ShouldProduceTraceOutput()) { 9867 if (ShouldProduceTraceOutput()) {
9849 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9868 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9850 } 9869 }
9851 9870
9852 #ifdef DEBUG 9871 #ifdef DEBUG
9853 graph_->Verify(false); // No full verify. 9872 graph_->Verify(false); // No full verify.
9854 #endif 9873 #endif
9855 } 9874 }
9856 9875
9857 } } // namespace v8::internal 9876 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698