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

Side by Side Diff: src/arm64/builtins-arm64.cc

Issue 1344893002: [builtins] Unify the String constructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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/arm/builtins-arm.cc ('k') | src/bootstrapper.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_ARM64 5 #if V8_TARGET_ARCH_ARM64
6 6
7 #include "src/arm64/frames-arm64.h" 7 #include "src/arm64/frames-arm64.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 125
126 // Run the native code for the Array function called as a normal function. 126 // Run the native code for the Array function called as a normal function.
127 __ LoadRoot(x2, Heap::kUndefinedValueRootIndex); 127 __ LoadRoot(x2, Heap::kUndefinedValueRootIndex);
128 __ Mov(x3, x1); 128 __ Mov(x3, x1);
129 ArrayConstructorStub stub(masm->isolate()); 129 ArrayConstructorStub stub(masm->isolate());
130 __ TailCallStub(&stub); 130 __ TailCallStub(&stub);
131 } 131 }
132 132
133 133
134 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { 134 // static
135 void Builtins::Generate_StringConstructor(MacroAssembler* masm) {
135 // ----------- S t a t e ------------- 136 // ----------- S t a t e -------------
136 // -- x0 : number of arguments 137 // -- x0 : number of arguments
137 // -- x1 : constructor function 138 // -- x1 : constructor function
139 // -- lr : return address
140 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based)
141 // -- sp[argc * 8] : receiver
142 // -----------------------------------
143 ASM_LOCATION("Builtins::Generate_StringConstructor");
144
145 // 1. Load the first argument into x0 and get rid of the rest (including the
146 // receiver).
147 Label no_arguments;
148 {
149 __ Cbz(x0, &no_arguments);
150 __ Sub(x0, x0, 1);
151 __ Drop(x0);
152 __ Ldr(x0, MemOperand(jssp, 2 * kPointerSize, PostIndex));
153 }
154
155 // 2a. At least one argument, return x0 if it's a string, otherwise
156 // dispatch to appropriate conversion.
157 Label to_string, symbol_descriptive_string;
158 {
159 __ JumpIfSmi(x0, &to_string);
160 STATIC_ASSERT(FIRST_NONSTRING_TYPE == SYMBOL_TYPE);
161 __ CompareObjectType(x0, x1, x1, FIRST_NONSTRING_TYPE);
162 __ B(hi, &to_string);
163 __ B(eq, &symbol_descriptive_string);
164 __ Ret();
165 }
166
167 // 2b. No arguments, return the empty string (and pop the receiver).
168 __ Bind(&no_arguments);
169 {
170 __ LoadRoot(x0, Heap::kempty_stringRootIndex);
171 __ Drop(1);
172 __ Ret();
173 }
174
175 // 3a. Convert x0 to a string.
176 __ Bind(&to_string);
177 {
178 ToStringStub stub(masm->isolate());
179 __ TailCallStub(&stub);
180 }
181
182 // 3b. Convert symbol in x0 to a string.
183 __ Bind(&symbol_descriptive_string);
184 {
185 __ Push(x0);
186 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1);
187 }
188 }
189
190
191 // static
192 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
193 // ----------- S t a t e -------------
194 // -- x0 : number of arguments
195 // -- x1 : constructor function
138 // -- lr : return address 196 // -- lr : return address
139 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) 197 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based)
140 // -- sp[argc * 8] : receiver 198 // -- sp[argc * 8] : receiver
141 // ----------------------------------- 199 // -----------------------------------
142 ASM_LOCATION("Builtins::Generate_StringConstructCode"); 200 ASM_LOCATION("Builtins::Generate_StringConstructor_ConstructStub");
143 201
144 // 1. Load the first argument into x2 and get rid of the rest (including the 202 // 1. Load the first argument into x2 and get rid of the rest (including the
145 // receiver). 203 // receiver).
146 { 204 {
147 Label no_arguments, done; 205 Label no_arguments, done;
148 __ Cbz(x0, &no_arguments); 206 __ Cbz(x0, &no_arguments);
149 __ Sub(x0, x0, 1); 207 __ Sub(x0, x0, 1);
150 __ Drop(x0, kXRegSize); 208 __ Drop(x0);
151 __ Ldr(x2, MemOperand(jssp, 2 * kPointerSize, PostIndex)); 209 __ Ldr(x2, MemOperand(jssp, 2 * kPointerSize, PostIndex));
152 __ B(&done); 210 __ B(&done);
153 __ Bind(&no_arguments); 211 __ Bind(&no_arguments);
154 __ Drop(1); 212 __ Drop(1);
155 __ LoadRoot(x2, Heap::kempty_stringRootIndex); 213 __ LoadRoot(x2, Heap::kempty_stringRootIndex);
156 __ Bind(&done); 214 __ Bind(&done);
157 } 215 }
158 216
159 // 2. Make sure x2 is a string. 217 // 2. Make sure x2 is a string.
160 { 218 {
(...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 } 1913 }
1856 } 1914 }
1857 1915
1858 1916
1859 #undef __ 1917 #undef __
1860 1918
1861 } // namespace internal 1919 } // namespace internal
1862 } // namespace v8 1920 } // namespace v8
1863 1921
1864 #endif // V8_TARGET_ARCH_ARM 1922 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698