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

Unified Diff: src/ia32/code-stubs-ia32.cc

Issue 1412963002: [runtime] Implement %_ToLength via ToLengthStub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: src/ia32/code-stubs-ia32.cc
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc
index 4431944c1fe5facc5c5329776b42083ee2d7befa..2f2929f5cffa13a72e30f1cc52969a91aed73fe9 100644
--- a/src/ia32/code-stubs-ia32.cc
+++ b/src/ia32/code-stubs-ia32.cc
@@ -3192,6 +3192,25 @@ void ToNumberStub::Generate(MacroAssembler* masm) {
}
+void ToLengthStub::Generate(MacroAssembler* masm) {
+ // The ToLength stub takes on argument in eax.
+ Label not_smi, positive_smi;
+ __ JumpIfNotSmi(eax, &not_smi, Label::kNear);
+ STATIC_ASSERT(kSmiTag == 0);
+ __ test(eax, eax);
+ __ j(greater_equal, &positive_smi, Label::kNear);
+ __ xor_(eax, eax);
+ __ bind(&positive_smi);
+ __ Ret();
+ __ bind(&not_smi);
+
+ __ pop(ecx); // Pop return address.
+ __ push(eax); // Push argument.
+ __ push(ecx); // Push return address.
+ __ TailCallRuntime(Runtime::kToLength, 1, 1);
+}
+
+
void ToStringStub::Generate(MacroAssembler* masm) {
// The ToString stub takes one argument in eax.
Label is_number;

Powered by Google App Engine
This is Rietveld 408576698