OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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-stub-assembler.h" | 5 #include "src/code-stub-assembler.h" |
6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
7 #include "src/frames-inl.h" | 7 #include "src/frames-inl.h" |
8 #include "src/frames.h" | 8 #include "src/frames.h" |
9 #include "src/ic/handler-configuration.h" | 9 #include "src/ic/handler-configuration.h" |
10 #include "src/ic/stub-cache.h" | 10 #include "src/ic/stub-cache.h" |
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 StoreObjectFieldNoWriteBarrier(result, SlicedString::kHashFieldOffset, | 1311 StoreObjectFieldNoWriteBarrier(result, SlicedString::kHashFieldOffset, |
1312 Int32Constant(String::kEmptyHashField), | 1312 Int32Constant(String::kEmptyHashField), |
1313 MachineRepresentation::kWord32); | 1313 MachineRepresentation::kWord32); |
1314 StoreObjectFieldNoWriteBarrier(result, SlicedString::kParentOffset, parent, | 1314 StoreObjectFieldNoWriteBarrier(result, SlicedString::kParentOffset, parent, |
1315 MachineRepresentation::kTagged); | 1315 MachineRepresentation::kTagged); |
1316 StoreObjectFieldNoWriteBarrier(result, SlicedString::kOffsetOffset, offset, | 1316 StoreObjectFieldNoWriteBarrier(result, SlicedString::kOffsetOffset, offset, |
1317 MachineRepresentation::kTagged); | 1317 MachineRepresentation::kTagged); |
1318 return result; | 1318 return result; |
1319 } | 1319 } |
1320 | 1320 |
| 1321 Node* CodeStubAssembler::AllocateRegExpResult(Node* context, Node* length, |
| 1322 Node* index, Node* input) { |
| 1323 Node* const max_length = |
| 1324 SmiConstant(Smi::FromInt(JSArray::kInitialMaxFastElementArray)); |
| 1325 Assert(SmiLessThanOrEqual(length, max_length)); |
| 1326 |
| 1327 // Allocate the JSRegExpResult. |
| 1328 // TODO(jgruber): Fold JSArray and FixedArray allocations, then remove |
| 1329 // unneeded store of elements. |
| 1330 Node* const result = Allocate(JSRegExpResult::kSize); |
| 1331 |
| 1332 // TODO(jgruber): Store map as Heap constant? |
| 1333 Node* const native_context = LoadNativeContext(context); |
| 1334 Node* const map = |
| 1335 LoadContextElement(native_context, Context::REGEXP_RESULT_MAP_INDEX); |
| 1336 StoreMapNoWriteBarrier(result, map); |
| 1337 |
| 1338 // Initialize the header before allocating the elements. |
| 1339 Node* const empty_array = EmptyFixedArrayConstant(); |
| 1340 DCHECK(Heap::RootIsImmortalImmovable(Heap::kEmptyFixedArrayRootIndex)); |
| 1341 StoreObjectFieldNoWriteBarrier(result, JSArray::kPropertiesOffset, |
| 1342 empty_array); |
| 1343 StoreObjectFieldNoWriteBarrier(result, JSArray::kElementsOffset, empty_array); |
| 1344 StoreObjectFieldNoWriteBarrier(result, JSArray::kLengthOffset, length); |
| 1345 |
| 1346 StoreObjectFieldNoWriteBarrier(result, JSRegExpResult::kIndexOffset, index); |
| 1347 StoreObjectField(result, JSRegExpResult::kInputOffset, input); |
| 1348 |
| 1349 Node* const zero = IntPtrConstant(0); |
| 1350 Node* const length_intptr = SmiUntag(length); |
| 1351 const ElementsKind elements_kind = FAST_ELEMENTS; |
| 1352 const ParameterMode parameter_mode = INTPTR_PARAMETERS; |
| 1353 |
| 1354 Node* const elements = |
| 1355 AllocateFixedArray(elements_kind, length_intptr, parameter_mode); |
| 1356 StoreObjectField(result, JSArray::kElementsOffset, elements); |
| 1357 |
| 1358 // Fill in the elements with undefined. |
| 1359 FillFixedArrayWithValue(elements_kind, elements, zero, length_intptr, |
| 1360 Heap::kUndefinedValueRootIndex, parameter_mode); |
| 1361 |
| 1362 return result; |
| 1363 } |
| 1364 |
1321 Node* CodeStubAssembler::AllocateUninitializedJSArrayWithoutElements( | 1365 Node* CodeStubAssembler::AllocateUninitializedJSArrayWithoutElements( |
1322 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site) { | 1366 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site) { |
1323 Comment("begin allocation of JSArray without elements"); | 1367 Comment("begin allocation of JSArray without elements"); |
1324 int base_size = JSArray::kSize; | 1368 int base_size = JSArray::kSize; |
1325 if (allocation_site != nullptr) { | 1369 if (allocation_site != nullptr) { |
1326 base_size += AllocationMemento::kSize; | 1370 base_size += AllocationMemento::kSize; |
1327 } | 1371 } |
1328 | 1372 |
1329 Node* size = IntPtrConstant(base_size); | 1373 Node* size = IntPtrConstant(base_size); |
1330 Node* array = AllocateUninitializedJSArray(kind, array_map, length, | 1374 Node* array = AllocateUninitializedJSArray(kind, array_map, length, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 FillFixedArrayWithValue(kind, elements, IntPtrConstant(0), capacity, | 1445 FillFixedArrayWithValue(kind, elements, IntPtrConstant(0), capacity, |
1402 Heap::kTheHoleValueRootIndex, capacity_mode); | 1446 Heap::kTheHoleValueRootIndex, capacity_mode); |
1403 | 1447 |
1404 return array; | 1448 return array; |
1405 } | 1449 } |
1406 | 1450 |
1407 Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, | 1451 Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, |
1408 Node* capacity_node, | 1452 Node* capacity_node, |
1409 ParameterMode mode, | 1453 ParameterMode mode, |
1410 AllocationFlags flags) { | 1454 AllocationFlags flags) { |
1411 Node* total_size = GetFixedAarrayAllocationSize(capacity_node, kind, mode); | 1455 Node* total_size = GetFixedArrayAllocationSize(capacity_node, kind, mode); |
1412 | 1456 |
1413 // Allocate both array and elements object, and initialize the JSArray. | 1457 // Allocate both array and elements object, and initialize the JSArray. |
1414 Node* array = Allocate(total_size, flags); | 1458 Node* array = Allocate(total_size, flags); |
1415 Heap* heap = isolate()->heap(); | 1459 Heap* heap = isolate()->heap(); |
1416 Handle<Map> map(IsFastDoubleElementsKind(kind) | 1460 Handle<Map> map(IsFastDoubleElementsKind(kind) |
1417 ? heap->fixed_double_array_map() | 1461 ? heap->fixed_double_array_map() |
1418 : heap->fixed_array_map()); | 1462 : heap->fixed_array_map()); |
1419 if (flags & kPretenured) { | 1463 if (flags & kPretenured) { |
1420 StoreObjectField(array, JSObject::kMapOffset, HeapConstant(map)); | 1464 StoreObjectField(array, JSObject::kMapOffset, HeapConstant(map)); |
1421 } else { | 1465 } else { |
(...skipping 4273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5695 Heap::kTheHoleValueRootIndex); | 5739 Heap::kTheHoleValueRootIndex); |
5696 | 5740 |
5697 // Store the WeakCell in the feedback vector. | 5741 // Store the WeakCell in the feedback vector. |
5698 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, | 5742 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, |
5699 CodeStubAssembler::SMI_PARAMETERS); | 5743 CodeStubAssembler::SMI_PARAMETERS); |
5700 return cell; | 5744 return cell; |
5701 } | 5745 } |
5702 | 5746 |
5703 } // namespace internal | 5747 } // namespace internal |
5704 } // namespace v8 | 5748 } // namespace v8 |
OLD | NEW |