Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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. | 9457 // Can't have initialized one but not the other. |
| 9458 ASSERT(right_info.IsUninitialized()); | 9458 ASSERT(right_type->Is(Type::None())); |
|
rossberg
2013/06/13 14:24:30
This might no longer be true in the future. I thin
Jakob Kummerow
2013/06/14 14:26:57
Done.
| |
| 9459 AddSoftDeoptimize(); | 9459 AddSoftDeoptimize(); |
| 9460 left_info = right_info = TypeInfo::Unknown(); | 9460 left_type = right_type = handle(Type::Any(), isolate()); |
| 9461 } | 9461 } |
| 9462 HInstruction* instr = NULL; | 9462 HInstruction* instr = NULL; |
| 9463 switch (expr->op()) { | 9463 switch (expr->op()) { |
| 9464 case Token::ADD: | 9464 case Token::ADD: |
| 9465 if (left_info.IsString() && right_info.IsString()) { | 9465 if (left_type->Is(Type::String()) && right_type->Is(Type::String())) { |
| 9466 BuildCheckNonSmi(left); | 9466 BuildCheckNonSmi(left); |
| 9467 AddInstruction(HCheckInstanceType::NewIsString(left, zone())); | 9467 AddInstruction(HCheckInstanceType::NewIsString(left, zone())); |
| 9468 BuildCheckNonSmi(right); | 9468 BuildCheckNonSmi(right); |
| 9469 AddInstruction(HCheckInstanceType::NewIsString(right, zone())); | 9469 AddInstruction(HCheckInstanceType::NewIsString(right, zone())); |
| 9470 instr = HStringAdd::New(zone(), context, left, right); | 9470 instr = HStringAdd::New(zone(), context, left, right); |
| 9471 } else { | 9471 } else { |
| 9472 instr = HAdd::New(zone(), context, left, right); | 9472 instr = HAdd::New(zone(), context, left, right); |
| 9473 } | 9473 } |
| 9474 break; | 9474 break; |
| 9475 case Token::SUB: | 9475 case Token::SUB: |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 9488 break; | 9488 break; |
| 9489 case Token::DIV: | 9489 case Token::DIV: |
| 9490 instr = HDiv::New(zone(), context, left, right); | 9490 instr = HDiv::New(zone(), context, left, right); |
| 9491 break; | 9491 break; |
| 9492 case Token::BIT_XOR: | 9492 case Token::BIT_XOR: |
| 9493 case Token::BIT_AND: | 9493 case Token::BIT_AND: |
| 9494 instr = HBitwise::New(zone(), expr->op(), context, left, right); | 9494 instr = HBitwise::New(zone(), expr->op(), context, left, right); |
| 9495 break; | 9495 break; |
| 9496 case Token::BIT_OR: { | 9496 case Token::BIT_OR: { |
| 9497 HValue* operand, *shift_amount; | 9497 HValue* operand, *shift_amount; |
| 9498 if (left_info.IsInteger32() && right_info.IsInteger32() && | 9498 if (left_type->Is(Type::Integer32()) && |
| 9499 right_type->Is(Type::Integer32()) && | |
| 9499 MatchRotateRight(left, right, &operand, &shift_amount)) { | 9500 MatchRotateRight(left, right, &operand, &shift_amount)) { |
| 9500 instr = new(zone()) HRor(context, operand, shift_amount); | 9501 instr = new(zone()) HRor(context, operand, shift_amount); |
| 9501 } else { | 9502 } else { |
| 9502 instr = HBitwise::New(zone(), expr->op(), context, left, right); | 9503 instr = HBitwise::New(zone(), expr->op(), context, left, right); |
| 9503 } | 9504 } |
| 9504 break; | 9505 break; |
| 9505 } | 9506 } |
| 9506 case Token::SAR: | 9507 case Token::SAR: |
| 9507 instr = HSar::New(zone(), context, left, right); | 9508 instr = HSar::New(zone(), context, left, right); |
| 9508 break; | 9509 break; |
| (...skipping 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11614 } | 11615 } |
| 11615 } | 11616 } |
| 11616 | 11617 |
| 11617 #ifdef DEBUG | 11618 #ifdef DEBUG |
| 11618 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 11619 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 11619 if (allocator_ != NULL) allocator_->Verify(); | 11620 if (allocator_ != NULL) allocator_->Verify(); |
| 11620 #endif | 11621 #endif |
| 11621 } | 11622 } |
| 11622 | 11623 |
| 11623 } } // namespace v8::internal | 11624 } } // namespace v8::internal |
| OLD | NEW |