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

Unified Diff: src/ia32/codegen-ia32.cc

Issue 1560001: Call binary op stub instead of runtime in count operations. (Closed)
Patch Set: Created 10 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/x64/codegen-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/codegen-ia32.cc
diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc
index d3e7de6741e3d078a1d24a062a28ead102c9a480..4b6c55ef1803b1fb7be7a3e6d2e49734dd0aa78c 100644
--- a/src/ia32/codegen-ia32.cc
+++ b/src/ia32/codegen-ia32.cc
@@ -7034,17 +7034,21 @@ void DeferredPrefixCountOperation::Generate() {
} else {
__ add(Operand(dst_), Immediate(Smi::FromInt(1)));
}
- __ push(dst_);
- if (!input_type_.IsNumber()) {
- __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION);
- __ push(eax);
- }
- __ push(Immediate(Smi::FromInt(1)));
- if (is_increment_) {
- __ CallRuntime(Runtime::kNumberAdd, 2);
+ Register left;
+ if (input_type_.IsNumber()) {
+ left = dst_;
} else {
- __ CallRuntime(Runtime::kNumberSub, 2);
+ __ push(dst_);
+ __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION);
+ left = eax;
}
+
+ GenericBinaryOpStub stub(is_increment_ ? Token::ADD : Token::SUB,
+ NO_OVERWRITE,
+ NO_GENERIC_BINARY_FLAGS,
+ TypeInfo::Number());
+ stub.GenerateCall(masm_, left, Smi::FromInt(1));
+
if (!dst_.is(eax)) __ mov(dst_, eax);
}
@@ -7084,23 +7088,23 @@ void DeferredPostfixCountOperation::Generate() {
} else {
__ add(Operand(dst_), Immediate(Smi::FromInt(1)));
}
+ Register left;
if (input_type_.IsNumber()) {
__ push(dst_); // Save the input to use as the old value.
- __ push(dst_);
+ left = dst_;
} else {
__ push(dst_);
__ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION);
__ push(eax); // Save the result of ToNumber to use as the old value.
- __ push(eax);
+ left = eax;
}
- // Call the runtime for the addition or subtraction.
- __ push(Immediate(Smi::FromInt(1)));
- if (is_increment_) {
- __ CallRuntime(Runtime::kNumberAdd, 2);
- } else {
- __ CallRuntime(Runtime::kNumberSub, 2);
- }
+ GenericBinaryOpStub stub(is_increment_ ? Token::ADD : Token::SUB,
+ NO_OVERWRITE,
+ NO_GENERIC_BINARY_FLAGS,
+ TypeInfo::Number());
+ stub.GenerateCall(masm_, left, Smi::FromInt(1));
+
if (!dst_.is(eax)) __ mov(dst_, eax);
__ pop(old_);
}
« 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