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

Side by Side Diff: src/x64/codegen-x64.cc

Issue 465028: String check for binary add on x64 and ARM... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years 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/arm/codegen-arm.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 7759 matching lines...) Expand 10 before | Expand all | Expand 10 after
7770 if (HasArgumentsReversed()) { 7770 if (HasArgumentsReversed()) {
7771 __ push(rax); 7771 __ push(rax);
7772 __ push(rdx); 7772 __ push(rdx);
7773 } else { 7773 } else {
7774 __ push(rdx); 7774 __ push(rdx);
7775 __ push(rax); 7775 __ push(rax);
7776 } 7776 }
7777 __ push(rcx); 7777 __ push(rcx);
7778 } 7778 }
7779 switch (op_) { 7779 switch (op_) {
7780 case Token::ADD: 7780 case Token::ADD: {
7781 // Test for string arguments before calling runtime.
7782 Label not_strings, both_strings, not_string1, string1;
7783 Condition is_smi;
7784 Result answer;
7785 __ movq(rdx, Operand(rsp, 2 * kPointerSize)); // First argument.
7786 __ movq(rax, Operand(rsp, 1 * kPointerSize)); // Second argument.
7787 is_smi = masm->CheckSmi(rdx);
7788 __ j(is_smi, &not_string1);
7789 __ CmpObjectType(rdx, FIRST_NONSTRING_TYPE, rdx);
7790 __ j(above_equal, &not_string1);
7791
7792 // First argument is a a string, test second.
7793 is_smi = masm->CheckSmi(rax);
7794 __ j(is_smi, &string1);
7795 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rax);
7796 __ j(above_equal, &string1);
7797
7798 // First and second argument are strings.
7799 Runtime::Function* f = Runtime::FunctionForId(Runtime::kStringAdd);
7800 __ TailCallRuntime(ExternalReference(f), 2, f->result_size);
7801
7802 // Only first argument is a string.
7803 __ bind(&string1);
7804 __ InvokeBuiltin(Builtins::STRING_ADD_LEFT, JUMP_FUNCTION);
7805
7806 // First argument was not a string, test second.
7807 __ bind(&not_string1);
7808 is_smi = masm->CheckSmi(rax);
7809 __ j(is_smi, &not_strings);
7810 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rax);
7811 __ j(above_equal, &not_strings);
7812
7813 // Only second argument is a string.
7814 __ InvokeBuiltin(Builtins::STRING_ADD_RIGHT, JUMP_FUNCTION);
7815
7816 __ bind(&not_strings);
7817 // Neither argument is a string.
7781 __ InvokeBuiltin(Builtins::ADD, JUMP_FUNCTION); 7818 __ InvokeBuiltin(Builtins::ADD, JUMP_FUNCTION);
7782 break; 7819 break;
7820 }
7783 case Token::SUB: 7821 case Token::SUB:
7784 __ InvokeBuiltin(Builtins::SUB, JUMP_FUNCTION); 7822 __ InvokeBuiltin(Builtins::SUB, JUMP_FUNCTION);
7785 break; 7823 break;
7786 case Token::MUL: 7824 case Token::MUL:
7787 __ InvokeBuiltin(Builtins::MUL, JUMP_FUNCTION); 7825 __ InvokeBuiltin(Builtins::MUL, JUMP_FUNCTION);
7788 break; 7826 break;
7789 case Token::DIV: 7827 case Token::DIV:
7790 __ InvokeBuiltin(Builtins::DIV, JUMP_FUNCTION); 7828 __ InvokeBuiltin(Builtins::DIV, JUMP_FUNCTION);
7791 break; 7829 break;
7792 case Token::MOD: 7830 case Token::MOD:
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
7931 masm.GetCode(&desc); 7969 masm.GetCode(&desc);
7932 // Call the function from C++. 7970 // Call the function from C++.
7933 return FUNCTION_CAST<ModuloFunction>(buffer); 7971 return FUNCTION_CAST<ModuloFunction>(buffer);
7934 } 7972 }
7935 7973
7936 #endif 7974 #endif
7937 7975
7938 #undef __ 7976 #undef __
7939 7977
7940 } } // namespace v8::internal 7978 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/codegen-arm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698