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

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

Issue 27674002: Inline number to string conversion for string addition into BinaryOp(Stub). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Improve string-check in BuildBinaryOperation. Created 7 years, 2 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 344
345 Handle<Code> ToNumberStub::GenerateCode(Isolate* isolate) { 345 Handle<Code> ToNumberStub::GenerateCode(Isolate* isolate) {
346 return DoGenerateCode(isolate, this); 346 return DoGenerateCode(isolate, this);
347 } 347 }
348 348
349 349
350 template <> 350 template <>
351 HValue* CodeStubGraphBuilder<NumberToStringStub>::BuildCodeStub() { 351 HValue* CodeStubGraphBuilder<NumberToStringStub>::BuildCodeStub() {
352 info()->MarkAsSavesCallerDoubles(); 352 info()->MarkAsSavesCallerDoubles();
353 HValue* number = GetParameter(NumberToStringStub::kNumber); 353 HValue* number = GetParameter(NumberToStringStub::kNumber);
354 return BuildNumberToString(number); 354 return BuildNumberToString(number, handle(Type::Number(), isolate()));
355 } 355 }
356 356
357 357
358 Handle<Code> NumberToStringStub::GenerateCode(Isolate* isolate) { 358 Handle<Code> NumberToStringStub::GenerateCode(Isolate* isolate) {
359 return DoGenerateCode(isolate, this); 359 return DoGenerateCode(isolate, this);
360 } 360 }
361 361
362 362
363 template <> 363 template <>
364 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { 364 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() {
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 Handle<Type> right_type = stub->GetRightType(isolate()); 874 Handle<Type> right_type = stub->GetRightType(isolate());
875 Handle<Type> result_type = stub->GetResultType(isolate()); 875 Handle<Type> result_type = stub->GetResultType(isolate());
876 876
877 ASSERT(!left_type->Is(Type::None()) && !right_type->Is(Type::None()) && 877 ASSERT(!left_type->Is(Type::None()) && !right_type->Is(Type::None()) &&
878 (stub->HasSideEffects(isolate()) || !result_type->Is(Type::None()))); 878 (stub->HasSideEffects(isolate()) || !result_type->Is(Type::None())));
879 879
880 HValue* result = NULL; 880 HValue* result = NULL;
881 if (stub->operation() == Token::ADD && 881 if (stub->operation() == Token::ADD &&
882 (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) && 882 (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) &&
883 !left_type->Is(Type::String()) && !right_type->Is(Type::String())) { 883 !left_type->Is(Type::String()) && !right_type->Is(Type::String())) {
884 // For the generic add stub a fast case for String add is performance 884 // For the generic add stub a fast case for string addition is performance
885 // critical. 885 // critical.
886 if (left_type->Maybe(Type::String())) { 886 if (left_type->Maybe(Type::String())) {
887 IfBuilder left_string(this); 887 IfBuilder if_leftisstring(this);
888 left_string.If<HIsStringAndBranch>(left); 888 if_leftisstring.If<HIsStringAndBranch>(left);
889 left_string.Then(); 889 if_leftisstring.Then();
890 Push(Add<HStringAdd>(left, right, STRING_ADD_CHECK_RIGHT)); 890 {
891 left_string.Else(); 891 Push(AddInstruction(BuildBinaryOperation(
892 Push(AddInstruction(BuildBinaryOperation(stub->operation(), 892 stub->operation(), left, right,
893 left, right, left_type, right_type, result_type, 893 handle(Type::String(), isolate()), right_type,
894 stub->fixed_right_arg(), true))); 894 result_type, stub->fixed_right_arg(), true)));
895 left_string.End(); 895 }
896 if_leftisstring.Else();
897 {
898 Push(AddInstruction(BuildBinaryOperation(
899 stub->operation(), left, right,
900 left_type, right_type, result_type,
901 stub->fixed_right_arg(), true)));
902 }
903 if_leftisstring.End();
896 result = Pop(); 904 result = Pop();
897 } else { 905 } else {
898 IfBuilder right_string(this); 906 IfBuilder if_rightisstring(this);
899 right_string.If<HIsStringAndBranch>(right); 907 if_rightisstring.If<HIsStringAndBranch>(right);
900 right_string.Then(); 908 if_rightisstring.Then();
901 Push(Add<HStringAdd>(left, right, STRING_ADD_CHECK_LEFT)); 909 {
902 right_string.Else(); 910 Push(AddInstruction(BuildBinaryOperation(
903 Push(AddInstruction(BuildBinaryOperation(stub->operation(), 911 stub->operation(), left, right,
904 left, right, left_type, right_type, result_type, 912 left_type, handle(Type::String(), isolate()),
905 stub->fixed_right_arg(), true))); 913 result_type, stub->fixed_right_arg(), true)));
906 right_string.End(); 914 }
915 if_rightisstring.Else();
916 {
917 Push(AddInstruction(BuildBinaryOperation(
918 stub->operation(), left, right,
919 left_type, right_type, result_type,
920 stub->fixed_right_arg(), true)));
921 }
922 if_rightisstring.End();
907 result = Pop(); 923 result = Pop();
908 } 924 }
909 } else { 925 } else {
910 result = AddInstruction(BuildBinaryOperation(stub->operation(), 926 result = AddInstruction(BuildBinaryOperation(
911 left, right, left_type, right_type, result_type, 927 stub->operation(), left, right,
912 stub->fixed_right_arg(), true)); 928 left_type, right_type, result_type,
929 stub->fixed_right_arg(), true));
913 } 930 }
914 931
915 // If we encounter a generic argument, the number conversion is 932 // If we encounter a generic argument, the number conversion is
916 // observable, thus we cannot afford to bail out after the fact. 933 // observable, thus we cannot afford to bail out after the fact.
917 if (!stub->HasSideEffects(isolate())) { 934 if (!stub->HasSideEffects(isolate())) {
918 if (result_type->Is(Type::Smi())) { 935 if (result_type->Is(Type::Smi())) {
919 if (stub->operation() == Token::SHR) { 936 if (stub->operation() == Token::SHR) {
920 // TODO(olivf) Replace this by a SmiTagU Instruction. 937 // TODO(olivf) Replace this by a SmiTagU Instruction.
921 // 0x40000000: this number would convert to negative when interpreting 938 // 0x40000000: this number would convert to negative when interpreting
922 // the register as signed value; 939 // the register as signed value;
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 return js_function; 1259 return js_function;
1243 } 1260 }
1244 1261
1245 1262
1246 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { 1263 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) {
1247 return DoGenerateCode(isolate, this); 1264 return DoGenerateCode(isolate, this);
1248 } 1265 }
1249 1266
1250 1267
1251 } } // namespace v8::internal 1268 } } // 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