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

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 106313003: Reland "Allocation site support for monomorphic StringAdds in BinaryOps". (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 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/code-stubs.cc ('k') | src/hydrogen.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 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 HValue* right = GetParameter(BinaryOpICStub::kRight); 904 HValue* right = GetParameter(BinaryOpICStub::kRight);
905 905
906 Handle<Type> left_type = state.GetLeftType(isolate()); 906 Handle<Type> left_type = state.GetLeftType(isolate());
907 Handle<Type> right_type = state.GetRightType(isolate()); 907 Handle<Type> right_type = state.GetRightType(isolate());
908 Handle<Type> result_type = state.GetResultType(isolate()); 908 Handle<Type> result_type = state.GetResultType(isolate());
909 909
910 ASSERT(!left_type->Is(Type::None()) && !right_type->Is(Type::None()) && 910 ASSERT(!left_type->Is(Type::None()) && !right_type->Is(Type::None()) &&
911 (state.HasSideEffects() || !result_type->Is(Type::None()))); 911 (state.HasSideEffects() || !result_type->Is(Type::None())));
912 912
913 HValue* result = NULL; 913 HValue* result = NULL;
914 HAllocationMode allocation_mode(NOT_TENURED);
914 if (state.op() == Token::ADD && 915 if (state.op() == Token::ADD &&
915 (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) && 916 (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) &&
916 !left_type->Is(Type::String()) && !right_type->Is(Type::String())) { 917 !left_type->Is(Type::String()) && !right_type->Is(Type::String())) {
917 // For the generic add stub a fast case for string addition is performance 918 // For the generic add stub a fast case for string addition is performance
918 // critical. 919 // critical.
919 if (left_type->Maybe(Type::String())) { 920 if (left_type->Maybe(Type::String())) {
920 IfBuilder if_leftisstring(this); 921 IfBuilder if_leftisstring(this);
921 if_leftisstring.If<HIsStringAndBranch>(left); 922 if_leftisstring.If<HIsStringAndBranch>(left);
922 if_leftisstring.Then(); 923 if_leftisstring.Then();
923 { 924 {
924 Push(BuildBinaryOperation( 925 Push(BuildBinaryOperation(
925 state.op(), left, right, 926 state.op(), left, right,
926 handle(Type::String(), isolate()), right_type, 927 handle(Type::String(), isolate()), right_type,
927 result_type, state.fixed_right_arg())); 928 result_type, state.fixed_right_arg(),
929 allocation_mode));
928 } 930 }
929 if_leftisstring.Else(); 931 if_leftisstring.Else();
930 { 932 {
931 Push(BuildBinaryOperation( 933 Push(BuildBinaryOperation(
932 state.op(), left, right, 934 state.op(), left, right,
933 left_type, right_type, result_type, 935 left_type, right_type, result_type,
934 state.fixed_right_arg())); 936 state.fixed_right_arg(), allocation_mode));
935 } 937 }
936 if_leftisstring.End(); 938 if_leftisstring.End();
937 result = Pop(); 939 result = Pop();
938 } else { 940 } else {
939 IfBuilder if_rightisstring(this); 941 IfBuilder if_rightisstring(this);
940 if_rightisstring.If<HIsStringAndBranch>(right); 942 if_rightisstring.If<HIsStringAndBranch>(right);
941 if_rightisstring.Then(); 943 if_rightisstring.Then();
942 { 944 {
943 Push(BuildBinaryOperation( 945 Push(BuildBinaryOperation(
944 state.op(), left, right, 946 state.op(), left, right,
945 left_type, handle(Type::String(), isolate()), 947 left_type, handle(Type::String(), isolate()),
946 result_type, state.fixed_right_arg())); 948 result_type, state.fixed_right_arg(),
949 allocation_mode));
947 } 950 }
948 if_rightisstring.Else(); 951 if_rightisstring.Else();
949 { 952 {
950 Push(BuildBinaryOperation( 953 Push(BuildBinaryOperation(
951 state.op(), left, right, 954 state.op(), left, right,
952 left_type, right_type, result_type, 955 left_type, right_type, result_type,
953 state.fixed_right_arg())); 956 state.fixed_right_arg(), allocation_mode));
954 } 957 }
955 if_rightisstring.End(); 958 if_rightisstring.End();
956 result = Pop(); 959 result = Pop();
957 } 960 }
958 } else { 961 } else {
959 result = BuildBinaryOperation( 962 result = BuildBinaryOperation(
960 state.op(), left, right, 963 state.op(), left, right,
961 left_type, right_type, result_type, 964 left_type, right_type, result_type,
962 state.fixed_right_arg()); 965 state.fixed_right_arg(), allocation_mode);
963 } 966 }
964 967
965 // If we encounter a generic argument, the number conversion is 968 // If we encounter a generic argument, the number conversion is
966 // observable, thus we cannot afford to bail out after the fact. 969 // observable, thus we cannot afford to bail out after the fact.
967 if (!state.HasSideEffects()) { 970 if (!state.HasSideEffects()) {
968 if (result_type->Is(Type::Smi())) { 971 if (result_type->Is(Type::Smi())) {
969 if (state.op() == Token::SHR) { 972 if (state.op() == Token::SHR) {
970 // TODO(olivf) Replace this by a SmiTagU Instruction. 973 // TODO(olivf) Replace this by a SmiTagU Instruction.
971 // 0x40000000: this number would convert to negative when interpreting 974 // 0x40000000: this number would convert to negative when interpreting
972 // the register as signed value; 975 // the register as signed value;
(...skipping 27 matching lines...) Expand all
1000 return result; 1003 return result;
1001 } 1004 }
1002 1005
1003 1006
1004 Handle<Code> BinaryOpICStub::GenerateCode(Isolate* isolate) { 1007 Handle<Code> BinaryOpICStub::GenerateCode(Isolate* isolate) {
1005 return DoGenerateCode(isolate, this); 1008 return DoGenerateCode(isolate, this);
1006 } 1009 }
1007 1010
1008 1011
1009 template <> 1012 template <>
1013 HValue* CodeStubGraphBuilder<BinaryOpWithAllocationSiteStub>::BuildCodeStub() {
1014 BinaryOpIC::State state = casted_stub()->state();
1015
1016 HValue* allocation_site = GetParameter(
1017 BinaryOpWithAllocationSiteStub::kAllocationSite);
1018 HValue* left = GetParameter(BinaryOpWithAllocationSiteStub::kLeft);
1019 HValue* right = GetParameter(BinaryOpWithAllocationSiteStub::kRight);
1020
1021 Handle<Type> left_type = state.GetLeftType(isolate());
1022 Handle<Type> right_type = state.GetRightType(isolate());
1023 Handle<Type> result_type = state.GetResultType(isolate());
1024 HAllocationMode allocation_mode(allocation_site);
1025
1026 return BuildBinaryOperation(state.op(), left, right,
1027 left_type, right_type, result_type,
1028 state.fixed_right_arg(), allocation_mode);
1029 }
1030
1031
1032 Handle<Code> BinaryOpWithAllocationSiteStub::GenerateCode(Isolate* isolate) {
1033 return DoGenerateCode(isolate, this);
1034 }
1035
1036
1037 template <>
1010 HValue* CodeStubGraphBuilder<NewStringAddStub>::BuildCodeInitializedStub() { 1038 HValue* CodeStubGraphBuilder<NewStringAddStub>::BuildCodeInitializedStub() {
1011 NewStringAddStub* stub = casted_stub(); 1039 NewStringAddStub* stub = casted_stub();
1012 StringAddFlags flags = stub->flags(); 1040 StringAddFlags flags = stub->flags();
1013 PretenureFlag pretenure_flag = stub->pretenure_flag(); 1041 PretenureFlag pretenure_flag = stub->pretenure_flag();
1014 1042
1015 HValue* left = GetParameter(NewStringAddStub::kLeft); 1043 HValue* left = GetParameter(NewStringAddStub::kLeft);
1016 HValue* right = GetParameter(NewStringAddStub::kRight); 1044 HValue* right = GetParameter(NewStringAddStub::kRight);
1017 1045
1018 // Make sure that both arguments are strings if not known in advance. 1046 // Make sure that both arguments are strings if not known in advance.
1019 if ((flags & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) { 1047 if ((flags & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) {
1020 left = BuildCheckString(left); 1048 left = BuildCheckString(left);
1021 } 1049 }
1022 if ((flags & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) { 1050 if ((flags & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) {
1023 right = BuildCheckString(right); 1051 right = BuildCheckString(right);
1024 } 1052 }
1025 1053
1026 return BuildStringAdd(left, right, pretenure_flag); 1054 return BuildStringAdd(left, right, HAllocationMode(pretenure_flag));
1027 } 1055 }
1028 1056
1029 1057
1030 Handle<Code> NewStringAddStub::GenerateCode(Isolate* isolate) { 1058 Handle<Code> NewStringAddStub::GenerateCode(Isolate* isolate) {
1031 return DoGenerateCode(isolate, this); 1059 return DoGenerateCode(isolate, this);
1032 } 1060 }
1033 1061
1034 1062
1035 template <> 1063 template <>
1036 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { 1064 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() {
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 return BuildUncheckedDictionaryElementLoad(receiver, key); 1374 return BuildUncheckedDictionaryElementLoad(receiver, key);
1347 } 1375 }
1348 1376
1349 1377
1350 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) { 1378 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) {
1351 return DoGenerateCode(isolate, this); 1379 return DoGenerateCode(isolate, this);
1352 } 1380 }
1353 1381
1354 1382
1355 } } // namespace v8::internal 1383 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698