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

Side by Side Diff: src/hydrogen.cc

Issue 16957004: Migrate BinaryOpICs and UnaryOpICs to new type rep (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years, 6 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/ast.cc ('k') | src/ic.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 9049 matching lines...) Expand 10 before | Expand all | Expand 10 after
9060 return ast_context()->ReturnInstruction(instr, expr->id()); 9060 return ast_context()->ReturnInstruction(instr, expr->id());
9061 } 9061 }
9062 9062
9063 9063
9064 void HOptimizedGraphBuilder::VisitSub(UnaryOperation* expr) { 9064 void HOptimizedGraphBuilder::VisitSub(UnaryOperation* expr) {
9065 CHECK_ALIVE(VisitForValue(expr->expression())); 9065 CHECK_ALIVE(VisitForValue(expr->expression()));
9066 HValue* value = Pop(); 9066 HValue* value = Pop();
9067 HValue* context = environment()->LookupContext(); 9067 HValue* context = environment()->LookupContext();
9068 HInstruction* instr = 9068 HInstruction* instr =
9069 HMul::New(zone(), context, value, graph()->GetConstantMinus1()); 9069 HMul::New(zone(), context, value, graph()->GetConstantMinus1());
9070 TypeInfo info = expr->type(); 9070 Handle<Type> type = expr->type();
9071 Representation rep = ToRepresentation(info); 9071 Representation rep = ToRepresentation(type);
9072 if (info.IsUninitialized()) { 9072 if (type->Is(Type::None())) {
9073 AddSoftDeoptimize(); 9073 AddSoftDeoptimize();
9074 info = TypeInfo::Unknown(); 9074 type = handle(Type::Any(), isolate());
9075 } 9075 }
9076 if (instr->IsBinaryOperation()) { 9076 if (instr->IsBinaryOperation()) {
9077 HBinaryOperation::cast(instr)->set_observed_input_representation(1, rep); 9077 HBinaryOperation::cast(instr)->set_observed_input_representation(1, rep);
9078 HBinaryOperation::cast(instr)->set_observed_input_representation(2, rep); 9078 HBinaryOperation::cast(instr)->set_observed_input_representation(2, rep);
9079 } 9079 }
9080 return ast_context()->ReturnInstruction(instr, expr->id()); 9080 return ast_context()->ReturnInstruction(instr, expr->id());
9081 } 9081 }
9082 9082
9083 9083
9084 void HOptimizedGraphBuilder::VisitBitNot(UnaryOperation* expr) { 9084 void HOptimizedGraphBuilder::VisitBitNot(UnaryOperation* expr) {
9085 CHECK_ALIVE(VisitForValue(expr->expression())); 9085 CHECK_ALIVE(VisitForValue(expr->expression()));
9086 HValue* value = Pop(); 9086 HValue* value = Pop();
9087 TypeInfo info = expr->type(); 9087 Handle<Type> info = expr->type();
9088 if (info.IsUninitialized()) { 9088 if (info->Is(Type::None())) {
9089 AddSoftDeoptimize(); 9089 AddSoftDeoptimize();
9090 } 9090 }
9091 HInstruction* instr = new(zone()) HBitNot(value); 9091 HInstruction* instr = new(zone()) HBitNot(value);
9092 return ast_context()->ReturnInstruction(instr, expr->id()); 9092 return ast_context()->ReturnInstruction(instr, expr->id());
9093 } 9093 }
9094 9094
9095 9095
9096 void HOptimizedGraphBuilder::VisitNot(UnaryOperation* expr) { 9096 void HOptimizedGraphBuilder::VisitNot(UnaryOperation* expr) {
9097 if (ast_context()->IsTest()) { 9097 if (ast_context()->IsTest()) {
9098 TestContext* context = TestContext::cast(ast_context()); 9098 TestContext* context = TestContext::cast(ast_context());
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
9438 } 9438 }
9439 return true; 9439 return true;
9440 } 9440 }
9441 9441
9442 9442
9443 HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation( 9443 HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation(
9444 BinaryOperation* expr, 9444 BinaryOperation* expr,
9445 HValue* left, 9445 HValue* left,
9446 HValue* right) { 9446 HValue* right) {
9447 HValue* context = environment()->LookupContext(); 9447 HValue* context = environment()->LookupContext();
9448 TypeInfo left_info = expr->left_type(); 9448 Handle<Type> left_type = expr->left_type();
9449 TypeInfo right_info = expr->right_type(); 9449 Handle<Type> right_type = expr->right_type();
9450 TypeInfo result_info = expr->result_type(); 9450 Handle<Type> result_type = expr->result_type();
9451 bool has_fixed_right_arg = expr->has_fixed_right_arg(); 9451 bool has_fixed_right_arg = expr->has_fixed_right_arg();
9452 int fixed_right_arg_value = expr->fixed_right_arg_value(); 9452 int fixed_right_arg_value = expr->fixed_right_arg_value();
9453 Representation left_rep = ToRepresentation(left_info); 9453 Representation left_rep = ToRepresentation(left_type);
9454 Representation right_rep = ToRepresentation(right_info); 9454 Representation right_rep = ToRepresentation(right_type);
9455 Representation result_rep = ToRepresentation(result_info); 9455 Representation result_rep = ToRepresentation(result_type);
9456 if (left_info.IsUninitialized()) { 9456 if (left_type->Is(Type::None())) {
9457 // Can't have initialized one but not the other.
9458 ASSERT(right_info.IsUninitialized());
9459 AddSoftDeoptimize(); 9457 AddSoftDeoptimize();
9460 left_info = right_info = TypeInfo::Unknown(); 9458 left_type = handle(Type::Any(), isolate());
9459 }
9460 if (right_type->Is(Type::None())) {
9461 AddSoftDeoptimize();
rossberg 2013/06/14 14:45:45 Hm, this version will produce two deopts in the co
Jakob Kummerow 2013/06/14 14:47:27 No, it won't. If the current block is already mark
9462 right_type = handle(Type::Any(), isolate());
9461 } 9463 }
9462 HInstruction* instr = NULL; 9464 HInstruction* instr = NULL;
9463 switch (expr->op()) { 9465 switch (expr->op()) {
9464 case Token::ADD: 9466 case Token::ADD:
9465 if (left_info.IsString() && right_info.IsString()) { 9467 if (left_type->Is(Type::String()) && right_type->Is(Type::String())) {
9466 BuildCheckNonSmi(left); 9468 BuildCheckNonSmi(left);
9467 AddInstruction(HCheckInstanceType::NewIsString(left, zone())); 9469 AddInstruction(HCheckInstanceType::NewIsString(left, zone()));
9468 BuildCheckNonSmi(right); 9470 BuildCheckNonSmi(right);
9469 AddInstruction(HCheckInstanceType::NewIsString(right, zone())); 9471 AddInstruction(HCheckInstanceType::NewIsString(right, zone()));
9470 instr = HStringAdd::New(zone(), context, left, right); 9472 instr = HStringAdd::New(zone(), context, left, right);
9471 } else { 9473 } else {
9472 instr = HAdd::New(zone(), context, left, right); 9474 instr = HAdd::New(zone(), context, left, right);
9473 } 9475 }
9474 break; 9476 break;
9475 case Token::SUB: 9477 case Token::SUB:
(...skipping 12 matching lines...) Expand all
9488 break; 9490 break;
9489 case Token::DIV: 9491 case Token::DIV:
9490 instr = HDiv::New(zone(), context, left, right); 9492 instr = HDiv::New(zone(), context, left, right);
9491 break; 9493 break;
9492 case Token::BIT_XOR: 9494 case Token::BIT_XOR:
9493 case Token::BIT_AND: 9495 case Token::BIT_AND:
9494 instr = HBitwise::New(zone(), expr->op(), context, left, right); 9496 instr = HBitwise::New(zone(), expr->op(), context, left, right);
9495 break; 9497 break;
9496 case Token::BIT_OR: { 9498 case Token::BIT_OR: {
9497 HValue* operand, *shift_amount; 9499 HValue* operand, *shift_amount;
9498 if (left_info.IsInteger32() && right_info.IsInteger32() && 9500 if (left_type->Is(Type::Integer32()) &&
9501 right_type->Is(Type::Integer32()) &&
9499 MatchRotateRight(left, right, &operand, &shift_amount)) { 9502 MatchRotateRight(left, right, &operand, &shift_amount)) {
9500 instr = new(zone()) HRor(context, operand, shift_amount); 9503 instr = new(zone()) HRor(context, operand, shift_amount);
9501 } else { 9504 } else {
9502 instr = HBitwise::New(zone(), expr->op(), context, left, right); 9505 instr = HBitwise::New(zone(), expr->op(), context, left, right);
9503 } 9506 }
9504 break; 9507 break;
9505 } 9508 }
9506 case Token::SAR: 9509 case Token::SAR:
9507 instr = HSar::New(zone(), context, left, right); 9510 instr = HSar::New(zone(), context, left, right);
9508 break; 9511 break;
(...skipping 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after
11614 } 11617 }
11615 } 11618 }
11616 11619
11617 #ifdef DEBUG 11620 #ifdef DEBUG
11618 if (graph_ != NULL) graph_->Verify(false); // No full verify. 11621 if (graph_ != NULL) graph_->Verify(false); // No full verify.
11619 if (allocator_ != NULL) allocator_->Verify(); 11622 if (allocator_ != NULL) allocator_->Verify();
11620 #endif 11623 #endif
11621 } 11624 }
11622 11625
11623 } } // namespace v8::internal 11626 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/ic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698