| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 | 1515 |
| 1516 // Jump to the generic array code in case the specialized code cannot handle | 1516 // Jump to the generic array code in case the specialized code cannot handle |
| 1517 // the construction. | 1517 // the construction. |
| 1518 __ bind(&generic_array_code); | 1518 __ bind(&generic_array_code); |
| 1519 Handle<Code> array_code = | 1519 Handle<Code> array_code = |
| 1520 masm->isolate()->builtins()->ArrayCodeGeneric(); | 1520 masm->isolate()->builtins()->ArrayCodeGeneric(); |
| 1521 __ Jump(array_code, RelocInfo::CODE_TARGET); | 1521 __ Jump(array_code, RelocInfo::CODE_TARGET); |
| 1522 } | 1522 } |
| 1523 | 1523 |
| 1524 | 1524 |
| 1525 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { | 1525 void Builtins::Generate_InternalArrayConstructCode(MacroAssembler* masm) { |
| 1526 // ----------- S t a t e ------------- | 1526 // ----------- S t a t e ------------- |
| 1527 // -- rax : argc | 1527 // -- rax : argc |
| 1528 // -- rdi : constructor | 1528 // -- rdi : constructor |
| 1529 // -- rsp[0] : return address | 1529 // -- rsp[0] : return address |
| 1530 // -- rsp[8] : last argument | 1530 // -- rsp[8] : last argument |
| 1531 // ----------------------------------- | 1531 // ----------------------------------- |
| 1532 if (FLAG_debug_code) { | 1532 if (FLAG_debug_code) { |
| 1533 // The array construct code is only set for the builtin and internal | 1533 // The array construct code is only set for the builtin and internal |
| 1534 // Array functions which always have a map. | 1534 // Array functions which always have a map. |
| 1535 | 1535 |
| 1536 // Initial map for the builtin Array function should be a map. | 1536 // Initial map for the builtin Array function should be a map. |
| 1537 __ movq(rcx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); | 1537 __ movq(rcx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); |
| 1538 // Will both indicate a NULL and a Smi. | 1538 // Will both indicate a NULL and a Smi. |
| 1539 STATIC_ASSERT(kSmiTag == 0); | 1539 STATIC_ASSERT(kSmiTag == 0); |
| 1540 Condition not_smi = NegateCondition(masm->CheckSmi(rcx)); | 1540 Condition not_smi = NegateCondition(masm->CheckSmi(rcx)); |
| 1541 __ Check(not_smi, "Unexpected initial map for Array function"); | 1541 __ Check(not_smi, "Unexpected initial map for Array function"); |
| 1542 __ CmpObjectType(rcx, MAP_TYPE, rcx); | 1542 __ CmpObjectType(rcx, MAP_TYPE, rcx); |
| 1543 __ Check(equal, "Unexpected initial map for Array function"); | 1543 __ Check(equal, "Unexpected initial map for Array function"); |
| 1544 | |
| 1545 if (FLAG_optimize_constructed_arrays) { | |
| 1546 // We should either have undefined in ebx or a valid jsglobalpropertycell | |
| 1547 Label okay_here; | |
| 1548 Handle<Object> undefined_sentinel( | |
| 1549 masm->isolate()->factory()->undefined_value()); | |
| 1550 Handle<Map> global_property_cell_map( | |
| 1551 masm->isolate()->heap()->global_property_cell_map()); | |
| 1552 __ Cmp(rbx, undefined_sentinel); | |
| 1553 __ j(equal, &okay_here); | |
| 1554 __ Cmp(FieldOperand(rbx, 0), global_property_cell_map); | |
| 1555 __ Assert(equal, "Expected property cell in register rbx"); | |
| 1556 __ bind(&okay_here); | |
| 1557 } | |
| 1558 } | 1544 } |
| 1559 | 1545 |
| 1560 if (FLAG_optimize_constructed_arrays) { | 1546 Label generic_constructor; |
| 1561 Label not_zero_case, not_one_case; | 1547 // Run the native code for the Array function called as constructor. |
| 1562 __ testq(rax, rax); | 1548 ArrayNativeCode(masm, &generic_constructor); |
| 1563 __ j(not_zero, ¬_zero_case); | 1549 // Jump to the generic construct code in case the specialized code cannot |
| 1564 ArrayNoArgumentConstructorStub no_argument_stub; | 1550 // handle the construction. |
| 1565 __ TailCallStub(&no_argument_stub); | 1551 __ bind(&generic_constructor); |
| 1552 Handle<Code> generic_construct_stub = |
| 1553 masm->isolate()->builtins()->JSConstructStubGeneric(); |
| 1554 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
| 1555 } |
| 1566 | 1556 |
| 1567 __ bind(¬_zero_case); | |
| 1568 __ cmpq(rax, Immediate(1)); | |
| 1569 __ j(greater, ¬_one_case); | |
| 1570 ArraySingleArgumentConstructorStub single_argument_stub; | |
| 1571 __ TailCallStub(&single_argument_stub); | |
| 1572 | |
| 1573 __ bind(¬_one_case); | |
| 1574 ArrayNArgumentsConstructorStub n_argument_stub; | |
| 1575 __ TailCallStub(&n_argument_stub); | |
| 1576 } else { | |
| 1577 Label generic_constructor; | |
| 1578 // Run the native code for the Array function called as constructor. | |
| 1579 ArrayNativeCode(masm, &generic_constructor); | |
| 1580 | |
| 1581 // Jump to the generic construct code in case the specialized code cannot | |
| 1582 // handle the construction. | |
| 1583 __ bind(&generic_constructor); | |
| 1584 Handle<Code> generic_construct_stub = | |
| 1585 masm->isolate()->builtins()->JSConstructStubGeneric(); | |
| 1586 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); | |
| 1587 } | |
| 1588 } | |
| 1589 | 1557 |
| 1590 | 1558 |
| 1591 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { | 1559 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { |
| 1592 // ----------- S t a t e ------------- | 1560 // ----------- S t a t e ------------- |
| 1593 // -- rax : number of arguments | 1561 // -- rax : number of arguments |
| 1594 // -- rdi : constructor function | 1562 // -- rdi : constructor function |
| 1595 // -- rsp[0] : return address | 1563 // -- rsp[0] : return address |
| 1596 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) | 1564 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) |
| 1597 // -- rsp[(argc + 1) * 8] : receiver | 1565 // -- rsp[(argc + 1) * 8] : receiver |
| 1598 // ----------------------------------- | 1566 // ----------------------------------- |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1864 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1832 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
| 1865 generator.Generate(); | 1833 generator.Generate(); |
| 1866 } | 1834 } |
| 1867 | 1835 |
| 1868 | 1836 |
| 1869 #undef __ | 1837 #undef __ |
| 1870 | 1838 |
| 1871 } } // namespace v8::internal | 1839 } } // namespace v8::internal |
| 1872 | 1840 |
| 1873 #endif // V8_TARGET_ARCH_X64 | 1841 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |