| OLD | NEW |
| 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 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 __ Push(rdi); | 1461 __ Push(rdi); |
| 1462 __ Move(rax, rbx); | 1462 __ Move(rax, rbx); |
| 1463 __ CallStub(&stub); | 1463 __ CallStub(&stub); |
| 1464 __ Move(rbx, rax); | 1464 __ Move(rbx, rax); |
| 1465 __ Pop(rdi); | 1465 __ Pop(rdi); |
| 1466 __ Pop(rdx); | 1466 __ Pop(rdx); |
| 1467 } | 1467 } |
| 1468 __ bind(&done_convert); | 1468 __ bind(&done_convert); |
| 1469 } | 1469 } |
| 1470 | 1470 |
| 1471 // 3. Allocate a JSValue wrapper for the string. | 1471 // 3. Check if original constructor and constructor differ. |
| 1472 Label new_object; |
| 1473 __ cmpp(rdx, rdi); |
| 1474 __ j(not_equal, &new_object); |
| 1475 |
| 1476 // 4. Allocate a JSValue wrapper for the string. |
| 1472 { | 1477 { |
| 1473 // ----------- S t a t e ------------- | 1478 // ----------- S t a t e ------------- |
| 1474 // -- rbx : the first argument | 1479 // -- rbx : the first argument |
| 1475 // -- rdi : constructor function | 1480 // -- rdi : constructor function |
| 1476 // -- rdx : original constructor | 1481 // -- rdx : original constructor |
| 1477 // ----------------------------------- | 1482 // ----------------------------------- |
| 1478 Label allocate, done_allocate, rt_call; | 1483 __ Allocate(JSValue::kSize, rax, rcx, no_reg, &new_object, TAG_OBJECT); |
| 1479 | |
| 1480 // Fall back to runtime if the original constructor and constructor differ. | |
| 1481 __ cmpp(rdx, rdi); | |
| 1482 __ j(not_equal, &rt_call); | |
| 1483 | |
| 1484 __ Allocate(JSValue::kSize, rax, rcx, no_reg, &allocate, TAG_OBJECT); | |
| 1485 __ bind(&done_allocate); | |
| 1486 | 1484 |
| 1487 // Initialize the JSValue in rax. | 1485 // Initialize the JSValue in rax. |
| 1488 __ LoadGlobalFunctionInitialMap(rdi, rcx); | 1486 __ LoadGlobalFunctionInitialMap(rdi, rcx); |
| 1489 __ movp(FieldOperand(rax, HeapObject::kMapOffset), rcx); | 1487 __ movp(FieldOperand(rax, HeapObject::kMapOffset), rcx); |
| 1490 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex); | 1488 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex); |
| 1491 __ movp(FieldOperand(rax, JSObject::kPropertiesOffset), rcx); | 1489 __ movp(FieldOperand(rax, JSObject::kPropertiesOffset), rcx); |
| 1492 __ movp(FieldOperand(rax, JSObject::kElementsOffset), rcx); | 1490 __ movp(FieldOperand(rax, JSObject::kElementsOffset), rcx); |
| 1493 __ movp(FieldOperand(rax, JSValue::kValueOffset), rbx); | 1491 __ movp(FieldOperand(rax, JSValue::kValueOffset), rbx); |
| 1494 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); | 1492 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); |
| 1495 __ Ret(); | 1493 __ Ret(); |
| 1494 } |
| 1496 | 1495 |
| 1497 // Fallback to the runtime to allocate in new space. | 1496 // 5. Fallback to the runtime to create new object. |
| 1498 __ bind(&allocate); | 1497 __ bind(&new_object); |
| 1499 { | 1498 { |
| 1500 FrameScope scope(masm, StackFrame::INTERNAL); | 1499 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1501 __ Push(rbx); | 1500 __ Push(rbx); // the first argument |
| 1502 __ Push(rdi); | 1501 __ Push(rdi); // constructor function |
| 1503 __ Push(Smi::FromInt(JSValue::kSize)); | 1502 __ Push(rdx); // original constructor |
| 1504 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); | 1503 __ CallRuntime(Runtime::kNewObject, 2); |
| 1505 __ Pop(rdi); | 1504 __ Pop(FieldOperand(rax, JSValue::kValueOffset)); |
| 1506 __ Pop(rbx); | |
| 1507 } | |
| 1508 __ jmp(&done_allocate); | |
| 1509 | |
| 1510 // Fallback to the runtime to create new object. | |
| 1511 __ bind(&rt_call); | |
| 1512 { | |
| 1513 FrameScope scope(masm, StackFrame::INTERNAL); | |
| 1514 __ Push(rbx); | |
| 1515 __ Push(rdi); | |
| 1516 __ Push(rdi); // constructor function | |
| 1517 __ Push(rdx); // original constructor | |
| 1518 __ CallRuntime(Runtime::kNewObject, 2); | |
| 1519 __ Pop(rdi); | |
| 1520 __ Pop(rbx); | |
| 1521 } | |
| 1522 __ movp(FieldOperand(rax, JSValue::kValueOffset), rbx); | |
| 1523 __ Ret(); | |
| 1524 } | 1505 } |
| 1506 __ Ret(); |
| 1525 } | 1507 } |
| 1526 | 1508 |
| 1527 | 1509 |
| 1528 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm, | 1510 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm, |
| 1529 Label* stack_overflow) { | 1511 Label* stack_overflow) { |
| 1530 // ----------- S t a t e ------------- | 1512 // ----------- S t a t e ------------- |
| 1531 // -- rax : actual number of arguments | 1513 // -- rax : actual number of arguments |
| 1532 // -- rbx : expected number of arguments | 1514 // -- rbx : expected number of arguments |
| 1533 // -- rdi: function (passed through to callee) | 1515 // -- rdi: function (passed through to callee) |
| 1534 // ----------------------------------- | 1516 // ----------------------------------- |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 __ ret(0); | 2001 __ ret(0); |
| 2020 } | 2002 } |
| 2021 | 2003 |
| 2022 | 2004 |
| 2023 #undef __ | 2005 #undef __ |
| 2024 | 2006 |
| 2025 } // namespace internal | 2007 } // namespace internal |
| 2026 } // namespace v8 | 2008 } // namespace v8 |
| 2027 | 2009 |
| 2028 #endif // V8_TARGET_ARCH_X64 | 2010 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |