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

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

Issue 1560001: Call binary op stub instead of runtime in count operations. (Closed)
Patch Set: Created 10 years, 8 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
« no previous file with comments | « no previous file | src/x64/codegen-x64.cc » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 7016 matching lines...) Expand 10 before | Expand all | Expand 10 after
7027 }; 7027 };
7028 7028
7029 7029
7030 void DeferredPrefixCountOperation::Generate() { 7030 void DeferredPrefixCountOperation::Generate() {
7031 // Undo the optimistic smi operation. 7031 // Undo the optimistic smi operation.
7032 if (is_increment_) { 7032 if (is_increment_) {
7033 __ sub(Operand(dst_), Immediate(Smi::FromInt(1))); 7033 __ sub(Operand(dst_), Immediate(Smi::FromInt(1)));
7034 } else { 7034 } else {
7035 __ add(Operand(dst_), Immediate(Smi::FromInt(1))); 7035 __ add(Operand(dst_), Immediate(Smi::FromInt(1)));
7036 } 7036 }
7037 __ push(dst_); 7037 Register left;
7038 if (!input_type_.IsNumber()) { 7038 if (input_type_.IsNumber()) {
7039 left = dst_;
7040 } else {
7041 __ push(dst_);
7039 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION); 7042 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION);
7040 __ push(eax); 7043 left = eax;
7041 } 7044 }
7042 __ push(Immediate(Smi::FromInt(1))); 7045
7043 if (is_increment_) { 7046 GenericBinaryOpStub stub(is_increment_ ? Token::ADD : Token::SUB,
7044 __ CallRuntime(Runtime::kNumberAdd, 2); 7047 NO_OVERWRITE,
7045 } else { 7048 NO_GENERIC_BINARY_FLAGS,
7046 __ CallRuntime(Runtime::kNumberSub, 2); 7049 TypeInfo::Number());
7047 } 7050 stub.GenerateCall(masm_, left, Smi::FromInt(1));
7051
7048 if (!dst_.is(eax)) __ mov(dst_, eax); 7052 if (!dst_.is(eax)) __ mov(dst_, eax);
7049 } 7053 }
7050 7054
7051 7055
7052 // The value in dst was optimistically incremented or decremented. The 7056 // The value in dst was optimistically incremented or decremented. The
7053 // result overflowed or was not smi tagged. Undo the operation and call 7057 // result overflowed or was not smi tagged. Undo the operation and call
7054 // into the runtime to convert the argument to a number. Update the 7058 // into the runtime to convert the argument to a number. Update the
7055 // original value in old. Call the specialized add or subtract stub. 7059 // original value in old. Call the specialized add or subtract stub.
7056 // The result is left in dst. 7060 // The result is left in dst.
7057 class DeferredPostfixCountOperation: public DeferredCode { 7061 class DeferredPostfixCountOperation: public DeferredCode {
(...skipping 19 matching lines...) Expand all
7077 }; 7081 };
7078 7082
7079 7083
7080 void DeferredPostfixCountOperation::Generate() { 7084 void DeferredPostfixCountOperation::Generate() {
7081 // Undo the optimistic smi operation. 7085 // Undo the optimistic smi operation.
7082 if (is_increment_) { 7086 if (is_increment_) {
7083 __ sub(Operand(dst_), Immediate(Smi::FromInt(1))); 7087 __ sub(Operand(dst_), Immediate(Smi::FromInt(1)));
7084 } else { 7088 } else {
7085 __ add(Operand(dst_), Immediate(Smi::FromInt(1))); 7089 __ add(Operand(dst_), Immediate(Smi::FromInt(1)));
7086 } 7090 }
7091 Register left;
7087 if (input_type_.IsNumber()) { 7092 if (input_type_.IsNumber()) {
7088 __ push(dst_); // Save the input to use as the old value. 7093 __ push(dst_); // Save the input to use as the old value.
7089 __ push(dst_); 7094 left = dst_;
7090 } else { 7095 } else {
7091 __ push(dst_); 7096 __ push(dst_);
7092 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION); 7097 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION);
7093 __ push(eax); // Save the result of ToNumber to use as the old value. 7098 __ push(eax); // Save the result of ToNumber to use as the old value.
7094 __ push(eax); 7099 left = eax;
7095 } 7100 }
7096 7101
7097 // Call the runtime for the addition or subtraction. 7102 GenericBinaryOpStub stub(is_increment_ ? Token::ADD : Token::SUB,
7098 __ push(Immediate(Smi::FromInt(1))); 7103 NO_OVERWRITE,
7099 if (is_increment_) { 7104 NO_GENERIC_BINARY_FLAGS,
7100 __ CallRuntime(Runtime::kNumberAdd, 2); 7105 TypeInfo::Number());
7101 } else { 7106 stub.GenerateCall(masm_, left, Smi::FromInt(1));
7102 __ CallRuntime(Runtime::kNumberSub, 2); 7107
7103 }
7104 if (!dst_.is(eax)) __ mov(dst_, eax); 7108 if (!dst_.is(eax)) __ mov(dst_, eax);
7105 __ pop(old_); 7109 __ pop(old_);
7106 } 7110 }
7107 7111
7108 7112
7109 void CodeGenerator::VisitCountOperation(CountOperation* node) { 7113 void CodeGenerator::VisitCountOperation(CountOperation* node) {
7110 ASSERT(!in_safe_int32_mode()); 7114 ASSERT(!in_safe_int32_mode());
7111 Comment cmnt(masm_, "[ CountOperation"); 7115 Comment cmnt(masm_, "[ CountOperation");
7112 7116
7113 bool is_postfix = node->is_postfix(); 7117 bool is_postfix = node->is_postfix();
(...skipping 5486 matching lines...) Expand 10 before | Expand all | Expand 10 after
12600 12604
12601 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 12605 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
12602 // tagged as a small integer. 12606 // tagged as a small integer.
12603 __ bind(&runtime); 12607 __ bind(&runtime);
12604 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 12608 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
12605 } 12609 }
12606 12610
12607 #undef __ 12611 #undef __
12608 12612
12609 } } // namespace v8::internal 12613 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698