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

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

Issue 1427483002: [es6] Better support for built-ins subclassing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test cleanup Created 5 years, 1 month 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/runtime/runtime-typedarray.cc ('k') | test/mjsunit/es6/classes-subclass-builtins.js » ('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 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 270 }
271 271
272 // Allocate the new receiver object using the runtime call. 272 // Allocate the new receiver object using the runtime call.
273 // rdx: original constructor 273 // rdx: original constructor
274 __ bind(&rt_call); 274 __ bind(&rt_call);
275 int offset = kPointerSize; 275 int offset = kPointerSize;
276 276
277 // Must restore rsi (context) and rdi (constructor) before calling runtime. 277 // Must restore rsi (context) and rdi (constructor) before calling runtime.
278 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 278 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
279 __ movp(rdi, Operand(rsp, offset)); 279 __ movp(rdi, Operand(rsp, offset));
280 __ Push(rdi); // argument 2/1: constructor function 280 __ Push(rdi); // constructor function
281 __ Push(rdx); // argument 3/2: original constructor 281 __ Push(rdx); // original constructor
282 __ CallRuntime(Runtime::kNewObject, 2); 282 __ CallRuntime(Runtime::kNewObject, 2);
283 __ movp(rbx, rax); // store result in rbx 283 __ movp(rbx, rax); // store result in rbx
284 284
285 // New object allocated. 285 // New object allocated.
286 // rbx: newly allocated object 286 // rbx: newly allocated object
287 __ bind(&allocated); 287 __ bind(&allocated);
288 288
289 // Restore the parameters. 289 // Restore the parameters.
290 __ Pop(rdx); 290 __ Pop(rdx);
291 __ Pop(rdi); 291 __ Pop(rdi);
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1); 1414 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1);
1415 } 1415 }
1416 } 1416 }
1417 1417
1418 1418
1419 // static 1419 // static
1420 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { 1420 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
1421 // ----------- S t a t e ------------- 1421 // ----------- S t a t e -------------
1422 // -- rax : number of arguments 1422 // -- rax : number of arguments
1423 // -- rdi : constructor function 1423 // -- rdi : constructor function
1424 // -- rdx : original constructor
1424 // -- rsp[0] : return address 1425 // -- rsp[0] : return address
1425 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) 1426 // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
1426 // -- rsp[(argc + 1) * 8] : receiver 1427 // -- rsp[(argc + 1) * 8] : receiver
1427 // ----------------------------------- 1428 // -----------------------------------
1428 1429
1429 // 1. Load the first argument into rbx and get rid of the rest (including the 1430 // 1. Load the first argument into rbx and get rid of the rest (including the
1430 // receiver). 1431 // receiver).
1431 { 1432 {
1432 StackArgumentsAccessor args(rsp, rax); 1433 StackArgumentsAccessor args(rsp, rax);
1433 Label no_arguments, done; 1434 Label no_arguments, done;
1434 __ testp(rax, rax); 1435 __ testp(rax, rax);
1435 __ j(zero, &no_arguments, Label::kNear); 1436 __ j(zero, &no_arguments, Label::kNear);
1436 __ movp(rbx, args.GetArgumentOperand(1)); 1437 __ movp(rbx, args.GetArgumentOperand(1));
1437 __ jmp(&done, Label::kNear); 1438 __ jmp(&done, Label::kNear);
1438 __ bind(&no_arguments); 1439 __ bind(&no_arguments);
1439 __ LoadRoot(rbx, Heap::kempty_stringRootIndex); 1440 __ LoadRoot(rbx, Heap::kempty_stringRootIndex);
1440 __ bind(&done); 1441 __ bind(&done);
1441 __ PopReturnAddressTo(rcx); 1442 __ PopReturnAddressTo(rcx);
1442 __ leap(rsp, Operand(rsp, rax, times_pointer_size, kPointerSize)); 1443 __ leap(rsp, Operand(rsp, rax, times_pointer_size, kPointerSize));
1443 __ PushReturnAddressFrom(rcx); 1444 __ PushReturnAddressFrom(rcx);
1444 } 1445 }
1445 1446
1446 // 2. Make sure rbx is a string. 1447 // 2. Make sure rbx is a string.
1447 { 1448 {
1448 Label convert, done_convert; 1449 Label convert, done_convert;
1449 __ JumpIfSmi(rbx, &convert, Label::kNear); 1450 __ JumpIfSmi(rbx, &convert, Label::kNear);
1450 __ CmpObjectType(rbx, FIRST_NONSTRING_TYPE, rdx); 1451 __ CmpObjectType(rbx, FIRST_NONSTRING_TYPE, rcx);
1451 __ j(below, &done_convert); 1452 __ j(below, &done_convert);
1452 __ bind(&convert); 1453 __ bind(&convert);
1453 { 1454 {
1454 FrameScope scope(masm, StackFrame::INTERNAL); 1455 FrameScope scope(masm, StackFrame::INTERNAL);
1455 ToStringStub stub(masm->isolate()); 1456 ToStringStub stub(masm->isolate());
1457 __ Push(rdx);
1456 __ Push(rdi); 1458 __ Push(rdi);
1457 __ Move(rax, rbx); 1459 __ Move(rax, rbx);
1458 __ CallStub(&stub); 1460 __ CallStub(&stub);
1459 __ Move(rbx, rax); 1461 __ Move(rbx, rax);
1460 __ Pop(rdi); 1462 __ Pop(rdi);
1463 __ Pop(rdx);
1461 } 1464 }
1462 __ bind(&done_convert); 1465 __ bind(&done_convert);
1463 } 1466 }
1464 1467
1465 // 3. Allocate a JSValue wrapper for the string. 1468 // 3. Allocate a JSValue wrapper for the string.
1466 { 1469 {
1467 // ----------- S t a t e ------------- 1470 // ----------- S t a t e -------------
1468 // -- rbx : the first argument 1471 // -- rbx : the first argument
1469 // -- rdi : constructor function 1472 // -- rdi : constructor function
1473 // -- rdx : original constructor
1470 // ----------------------------------- 1474 // -----------------------------------
1475 Label allocate, done_allocate, rt_call;
1471 1476
1472 Label allocate, done_allocate; 1477 // Fall back to runtime if the original constructor and constructor differ.
1478 __ cmpp(rdx, rdi);
1479 __ j(not_equal, &rt_call);
1480
1473 __ Allocate(JSValue::kSize, rax, rcx, no_reg, &allocate, TAG_OBJECT); 1481 __ Allocate(JSValue::kSize, rax, rcx, no_reg, &allocate, TAG_OBJECT);
1474 __ bind(&done_allocate); 1482 __ bind(&done_allocate);
1475 1483
1476 // Initialize the JSValue in rax. 1484 // Initialize the JSValue in rax.
1477 __ LoadGlobalFunctionInitialMap(rdi, rcx); 1485 __ LoadGlobalFunctionInitialMap(rdi, rcx);
1478 __ movp(FieldOperand(rax, HeapObject::kMapOffset), rcx); 1486 __ movp(FieldOperand(rax, HeapObject::kMapOffset), rcx);
1479 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex); 1487 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex);
1480 __ movp(FieldOperand(rax, JSObject::kPropertiesOffset), rcx); 1488 __ movp(FieldOperand(rax, JSObject::kPropertiesOffset), rcx);
1481 __ movp(FieldOperand(rax, JSObject::kElementsOffset), rcx); 1489 __ movp(FieldOperand(rax, JSObject::kElementsOffset), rcx);
1482 __ movp(FieldOperand(rax, JSValue::kValueOffset), rbx); 1490 __ movp(FieldOperand(rax, JSValue::kValueOffset), rbx);
1483 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); 1491 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize);
1484 __ Ret(); 1492 __ Ret();
1485 1493
1486 // Fallback to the runtime to allocate in new space. 1494 // Fallback to the runtime to allocate in new space.
1487 __ bind(&allocate); 1495 __ bind(&allocate);
1488 { 1496 {
1489 FrameScope scope(masm, StackFrame::INTERNAL); 1497 FrameScope scope(masm, StackFrame::INTERNAL);
1490 __ Push(rbx); 1498 __ Push(rbx);
1491 __ Push(rdi); 1499 __ Push(rdi);
1492 __ Push(Smi::FromInt(JSValue::kSize)); 1500 __ Push(Smi::FromInt(JSValue::kSize));
1493 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); 1501 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
1494 __ Pop(rdi); 1502 __ Pop(rdi);
1495 __ Pop(rbx); 1503 __ Pop(rbx);
1496 } 1504 }
1497 __ jmp(&done_allocate); 1505 __ jmp(&done_allocate);
1506
1507 // Fallback to the runtime to create new object.
1508 __ bind(&rt_call);
1509 {
1510 FrameScope scope(masm, StackFrame::INTERNAL);
1511 __ Push(rbx);
1512 __ Push(rdi);
1513 __ Push(rdi); // constructor function
1514 __ Push(rdx); // original constructor
1515 __ CallRuntime(Runtime::kNewObject, 2);
1516 __ Pop(rdi);
1517 __ Pop(rbx);
1518 }
1519 __ movp(FieldOperand(rax, JSValue::kValueOffset), rbx);
1520 __ Ret();
1498 } 1521 }
1499 } 1522 }
1500 1523
1501 1524
1502 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm, 1525 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm,
1503 Label* stack_overflow) { 1526 Label* stack_overflow) {
1504 // ----------- S t a t e ------------- 1527 // ----------- S t a t e -------------
1505 // -- rax : actual number of arguments 1528 // -- rax : actual number of arguments
1506 // -- rbx : expected number of arguments 1529 // -- rbx : expected number of arguments
1507 // -- rdi: function (passed through to callee) 1530 // -- rdi: function (passed through to callee)
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1967 __ ret(0); 1990 __ ret(0);
1968 } 1991 }
1969 1992
1970 1993
1971 #undef __ 1994 #undef __
1972 1995
1973 } // namespace internal 1996 } // namespace internal
1974 } // namespace v8 1997 } // namespace v8
1975 1998
1976 #endif // V8_TARGET_ARCH_X64 1999 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/runtime/runtime-typedarray.cc ('k') | test/mjsunit/es6/classes-subclass-builtins.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698