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 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); | 1452 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); |
1453 // Will both indicate a NULL and a Smi. | 1453 // Will both indicate a NULL and a Smi. |
1454 __ test(ebx, Immediate(kSmiTagMask)); | 1454 __ test(ebx, Immediate(kSmiTagMask)); |
1455 __ Assert(not_zero, "Unexpected initial map for InternalArray function"); | 1455 __ Assert(not_zero, "Unexpected initial map for InternalArray function"); |
1456 __ CmpObjectType(ebx, MAP_TYPE, ecx); | 1456 __ CmpObjectType(ebx, MAP_TYPE, ecx); |
1457 __ Assert(equal, "Unexpected initial map for InternalArray function"); | 1457 __ Assert(equal, "Unexpected initial map for InternalArray function"); |
1458 } | 1458 } |
1459 | 1459 |
1460 // Run the native code for the InternalArray function called as a normal | 1460 // Run the native code for the InternalArray function called as a normal |
1461 // function. | 1461 // function. |
1462 ArrayNativeCode(masm, false, &generic_array_code); | 1462 if (FLAG_optimize_constructed_arrays) { |
| 1463 // tail call a stub |
| 1464 InternalArrayConstructorStub stub(masm->isolate()); |
| 1465 __ TailCallStub(&stub); |
| 1466 } else { |
| 1467 ArrayNativeCode(masm, false, &generic_array_code); |
1463 | 1468 |
1464 // Jump to the generic internal array code in case the specialized code cannot | 1469 // Jump to the generic internal array code in case the specialized code |
1465 // handle the construction. | 1470 // cannot handle the construction. |
1466 __ bind(&generic_array_code); | 1471 __ bind(&generic_array_code); |
1467 Handle<Code> array_code = | 1472 Handle<Code> array_code = |
1468 masm->isolate()->builtins()->InternalArrayCodeGeneric(); | 1473 masm->isolate()->builtins()->InternalArrayCodeGeneric(); |
1469 __ jmp(array_code, RelocInfo::CODE_TARGET); | 1474 __ jmp(array_code, RelocInfo::CODE_TARGET); |
| 1475 } |
1470 } | 1476 } |
1471 | 1477 |
1472 | 1478 |
1473 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { | 1479 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { |
1474 // ----------- S t a t e ------------- | 1480 // ----------- S t a t e ------------- |
1475 // -- eax : argc | 1481 // -- eax : argc |
1476 // -- esp[0] : return address | 1482 // -- esp[0] : return address |
1477 // -- esp[4] : last argument | 1483 // -- esp[4] : last argument |
1478 // ----------------------------------- | 1484 // ----------------------------------- |
1479 Label generic_array_code; | 1485 Label generic_array_code; |
1480 | 1486 |
1481 // Get the Array function. | 1487 // Get the Array function. |
1482 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, edi); | 1488 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, edi); |
1483 | 1489 |
1484 if (FLAG_debug_code) { | 1490 if (FLAG_debug_code) { |
1485 // Initial map for the builtin Array function should be a map. | 1491 // Initial map for the builtin Array function should be a map. |
1486 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); | 1492 __ mov(ebx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); |
1487 // Will both indicate a NULL and a Smi. | 1493 // Will both indicate a NULL and a Smi. |
1488 __ test(ebx, Immediate(kSmiTagMask)); | 1494 __ test(ebx, Immediate(kSmiTagMask)); |
1489 __ Assert(not_zero, "Unexpected initial map for Array function"); | 1495 __ Assert(not_zero, "Unexpected initial map for Array function"); |
1490 __ CmpObjectType(ebx, MAP_TYPE, ecx); | 1496 __ CmpObjectType(ebx, MAP_TYPE, ecx); |
1491 __ Assert(equal, "Unexpected initial map for Array function"); | 1497 __ Assert(equal, "Unexpected initial map for Array function"); |
1492 } | 1498 } |
1493 | 1499 |
1494 // Run the native code for the Array function called as a normal function. | 1500 // Run the native code for the Array function called as a normal function. |
1495 ArrayNativeCode(masm, false, &generic_array_code); | 1501 if (FLAG_optimize_constructed_arrays) { |
| 1502 // tail call a stub |
| 1503 Handle<Object> undefined_sentinel( |
| 1504 masm->isolate()->heap()->undefined_value(), |
| 1505 masm->isolate()); |
| 1506 __ mov(ebx, Immediate(undefined_sentinel)); |
| 1507 ArrayConstructorStub stub(masm->isolate()); |
| 1508 __ TailCallStub(&stub); |
| 1509 } else { |
| 1510 ArrayNativeCode(masm, false, &generic_array_code); |
1496 | 1511 |
1497 // Jump to the generic array code in case the specialized code cannot handle | 1512 // Jump to the generic internal array code in case the specialized code |
1498 // the construction. | 1513 // cannot handle the construction. |
1499 __ bind(&generic_array_code); | 1514 __ bind(&generic_array_code); |
1500 Handle<Code> array_code = | 1515 Handle<Code> array_code = |
1501 masm->isolate()->builtins()->ArrayCodeGeneric(); | 1516 masm->isolate()->builtins()->ArrayCodeGeneric(); |
1502 __ jmp(array_code, RelocInfo::CODE_TARGET); | 1517 __ jmp(array_code, RelocInfo::CODE_TARGET); |
| 1518 } |
1503 } | 1519 } |
1504 | 1520 |
1505 | 1521 |
1506 void Builtins::Generate_CommonArrayConstructCode(MacroAssembler* masm) { | 1522 void Builtins::Generate_CommonArrayConstructCode(MacroAssembler* masm) { |
1507 // ----------- S t a t e ------------- | 1523 // ----------- S t a t e ------------- |
1508 // -- eax : argc | 1524 // -- eax : argc |
1509 // -- ebx : type info cell | 1525 // -- ebx : type info cell |
1510 // -- edi : constructor | 1526 // -- edi : constructor |
1511 // -- esp[0] : return address | 1527 // -- esp[0] : return address |
1512 // -- esp[4] : last argument | 1528 // -- esp[4] : last argument |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1814 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1830 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
1815 generator.Generate(); | 1831 generator.Generate(); |
1816 } | 1832 } |
1817 | 1833 |
1818 | 1834 |
1819 #undef __ | 1835 #undef __ |
1820 } | 1836 } |
1821 } // namespace v8::internal | 1837 } // namespace v8::internal |
1822 | 1838 |
1823 #endif // V8_TARGET_ARCH_IA32 | 1839 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |