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

Side by Side Diff: src/hydrogen.cc

Issue 12315005: Constant fold math and string operations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: made ctors private Created 7 years, 10 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') | 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 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 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 new(zone()) HCompareIDAndBranch(phi_, terminating, token); 711 new(zone()) HCompareIDAndBranch(phi_, terminating, token);
712 compare->ChangeRepresentation(Representation::Integer32()); 712 compare->ChangeRepresentation(Representation::Integer32());
713 compare->SetSuccessorAt(0, body_block_); 713 compare->SetSuccessorAt(0, body_block_);
714 compare->SetSuccessorAt(1, exit_block_); 714 compare->SetSuccessorAt(1, exit_block_);
715 builder_->current_block()->Finish(compare); 715 builder_->current_block()->Finish(compare);
716 716
717 builder_->set_current_block(body_block_); 717 builder_->set_current_block(body_block_);
718 if (direction_ == kPreIncrement || direction_ == kPreDecrement) { 718 if (direction_ == kPreIncrement || direction_ == kPreDecrement) {
719 HValue* one = builder_->graph()->GetConstant1(); 719 HValue* one = builder_->graph()->GetConstant1();
720 if (direction_ == kPreIncrement) { 720 if (direction_ == kPreIncrement) {
721 increment_ = new(zone()) HAdd(context_, phi_, one); 721 increment_ = HAdd::New(zone(), context_, phi_, one);
722 } else { 722 } else {
723 increment_ = new(zone()) HSub(context_, phi_, one); 723 increment_ = HSub::New(zone(), context_, phi_, one);
724 } 724 }
725 increment_->ClearFlag(HValue::kCanOverflow); 725 increment_->ClearFlag(HValue::kCanOverflow);
726 increment_->ChangeRepresentation(Representation::Integer32()); 726 increment_->ChangeRepresentation(Representation::Integer32());
727 builder_->AddInstruction(increment_); 727 builder_->AddInstruction(increment_);
728 return increment_; 728 return increment_;
729 } else { 729 } else {
730 return phi_; 730 return phi_;
731 } 731 }
732 } 732 }
733 733
734 734
735 void HGraphBuilder::LoopBuilder::EndBody() { 735 void HGraphBuilder::LoopBuilder::EndBody() {
736 ASSERT(!finished_); 736 ASSERT(!finished_);
737 737
738 if (direction_ == kPostIncrement || direction_ == kPostDecrement) { 738 if (direction_ == kPostIncrement || direction_ == kPostDecrement) {
739 HValue* one = builder_->graph()->GetConstant1(); 739 HValue* one = builder_->graph()->GetConstant1();
740 if (direction_ == kPostIncrement) { 740 if (direction_ == kPostIncrement) {
741 increment_ = new(zone()) HAdd(context_, phi_, one); 741 increment_ = HAdd::New(zone(), context_, phi_, one);
742 } else { 742 } else {
743 increment_ = new(zone()) HSub(context_, phi_, one); 743 increment_ = HSub::New(zone(), context_, phi_, one);
744 } 744 }
745 increment_->ClearFlag(HValue::kCanOverflow); 745 increment_->ClearFlag(HValue::kCanOverflow);
746 increment_->ChangeRepresentation(Representation::Integer32()); 746 increment_->ChangeRepresentation(Representation::Integer32());
747 builder_->AddInstruction(increment_); 747 builder_->AddInstruction(increment_);
748 } 748 }
749 749
750 builder_->environment()->Push(increment_); 750 builder_->environment()->Push(increment_);
751 builder_->current_block()->Goto(header_block_); 751 builder_->current_block()->Goto(header_block_);
752 header_block_->loop_information()->RegisterBackEdge(body_block_); 752 header_block_->loop_information()->RegisterBackEdge(body_block_);
753 header_block_->SetJoinId(BailoutId::StubEntry()); 753 header_block_->SetJoinId(BailoutId::StubEntry());
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 ElementsKind kind, 967 ElementsKind kind,
968 HValue* capacity) { 968 HValue* capacity) {
969 Zone* zone = this->zone(); 969 Zone* zone = this->zone();
970 970
971 int elements_size = IsFastDoubleElementsKind(kind) 971 int elements_size = IsFastDoubleElementsKind(kind)
972 ? kDoubleSize : kPointerSize; 972 ? kDoubleSize : kPointerSize;
973 HConstant* elements_size_value = 973 HConstant* elements_size_value =
974 new(zone) HConstant(elements_size, Representation::Integer32()); 974 new(zone) HConstant(elements_size, Representation::Integer32());
975 AddInstruction(elements_size_value); 975 AddInstruction(elements_size_value);
976 HValue* mul = AddInstruction( 976 HValue* mul = AddInstruction(
977 new(zone) HMul(context, capacity, elements_size_value)); 977 HMul::New(zone, context, capacity, elements_size_value));
978 mul->ChangeRepresentation(Representation::Integer32()); 978 mul->ChangeRepresentation(Representation::Integer32());
979 mul->ClearFlag(HValue::kCanOverflow); 979 mul->ClearFlag(HValue::kCanOverflow);
980 980
981 HConstant* header_size = 981 HConstant* header_size =
982 new(zone) HConstant(FixedArray::kHeaderSize, Representation::Integer32()); 982 new(zone) HConstant(FixedArray::kHeaderSize, Representation::Integer32());
983 AddInstruction(header_size); 983 AddInstruction(header_size);
984 HValue* total_size = AddInstruction( 984 HValue* total_size = AddInstruction(
985 new(zone) HAdd(context, mul, header_size)); 985 HAdd::New(zone, context, mul, header_size));
986 total_size->ChangeRepresentation(Representation::Integer32()); 986 total_size->ChangeRepresentation(Representation::Integer32());
987 total_size->ClearFlag(HValue::kCanOverflow); 987 total_size->ClearFlag(HValue::kCanOverflow);
988 988
989 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; 989 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE;
990 if (IsFastDoubleElementsKind(kind)) { 990 if (IsFastDoubleElementsKind(kind)) {
991 flags = static_cast<HAllocate::Flags>( 991 flags = static_cast<HAllocate::Flags>(
992 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED); 992 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED);
993 } 993 }
994 994
995 HValue* elements = 995 HValue* elements =
(...skipping 3107 matching lines...) Expand 10 before | Expand all | Expand 10 after
4103 next_in_bb_(next_in_bb), 4103 next_in_bb_(next_in_bb),
4104 father_in_dt_(father_in_dt) { } 4104 father_in_dt_(father_in_dt) { }
4105 4105
4106 private: 4106 private:
4107 BoundsCheckKey* key_; 4107 BoundsCheckKey* key_;
4108 int32_t lower_offset_; 4108 int32_t lower_offset_;
4109 int32_t upper_offset_; 4109 int32_t upper_offset_;
4110 HBasicBlock* basic_block_; 4110 HBasicBlock* basic_block_;
4111 HBoundsCheck* lower_check_; 4111 HBoundsCheck* lower_check_;
4112 HBoundsCheck* upper_check_; 4112 HBoundsCheck* upper_check_;
4113 HAdd* added_lower_index_; 4113 HInstruction* added_lower_index_;
4114 HConstant* added_lower_offset_; 4114 HConstant* added_lower_offset_;
4115 HAdd* added_upper_index_; 4115 HInstruction* added_upper_index_;
4116 HConstant* added_upper_offset_; 4116 HConstant* added_upper_offset_;
4117 BoundsCheckBbData* next_in_bb_; 4117 BoundsCheckBbData* next_in_bb_;
4118 BoundsCheckBbData* father_in_dt_; 4118 BoundsCheckBbData* father_in_dt_;
4119 4119
4120 // Given an existing add instruction and a bounds check it tries to 4120 // Given an existing add instruction and a bounds check it tries to
4121 // find the current context (either of the add or of the check index). 4121 // find the current context (either of the add or of the check index).
4122 HValue* IndexContext(HAdd* add, HBoundsCheck* check) { 4122 HValue* IndexContext(HInstruction* add, HBoundsCheck* check) {
4123 if (add != NULL) { 4123 if (add != NULL && add->IsAdd()) {
4124 return add->context(); 4124 return HAdd::cast(add)->context();
4125 } 4125 }
4126 if (check->index()->IsBinaryOperation()) { 4126 if (check->index()->IsBinaryOperation()) {
4127 return HBinaryOperation::cast(check->index())->context(); 4127 return HBinaryOperation::cast(check->index())->context();
4128 } 4128 }
4129 return NULL; 4129 return NULL;
4130 } 4130 }
4131 4131
4132 // This function returns false if it cannot build the add because the 4132 // This function returns false if it cannot build the add because the
4133 // current context cannot be determined. 4133 // current context cannot be determined.
4134 bool BuildOffsetAdd(HBoundsCheck* check, 4134 bool BuildOffsetAdd(HBoundsCheck* check,
4135 HAdd** add, 4135 HInstruction** add,
4136 HConstant** constant, 4136 HConstant** constant,
4137 HValue* original_value, 4137 HValue* original_value,
4138 Representation representation, 4138 Representation representation,
4139 int32_t new_offset) { 4139 int32_t new_offset) {
4140 HValue* index_context = IndexContext(*add, check); 4140 HValue* index_context = IndexContext(*add, check);
4141 if (index_context == NULL) return false; 4141 if (index_context == NULL) return false;
4142 4142
4143 HConstant* new_constant = new(BasicBlock()->zone()) 4143 HConstant* new_constant = new(BasicBlock()->zone())
4144 HConstant(new_offset, Representation::Integer32()); 4144 HConstant(new_offset, Representation::Integer32());
4145 if (*add == NULL) { 4145 if (*add == NULL) {
4146 new_constant->InsertBefore(check); 4146 new_constant->InsertBefore(check);
4147 *add = new(BasicBlock()->zone()) HAdd(index_context, 4147 (*add) = HAdd::New(
4148 original_value, 4148 BasicBlock()->zone(), index_context, original_value, new_constant);
4149 new_constant);
4150 (*add)->AssumeRepresentation(representation); 4149 (*add)->AssumeRepresentation(representation);
4151 (*add)->InsertBefore(check); 4150 (*add)->InsertBefore(check);
4152 } else { 4151 } else {
4153 new_constant->InsertBefore(*add); 4152 new_constant->InsertBefore(*add);
4154 (*constant)->DeleteAndReplaceWith(new_constant); 4153 (*constant)->DeleteAndReplaceWith(new_constant);
4155 } 4154 }
4156 *constant = new_constant; 4155 *constant = new_constant;
4157 return true; 4156 return true;
4158 } 4157 }
4159 4158
4160 void RemoveZeroAdd(HAdd** add, HConstant** constant) { 4159 void RemoveZeroAdd(HInstruction** add, HConstant** constant) {
4161 if (*add != NULL && (*constant)->Integer32Value() == 0) { 4160 if (*add != NULL && (*add)->IsAdd() && (*constant)->Integer32Value() == 0) {
4162 (*add)->DeleteAndReplaceWith((*add)->left()); 4161 (*add)->DeleteAndReplaceWith(HAdd::cast(*add)->left());
4163 (*constant)->DeleteAndReplaceWith(NULL); 4162 (*constant)->DeleteAndReplaceWith(NULL);
4164 } 4163 }
4165 } 4164 }
4166 }; 4165 };
4167 4166
4168 4167
4169 static bool BoundsCheckKeyMatch(void* key1, void* key2) { 4168 static bool BoundsCheckKeyMatch(void* key1, void* key2) {
4170 BoundsCheckKey* k1 = static_cast<BoundsCheckKey*>(key1); 4169 BoundsCheckKey* k1 = static_cast<BoundsCheckKey*>(key1);
4171 BoundsCheckKey* k2 = static_cast<BoundsCheckKey*>(key2); 4170 BoundsCheckKey* k2 = static_cast<BoundsCheckKey*>(key2);
4172 return k1->IndexBase() == k2->IndexBase() && k1->Length() == k2->Length(); 4171 return k1->IndexBase() == k2->IndexBase() && k1->Length() == k2->Length();
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
5204 BreakAndContinueInfo break_info(stmt, 5); 5203 BreakAndContinueInfo break_info(stmt, 5);
5205 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info)); 5204 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info));
5206 5205
5207 HBasicBlock* body_exit = 5206 HBasicBlock* body_exit =
5208 JoinContinue(stmt, current_block(), break_info.continue_block()); 5207 JoinContinue(stmt, current_block(), break_info.continue_block());
5209 5208
5210 if (body_exit != NULL) { 5209 if (body_exit != NULL) {
5211 set_current_block(body_exit); 5210 set_current_block(body_exit);
5212 5211
5213 HValue* current_index = Pop(); 5212 HValue* current_index = Pop();
5214 HInstruction* new_index = new(zone()) HAdd(environment()->LookupContext(), 5213 HInstruction* new_index = HAdd::New(zone(),
5215 current_index, 5214 environment()->LookupContext(),
5216 graph()->GetConstant1()); 5215 current_index,
5216 graph()->GetConstant1());
5217 new_index->AssumeRepresentation(Representation::Integer32()); 5217 new_index->AssumeRepresentation(Representation::Integer32());
5218 PushAndAdd(new_index); 5218 PushAndAdd(new_index);
5219 body_exit = current_block(); 5219 body_exit = current_block();
5220 } 5220 }
5221 5221
5222 HBasicBlock* loop_exit = CreateLoop(stmt, 5222 HBasicBlock* loop_exit = CreateLoop(stmt,
5223 loop_entry, 5223 loop_entry,
5224 body_exit, 5224 body_exit,
5225 loop_successor, 5225 loop_successor,
5226 break_info.break_block()); 5226 break_info.break_block());
(...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after
7110 if (expr->AsProperty()->IsArrayLength()) { 7110 if (expr->AsProperty()->IsArrayLength()) {
7111 HValue* array = Pop(); 7111 HValue* array = Pop();
7112 AddInstruction(new(zone()) HCheckNonSmi(array)); 7112 AddInstruction(new(zone()) HCheckNonSmi(array));
7113 HInstruction* mapcheck = 7113 HInstruction* mapcheck =
7114 AddInstruction(HCheckInstanceType::NewIsJSArray(array, zone())); 7114 AddInstruction(HCheckInstanceType::NewIsJSArray(array, zone()));
7115 instr = new(zone()) HJSArrayLength(array, mapcheck); 7115 instr = new(zone()) HJSArrayLength(array, mapcheck);
7116 } else if (expr->IsStringLength()) { 7116 } else if (expr->IsStringLength()) {
7117 HValue* string = Pop(); 7117 HValue* string = Pop();
7118 AddInstruction(new(zone()) HCheckNonSmi(string)); 7118 AddInstruction(new(zone()) HCheckNonSmi(string));
7119 AddInstruction(HCheckInstanceType::NewIsString(string, zone())); 7119 AddInstruction(HCheckInstanceType::NewIsString(string, zone()));
7120 instr = new(zone()) HStringLength(string); 7120 instr = HStringLength::New(zone(), string);
7121 } else if (expr->IsStringAccess()) { 7121 } else if (expr->IsStringAccess()) {
7122 CHECK_ALIVE(VisitForValue(expr->key())); 7122 CHECK_ALIVE(VisitForValue(expr->key()));
7123 HValue* index = Pop(); 7123 HValue* index = Pop();
7124 HValue* string = Pop(); 7124 HValue* string = Pop();
7125 HValue* context = environment()->LookupContext(); 7125 HValue* context = environment()->LookupContext();
7126 HStringCharCodeAt* char_code = 7126 HInstruction* char_code =
7127 BuildStringCharCodeAt(context, string, index); 7127 BuildStringCharCodeAt(context, string, index);
7128 AddInstruction(char_code); 7128 AddInstruction(char_code);
7129 instr = new(zone()) HStringCharFromCode(context, char_code); 7129 instr = HStringCharFromCode::New(zone(), context, char_code);
7130 7130
7131 } else if (expr->IsFunctionPrototype()) { 7131 } else if (expr->IsFunctionPrototype()) {
7132 HValue* function = Pop(); 7132 HValue* function = Pop();
7133 AddInstruction(new(zone()) HCheckNonSmi(function)); 7133 AddInstruction(new(zone()) HCheckNonSmi(function));
7134 instr = new(zone()) HLoadFunctionPrototype(function); 7134 instr = new(zone()) HLoadFunctionPrototype(function);
7135 7135
7136 } else if (expr->key()->IsPropertyName()) { 7136 } else if (expr->key()->IsPropertyName()) {
7137 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); 7137 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName();
7138 SmallMapList* types = expr->GetReceiverTypes(); 7138 SmallMapList* types = expr->GetReceiverTypes();
7139 HValue* object = Top(); 7139 HValue* object = Top();
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
7789 7789
7790 bool HOptimizedGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr, 7790 bool HOptimizedGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr,
7791 bool drop_extra) { 7791 bool drop_extra) {
7792 if (!expr->target()->shared()->HasBuiltinFunctionId()) return false; 7792 if (!expr->target()->shared()->HasBuiltinFunctionId()) return false;
7793 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); 7793 BuiltinFunctionId id = expr->target()->shared()->builtin_function_id();
7794 switch (id) { 7794 switch (id) {
7795 case kMathExp: 7795 case kMathExp:
7796 if (!FLAG_fast_math) break; 7796 if (!FLAG_fast_math) break;
7797 // Fall through if FLAG_fast_math. 7797 // Fall through if FLAG_fast_math.
7798 case kMathRound: 7798 case kMathRound:
7799 case kMathFloor:
7799 case kMathAbs: 7800 case kMathAbs:
7800 case kMathSqrt: 7801 case kMathSqrt:
7801 case kMathLog: 7802 case kMathLog:
7802 case kMathSin: 7803 case kMathSin:
7803 case kMathCos: 7804 case kMathCos:
7804 case kMathTan: 7805 case kMathTan:
7805 if (expr->arguments()->length() == 1) { 7806 if (expr->arguments()->length() == 1) {
7806 HValue* argument = Pop(); 7807 HValue* argument = Pop();
7807 HValue* context = environment()->LookupContext(); 7808 HValue* context = environment()->LookupContext();
7808 Drop(1); // Receiver. 7809 Drop(1); // Receiver.
7809 HUnaryMathOperation* op = 7810 HInstruction* op =
7810 new(zone()) HUnaryMathOperation(context, argument, id); 7811 HUnaryMathOperation::New(zone(), context, argument, id);
7811 op->set_position(expr->position()); 7812 op->set_position(expr->position());
7812 if (drop_extra) Drop(1); // Optionally drop the function. 7813 if (drop_extra) Drop(1); // Optionally drop the function.
7813 ast_context()->ReturnInstruction(op, expr->id()); 7814 ast_context()->ReturnInstruction(op, expr->id());
7814 return true; 7815 return true;
7815 } 7816 }
7816 break; 7817 break;
7817 default: 7818 default:
7818 // Not supported for inlining yet. 7819 // Not supported for inlining yet.
7819 break; 7820 break;
7820 } 7821 }
(...skipping 16 matching lines...) Expand all
7837 case kStringCharAt: 7838 case kStringCharAt:
7838 if (argument_count == 2 && check_type == STRING_CHECK) { 7839 if (argument_count == 2 && check_type == STRING_CHECK) {
7839 HValue* index = Pop(); 7840 HValue* index = Pop();
7840 HValue* string = Pop(); 7841 HValue* string = Pop();
7841 HValue* context = environment()->LookupContext(); 7842 HValue* context = environment()->LookupContext();
7842 ASSERT(!expr->holder().is_null()); 7843 ASSERT(!expr->holder().is_null());
7843 AddInstruction(new(zone()) HCheckPrototypeMaps( 7844 AddInstruction(new(zone()) HCheckPrototypeMaps(
7844 oracle()->GetPrototypeForPrimitiveCheck(STRING_CHECK), 7845 oracle()->GetPrototypeForPrimitiveCheck(STRING_CHECK),
7845 expr->holder(), 7846 expr->holder(),
7846 zone())); 7847 zone()));
7847 HStringCharCodeAt* char_code = 7848 HInstruction* char_code =
7848 BuildStringCharCodeAt(context, string, index); 7849 BuildStringCharCodeAt(context, string, index);
7849 if (id == kStringCharCodeAt) { 7850 if (id == kStringCharCodeAt) {
7850 ast_context()->ReturnInstruction(char_code, expr->id()); 7851 ast_context()->ReturnInstruction(char_code, expr->id());
7851 return true; 7852 return true;
7852 } 7853 }
7853 AddInstruction(char_code); 7854 AddInstruction(char_code);
7854 HStringCharFromCode* result = 7855 HInstruction* result =
7855 new(zone()) HStringCharFromCode(context, char_code); 7856 HStringCharFromCode::New(zone(), context, char_code);
7856 ast_context()->ReturnInstruction(result, expr->id()); 7857 ast_context()->ReturnInstruction(result, expr->id());
7857 return true; 7858 return true;
7858 } 7859 }
7859 break; 7860 break;
7860 case kMathExp: 7861 case kMathExp:
7861 if (!FLAG_fast_math) break; 7862 if (!FLAG_fast_math) break;
7862 // Fall through if FLAG_fast_math. 7863 // Fall through if FLAG_fast_math.
7863 case kMathRound: 7864 case kMathRound:
7864 case kMathFloor: 7865 case kMathFloor:
7865 case kMathAbs: 7866 case kMathAbs:
7866 case kMathSqrt: 7867 case kMathSqrt:
7867 case kMathLog: 7868 case kMathLog:
7868 case kMathSin: 7869 case kMathSin:
7869 case kMathCos: 7870 case kMathCos:
7870 case kMathTan: 7871 case kMathTan:
7871 if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) { 7872 if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) {
7872 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); 7873 AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
7873 HValue* argument = Pop(); 7874 HValue* argument = Pop();
7874 HValue* context = environment()->LookupContext(); 7875 HValue* context = environment()->LookupContext();
7875 Drop(1); // Receiver. 7876 Drop(1); // Receiver.
7876 HUnaryMathOperation* op = 7877 HInstruction* op =
7877 new(zone()) HUnaryMathOperation(context, argument, id); 7878 HUnaryMathOperation::New(zone(), context, argument, id);
7878 op->set_position(expr->position()); 7879 op->set_position(expr->position());
7879 ast_context()->ReturnInstruction(op, expr->id()); 7880 ast_context()->ReturnInstruction(op, expr->id());
7880 return true; 7881 return true;
7881 } 7882 }
7882 break; 7883 break;
7883 case kMathPow: 7884 case kMathPow:
7884 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) { 7885 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) {
7885 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); 7886 AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
7886 HValue* right = Pop(); 7887 HValue* right = Pop();
7887 HValue* left = Pop(); 7888 HValue* left = Pop();
7888 Pop(); // Pop receiver. 7889 Pop(); // Pop receiver.
7889 HValue* context = environment()->LookupContext(); 7890 HValue* context = environment()->LookupContext();
7890 HInstruction* result = NULL; 7891 HInstruction* result = NULL;
7891 // Use sqrt() if exponent is 0.5 or -0.5. 7892 // Use sqrt() if exponent is 0.5 or -0.5.
7892 if (right->IsConstant() && HConstant::cast(right)->HasDoubleValue()) { 7893 if (right->IsConstant() && HConstant::cast(right)->HasDoubleValue()) {
7893 double exponent = HConstant::cast(right)->DoubleValue(); 7894 double exponent = HConstant::cast(right)->DoubleValue();
7894 if (exponent == 0.5) { 7895 if (exponent == 0.5) {
7895 result = 7896 result =
7896 new(zone()) HUnaryMathOperation(context, left, kMathPowHalf); 7897 HUnaryMathOperation::New(zone(), context, left, kMathPowHalf);
7897 } else if (exponent == -0.5) { 7898 } else if (exponent == -0.5) {
7898 HConstant* double_one = 7899 HConstant* double_one =
7899 new(zone()) HConstant(Handle<Object>(Smi::FromInt(1)), 7900 new(zone()) HConstant(Handle<Object>(Smi::FromInt(1)),
7900 Representation::Double()); 7901 Representation::Double());
7901 AddInstruction(double_one); 7902 AddInstruction(double_one);
7902 HUnaryMathOperation* square_root = 7903 HInstruction* sqrt =
7903 new(zone()) HUnaryMathOperation(context, left, kMathPowHalf); 7904 HUnaryMathOperation::New(zone(), context, left, kMathPowHalf);
7904 AddInstruction(square_root); 7905 AddInstruction(sqrt);
7905 // MathPowHalf doesn't have side effects so there's no need for 7906 // MathPowHalf doesn't have side effects so there's no need for
7906 // an environment simulation here. 7907 // an environment simulation here.
7907 ASSERT(!square_root->HasObservableSideEffects()); 7908 ASSERT(!sqrt->HasObservableSideEffects());
7908 result = new(zone()) HDiv(context, double_one, square_root); 7909 result = HDiv::New(zone(), context, double_one, sqrt);
7909 } else if (exponent == 2.0) { 7910 } else if (exponent == 2.0) {
7910 result = new(zone()) HMul(context, left, left); 7911 result = HMul::New(zone(), context, left, left);
7911 } 7912 }
7912 } else if (right->IsConstant() && 7913 } else if (right->IsConstant() &&
7913 HConstant::cast(right)->HasInteger32Value() && 7914 HConstant::cast(right)->HasInteger32Value() &&
7914 HConstant::cast(right)->Integer32Value() == 2) { 7915 HConstant::cast(right)->Integer32Value() == 2) {
7915 result = new(zone()) HMul(context, left, left); 7916 result = HMul::New(zone(), context, left, left);
7916 } 7917 }
7917 7918
7918 if (result == NULL) { 7919 if (result == NULL) {
7919 result = new(zone()) HPower(left, right); 7920 result = HPower::New(zone(), left, right);
7920 } 7921 }
7921 ast_context()->ReturnInstruction(result, expr->id()); 7922 ast_context()->ReturnInstruction(result, expr->id());
7922 return true; 7923 return true;
7923 } 7924 }
7924 break; 7925 break;
7925 case kMathRandom: 7926 case kMathRandom:
7926 if (argument_count == 1 && check_type == RECEIVER_MAP_CHECK) { 7927 if (argument_count == 1 && check_type == RECEIVER_MAP_CHECK) {
7927 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); 7928 AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
7928 Drop(1); // Receiver. 7929 Drop(1); // Receiver.
7929 HValue* context = environment()->LookupContext(); 7930 HValue* context = environment()->LookupContext();
7930 HGlobalObject* global_object = new(zone()) HGlobalObject(context); 7931 HGlobalObject* global_object = new(zone()) HGlobalObject(context);
7931 AddInstruction(global_object); 7932 AddInstruction(global_object);
7932 HRandom* result = new(zone()) HRandom(global_object); 7933 HRandom* result = new(zone()) HRandom(global_object);
7933 ast_context()->ReturnInstruction(result, expr->id()); 7934 ast_context()->ReturnInstruction(result, expr->id());
7934 return true; 7935 return true;
7935 } 7936 }
7936 break; 7937 break;
7937 case kMathMax: 7938 case kMathMax:
7938 case kMathMin: 7939 case kMathMin:
7939 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) { 7940 if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) {
7940 AddCheckConstantFunction(expr->holder(), receiver, receiver_map); 7941 AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
7941 HValue* right = Pop(); 7942 HValue* right = Pop();
7942 HValue* left = Pop(); 7943 HValue* left = Pop();
7943 Drop(1); // Receiver. 7944 Drop(1); // Receiver.
7944 HValue* context = environment()->LookupContext(); 7945 HValue* context = environment()->LookupContext();
7945 HMathMinMax::Operation op = (id == kMathMin) ? HMathMinMax::kMathMin 7946 HMathMinMax::Operation op = (id == kMathMin) ? HMathMinMax::kMathMin
7946 : HMathMinMax::kMathMax; 7947 : HMathMinMax::kMathMax;
7947 HMathMinMax* result = new(zone()) HMathMinMax(context, left, right, op); 7948 HInstruction* result =
7949 HMathMinMax::New(zone(), context, left, right, op);
7948 ast_context()->ReturnInstruction(result, expr->id()); 7950 ast_context()->ReturnInstruction(result, expr->id());
7949 return true; 7951 return true;
7950 } 7952 }
7951 break; 7953 break;
7952 default: 7954 default:
7953 // Not yet supported for inlining. 7955 // Not yet supported for inlining.
7954 break; 7956 break;
7955 } 7957 }
7956 return false; 7958 return false;
7957 } 7959 }
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
8511 HInstruction* instr = new(zone()) HTypeof(context, value); 8513 HInstruction* instr = new(zone()) HTypeof(context, value);
8512 return ast_context()->ReturnInstruction(instr, expr->id()); 8514 return ast_context()->ReturnInstruction(instr, expr->id());
8513 } 8515 }
8514 8516
8515 8517
8516 void HOptimizedGraphBuilder::VisitAdd(UnaryOperation* expr) { 8518 void HOptimizedGraphBuilder::VisitAdd(UnaryOperation* expr) {
8517 CHECK_ALIVE(VisitForValue(expr->expression())); 8519 CHECK_ALIVE(VisitForValue(expr->expression()));
8518 HValue* value = Pop(); 8520 HValue* value = Pop();
8519 HValue* context = environment()->LookupContext(); 8521 HValue* context = environment()->LookupContext();
8520 HInstruction* instr = 8522 HInstruction* instr =
8521 new(zone()) HMul(context, value, graph()->GetConstant1()); 8523 HMul::New(zone(), context, value, graph()->GetConstant1());
8522 return ast_context()->ReturnInstruction(instr, expr->id()); 8524 return ast_context()->ReturnInstruction(instr, expr->id());
8523 } 8525 }
8524 8526
8525 8527
8526 void HOptimizedGraphBuilder::VisitSub(UnaryOperation* expr) { 8528 void HOptimizedGraphBuilder::VisitSub(UnaryOperation* expr) {
8527 CHECK_ALIVE(VisitForValue(expr->expression())); 8529 CHECK_ALIVE(VisitForValue(expr->expression()));
8528 HValue* value = Pop(); 8530 HValue* value = Pop();
8529 HValue* context = environment()->LookupContext(); 8531 HValue* context = environment()->LookupContext();
8530 HInstruction* instr = 8532 HInstruction* instr =
8531 new(zone()) HMul(context, value, graph()->GetConstantMinus1()); 8533 HMul::New(zone(), context, value, graph()->GetConstantMinus1());
8532 TypeInfo info = oracle()->UnaryType(expr); 8534 TypeInfo info = oracle()->UnaryType(expr);
8533 Representation rep = ToRepresentation(info); 8535 Representation rep = ToRepresentation(info);
8534 if (info.IsUninitialized()) { 8536 if (info.IsUninitialized()) {
8535 AddSoftDeoptimize(); 8537 AddSoftDeoptimize();
8536 info = TypeInfo::Unknown(); 8538 info = TypeInfo::Unknown();
8537 } 8539 }
8538 HBinaryOperation::cast(instr)->set_observed_input_representation(rep, rep); 8540 if (instr->IsBinaryOperation()) {
8541 HBinaryOperation::cast(instr)->set_observed_input_representation(rep, rep);
8542 }
8539 return ast_context()->ReturnInstruction(instr, expr->id()); 8543 return ast_context()->ReturnInstruction(instr, expr->id());
8540 } 8544 }
8541 8545
8542 8546
8543 void HOptimizedGraphBuilder::VisitBitNot(UnaryOperation* expr) { 8547 void HOptimizedGraphBuilder::VisitBitNot(UnaryOperation* expr) {
8544 CHECK_ALIVE(VisitForValue(expr->expression())); 8548 CHECK_ALIVE(VisitForValue(expr->expression()));
8545 HValue* value = Pop(); 8549 HValue* value = Pop();
8546 TypeInfo info = oracle()->UnaryType(expr); 8550 TypeInfo info = oracle()->UnaryType(expr);
8547 if (info.IsUninitialized()) { 8551 if (info.IsUninitialized()) {
8548 AddSoftDeoptimize(); 8552 AddSoftDeoptimize();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
8616 Push(number_input); 8620 Push(number_input);
8617 } 8621 }
8618 8622
8619 // The addition has no side effects, so we do not need 8623 // The addition has no side effects, so we do not need
8620 // to simulate the expression stack after this instruction. 8624 // to simulate the expression stack after this instruction.
8621 // Any later failures deopt to the load of the input or earlier. 8625 // Any later failures deopt to the load of the input or earlier.
8622 HConstant* delta = (expr->op() == Token::INC) 8626 HConstant* delta = (expr->op() == Token::INC)
8623 ? graph()->GetConstant1() 8627 ? graph()->GetConstant1()
8624 : graph()->GetConstantMinus1(); 8628 : graph()->GetConstantMinus1();
8625 HValue* context = environment()->LookupContext(); 8629 HValue* context = environment()->LookupContext();
8626 HInstruction* instr = new(zone()) HAdd(context, Top(), delta); 8630 HInstruction* instr = HAdd::New(zone(), context, Top(), delta);
8627 // We can't insert a simulate here, because it would break deoptimization, 8631 // We can't insert a simulate here, because it would break deoptimization,
8628 // so the HAdd must not have side effects, so we must freeze its 8632 // so the HAdd must not have side effects, so we must freeze its
8629 // representation. 8633 // representation.
8630 instr->AssumeRepresentation(rep); 8634 instr->AssumeRepresentation(rep);
8631 instr->ClearAllSideEffects(); 8635 instr->ClearAllSideEffects();
8632 AddInstruction(instr); 8636 AddInstruction(instr);
8633 return instr; 8637 return instr;
8634 } 8638 }
8635 8639
8636 8640
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
8812 ASSERT(has_side_effects); // Stores always have side effects. 8816 ASSERT(has_side_effects); // Stores always have side effects.
8813 AddSimulate(expr->AssignmentId(), REMOVABLE_SIMULATE); 8817 AddSimulate(expr->AssignmentId(), REMOVABLE_SIMULATE);
8814 } 8818 }
8815 } 8819 }
8816 8820
8817 Drop(returns_original_input ? 2 : 1); 8821 Drop(returns_original_input ? 2 : 1);
8818 return ast_context()->ReturnValue(expr->is_postfix() ? input : after); 8822 return ast_context()->ReturnValue(expr->is_postfix() ? input : after);
8819 } 8823 }
8820 8824
8821 8825
8822 HStringCharCodeAt* HOptimizedGraphBuilder::BuildStringCharCodeAt( 8826 HInstruction* HOptimizedGraphBuilder::BuildStringCharCodeAt(
8823 HValue* context, 8827 HValue* context,
8824 HValue* string, 8828 HValue* string,
8825 HValue* index) { 8829 HValue* index) {
8830 if (string->IsConstant() && index->IsConstant()) {
8831 HConstant* c_string = HConstant::cast(string);
8832 HConstant* c_index = HConstant::cast(index);
8833 if (c_string->HasStringValue() && c_index->HasNumberValue()) {
8834 int32_t i = c_index->NumberValueAsInteger32();
8835 Handle<String> s = c_string->StringValue();
8836 if (i < 0 || i >= s->length()) {
8837 return new(zone()) HConstant(OS::nan_value(), Representation::Double());
8838 }
8839 return new(zone()) HConstant(s->Get(i), Representation::Integer32());
8840 }
8841 }
8826 AddInstruction(new(zone()) HCheckNonSmi(string)); 8842 AddInstruction(new(zone()) HCheckNonSmi(string));
8827 AddInstruction(HCheckInstanceType::NewIsString(string, zone())); 8843 AddInstruction(HCheckInstanceType::NewIsString(string, zone()));
8828 HStringLength* length = new(zone()) HStringLength(string); 8844 HInstruction* length = HStringLength::New(zone(), string);
8829 AddInstruction(length); 8845 AddInstruction(length);
8830 HInstruction* checked_index = AddBoundsCheck(index, length); 8846 HInstruction* checked_index = AddBoundsCheck(index, length);
8831 return new(zone()) HStringCharCodeAt(context, string, checked_index); 8847 return new(zone()) HStringCharCodeAt(context, string, checked_index);
8832 } 8848 }
8833 8849
8834 // Checks if the given shift amounts have form: (sa) and (32 - sa). 8850 // Checks if the given shift amounts have form: (sa) and (32 - sa).
8835 static bool ShiftAmountsAllowReplaceByRotate(HValue* sa, 8851 static bool ShiftAmountsAllowReplaceByRotate(HValue* sa,
8836 HValue* const32_minus_sa) { 8852 HValue* const32_minus_sa) {
8837 if (!const32_minus_sa->IsSub()) return false; 8853 if (!const32_minus_sa->IsSub()) return false;
8838 HSub* sub = HSub::cast(const32_minus_sa); 8854 HSub* sub = HSub::cast(const32_minus_sa);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
8906 left_info = right_info = TypeInfo::Unknown(); 8922 left_info = right_info = TypeInfo::Unknown();
8907 } 8923 }
8908 HInstruction* instr = NULL; 8924 HInstruction* instr = NULL;
8909 switch (expr->op()) { 8925 switch (expr->op()) {
8910 case Token::ADD: 8926 case Token::ADD:
8911 if (left_info.IsString() && right_info.IsString()) { 8927 if (left_info.IsString() && right_info.IsString()) {
8912 AddInstruction(new(zone()) HCheckNonSmi(left)); 8928 AddInstruction(new(zone()) HCheckNonSmi(left));
8913 AddInstruction(HCheckInstanceType::NewIsString(left, zone())); 8929 AddInstruction(HCheckInstanceType::NewIsString(left, zone()));
8914 AddInstruction(new(zone()) HCheckNonSmi(right)); 8930 AddInstruction(new(zone()) HCheckNonSmi(right));
8915 AddInstruction(HCheckInstanceType::NewIsString(right, zone())); 8931 AddInstruction(HCheckInstanceType::NewIsString(right, zone()));
8916 instr = new(zone()) HStringAdd(context, left, right); 8932 instr = HStringAdd::New(zone(), context, left, right);
8917 } else { 8933 } else {
8918 instr = HAdd::NewHAdd(zone(), context, left, right); 8934 instr = HAdd::New(zone(), context, left, right);
8919 } 8935 }
8920 break; 8936 break;
8921 case Token::SUB: 8937 case Token::SUB:
8922 instr = HSub::NewHSub(zone(), context, left, right); 8938 instr = HSub::New(zone(), context, left, right);
8923 break; 8939 break;
8924 case Token::MUL: 8940 case Token::MUL:
8925 instr = HMul::NewHMul(zone(), context, left, right); 8941 instr = HMul::New(zone(), context, left, right);
8926 break; 8942 break;
8927 case Token::MOD: 8943 case Token::MOD:
8928 instr = HMod::NewHMod(zone(), context, left, right); 8944 instr = HMod::New(zone(), context, left, right);
8929 break; 8945 break;
8930 case Token::DIV: 8946 case Token::DIV:
8931 instr = HDiv::NewHDiv(zone(), context, left, right); 8947 instr = HDiv::New(zone(), context, left, right);
8932 break; 8948 break;
8933 case Token::BIT_XOR: 8949 case Token::BIT_XOR:
8934 case Token::BIT_AND: 8950 case Token::BIT_AND:
8935 instr = HBitwise::NewHBitwise(zone(), expr->op(), context, left, right); 8951 instr = HBitwise::New(zone(), expr->op(), context, left, right);
8936 break; 8952 break;
8937 case Token::BIT_OR: { 8953 case Token::BIT_OR: {
8938 HValue* operand, *shift_amount; 8954 HValue* operand, *shift_amount;
8939 if (left_info.IsInteger32() && right_info.IsInteger32() && 8955 if (left_info.IsInteger32() && right_info.IsInteger32() &&
8940 MatchRotateRight(left, right, &operand, &shift_amount)) { 8956 MatchRotateRight(left, right, &operand, &shift_amount)) {
8941 instr = new(zone()) HRor(context, operand, shift_amount); 8957 instr = new(zone()) HRor(context, operand, shift_amount);
8942 } else { 8958 } else {
8943 instr = HBitwise::NewHBitwise(zone(), expr->op(), context, left, right); 8959 instr = HBitwise::New(zone(), expr->op(), context, left, right);
8944 } 8960 }
8945 break; 8961 break;
8946 } 8962 }
8947 case Token::SAR: 8963 case Token::SAR:
8948 instr = HSar::NewHSar(zone(), context, left, right); 8964 instr = HSar::New(zone(), context, left, right);
8949 break; 8965 break;
8950 case Token::SHR: 8966 case Token::SHR:
8951 instr = HShr::NewHShr(zone(), context, left, right); 8967 instr = HShr::New(zone(), context, left, right);
8952 if (FLAG_opt_safe_uint32_operations && instr->IsShr() && 8968 if (FLAG_opt_safe_uint32_operations && instr->IsShr() &&
8953 CanBeZero(right)) { 8969 CanBeZero(right)) {
8954 graph()->RecordUint32Instruction(instr); 8970 graph()->RecordUint32Instruction(instr);
8955 } 8971 }
8956 break; 8972 break;
8957 case Token::SHL: 8973 case Token::SHL:
8958 instr = HShl::NewHShl(zone(), context, left, right); 8974 instr = HShl::New(zone(), context, left, right);
8959 break; 8975 break;
8960 default: 8976 default:
8961 UNREACHABLE(); 8977 UNREACHABLE();
8962 } 8978 }
8963 8979
8964 if (instr->IsBinaryOperation()) { 8980 if (instr->IsBinaryOperation()) {
8965 HBinaryOperation* binop = HBinaryOperation::cast(instr); 8981 HBinaryOperation* binop = HBinaryOperation::cast(instr);
8966 binop->set_observed_input_representation(left_rep, right_rep); 8982 binop->set_observed_input_representation(left_rep, right_rep);
8967 binop->initialize_output_representation(result_rep); 8983 binop->initialize_output_representation(result_rep);
8968 } 8984 }
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
9708 void HOptimizedGraphBuilder::GenerateTwoByteSeqStringSetChar( 9724 void HOptimizedGraphBuilder::GenerateTwoByteSeqStringSetChar(
9709 CallRuntime* call) { 9725 CallRuntime* call) {
9710 ASSERT(call->arguments()->length() == 3); 9726 ASSERT(call->arguments()->length() == 3);
9711 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9727 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9712 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); 9728 CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
9713 CHECK_ALIVE(VisitForValue(call->arguments()->at(2))); 9729 CHECK_ALIVE(VisitForValue(call->arguments()->at(2)));
9714 HValue* value = Pop(); 9730 HValue* value = Pop();
9715 HValue* index = Pop(); 9731 HValue* index = Pop();
9716 HValue* string = Pop(); 9732 HValue* string = Pop();
9717 HValue* context = environment()->LookupContext(); 9733 HValue* context = environment()->LookupContext();
9718 HStringCharCodeAt* char_code = BuildStringCharCodeAt(context, string, index); 9734 HInstruction* char_code = BuildStringCharCodeAt(context, string, index);
9719 AddInstruction(char_code); 9735 AddInstruction(char_code);
9720 HSeqStringSetChar* result = new(zone()) HSeqStringSetChar( 9736 HSeqStringSetChar* result = new(zone()) HSeqStringSetChar(
9721 String::TWO_BYTE_ENCODING, string, index, value); 9737 String::TWO_BYTE_ENCODING, string, index, value);
9722 return ast_context()->ReturnInstruction(result, call->id()); 9738 return ast_context()->ReturnInstruction(result, call->id());
9723 } 9739 }
9724 9740
9725 9741
9726 void HOptimizedGraphBuilder::GenerateSetValueOf(CallRuntime* call) { 9742 void HOptimizedGraphBuilder::GenerateSetValueOf(CallRuntime* call) {
9727 ASSERT(call->arguments()->length() == 2); 9743 ASSERT(call->arguments()->length() == 2);
9728 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9744 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
9766 9782
9767 9783
9768 // Fast support for charCodeAt(n). 9784 // Fast support for charCodeAt(n).
9769 void HOptimizedGraphBuilder::GenerateStringCharCodeAt(CallRuntime* call) { 9785 void HOptimizedGraphBuilder::GenerateStringCharCodeAt(CallRuntime* call) {
9770 ASSERT(call->arguments()->length() == 2); 9786 ASSERT(call->arguments()->length() == 2);
9771 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9787 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9772 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); 9788 CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
9773 HValue* index = Pop(); 9789 HValue* index = Pop();
9774 HValue* string = Pop(); 9790 HValue* string = Pop();
9775 HValue* context = environment()->LookupContext(); 9791 HValue* context = environment()->LookupContext();
9776 HStringCharCodeAt* result = BuildStringCharCodeAt(context, string, index); 9792 HInstruction* result = BuildStringCharCodeAt(context, string, index);
9777 return ast_context()->ReturnInstruction(result, call->id()); 9793 return ast_context()->ReturnInstruction(result, call->id());
9778 } 9794 }
9779 9795
9780 9796
9781 // Fast support for string.charAt(n) and string[n]. 9797 // Fast support for string.charAt(n) and string[n].
9782 void HOptimizedGraphBuilder::GenerateStringCharFromCode(CallRuntime* call) { 9798 void HOptimizedGraphBuilder::GenerateStringCharFromCode(CallRuntime* call) {
9783 ASSERT(call->arguments()->length() == 1); 9799 ASSERT(call->arguments()->length() == 1);
9784 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9800 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9785 HValue* char_code = Pop(); 9801 HValue* char_code = Pop();
9786 HValue* context = environment()->LookupContext(); 9802 HValue* context = environment()->LookupContext();
9787 HStringCharFromCode* result = 9803 HInstruction* result = HStringCharFromCode::New(zone(), context, char_code);
9788 new(zone()) HStringCharFromCode(context, char_code);
9789 return ast_context()->ReturnInstruction(result, call->id()); 9804 return ast_context()->ReturnInstruction(result, call->id());
9790 } 9805 }
9791 9806
9792 9807
9793 // Fast support for string.charAt(n) and string[n]. 9808 // Fast support for string.charAt(n) and string[n].
9794 void HOptimizedGraphBuilder::GenerateStringCharAt(CallRuntime* call) { 9809 void HOptimizedGraphBuilder::GenerateStringCharAt(CallRuntime* call) {
9795 ASSERT(call->arguments()->length() == 2); 9810 ASSERT(call->arguments()->length() == 2);
9796 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9811 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9797 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); 9812 CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
9798 HValue* index = Pop(); 9813 HValue* index = Pop();
9799 HValue* string = Pop(); 9814 HValue* string = Pop();
9800 HValue* context = environment()->LookupContext(); 9815 HValue* context = environment()->LookupContext();
9801 HStringCharCodeAt* char_code = BuildStringCharCodeAt(context, string, index); 9816 HInstruction* char_code = BuildStringCharCodeAt(context, string, index);
9802 AddInstruction(char_code); 9817 AddInstruction(char_code);
9803 HStringCharFromCode* result = 9818 HInstruction* result = HStringCharFromCode::New(zone(), context, char_code);
9804 new(zone()) HStringCharFromCode(context, char_code);
9805 return ast_context()->ReturnInstruction(result, call->id()); 9819 return ast_context()->ReturnInstruction(result, call->id());
9806 } 9820 }
9807 9821
9808 9822
9809 // Fast support for object equality testing. 9823 // Fast support for object equality testing.
9810 void HOptimizedGraphBuilder::GenerateObjectEquals(CallRuntime* call) { 9824 void HOptimizedGraphBuilder::GenerateObjectEquals(CallRuntime* call) {
9811 ASSERT(call->arguments()->length() == 2); 9825 ASSERT(call->arguments()->length() == 2);
9812 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9826 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9813 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); 9827 CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
9814 HValue* right = Pop(); 9828 HValue* right = Pop();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
9954 } 9968 }
9955 9969
9956 9970
9957 // Fast call to math functions. 9971 // Fast call to math functions.
9958 void HOptimizedGraphBuilder::GenerateMathPow(CallRuntime* call) { 9972 void HOptimizedGraphBuilder::GenerateMathPow(CallRuntime* call) {
9959 ASSERT_EQ(2, call->arguments()->length()); 9973 ASSERT_EQ(2, call->arguments()->length());
9960 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9974 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9961 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); 9975 CHECK_ALIVE(VisitForValue(call->arguments()->at(1)));
9962 HValue* right = Pop(); 9976 HValue* right = Pop();
9963 HValue* left = Pop(); 9977 HValue* left = Pop();
9964 HPower* result = new(zone()) HPower(left, right); 9978 HInstruction* result = HPower::New(zone(), left, right);
9965 return ast_context()->ReturnInstruction(result, call->id()); 9979 return ast_context()->ReturnInstruction(result, call->id());
9966 } 9980 }
9967 9981
9968 9982
9969 void HOptimizedGraphBuilder::GenerateMathSin(CallRuntime* call) { 9983 void HOptimizedGraphBuilder::GenerateMathSin(CallRuntime* call) {
9970 ASSERT_EQ(1, call->arguments()->length()); 9984 ASSERT_EQ(1, call->arguments()->length());
9971 CHECK_ALIVE(VisitArgumentList(call->arguments())); 9985 CHECK_ALIVE(VisitArgumentList(call->arguments()));
9972 HValue* context = environment()->LookupContext(); 9986 HValue* context = environment()->LookupContext();
9973 HCallStub* result = 9987 HCallStub* result =
9974 new(zone()) HCallStub(context, CodeStub::TranscendentalCache, 1); 9988 new(zone()) HCallStub(context, CodeStub::TranscendentalCache, 1);
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
10677 } 10691 }
10678 } 10692 }
10679 10693
10680 #ifdef DEBUG 10694 #ifdef DEBUG
10681 if (graph_ != NULL) graph_->Verify(false); // No full verify. 10695 if (graph_ != NULL) graph_->Verify(false); // No full verify.
10682 if (allocator_ != NULL) allocator_->Verify(); 10696 if (allocator_ != NULL) allocator_->Verify();
10683 #endif 10697 #endif
10684 } 10698 }
10685 10699
10686 } } // namespace v8::internal 10700 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698