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

Side by Side Diff: src/x64/builtins-x64.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/symbol.js ('k') | 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_X64 5 #if V8_TARGET_ARCH_X64
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 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 1297
1298 __ movp(rdx, rdi); 1298 __ movp(rdx, rdi);
1299 // Run the native code for the Array function called as a normal function. 1299 // Run the native code for the Array function called as a normal function.
1300 // tail call a stub 1300 // tail call a stub
1301 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); 1301 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex);
1302 ArrayConstructorStub stub(masm->isolate()); 1302 ArrayConstructorStub stub(masm->isolate());
1303 __ TailCallStub(&stub); 1303 __ TailCallStub(&stub);
1304 } 1304 }
1305 1305
1306 1306
1307 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { 1307 // static
1308 void Builtins::Generate_StringConstructor(MacroAssembler* masm) {
1308 // ----------- S t a t e ------------- 1309 // ----------- S t a t e -------------
1309 // -- rax : number of arguments 1310 // -- rax : number of arguments
1310 // -- rdi : constructor function 1311 // -- rdi : constructor function
1312 // -- rsp[0] : return address
1313 // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
1314 // -- rsp[(argc + 1) * 8] : receiver
1315 // -----------------------------------
1316
1317 // 1. Load the first argument into rax and get rid of the rest (including the
1318 // receiver).
1319 Label no_arguments;
1320 {
1321 StackArgumentsAccessor args(rsp, rax);
1322 __ testp(rax, rax);
1323 __ j(zero, &no_arguments, Label::kNear);
1324 __ movp(rbx, args.GetArgumentOperand(1));
1325 __ PopReturnAddressTo(rcx);
1326 __ leap(rsp, Operand(rsp, rax, times_pointer_size, kPointerSize));
1327 __ PushReturnAddressFrom(rcx);
1328 __ movp(rax, rbx);
1329 }
1330
1331 // 2a. At least one argument, return rax if it's a string, otherwise
1332 // dispatch to appropriate conversion.
1333 Label to_string, symbol_descriptive_string;
1334 {
1335 __ JumpIfSmi(rax, &to_string, Label::kNear);
1336 STATIC_ASSERT(FIRST_NONSTRING_TYPE == SYMBOL_TYPE);
1337 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdx);
1338 __ j(above, &to_string, Label::kNear);
1339 __ j(equal, &symbol_descriptive_string, Label::kNear);
1340 __ Ret();
1341 }
1342
1343 // 2b. No arguments, return the empty string (and pop the receiver).
1344 __ bind(&no_arguments);
1345 {
1346 __ LoadRoot(rax, Heap::kempty_stringRootIndex);
1347 __ ret(1 * kPointerSize);
1348 }
1349
1350 // 3a. Convert rax to a string.
1351 __ bind(&to_string);
1352 {
1353 ToStringStub stub(masm->isolate());
1354 __ TailCallStub(&stub);
1355 }
1356
1357 // 3b. Convert symbol in rax to a string.
1358 __ bind(&symbol_descriptive_string);
1359 {
1360 __ PopReturnAddressTo(rcx);
1361 __ Push(rax);
1362 __ PushReturnAddressFrom(rcx);
1363 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1);
1364 }
1365 }
1366
1367
1368 // static
1369 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
1370 // ----------- S t a t e -------------
1371 // -- rax : number of arguments
1372 // -- rdi : constructor function
1311 // -- rsp[0] : return address 1373 // -- rsp[0] : return address
1312 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) 1374 // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
1313 // -- rsp[(argc + 1) * 8] : receiver 1375 // -- rsp[(argc + 1) * 8] : receiver
1314 // ----------------------------------- 1376 // -----------------------------------
1315 1377
1316 // 1. Load the first argument into rbx and get rid of the rest (including the 1378 // 1. Load the first argument into rbx and get rid of the rest (including the
1317 // receiver). 1379 // receiver).
1318 { 1380 {
1319 StackArgumentsAccessor args(rsp, rax); 1381 StackArgumentsAccessor args(rsp, rax);
1320 Label no_arguments, done; 1382 Label no_arguments, done;
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1809 __ ret(0); 1871 __ ret(0);
1810 } 1872 }
1811 1873
1812 1874
1813 #undef __ 1875 #undef __
1814 1876
1815 } // namespace internal 1877 } // namespace internal
1816 } // namespace v8 1878 } // namespace v8
1817 1879
1818 #endif // V8_TARGET_ARCH_X64 1880 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/symbol.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698