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

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

Issue 1349403002: X87: [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 | « no previous file | 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_X87 5 #if V8_TARGET_ARCH_X87
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 } 1244 }
1245 1245
1246 // Run the native code for the Array function called as a normal function. 1246 // Run the native code for the Array function called as a normal function.
1247 // tail call a stub 1247 // tail call a stub
1248 __ mov(ebx, masm->isolate()->factory()->undefined_value()); 1248 __ mov(ebx, masm->isolate()->factory()->undefined_value());
1249 ArrayConstructorStub stub(masm->isolate()); 1249 ArrayConstructorStub stub(masm->isolate());
1250 __ TailCallStub(&stub); 1250 __ TailCallStub(&stub);
1251 } 1251 }
1252 1252
1253 1253
1254 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { 1254 // static
1255 void Builtins::Generate_StringConstructor(MacroAssembler* masm) {
1255 // ----------- S t a t e ------------- 1256 // ----------- S t a t e -------------
1256 // -- eax : number of arguments 1257 // -- eax : number of arguments
1257 // -- edi : constructor function 1258 // -- edi : constructor function
1259 // -- esp[0] : return address
1260 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
1261 // -- esp[(argc + 1) * 4] : receiver
1262 // -----------------------------------
1263
1264 // 1. Load the first argument into eax and get rid of the rest (including the
1265 // receiver).
1266 Label no_arguments;
1267 {
1268 __ test(eax, eax);
1269 __ j(zero, &no_arguments, Label::kNear);
1270 __ mov(ebx, Operand(esp, eax, times_pointer_size, 0));
1271 __ PopReturnAddressTo(ecx);
1272 __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize));
1273 __ PushReturnAddressFrom(ecx);
1274 __ mov(eax, ebx);
1275 }
1276
1277 // 2a. At least one argument, return eax if it's a string, otherwise
1278 // dispatch to appropriate conversion.
1279 Label to_string, symbol_descriptive_string;
1280 {
1281 __ JumpIfSmi(eax, &to_string, Label::kNear);
1282 STATIC_ASSERT(FIRST_NONSTRING_TYPE == SYMBOL_TYPE);
1283 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edx);
1284 __ j(above, &to_string, Label::kNear);
1285 __ j(equal, &symbol_descriptive_string, Label::kNear);
1286 __ Ret();
1287 }
1288
1289 // 2b. No arguments, return the empty string (and pop the receiver).
1290 __ bind(&no_arguments);
1291 {
1292 __ LoadRoot(eax, Heap::kempty_stringRootIndex);
1293 __ ret(1 * kPointerSize);
1294 }
1295
1296 // 3a. Convert eax to a string.
1297 __ bind(&to_string);
1298 {
1299 ToStringStub stub(masm->isolate());
1300 __ TailCallStub(&stub);
1301 }
1302
1303 // 3b. Convert symbol in eax to a string.
1304 __ bind(&symbol_descriptive_string);
1305 {
1306 __ PopReturnAddressTo(ecx);
1307 __ Push(eax);
1308 __ PushReturnAddressFrom(ecx);
1309 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1);
1310 }
1311 }
1312
1313
1314 // static
1315 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
1316 // ----------- S t a t e -------------
1317 // -- eax : number of arguments
1318 // -- edi : constructor function
1258 // -- esp[0] : return address 1319 // -- esp[0] : return address
1259 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 1320 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
1260 // -- esp[(argc + 1) * 4] : receiver 1321 // -- esp[(argc + 1) * 4] : receiver
1261 // ----------------------------------- 1322 // -----------------------------------
1262 1323
1263 // 1. Load the first argument into ebx and get rid of the rest (including the 1324 // 1. Load the first argument into ebx and get rid of the rest (including the
1264 // receiver). 1325 // receiver).
1265 { 1326 {
1266 Label no_arguments, done; 1327 Label no_arguments, done;
1267 __ test(eax, eax); 1328 __ test(eax, eax);
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 1811
1751 __ bind(&ok); 1812 __ bind(&ok);
1752 __ ret(0); 1813 __ ret(0);
1753 } 1814 }
1754 1815
1755 #undef __ 1816 #undef __
1756 } // namespace internal 1817 } // namespace internal
1757 } // namespace v8 1818 } // namespace v8
1758 1819
1759 #endif // V8_TARGET_ARCH_X87 1820 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698