| 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 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 // Will both indicate a NULL and a Smi. | 1470 // Will both indicate a NULL and a Smi. |
| 1471 STATIC_ASSERT(kSmiTag == 0); | 1471 STATIC_ASSERT(kSmiTag == 0); |
| 1472 Condition not_smi = NegateCondition(masm->CheckSmi(rbx)); | 1472 Condition not_smi = NegateCondition(masm->CheckSmi(rbx)); |
| 1473 __ Check(not_smi, "Unexpected initial map for InternalArray function"); | 1473 __ Check(not_smi, "Unexpected initial map for InternalArray function"); |
| 1474 __ CmpObjectType(rbx, MAP_TYPE, rcx); | 1474 __ CmpObjectType(rbx, MAP_TYPE, rcx); |
| 1475 __ Check(equal, "Unexpected initial map for InternalArray function"); | 1475 __ Check(equal, "Unexpected initial map for InternalArray function"); |
| 1476 } | 1476 } |
| 1477 | 1477 |
| 1478 // Run the native code for the InternalArray function called as a normal | 1478 // Run the native code for the InternalArray function called as a normal |
| 1479 // function. | 1479 // function. |
| 1480 ArrayNativeCode(masm, &generic_array_code); | 1480 if (FLAG_optimize_constructed_arrays) { |
| 1481 // tail call a stub |
| 1482 InternalArrayConstructorStub stub(masm->isolate()); |
| 1483 __ TailCallStub(&stub); |
| 1484 } else { |
| 1485 ArrayNativeCode(masm, &generic_array_code); |
| 1481 | 1486 |
| 1482 // Jump to the generic array code in case the specialized code cannot handle | 1487 // Jump to the generic array code in case the specialized code cannot handle |
| 1483 // the construction. | 1488 // the construction. |
| 1484 __ bind(&generic_array_code); | 1489 __ bind(&generic_array_code); |
| 1485 Handle<Code> array_code = | 1490 Handle<Code> array_code = |
| 1486 masm->isolate()->builtins()->InternalArrayCodeGeneric(); | 1491 masm->isolate()->builtins()->InternalArrayCodeGeneric(); |
| 1487 __ Jump(array_code, RelocInfo::CODE_TARGET); | 1492 __ Jump(array_code, RelocInfo::CODE_TARGET); |
| 1493 } |
| 1488 } | 1494 } |
| 1489 | 1495 |
| 1490 | 1496 |
| 1491 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { | 1497 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { |
| 1492 // ----------- S t a t e ------------- | 1498 // ----------- S t a t e ------------- |
| 1493 // -- rax : argc | 1499 // -- rax : argc |
| 1494 // -- rsp[0] : return address | 1500 // -- rsp[0] : return address |
| 1495 // -- rsp[8] : last argument | 1501 // -- rsp[8] : last argument |
| 1496 // ----------------------------------- | 1502 // ----------------------------------- |
| 1497 Label generic_array_code; | 1503 Label generic_array_code; |
| 1498 | 1504 |
| 1499 // Get the Array function. | 1505 // Get the Array function. |
| 1500 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, rdi); | 1506 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, rdi); |
| 1501 | 1507 |
| 1502 if (FLAG_debug_code) { | 1508 if (FLAG_debug_code) { |
| 1503 // Initial map for the builtin Array functions should be maps. | 1509 // Initial map for the builtin Array functions should be maps. |
| 1504 __ movq(rbx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); | 1510 __ movq(rbx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); |
| 1505 // Will both indicate a NULL and a Smi. | 1511 // Will both indicate a NULL and a Smi. |
| 1506 STATIC_ASSERT(kSmiTag == 0); | 1512 STATIC_ASSERT(kSmiTag == 0); |
| 1507 Condition not_smi = NegateCondition(masm->CheckSmi(rbx)); | 1513 Condition not_smi = NegateCondition(masm->CheckSmi(rbx)); |
| 1508 __ Check(not_smi, "Unexpected initial map for Array function"); | 1514 __ Check(not_smi, "Unexpected initial map for Array function"); |
| 1509 __ CmpObjectType(rbx, MAP_TYPE, rcx); | 1515 __ CmpObjectType(rbx, MAP_TYPE, rcx); |
| 1510 __ Check(equal, "Unexpected initial map for Array function"); | 1516 __ Check(equal, "Unexpected initial map for Array function"); |
| 1511 } | 1517 } |
| 1512 | 1518 |
| 1513 // Run the native code for the Array function called as a normal function. | 1519 // Run the native code for the Array function called as a normal function. |
| 1514 ArrayNativeCode(masm, &generic_array_code); | 1520 if (FLAG_optimize_constructed_arrays) { |
| 1521 // tail call a stub |
| 1522 Handle<Object> undefined_sentinel( |
| 1523 masm->isolate()->heap()->undefined_value(), |
| 1524 masm->isolate()); |
| 1525 __ Move(rbx, undefined_sentinel); |
| 1526 ArrayConstructorStub stub(masm->isolate()); |
| 1527 __ TailCallStub(&stub); |
| 1528 } else { |
| 1529 ArrayNativeCode(masm, &generic_array_code); |
| 1515 | 1530 |
| 1516 // Jump to the generic array code in case the specialized code cannot handle | 1531 // Jump to the generic array code in case the specialized code cannot handle |
| 1517 // the construction. | 1532 // the construction. |
| 1518 __ bind(&generic_array_code); | 1533 __ bind(&generic_array_code); |
| 1519 Handle<Code> array_code = | 1534 Handle<Code> array_code = |
| 1520 masm->isolate()->builtins()->ArrayCodeGeneric(); | 1535 masm->isolate()->builtins()->ArrayCodeGeneric(); |
| 1521 __ Jump(array_code, RelocInfo::CODE_TARGET); | 1536 __ Jump(array_code, RelocInfo::CODE_TARGET); |
| 1537 } |
| 1522 } | 1538 } |
| 1523 | 1539 |
| 1524 | 1540 |
| 1525 void Builtins::Generate_CommonArrayConstructCode(MacroAssembler* masm) { | 1541 void Builtins::Generate_CommonArrayConstructCode(MacroAssembler* masm) { |
| 1526 // ----------- S t a t e ------------- | 1542 // ----------- S t a t e ------------- |
| 1527 // -- rax : argc | 1543 // -- rax : argc |
| 1528 // -- rdi : constructor | 1544 // -- rdi : constructor |
| 1529 // -- rsp[0] : return address | 1545 // -- rsp[0] : return address |
| 1530 // -- rsp[8] : last argument | 1546 // -- rsp[8] : last argument |
| 1531 // ----------------------------------- | 1547 // ----------------------------------- |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1832 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1848 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
| 1833 generator.Generate(); | 1849 generator.Generate(); |
| 1834 } | 1850 } |
| 1835 | 1851 |
| 1836 | 1852 |
| 1837 #undef __ | 1853 #undef __ |
| 1838 | 1854 |
| 1839 } } // namespace v8::internal | 1855 } } // namespace v8::internal |
| 1840 | 1856 |
| 1841 #endif // V8_TARGET_ARCH_X64 | 1857 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |