| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 HValue* return_value = BuildCodeStub(); | 182 HValue* return_value = BuildCodeStub(); |
| 183 | 183 |
| 184 // We might have extra expressions to pop from the stack in addition to the | 184 // We might have extra expressions to pop from the stack in addition to the |
| 185 // arguments above. | 185 // arguments above. |
| 186 HInstruction* stack_pop_count = stack_parameter_count; | 186 HInstruction* stack_pop_count = stack_parameter_count; |
| 187 if (descriptor_->function_mode_ == JS_FUNCTION_STUB_MODE) { | 187 if (descriptor_->function_mode_ == JS_FUNCTION_STUB_MODE) { |
| 188 if (!stack_parameter_count->IsConstant() && | 188 if (!stack_parameter_count->IsConstant() && |
| 189 descriptor_->hint_stack_parameter_count_ < 0) { | 189 descriptor_->hint_stack_parameter_count_ < 0) { |
| 190 HInstruction* constant_one = graph()->GetConstant1(); | 190 HInstruction* constant_one = graph()->GetConstant1(); |
| 191 stack_pop_count = Add<HAdd>(stack_parameter_count, constant_one); | 191 stack_pop_count = AddUncasted<HAdd>(stack_parameter_count, constant_one); |
| 192 stack_pop_count->ClearFlag(HValue::kCanOverflow); | 192 stack_pop_count->ClearFlag(HValue::kCanOverflow); |
| 193 // TODO(mvstanton): verify that stack_parameter_count+1 really fits in a | 193 // TODO(mvstanton): verify that stack_parameter_count+1 really fits in a |
| 194 // smi. | 194 // smi. |
| 195 } else { | 195 } else { |
| 196 int count = descriptor_->hint_stack_parameter_count_; | 196 int count = descriptor_->hint_stack_parameter_count_; |
| 197 stack_pop_count = Add<HConstant>(count); | 197 stack_pop_count = Add<HConstant>(count); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 | 200 |
| 201 if (current_block() != NULL) { | 201 if (current_block() != NULL) { |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 HObjectAccess::ForAllocationSiteOffset( | 504 HObjectAccess::ForAllocationSiteOffset( |
| 505 AllocationSite::kTransitionInfoOffset), | 505 AllocationSite::kTransitionInfoOffset), |
| 506 initial_elements_kind); | 506 initial_elements_kind); |
| 507 | 507 |
| 508 // Unlike literals, constructed arrays don't have nested sites | 508 // Unlike literals, constructed arrays don't have nested sites |
| 509 Add<HStoreNamedField>(object, | 509 Add<HStoreNamedField>(object, |
| 510 HObjectAccess::ForAllocationSiteOffset( | 510 HObjectAccess::ForAllocationSiteOffset( |
| 511 AllocationSite::kNestedSiteOffset), | 511 AllocationSite::kNestedSiteOffset), |
| 512 graph()->GetConstant0()); | 512 graph()->GetConstant0()); |
| 513 | 513 |
| 514 // Pretenuring calculation fields. |
| 515 Add<HStoreNamedField>(object, |
| 516 HObjectAccess::ForAllocationSiteOffset( |
| 517 AllocationSite::kMementoFoundCountOffset), |
| 518 graph()->GetConstant0()); |
| 519 |
| 520 Add<HStoreNamedField>(object, |
| 521 HObjectAccess::ForAllocationSiteOffset( |
| 522 AllocationSite::kMementoCreateCountOffset), |
| 523 graph()->GetConstant0()); |
| 524 |
| 525 Add<HStoreNamedField>(object, |
| 526 HObjectAccess::ForAllocationSiteOffset( |
| 527 AllocationSite::kPretenureDecisionOffset), |
| 528 graph()->GetConstant0()); |
| 529 |
| 514 // Store an empty fixed array for the code dependency. | 530 // Store an empty fixed array for the code dependency. |
| 515 HConstant* empty_fixed_array = | 531 HConstant* empty_fixed_array = |
| 516 Add<HConstant>(isolate()->factory()->empty_fixed_array()); | 532 Add<HConstant>(isolate()->factory()->empty_fixed_array()); |
| 517 HStoreNamedField* store = Add<HStoreNamedField>( | 533 HStoreNamedField* store = Add<HStoreNamedField>( |
| 518 object, | 534 object, |
| 519 HObjectAccess::ForAllocationSiteOffset( | 535 HObjectAccess::ForAllocationSiteOffset( |
| 520 AllocationSite::kDependentCodeOffset), | 536 AllocationSite::kDependentCodeOffset), |
| 521 empty_fixed_array); | 537 empty_fixed_array); |
| 522 | 538 |
| 523 // Link the object to the allocation site list | 539 // Link the object to the allocation site list |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 // For the generic add stub a fast case for string addition is performance | 908 // For the generic add stub a fast case for string addition is performance |
| 893 // critical. | 909 // critical. |
| 894 if (left_type->Maybe(Type::String())) { | 910 if (left_type->Maybe(Type::String())) { |
| 895 IfBuilder if_leftisstring(this); | 911 IfBuilder if_leftisstring(this); |
| 896 if_leftisstring.If<HIsStringAndBranch>(left); | 912 if_leftisstring.If<HIsStringAndBranch>(left); |
| 897 if_leftisstring.Then(); | 913 if_leftisstring.Then(); |
| 898 { | 914 { |
| 899 Push(BuildBinaryOperation( | 915 Push(BuildBinaryOperation( |
| 900 stub->operation(), left, right, | 916 stub->operation(), left, right, |
| 901 handle(Type::String(), isolate()), right_type, | 917 handle(Type::String(), isolate()), right_type, |
| 902 result_type, stub->fixed_right_arg(), true)); | 918 result_type, stub->fixed_right_arg())); |
| 903 } | 919 } |
| 904 if_leftisstring.Else(); | 920 if_leftisstring.Else(); |
| 905 { | 921 { |
| 906 Push(BuildBinaryOperation( | 922 Push(BuildBinaryOperation( |
| 907 stub->operation(), left, right, | 923 stub->operation(), left, right, |
| 908 left_type, right_type, result_type, | 924 left_type, right_type, result_type, |
| 909 stub->fixed_right_arg(), true)); | 925 stub->fixed_right_arg())); |
| 910 } | 926 } |
| 911 if_leftisstring.End(); | 927 if_leftisstring.End(); |
| 912 result = Pop(); | 928 result = Pop(); |
| 913 } else { | 929 } else { |
| 914 IfBuilder if_rightisstring(this); | 930 IfBuilder if_rightisstring(this); |
| 915 if_rightisstring.If<HIsStringAndBranch>(right); | 931 if_rightisstring.If<HIsStringAndBranch>(right); |
| 916 if_rightisstring.Then(); | 932 if_rightisstring.Then(); |
| 917 { | 933 { |
| 918 Push(BuildBinaryOperation( | 934 Push(BuildBinaryOperation( |
| 919 stub->operation(), left, right, | 935 stub->operation(), left, right, |
| 920 left_type, handle(Type::String(), isolate()), | 936 left_type, handle(Type::String(), isolate()), |
| 921 result_type, stub->fixed_right_arg(), true)); | 937 result_type, stub->fixed_right_arg())); |
| 922 } | 938 } |
| 923 if_rightisstring.Else(); | 939 if_rightisstring.Else(); |
| 924 { | 940 { |
| 925 Push(BuildBinaryOperation( | 941 Push(BuildBinaryOperation( |
| 926 stub->operation(), left, right, | 942 stub->operation(), left, right, |
| 927 left_type, right_type, result_type, | 943 left_type, right_type, result_type, |
| 928 stub->fixed_right_arg(), true)); | 944 stub->fixed_right_arg())); |
| 929 } | 945 } |
| 930 if_rightisstring.End(); | 946 if_rightisstring.End(); |
| 931 result = Pop(); | 947 result = Pop(); |
| 932 } | 948 } |
| 933 } else { | 949 } else { |
| 934 result = BuildBinaryOperation( | 950 result = BuildBinaryOperation( |
| 935 stub->operation(), left, right, | 951 stub->operation(), left, right, |
| 936 left_type, right_type, result_type, | 952 left_type, right_type, result_type, |
| 937 stub->fixed_right_arg(), true); | 953 stub->fixed_right_arg()); |
| 938 } | 954 } |
| 939 | 955 |
| 940 // If we encounter a generic argument, the number conversion is | 956 // If we encounter a generic argument, the number conversion is |
| 941 // observable, thus we cannot afford to bail out after the fact. | 957 // observable, thus we cannot afford to bail out after the fact. |
| 942 if (!stub->HasSideEffects(isolate())) { | 958 if (!stub->HasSideEffects(isolate())) { |
| 943 if (result_type->Is(Type::Smi())) { | 959 if (result_type->Is(Type::Smi())) { |
| 944 if (stub->operation() == Token::SHR) { | 960 if (stub->operation() == Token::SHR) { |
| 945 // TODO(olivf) Replace this by a SmiTagU Instruction. | 961 // TODO(olivf) Replace this by a SmiTagU Instruction. |
| 946 // 0x40000000: this number would convert to negative when interpreting | 962 // 0x40000000: this number would convert to negative when interpreting |
| 947 // the register as signed value; | 963 // the register as signed value; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 HValue* CodeStubGraphBuilder<NewStringAddStub>::BuildCodeInitializedStub() { | 1001 HValue* CodeStubGraphBuilder<NewStringAddStub>::BuildCodeInitializedStub() { |
| 986 NewStringAddStub* stub = casted_stub(); | 1002 NewStringAddStub* stub = casted_stub(); |
| 987 StringAddFlags flags = stub->flags(); | 1003 StringAddFlags flags = stub->flags(); |
| 988 PretenureFlag pretenure_flag = stub->pretenure_flag(); | 1004 PretenureFlag pretenure_flag = stub->pretenure_flag(); |
| 989 | 1005 |
| 990 HValue* left = GetParameter(NewStringAddStub::kLeft); | 1006 HValue* left = GetParameter(NewStringAddStub::kLeft); |
| 991 HValue* right = GetParameter(NewStringAddStub::kRight); | 1007 HValue* right = GetParameter(NewStringAddStub::kRight); |
| 992 | 1008 |
| 993 // Make sure that both arguments are strings if not known in advance. | 1009 // Make sure that both arguments are strings if not known in advance. |
| 994 if ((flags & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) { | 1010 if ((flags & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) { |
| 995 IfBuilder if_leftnotstring(this); | 1011 left = BuildCheckString(left); |
| 996 if_leftnotstring.IfNot<HIsStringAndBranch>(left); | |
| 997 if_leftnotstring.Then(); | |
| 998 if_leftnotstring.Deopt("Expected string for LHS of string addition"); | |
| 999 } | 1012 } |
| 1000 if ((flags & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) { | 1013 if ((flags & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) { |
| 1001 IfBuilder if_rightnotstring(this); | 1014 right = BuildCheckString(right); |
| 1002 if_rightnotstring.IfNot<HIsStringAndBranch>(right); | |
| 1003 if_rightnotstring.Then(); | |
| 1004 if_rightnotstring.Deopt("Expected string for RHS of string addition"); | |
| 1005 } | 1015 } |
| 1006 | 1016 |
| 1007 return BuildStringAdd(left, right, pretenure_flag); | 1017 return BuildStringAdd(left, right, pretenure_flag); |
| 1008 } | 1018 } |
| 1009 | 1019 |
| 1010 | 1020 |
| 1011 Handle<Code> NewStringAddStub::GenerateCode(Isolate* isolate) { | 1021 Handle<Code> NewStringAddStub::GenerateCode(Isolate* isolate) { |
| 1012 return DoGenerateCode(isolate, this); | 1022 return DoGenerateCode(isolate, this); |
| 1013 } | 1023 } |
| 1014 | 1024 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 return BuildUncheckedDictionaryElementLoad(receiver, key); | 1323 return BuildUncheckedDictionaryElementLoad(receiver, key); |
| 1314 } | 1324 } |
| 1315 | 1325 |
| 1316 | 1326 |
| 1317 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) { | 1327 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) { |
| 1318 return DoGenerateCode(isolate, this); | 1328 return DoGenerateCode(isolate, this); |
| 1319 } | 1329 } |
| 1320 | 1330 |
| 1321 | 1331 |
| 1322 } } // namespace v8::internal | 1332 } } // namespace v8::internal |
| OLD | NEW |