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 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1468 __ bind(&generic_array_code); | 1468 __ bind(&generic_array_code); |
1469 Handle<Code> array_code = | 1469 Handle<Code> array_code = |
1470 masm->isolate()->builtins()->ArrayCodeGeneric(); | 1470 masm->isolate()->builtins()->ArrayCodeGeneric(); |
1471 __ jmp(array_code, RelocInfo::CODE_TARGET); | 1471 __ jmp(array_code, RelocInfo::CODE_TARGET); |
1472 } | 1472 } |
1473 | 1473 |
1474 | 1474 |
1475 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { | 1475 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { |
1476 // ----------- S t a t e ------------- | 1476 // ----------- S t a t e ------------- |
1477 // -- eax : argc | 1477 // -- eax : argc |
1478 // -- ebx : type info cell | |
1479 // -- edi : constructor | |
1480 // -- esp[0] : return address | |
1481 // -- esp[4] : last argument | |
1482 // ----------------------------------- | |
1483 if (FLAG_debug_code) { | |
1484 // The array construct code is only set for the global and natives | |
1485 // builtin Array functions which always have maps. | |
1486 | |
1487 // Initial map for the builtin Array function should be a map. | |
1488 __ mov(ecx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); | |
1489 // Will both indicate a NULL and a Smi. | |
1490 __ test(ecx, Immediate(kSmiTagMask)); | |
1491 __ Assert(not_zero, "Unexpected initial map for Array function"); | |
1492 __ CmpObjectType(ecx, MAP_TYPE, ecx); | |
1493 __ Assert(equal, "Unexpected initial map for Array function"); | |
1494 | |
1495 // We should either have undefined in ebx or a valid jsglobalpropertycell | |
1496 Label okay_here; | |
1497 Handle<Object> undefined_sentinel( | |
1498 masm->isolate()->heap()->undefined_value()); | |
1499 Handle<Map> global_property_cell_map( | |
1500 masm->isolate()->heap()->global_property_cell_map()); | |
1501 __ cmp(ebx, Immediate(undefined_sentinel)); | |
1502 __ j(equal, &okay_here); | |
1503 __ cmp(FieldOperand(ebx, 0), Immediate(global_property_cell_map)); | |
1504 __ Assert(equal, "Expected property cell in register ebx"); | |
1505 __ bind(&okay_here); | |
1506 } | |
1507 | |
1508 if (FLAG_optimize_constructed_arrays) { | |
Toon Verwaest
2013/02/13 15:14:51
Given that the 2 blocks of code are entirely indep
mvstanton
2013/02/19 11:04:08
Actually I'd like to keep it this way because in t
| |
1509 Label not_zero_case, not_one_case; | |
1510 __ test(eax, eax); | |
1511 __ j(not_zero, ¬_zero_case); | |
1512 ArrayNoArgumentConstructorStub no_argument_stub; | |
1513 __ TailCallStub(&no_argument_stub); | |
1514 | |
1515 __ bind(¬_zero_case); | |
1516 __ cmp(eax, 1); | |
1517 __ j(greater, ¬_one_case); | |
1518 ArraySingleArgumentConstructorStub single_argument_stub; | |
1519 __ TailCallStub(&single_argument_stub); | |
1520 | |
1521 __ bind(¬_one_case); | |
1522 ArrayNArgumentsConstructorStub n_argument_stub; | |
1523 __ TailCallStub(&n_argument_stub); | |
1524 } else { | |
1525 Label generic_constructor; | |
1526 // Run the native code for the Array function called as constructor. | |
1527 ArrayNativeCode(masm, true, &generic_constructor); | |
1528 | |
1529 // Jump to the generic construct code in case the specialized code cannot | |
1530 // handle the construction. | |
1531 __ bind(&generic_constructor); | |
1532 Handle<Code> generic_construct_stub = | |
1533 masm->isolate()->builtins()->JSConstructStubGeneric(); | |
1534 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); | |
1535 } | |
1536 } | |
1537 | |
1538 | |
1539 void Builtins::Generate_InternalArrayConstructCode(MacroAssembler* masm) { | |
1540 // ----------- S t a t e ------------- | |
1541 // -- eax : argc | |
1478 // -- edi : constructor | 1542 // -- edi : constructor |
1479 // -- esp[0] : return address | 1543 // -- esp[0] : return address |
1480 // -- esp[4] : last argument | 1544 // -- esp[4] : last argument |
1481 // ----------------------------------- | 1545 // ----------------------------------- |
1482 Label generic_constructor; | 1546 Label generic_constructor; |
1483 | 1547 |
1484 if (FLAG_debug_code) { | 1548 if (FLAG_debug_code) { |
1485 // The array construct code is only set for the global and natives | 1549 // The array construct code is only set for the global and natives |
1486 // builtin Array functions which always have maps. | 1550 // builtin Array functions which always have maps. |
1487 | 1551 |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1824 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1888 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
1825 generator.Generate(); | 1889 generator.Generate(); |
1826 } | 1890 } |
1827 | 1891 |
1828 | 1892 |
1829 #undef __ | 1893 #undef __ |
1830 } | 1894 } |
1831 } // namespace v8::internal | 1895 } // namespace v8::internal |
1832 | 1896 |
1833 #endif // V8_TARGET_ARCH_IA32 | 1897 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |