OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compilation-dependencies.h" | 6 #include "src/compilation-dependencies.h" |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 } | 1251 } |
1252 node->RemoveInput(2); | 1252 node->RemoveInput(2); |
1253 node->ReplaceInput(2, effect); | 1253 node->ReplaceInput(2, effect); |
1254 NodeProperties::ChangeOp( | 1254 NodeProperties::ChangeOp( |
1255 node, | 1255 node, |
1256 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); | 1256 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); |
1257 return Changed(node); | 1257 return Changed(node); |
1258 } | 1258 } |
1259 | 1259 |
1260 | 1260 |
| 1261 Reduction JSTypedLowering::ReduceJSLoadNativeContext(Node* node) { |
| 1262 DCHECK_EQ(IrOpcode::kJSLoadNativeContext, node->opcode()); |
| 1263 Node* const effect = NodeProperties::GetEffectInput(node); |
| 1264 Node* const control = graph()->start(); |
| 1265 node->ReplaceInput(1, effect); |
| 1266 node->ReplaceInput(2, control); |
| 1267 NodeProperties::ChangeOp( |
| 1268 node, |
| 1269 simplified()->LoadField(AccessBuilder::ForJSGlobalObjectNativeContext())); |
| 1270 return Changed(node); |
| 1271 } |
| 1272 |
| 1273 |
1261 Reduction JSTypedLowering::ReduceJSConvertReceiver(Node* node) { | 1274 Reduction JSTypedLowering::ReduceJSConvertReceiver(Node* node) { |
1262 DCHECK_EQ(IrOpcode::kJSConvertReceiver, node->opcode()); | 1275 DCHECK_EQ(IrOpcode::kJSConvertReceiver, node->opcode()); |
1263 ConvertReceiverMode mode = ConvertReceiverModeOf(node->op()); | 1276 ConvertReceiverMode mode = ConvertReceiverModeOf(node->op()); |
1264 Node* receiver = NodeProperties::GetValueInput(node, 0); | 1277 Node* receiver = NodeProperties::GetValueInput(node, 0); |
1265 Type* receiver_type = NodeProperties::GetType(receiver); | 1278 Type* receiver_type = NodeProperties::GetType(receiver); |
1266 Node* context = NodeProperties::GetContextInput(node); | 1279 Node* context = NodeProperties::GetContextInput(node); |
1267 Type* context_type = NodeProperties::GetType(context); | 1280 Type* context_type = NodeProperties::GetType(context); |
1268 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); | 1281 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); |
1269 Node* effect = NodeProperties::GetEffectInput(node); | 1282 Node* effect = NodeProperties::GetEffectInput(node); |
1270 Node* control = NodeProperties::GetControlInput(node); | 1283 Node* control = NodeProperties::GetControlInput(node); |
1271 if (!receiver_type->Is(Type::Receiver())) { | 1284 if (!receiver_type->Is(Type::Receiver())) { |
1272 if (receiver_type->Is(Type::NullOrUndefined()) || | 1285 if (receiver_type->Is(Type::NullOrUndefined()) || |
1273 mode == ConvertReceiverMode::kNullOrUndefined) { | 1286 mode == ConvertReceiverMode::kNullOrUndefined) { |
1274 if (context_type->IsConstant()) { | 1287 if (context_type->IsConstant()) { |
1275 Handle<JSObject> global_proxy( | 1288 Handle<JSObject> global_proxy( |
1276 Handle<Context>::cast(context_type->AsConstant()->Value()) | 1289 Handle<Context>::cast(context_type->AsConstant()->Value()) |
1277 ->global_proxy(), | 1290 ->global_proxy(), |
1278 isolate()); | 1291 isolate()); |
1279 receiver = jsgraph()->Constant(global_proxy); | 1292 receiver = jsgraph()->Constant(global_proxy); |
1280 } else { | 1293 } else { |
1281 Node* native_context = effect = graph()->NewNode( | 1294 Node* global_object = effect = graph()->NewNode( |
1282 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 1295 javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true), |
1283 context, context, effect); | 1296 context, context, effect); |
1284 receiver = effect = graph()->NewNode( | 1297 receiver = effect = |
1285 javascript()->LoadContext(0, Context::GLOBAL_PROXY_INDEX, true), | 1298 graph()->NewNode(simplified()->LoadField( |
1286 native_context, native_context, effect); | 1299 AccessBuilder::ForJSGlobalObjectGlobalProxy()), |
| 1300 global_object, effect, control); |
1287 } | 1301 } |
1288 } else if (!receiver_type->Maybe(Type::NullOrUndefined()) || | 1302 } else if (!receiver_type->Maybe(Type::NullOrUndefined()) || |
1289 mode == ConvertReceiverMode::kNotNullOrUndefined) { | 1303 mode == ConvertReceiverMode::kNotNullOrUndefined) { |
1290 receiver = effect = | 1304 receiver = effect = |
1291 graph()->NewNode(javascript()->ToObject(), receiver, context, | 1305 graph()->NewNode(javascript()->ToObject(), receiver, context, |
1292 frame_state, effect, control); | 1306 frame_state, effect, control); |
1293 } else { | 1307 } else { |
1294 // Check {receiver} for undefined. | 1308 // Check {receiver} for undefined. |
1295 Node* check0 = | 1309 Node* check0 = |
1296 graph()->NewNode(simplified()->ReferenceEqual(receiver_type), | 1310 graph()->NewNode(simplified()->ReferenceEqual(receiver_type), |
(...skipping 28 matching lines...) Expand all Loading... |
1325 Node* eglobal = effect; | 1339 Node* eglobal = effect; |
1326 Node* rglobal; | 1340 Node* rglobal; |
1327 { | 1341 { |
1328 if (context_type->IsConstant()) { | 1342 if (context_type->IsConstant()) { |
1329 Handle<JSObject> global_proxy( | 1343 Handle<JSObject> global_proxy( |
1330 Handle<Context>::cast(context_type->AsConstant()->Value()) | 1344 Handle<Context>::cast(context_type->AsConstant()->Value()) |
1331 ->global_proxy(), | 1345 ->global_proxy(), |
1332 isolate()); | 1346 isolate()); |
1333 rglobal = jsgraph()->Constant(global_proxy); | 1347 rglobal = jsgraph()->Constant(global_proxy); |
1334 } else { | 1348 } else { |
1335 Node* native_context = eglobal = graph()->NewNode( | 1349 Node* global_object = eglobal = graph()->NewNode( |
1336 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 1350 javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true), |
1337 context, context, eglobal); | 1351 context, context, eglobal); |
1338 rglobal = eglobal = graph()->NewNode( | 1352 rglobal = eglobal = graph()->NewNode( |
1339 javascript()->LoadContext(0, Context::GLOBAL_PROXY_INDEX, true), | 1353 simplified()->LoadField( |
1340 native_context, native_context, eglobal); | 1354 AccessBuilder::ForJSGlobalObjectGlobalProxy()), |
| 1355 global_object, eglobal, if_global); |
1341 } | 1356 } |
1342 } | 1357 } |
1343 | 1358 |
1344 control = graph()->NewNode(common()->Merge(2), if_convert, if_global); | 1359 control = graph()->NewNode(common()->Merge(2), if_convert, if_global); |
1345 effect = | 1360 effect = |
1346 graph()->NewNode(common()->EffectPhi(2), econvert, eglobal, control); | 1361 graph()->NewNode(common()->EffectPhi(2), econvert, eglobal, control); |
1347 receiver = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), rconvert, | 1362 receiver = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), rconvert, |
1348 rglobal, control); | 1363 rglobal, control); |
1349 } | 1364 } |
1350 } | 1365 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1488 // there conceptually is an arguments adaptor frame in the call chain. | 1503 // there conceptually is an arguments adaptor frame in the call chain. |
1489 Node* const args_state = GetArgumentsFrameState(frame_state); | 1504 Node* const args_state = GetArgumentsFrameState(frame_state); |
1490 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); | 1505 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); |
1491 // Prepare element backing store to be used by arguments object. | 1506 // Prepare element backing store to be used by arguments object. |
1492 bool has_aliased_arguments = false; | 1507 bool has_aliased_arguments = false; |
1493 Node* const elements = AllocateAliasedArguments( | 1508 Node* const elements = AllocateAliasedArguments( |
1494 effect, control, args_state, context, shared, &has_aliased_arguments); | 1509 effect, control, args_state, context, shared, &has_aliased_arguments); |
1495 Node* allocate_effect = | 1510 Node* allocate_effect = |
1496 elements->op()->EffectOutputCount() > 0 ? elements : effect; | 1511 elements->op()->EffectOutputCount() > 0 ? elements : effect; |
1497 // Load the arguments object map from the current native context. | 1512 // Load the arguments object map from the current native context. |
1498 Node* const load_native_context = graph()->NewNode( | 1513 Node* const load_global_object = graph()->NewNode( |
1499 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 1514 simplified()->LoadField( |
1500 context, context, effect); | 1515 AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), |
| 1516 context, effect, control); |
| 1517 Node* const load_native_context = |
| 1518 graph()->NewNode(simplified()->LoadField( |
| 1519 AccessBuilder::ForJSGlobalObjectNativeContext()), |
| 1520 load_global_object, effect, control); |
1501 Node* const load_arguments_map = graph()->NewNode( | 1521 Node* const load_arguments_map = graph()->NewNode( |
1502 simplified()->LoadField(AccessBuilder::ForContextSlot( | 1522 simplified()->LoadField(AccessBuilder::ForContextSlot( |
1503 has_aliased_arguments ? Context::FAST_ALIASED_ARGUMENTS_MAP_INDEX | 1523 has_aliased_arguments ? Context::FAST_ALIASED_ARGUMENTS_MAP_INDEX |
1504 : Context::SLOPPY_ARGUMENTS_MAP_INDEX)), | 1524 : Context::SLOPPY_ARGUMENTS_MAP_INDEX)), |
1505 load_native_context, effect, control); | 1525 load_native_context, effect, control); |
1506 // Actually allocate and initialize the arguments object. | 1526 // Actually allocate and initialize the arguments object. |
1507 AllocationBuilder a(jsgraph(), allocate_effect, control); | 1527 AllocationBuilder a(jsgraph(), allocate_effect, control); |
1508 Node* properties = jsgraph()->EmptyFixedArrayConstant(); | 1528 Node* properties = jsgraph()->EmptyFixedArrayConstant(); |
1509 int length = args_state_info.parameter_count() - 1; // Minus receiver. | 1529 int length = args_state_info.parameter_count() - 1; // Minus receiver. |
1510 STATIC_ASSERT(Heap::kSloppyArgumentsObjectSize == 5 * kPointerSize); | 1530 STATIC_ASSERT(Heap::kSloppyArgumentsObjectSize == 5 * kPointerSize); |
(...skipping 17 matching lines...) Expand all Loading... |
1528 Node* const context = NodeProperties::GetContextInput(node); | 1548 Node* const context = NodeProperties::GetContextInput(node); |
1529 // Choose the correct frame state and frame state info depending on whether | 1549 // Choose the correct frame state and frame state info depending on whether |
1530 // there conceptually is an arguments adaptor frame in the call chain. | 1550 // there conceptually is an arguments adaptor frame in the call chain. |
1531 Node* const args_state = GetArgumentsFrameState(frame_state); | 1551 Node* const args_state = GetArgumentsFrameState(frame_state); |
1532 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); | 1552 FrameStateInfo args_state_info = OpParameter<FrameStateInfo>(args_state); |
1533 // Prepare element backing store to be used by arguments object. | 1553 // Prepare element backing store to be used by arguments object. |
1534 Node* const elements = AllocateArguments(effect, control, args_state); | 1554 Node* const elements = AllocateArguments(effect, control, args_state); |
1535 Node* allocate_effect = | 1555 Node* allocate_effect = |
1536 elements->op()->EffectOutputCount() > 0 ? elements : effect; | 1556 elements->op()->EffectOutputCount() > 0 ? elements : effect; |
1537 // Load the arguments object map from the current native context. | 1557 // Load the arguments object map from the current native context. |
1538 Node* const load_native_context = graph()->NewNode( | 1558 Node* const load_global_object = graph()->NewNode( |
1539 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 1559 simplified()->LoadField( |
1540 context, context, effect); | 1560 AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), |
| 1561 context, effect, control); |
| 1562 Node* const load_native_context = |
| 1563 graph()->NewNode(simplified()->LoadField( |
| 1564 AccessBuilder::ForJSGlobalObjectNativeContext()), |
| 1565 load_global_object, effect, control); |
1541 Node* const load_arguments_map = graph()->NewNode( | 1566 Node* const load_arguments_map = graph()->NewNode( |
1542 simplified()->LoadField( | 1567 simplified()->LoadField( |
1543 AccessBuilder::ForContextSlot(Context::STRICT_ARGUMENTS_MAP_INDEX)), | 1568 AccessBuilder::ForContextSlot(Context::STRICT_ARGUMENTS_MAP_INDEX)), |
1544 load_native_context, effect, control); | 1569 load_native_context, effect, control); |
1545 // Actually allocate and initialize the arguments object. | 1570 // Actually allocate and initialize the arguments object. |
1546 AllocationBuilder a(jsgraph(), allocate_effect, control); | 1571 AllocationBuilder a(jsgraph(), allocate_effect, control); |
1547 Node* properties = jsgraph()->EmptyFixedArrayConstant(); | 1572 Node* properties = jsgraph()->EmptyFixedArrayConstant(); |
1548 int length = args_state_info.parameter_count() - 1; // Minus receiver. | 1573 int length = args_state_info.parameter_count() - 1; // Minus receiver. |
1549 STATIC_ASSERT(Heap::kStrictArgumentsObjectSize == 4 * kPointerSize); | 1574 STATIC_ASSERT(Heap::kStrictArgumentsObjectSize == 4 * kPointerSize); |
1550 a.Allocate(Heap::kStrictArgumentsObjectSize); | 1575 a.Allocate(Heap::kStrictArgumentsObjectSize); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 Node* js_array_map; | 1610 Node* js_array_map; |
1586 if (target_type->IsConstant()) { | 1611 if (target_type->IsConstant()) { |
1587 Handle<JSFunction> target_function = | 1612 Handle<JSFunction> target_function = |
1588 Handle<JSFunction>::cast(target_type->AsConstant()->Value()); | 1613 Handle<JSFunction>::cast(target_type->AsConstant()->Value()); |
1589 Handle<FixedArray> js_array_maps( | 1614 Handle<FixedArray> js_array_maps( |
1590 FixedArray::cast(target_function->native_context()->js_array_maps()), | 1615 FixedArray::cast(target_function->native_context()->js_array_maps()), |
1591 isolate()); | 1616 isolate()); |
1592 js_array_map = jsgraph()->Constant( | 1617 js_array_map = jsgraph()->Constant( |
1593 handle(js_array_maps->get(elements_kind), isolate())); | 1618 handle(js_array_maps->get(elements_kind), isolate())); |
1594 } else { | 1619 } else { |
1595 Node* native_context = effect = graph()->NewNode( | 1620 Node* global_object = effect = graph()->NewNode( |
1596 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 1621 javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true), |
1597 context, context, effect); | 1622 context, context, effect); |
| 1623 Node* native_context = effect = |
| 1624 graph()->NewNode(simplified()->LoadField( |
| 1625 AccessBuilder::ForJSGlobalObjectNativeContext()), |
| 1626 global_object, effect, control); |
1598 Node* js_array_maps = effect = graph()->NewNode( | 1627 Node* js_array_maps = effect = graph()->NewNode( |
1599 javascript()->LoadContext(0, Context::JS_ARRAY_MAPS_INDEX, true), | 1628 javascript()->LoadContext(0, Context::JS_ARRAY_MAPS_INDEX, true), |
1600 native_context, native_context, effect); | 1629 native_context, native_context, effect); |
1601 js_array_map = effect = | 1630 js_array_map = effect = |
1602 graph()->NewNode(simplified()->LoadField( | 1631 graph()->NewNode(simplified()->LoadField( |
1603 AccessBuilder::ForFixedArraySlot(elements_kind)), | 1632 AccessBuilder::ForFixedArraySlot(elements_kind)), |
1604 js_array_maps, effect, control); | 1633 js_array_maps, effect, control); |
1605 } | 1634 } |
1606 | 1635 |
1607 // Setup elements and properties. | 1636 // Setup elements and properties. |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 | 1835 |
1807 | 1836 |
1808 Reduction JSTypedLowering::ReduceJSCreateFunctionContext(Node* node) { | 1837 Reduction JSTypedLowering::ReduceJSCreateFunctionContext(Node* node) { |
1809 DCHECK_EQ(IrOpcode::kJSCreateFunctionContext, node->opcode()); | 1838 DCHECK_EQ(IrOpcode::kJSCreateFunctionContext, node->opcode()); |
1810 int slot_count = OpParameter<int>(node->op()); | 1839 int slot_count = OpParameter<int>(node->op()); |
1811 Node* const closure = NodeProperties::GetValueInput(node, 0); | 1840 Node* const closure = NodeProperties::GetValueInput(node, 0); |
1812 | 1841 |
1813 // Use inline allocation for function contexts up to a size limit. | 1842 // Use inline allocation for function contexts up to a size limit. |
1814 if (slot_count < kFunctionContextAllocationLimit) { | 1843 if (slot_count < kFunctionContextAllocationLimit) { |
1815 // JSCreateFunctionContext[slot_count < limit]](fun) | 1844 // JSCreateFunctionContext[slot_count < limit]](fun) |
1816 Node* effect = NodeProperties::GetEffectInput(node); | 1845 Node* const effect = NodeProperties::GetEffectInput(node); |
1817 Node* control = NodeProperties::GetControlInput(node); | 1846 Node* const control = NodeProperties::GetControlInput(node); |
1818 Node* context = NodeProperties::GetContextInput(node); | 1847 Node* const context = NodeProperties::GetContextInput(node); |
1819 Node* extension = jsgraph()->ZeroConstant(); | 1848 Node* const extension = jsgraph()->ZeroConstant(); |
1820 Node* native_context = effect = graph()->NewNode( | 1849 Node* const load = graph()->NewNode( |
1821 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 1850 simplified()->LoadField( |
1822 context, context, effect); | 1851 AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), |
| 1852 context, effect, control); |
1823 AllocationBuilder a(jsgraph(), effect, control); | 1853 AllocationBuilder a(jsgraph(), effect, control); |
1824 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. | 1854 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
1825 int context_length = slot_count + Context::MIN_CONTEXT_SLOTS; | 1855 int context_length = slot_count + Context::MIN_CONTEXT_SLOTS; |
1826 a.AllocateArray(context_length, factory()->function_context_map()); | 1856 a.AllocateArray(context_length, factory()->function_context_map()); |
1827 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); | 1857 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); |
1828 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); | 1858 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); |
1829 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); | 1859 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); |
1830 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), | 1860 a.Store(AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX), load); |
1831 native_context); | |
1832 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { | 1861 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { |
1833 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->UndefinedConstant()); | 1862 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->UndefinedConstant()); |
1834 } | 1863 } |
1835 RelaxControls(node); | 1864 RelaxControls(node); |
1836 a.FinishAndChange(node); | 1865 a.FinishAndChange(node); |
1837 return Changed(node); | 1866 return Changed(node); |
1838 } | 1867 } |
1839 | 1868 |
1840 // Use the FastNewContextStub only for function contexts up maximum size. | 1869 // Use the FastNewContextStub only for function contexts up maximum size. |
1841 if (slot_count <= FastNewContextStub::kMaximumSlots) { | 1870 if (slot_count <= FastNewContextStub::kMaximumSlots) { |
(...skipping 13 matching lines...) Expand all Loading... |
1855 } | 1884 } |
1856 | 1885 |
1857 | 1886 |
1858 Reduction JSTypedLowering::ReduceJSCreateWithContext(Node* node) { | 1887 Reduction JSTypedLowering::ReduceJSCreateWithContext(Node* node) { |
1859 DCHECK_EQ(IrOpcode::kJSCreateWithContext, node->opcode()); | 1888 DCHECK_EQ(IrOpcode::kJSCreateWithContext, node->opcode()); |
1860 Node* object = NodeProperties::GetValueInput(node, 0); | 1889 Node* object = NodeProperties::GetValueInput(node, 0); |
1861 Node* closure = NodeProperties::GetValueInput(node, 1); | 1890 Node* closure = NodeProperties::GetValueInput(node, 1); |
1862 Node* effect = NodeProperties::GetEffectInput(node); | 1891 Node* effect = NodeProperties::GetEffectInput(node); |
1863 Node* control = NodeProperties::GetControlInput(node); | 1892 Node* control = NodeProperties::GetControlInput(node); |
1864 Node* context = NodeProperties::GetContextInput(node); | 1893 Node* context = NodeProperties::GetContextInput(node); |
1865 Node* native_context = effect = graph()->NewNode( | 1894 Node* global = effect = graph()->NewNode( |
1866 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 1895 simplified()->LoadField( |
1867 context, context, effect); | 1896 AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), |
| 1897 context, effect, control); |
1868 AllocationBuilder a(jsgraph(), effect, control); | 1898 AllocationBuilder a(jsgraph(), effect, control); |
1869 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. | 1899 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
1870 a.AllocateArray(Context::MIN_CONTEXT_SLOTS, factory()->with_context_map()); | 1900 a.AllocateArray(Context::MIN_CONTEXT_SLOTS, factory()->with_context_map()); |
1871 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); | 1901 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); |
1872 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); | 1902 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); |
1873 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), object); | 1903 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), object); |
1874 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), | 1904 a.Store(AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX), global); |
1875 native_context); | |
1876 RelaxControls(node); | 1905 RelaxControls(node); |
1877 a.FinishAndChange(node); | 1906 a.FinishAndChange(node); |
1878 return Changed(node); | 1907 return Changed(node); |
1879 } | 1908 } |
1880 | 1909 |
1881 | 1910 |
1882 Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) { | 1911 Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) { |
1883 DCHECK_EQ(IrOpcode::kJSCreateBlockContext, node->opcode()); | 1912 DCHECK_EQ(IrOpcode::kJSCreateBlockContext, node->opcode()); |
1884 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); | 1913 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); |
1885 int context_length = scope_info->ContextLength(); | 1914 int context_length = scope_info->ContextLength(); |
1886 Node* const closure = NodeProperties::GetValueInput(node, 0); | 1915 Node* const closure = NodeProperties::GetValueInput(node, 0); |
1887 | 1916 |
1888 // Use inline allocation for block contexts up to a size limit. | 1917 // Use inline allocation for block contexts up to a size limit. |
1889 if (context_length < kBlockContextAllocationLimit) { | 1918 if (context_length < kBlockContextAllocationLimit) { |
1890 // JSCreateBlockContext[scope[length < limit]](fun) | 1919 // JSCreateBlockContext[scope[length < limit]](fun) |
1891 Node* effect = NodeProperties::GetEffectInput(node); | 1920 Node* const effect = NodeProperties::GetEffectInput(node); |
1892 Node* control = NodeProperties::GetControlInput(node); | 1921 Node* const control = NodeProperties::GetControlInput(node); |
1893 Node* context = NodeProperties::GetContextInput(node); | 1922 Node* const context = NodeProperties::GetContextInput(node); |
1894 Node* extension = jsgraph()->Constant(scope_info); | 1923 Node* const extension = jsgraph()->Constant(scope_info); |
1895 Node* native_context = effect = graph()->NewNode( | 1924 Node* const load = graph()->NewNode( |
1896 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 1925 simplified()->LoadField( |
1897 context, context, effect); | 1926 AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), |
| 1927 context, effect, control); |
1898 AllocationBuilder a(jsgraph(), effect, control); | 1928 AllocationBuilder a(jsgraph(), effect, control); |
1899 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. | 1929 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
1900 a.AllocateArray(context_length, factory()->block_context_map()); | 1930 a.AllocateArray(context_length, factory()->block_context_map()); |
1901 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); | 1931 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); |
1902 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); | 1932 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); |
1903 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); | 1933 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); |
1904 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), | 1934 a.Store(AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX), load); |
1905 native_context); | |
1906 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { | 1935 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { |
1907 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->TheHoleConstant()); | 1936 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->TheHoleConstant()); |
1908 } | 1937 } |
1909 RelaxControls(node); | 1938 RelaxControls(node); |
1910 a.FinishAndChange(node); | 1939 a.FinishAndChange(node); |
1911 return Changed(node); | 1940 return Changed(node); |
1912 } | 1941 } |
1913 | 1942 |
1914 return NoChange(); | 1943 return NoChange(); |
1915 } | 1944 } |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2385 case IrOpcode::kJSLoadProperty: | 2414 case IrOpcode::kJSLoadProperty: |
2386 return ReduceJSLoadProperty(node); | 2415 return ReduceJSLoadProperty(node); |
2387 case IrOpcode::kJSStoreProperty: | 2416 case IrOpcode::kJSStoreProperty: |
2388 return ReduceJSStoreProperty(node); | 2417 return ReduceJSStoreProperty(node); |
2389 case IrOpcode::kJSInstanceOf: | 2418 case IrOpcode::kJSInstanceOf: |
2390 return ReduceJSInstanceOf(node); | 2419 return ReduceJSInstanceOf(node); |
2391 case IrOpcode::kJSLoadContext: | 2420 case IrOpcode::kJSLoadContext: |
2392 return ReduceJSLoadContext(node); | 2421 return ReduceJSLoadContext(node); |
2393 case IrOpcode::kJSStoreContext: | 2422 case IrOpcode::kJSStoreContext: |
2394 return ReduceJSStoreContext(node); | 2423 return ReduceJSStoreContext(node); |
| 2424 case IrOpcode::kJSLoadNativeContext: |
| 2425 return ReduceJSLoadNativeContext(node); |
2395 case IrOpcode::kJSConvertReceiver: | 2426 case IrOpcode::kJSConvertReceiver: |
2396 return ReduceJSConvertReceiver(node); | 2427 return ReduceJSConvertReceiver(node); |
2397 case IrOpcode::kJSCreate: | 2428 case IrOpcode::kJSCreate: |
2398 return ReduceJSCreate(node); | 2429 return ReduceJSCreate(node); |
2399 case IrOpcode::kJSCreateArguments: | 2430 case IrOpcode::kJSCreateArguments: |
2400 return ReduceJSCreateArguments(node); | 2431 return ReduceJSCreateArguments(node); |
2401 case IrOpcode::kJSCreateArray: | 2432 case IrOpcode::kJSCreateArray: |
2402 return ReduceJSCreateArray(node); | 2433 return ReduceJSCreateArray(node); |
2403 case IrOpcode::kJSCreateClosure: | 2434 case IrOpcode::kJSCreateClosure: |
2404 return ReduceJSCreateClosure(node); | 2435 return ReduceJSCreateClosure(node); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2568 } | 2599 } |
2569 | 2600 |
2570 | 2601 |
2571 CompilationDependencies* JSTypedLowering::dependencies() const { | 2602 CompilationDependencies* JSTypedLowering::dependencies() const { |
2572 return dependencies_; | 2603 return dependencies_; |
2573 } | 2604 } |
2574 | 2605 |
2575 } // namespace compiler | 2606 } // namespace compiler |
2576 } // namespace internal | 2607 } // namespace internal |
2577 } // namespace v8 | 2608 } // namespace v8 |
OLD | NEW |