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