| 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 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 // edi: constructor (built-in Array function) | 1200 // edi: constructor (built-in Array function) |
| 1201 // eax: argc | 1201 // eax: argc |
| 1202 // esp[0]: return address | 1202 // esp[0]: return address |
| 1203 // esp[4]: last argument | 1203 // esp[4]: last argument |
| 1204 // This function is used for both construct and normal calls of Array. Whether | 1204 // This function is used for both construct and normal calls of Array. Whether |
| 1205 // it is a construct call or not is indicated by the construct_call parameter. | 1205 // it is a construct call or not is indicated by the construct_call parameter. |
| 1206 // The only difference between handling a construct call and a normal call is | 1206 // The only difference between handling a construct call and a normal call is |
| 1207 // that for a construct call the constructor function in edi needs to be | 1207 // that for a construct call the constructor function in edi needs to be |
| 1208 // preserved for entering the generic code. In both cases argc in eax needs to | 1208 // preserved for entering the generic code. In both cases argc in eax needs to |
| 1209 // be preserved. | 1209 // be preserved. |
| 1210 static void ArrayNativeCode(MacroAssembler* masm, | 1210 void ArrayNativeCode(MacroAssembler* masm, |
| 1211 bool construct_call, | 1211 bool construct_call, |
| 1212 Label* call_generic_code) { | 1212 Label* call_generic_code) { |
| 1213 Label argc_one_or_more, argc_two_or_more, prepare_generic_code_call, | 1213 Label argc_one_or_more, argc_two_or_more, prepare_generic_code_call, |
| 1214 empty_array, not_empty_array, finish, cant_transition_map, not_double; | 1214 empty_array, not_empty_array, finish, cant_transition_map, not_double; |
| 1215 | 1215 |
| 1216 // Push the constructor and argc. No need to tag argc as a smi, as there will | 1216 // Push the constructor and argc. No need to tag argc as a smi, as there will |
| 1217 // be no garbage collection with this on the stack. | 1217 // be no garbage collection with this on the stack. |
| 1218 int push_count = 0; | 1218 int push_count = 0; |
| 1219 if (construct_call) { | 1219 if (construct_call) { |
| 1220 push_count++; | 1220 push_count++; |
| 1221 __ push(edi); | 1221 __ push(edi); |
| 1222 } | 1222 } |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 | 1487 |
| 1488 // Jump to the generic array code in case the specialized code cannot handle | 1488 // Jump to the generic array code in case the specialized code cannot handle |
| 1489 // the construction. | 1489 // the construction. |
| 1490 __ bind(&generic_array_code); | 1490 __ bind(&generic_array_code); |
| 1491 Handle<Code> array_code = | 1491 Handle<Code> array_code = |
| 1492 masm->isolate()->builtins()->ArrayCodeGeneric(); | 1492 masm->isolate()->builtins()->ArrayCodeGeneric(); |
| 1493 __ jmp(array_code, RelocInfo::CODE_TARGET); | 1493 __ jmp(array_code, RelocInfo::CODE_TARGET); |
| 1494 } | 1494 } |
| 1495 | 1495 |
| 1496 | 1496 |
| 1497 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { | 1497 void Builtins::Generate_CommonArrayConstructCode(MacroAssembler* masm) { |
| 1498 // ----------- S t a t e ------------- | 1498 // ----------- S t a t e ------------- |
| 1499 // -- eax : argc | 1499 // -- eax : argc |
| 1500 // -- ebx : type info cell | 1500 // -- ebx : type info cell |
| 1501 // -- edi : constructor | 1501 // -- edi : constructor |
| 1502 // -- esp[0] : return address | 1502 // -- esp[0] : return address |
| 1503 // -- esp[4] : last argument | 1503 // -- esp[4] : last argument |
| 1504 // ----------------------------------- | 1504 // ----------------------------------- |
| 1505 if (FLAG_debug_code) { | 1505 if (FLAG_debug_code) { |
| 1506 // The array construct code is only set for the global and natives | 1506 // The array construct code is only set for the global and natives |
| 1507 // builtin Array functions which always have maps. | 1507 // builtin Array functions which always have maps. |
| 1508 | 1508 |
| 1509 // Initial map for the builtin Array function should be a map. | 1509 // Initial map for the builtin Array function should be a map. |
| 1510 __ mov(ecx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); | 1510 __ mov(ecx, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); |
| 1511 // Will both indicate a NULL and a Smi. | 1511 // Will both indicate a NULL and a Smi. |
| 1512 __ test(ecx, Immediate(kSmiTagMask)); | 1512 __ test(ecx, Immediate(kSmiTagMask)); |
| 1513 __ Assert(not_zero, "Unexpected initial map for Array function"); | 1513 __ Assert(not_zero, "Unexpected initial map for Array function"); |
| 1514 __ CmpObjectType(ecx, MAP_TYPE, ecx); | 1514 __ CmpObjectType(ecx, MAP_TYPE, ecx); |
| 1515 __ Assert(equal, "Unexpected initial map for Array function"); | 1515 __ Assert(equal, "Unexpected initial map for Array function"); |
| 1516 | |
| 1517 if (FLAG_optimize_constructed_arrays) { | |
| 1518 // We should either have undefined in ebx or a valid jsglobalpropertycell | |
| 1519 Label okay_here; | |
| 1520 Handle<Object> undefined_sentinel( | |
| 1521 masm->isolate()->heap()->undefined_value(), masm->isolate()); | |
| 1522 Handle<Map> global_property_cell_map( | |
| 1523 masm->isolate()->heap()->global_property_cell_map()); | |
| 1524 __ cmp(ebx, Immediate(undefined_sentinel)); | |
| 1525 __ j(equal, &okay_here); | |
| 1526 __ cmp(FieldOperand(ebx, 0), Immediate(global_property_cell_map)); | |
| 1527 __ Assert(equal, "Expected property cell in register ebx"); | |
| 1528 __ bind(&okay_here); | |
| 1529 } | |
| 1530 } | 1516 } |
| 1531 | 1517 |
| 1532 if (FLAG_optimize_constructed_arrays) { | 1518 Label generic_constructor; |
| 1533 Label not_zero_case, not_one_case; | 1519 // Run the native code for the Array function called as constructor. |
| 1534 __ test(eax, eax); | 1520 ArrayNativeCode(masm, true, &generic_constructor); |
| 1535 __ j(not_zero, ¬_zero_case); | |
| 1536 ArrayNoArgumentConstructorStub no_argument_stub; | |
| 1537 __ TailCallStub(&no_argument_stub); | |
| 1538 | 1521 |
| 1539 __ bind(¬_zero_case); | 1522 // Jump to the generic construct code in case the specialized code cannot |
| 1540 __ cmp(eax, 1); | 1523 // handle the construction. |
| 1541 __ j(greater, ¬_one_case); | 1524 __ bind(&generic_constructor); |
| 1542 ArraySingleArgumentConstructorStub single_argument_stub; | 1525 Handle<Code> generic_construct_stub = |
| 1543 __ TailCallStub(&single_argument_stub); | 1526 masm->isolate()->builtins()->JSConstructStubGeneric(); |
| 1544 | 1527 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); |
| 1545 __ bind(¬_one_case); | |
| 1546 ArrayNArgumentsConstructorStub n_argument_stub; | |
| 1547 __ TailCallStub(&n_argument_stub); | |
| 1548 } else { | |
| 1549 Label generic_constructor; | |
| 1550 // Run the native code for the Array function called as constructor. | |
| 1551 ArrayNativeCode(masm, true, &generic_constructor); | |
| 1552 | |
| 1553 // Jump to the generic construct code in case the specialized code cannot | |
| 1554 // handle the construction. | |
| 1555 __ bind(&generic_constructor); | |
| 1556 Handle<Code> generic_construct_stub = | |
| 1557 masm->isolate()->builtins()->JSConstructStubGeneric(); | |
| 1558 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); | |
| 1559 } | |
| 1560 } | 1528 } |
| 1561 | 1529 |
| 1562 | 1530 |
| 1563 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { | 1531 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { |
| 1564 // ----------- S t a t e ------------- | 1532 // ----------- S t a t e ------------- |
| 1565 // -- eax : number of arguments | 1533 // -- eax : number of arguments |
| 1566 // -- edi : constructor function | 1534 // -- edi : constructor function |
| 1567 // -- esp[0] : return address | 1535 // -- esp[0] : return address |
| 1568 // -- esp[(argc - n) * 4] : arg[n] (zero-based) | 1536 // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
| 1569 // -- esp[(argc + 1) * 4] : receiver | 1537 // -- esp[(argc + 1) * 4] : receiver |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | 1805 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
| 1838 generator.Generate(); | 1806 generator.Generate(); |
| 1839 } | 1807 } |
| 1840 | 1808 |
| 1841 | 1809 |
| 1842 #undef __ | 1810 #undef __ |
| 1843 } | 1811 } |
| 1844 } // namespace v8::internal | 1812 } // namespace v8::internal |
| 1845 | 1813 |
| 1846 #endif // V8_TARGET_ARCH_IA32 | 1814 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |