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

Side by Side Diff: src/x64/codegen-x64.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 | « src/ia32/codegen-ia32.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 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 3134 matching lines...) Expand 10 before | Expand all | Expand 10 after
3145 virtual void Generate(); 3145 virtual void Generate();
3146 3146
3147 private: 3147 private:
3148 Register dst_; 3148 Register dst_;
3149 bool is_increment_; 3149 bool is_increment_;
3150 TypeInfo input_type_; 3150 TypeInfo input_type_;
3151 }; 3151 };
3152 3152
3153 3153
3154 void DeferredPrefixCountOperation::Generate() { 3154 void DeferredPrefixCountOperation::Generate() {
3155 __ push(dst_); 3155 Register left;
3156 if (!input_type_.IsNumber()) { 3156 if (input_type_.IsNumber()) {
3157 left = dst_;
3158 } else {
3159 __ push(dst_);
3157 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION); 3160 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION);
3158 __ push(rax); 3161 left = rax;
3159 } 3162 }
3160 __ Push(Smi::FromInt(1)); 3163
3161 if (is_increment_) { 3164 GenericBinaryOpStub stub(is_increment_ ? Token::ADD : Token::SUB,
3162 __ CallRuntime(Runtime::kNumberAdd, 2); 3165 NO_OVERWRITE,
3163 } else { 3166 NO_GENERIC_BINARY_FLAGS,
3164 __ CallRuntime(Runtime::kNumberSub, 2); 3167 TypeInfo::Number());
3165 } 3168 stub.GenerateCall(masm_, left, Smi::FromInt(1));
3169
3166 if (!dst_.is(rax)) __ movq(dst_, rax); 3170 if (!dst_.is(rax)) __ movq(dst_, rax);
3167 } 3171 }
3168 3172
3169 3173
3170 // The value in dst was optimistically incremented or decremented. 3174 // The value in dst was optimistically incremented or decremented.
3171 // The result overflowed or was not smi tagged. Call into the runtime 3175 // The result overflowed or was not smi tagged. Call into the runtime
3172 // to convert the argument to a number. Update the original value in 3176 // to convert the argument to a number. Update the original value in
3173 // old. Call the specialized add or subtract stub. The result is 3177 // old. Call the specialized add or subtract stub. The result is
3174 // left in dst. 3178 // left in dst.
3175 class DeferredPostfixCountOperation: public DeferredCode { 3179 class DeferredPostfixCountOperation: public DeferredCode {
(...skipping 13 matching lines...) Expand all
3189 3193
3190 private: 3194 private:
3191 Register dst_; 3195 Register dst_;
3192 Register old_; 3196 Register old_;
3193 bool is_increment_; 3197 bool is_increment_;
3194 TypeInfo input_type_; 3198 TypeInfo input_type_;
3195 }; 3199 };
3196 3200
3197 3201
3198 void DeferredPostfixCountOperation::Generate() { 3202 void DeferredPostfixCountOperation::Generate() {
3203 Register left;
3199 if (input_type_.IsNumber()) { 3204 if (input_type_.IsNumber()) {
3200 __ push(dst_); // Save the input to use as the old value. 3205 __ push(dst_); // Save the input to use as the old value.
3201 __ push(dst_); 3206 left = dst_;
3202 } else { 3207 } else {
3203 __ push(dst_); 3208 __ push(dst_);
3204 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION); 3209 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION);
3205 __ push(rax); // Save the result of ToNumber to use as the old value. 3210 __ push(rax); // Save the result of ToNumber to use as the old value.
3206 __ push(rax); 3211 left = rax;
3207 } 3212 }
3208 3213
3209 // Call the runtime for the addition or subtraction. 3214 GenericBinaryOpStub stub(is_increment_ ? Token::ADD : Token::SUB,
3210 __ Push(Smi::FromInt(1)); 3215 NO_OVERWRITE,
3211 if (is_increment_) { 3216 NO_GENERIC_BINARY_FLAGS,
3212 __ CallRuntime(Runtime::kNumberAdd, 2); 3217 TypeInfo::Number());
3213 } else { 3218 stub.GenerateCall(masm_, left, Smi::FromInt(1));
3214 __ CallRuntime(Runtime::kNumberSub, 2); 3219
3215 }
3216 if (!dst_.is(rax)) __ movq(dst_, rax); 3220 if (!dst_.is(rax)) __ movq(dst_, rax);
3217 __ pop(old_); 3221 __ pop(old_);
3218 } 3222 }
3219 3223
3220 3224
3221 void CodeGenerator::VisitCountOperation(CountOperation* node) { 3225 void CodeGenerator::VisitCountOperation(CountOperation* node) {
3222 Comment cmnt(masm_, "[ CountOperation"); 3226 Comment cmnt(masm_, "[ CountOperation");
3223 3227
3224 bool is_postfix = node->is_postfix(); 3228 bool is_postfix = node->is_postfix();
3225 bool is_increment = node->op() == Token::INC; 3229 bool is_increment = node->op() == Token::INC;
(...skipping 6811 matching lines...) Expand 10 before | Expand all | Expand 10 after
10037 // Call the function from C++. 10041 // Call the function from C++.
10038 return FUNCTION_CAST<ModuloFunction>(buffer); 10042 return FUNCTION_CAST<ModuloFunction>(buffer);
10039 } 10043 }
10040 10044
10041 #endif 10045 #endif
10042 10046
10043 10047
10044 #undef __ 10048 #undef __
10045 10049
10046 } } // namespace v8::internal 10050 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698