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

Unified Diff: src/x64/code-stubs-x64.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/x64/code-stubs-x64.cc
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
index 2df677fad10722a4f8ed5f8462441e5ba0617f36..481e100c77361db3b333794d1e82e34e5f19aa32 100644
--- a/src/x64/code-stubs-x64.cc
+++ b/src/x64/code-stubs-x64.cc
@@ -3122,6 +3122,25 @@ void ToNumberStub::Generate(MacroAssembler* masm) {
}
+void ToLengthStub::Generate(MacroAssembler* masm) {
+ // The ToLength stub takes on argument in rax.
+ Label not_smi, positive_smi;
+ __ JumpIfNotSmi(rax, &not_smi, Label::kNear);
+ STATIC_ASSERT(kSmiTag == 0);
+ __ testp(rax, rax);
+ __ j(greater_equal, &positive_smi, Label::kNear);
+ __ xorl(rax, rax);
+ __ bind(&positive_smi);
+ __ Ret();
+ __ bind(&not_smi);
+
+ __ PopReturnAddressTo(rcx); // Pop return address.
+ __ Push(rax); // Push argument.
+ __ PushReturnAddressFrom(rcx); // Push return address.
+ __ TailCallRuntime(Runtime::kToLength, 1, 1);
+}
+
+
void ToStringStub::Generate(MacroAssembler* masm) {
// The ToString stub takes one argument in rax.
Label is_number;

Powered by Google App Engine
This is Rietveld 408576698