Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(772)

Side by Side Diff: src/code-stub-assembler.cc

Issue 2304573004: Port FastCloneShallowArrayStub to Turbofan (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: comments from Michi Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 28 matching lines...) Expand all
39 } 39 }
40 40
41 Node* CodeStubAssembler::BooleanMapConstant() { 41 Node* CodeStubAssembler::BooleanMapConstant() {
42 return HeapConstant(isolate()->factory()->boolean_map()); 42 return HeapConstant(isolate()->factory()->boolean_map());
43 } 43 }
44 44
45 Node* CodeStubAssembler::EmptyStringConstant() { 45 Node* CodeStubAssembler::EmptyStringConstant() {
46 return LoadRoot(Heap::kempty_stringRootIndex); 46 return LoadRoot(Heap::kempty_stringRootIndex);
47 } 47 }
48 48
49 Node* CodeStubAssembler::FixedArrayMapConstant() {
50 return LoadRoot(Heap::kFixedArrayMapRootIndex);
51 }
52
53 Node* CodeStubAssembler::FixedCowArrayMapConstant() {
54 return LoadRoot(Heap::kFixedCOWArrayMapRootIndex);
55 }
56
57 Node* CodeStubAssembler::FixedDoubleArrayMapConstant() {
58 return LoadRoot(Heap::kFixedDoubleArrayMapRootIndex);
59 }
60
49 Node* CodeStubAssembler::HeapNumberMapConstant() { 61 Node* CodeStubAssembler::HeapNumberMapConstant() {
50 return LoadRoot(Heap::kHeapNumberMapRootIndex); 62 return LoadRoot(Heap::kHeapNumberMapRootIndex);
51 } 63 }
52 64
53 Node* CodeStubAssembler::NoContextConstant() { 65 Node* CodeStubAssembler::NoContextConstant() {
54 return SmiConstant(Smi::FromInt(0)); 66 return SmiConstant(Smi::FromInt(0));
55 } 67 }
56 68
57 Node* CodeStubAssembler::MinusZeroConstant() { 69 Node* CodeStubAssembler::MinusZeroConstant() {
58 return LoadRoot(Heap::kMinusZeroValueRootIndex); 70 return LoadRoot(Heap::kMinusZeroValueRootIndex);
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 } 1005 }
994 1006
995 Node* CodeStubAssembler::LoadProperties(Node* object) { 1007 Node* CodeStubAssembler::LoadProperties(Node* object) {
996 return LoadObjectField(object, JSObject::kPropertiesOffset); 1008 return LoadObjectField(object, JSObject::kPropertiesOffset);
997 } 1009 }
998 1010
999 Node* CodeStubAssembler::LoadElements(Node* object) { 1011 Node* CodeStubAssembler::LoadElements(Node* object) {
1000 return LoadObjectField(object, JSObject::kElementsOffset); 1012 return LoadObjectField(object, JSObject::kElementsOffset);
1001 } 1013 }
1002 1014
1015 Node* CodeStubAssembler::LoadJSArrayLength(compiler::Node* array) {
1016 return LoadObjectField(array, JSArray::kLengthOffset);
1017 }
1018
1003 Node* CodeStubAssembler::LoadFixedArrayBaseLength(compiler::Node* array) { 1019 Node* CodeStubAssembler::LoadFixedArrayBaseLength(compiler::Node* array) {
1004 return LoadObjectField(array, FixedArrayBase::kLengthOffset); 1020 return LoadObjectField(array, FixedArrayBase::kLengthOffset);
1005 } 1021 }
1006 1022
1007 Node* CodeStubAssembler::LoadAndUntagFixedArrayBaseLength(Node* array) { 1023 Node* CodeStubAssembler::LoadAndUntagFixedArrayBaseLength(Node* array) {
1008 return LoadAndUntagObjectField(array, FixedArrayBase::kLengthOffset); 1024 return LoadAndUntagObjectField(array, FixedArrayBase::kLengthOffset);
1009 } 1025 }
1010 1026
1011 Node* CodeStubAssembler::LoadMapBitField(Node* map) { 1027 Node* CodeStubAssembler::LoadMapBitField(Node* map) {
1012 return LoadObjectField(map, Map::kBitFieldOffset, MachineType::Uint8()); 1028 return LoadObjectField(map, Map::kBitFieldOffset, MachineType::Uint8());
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 Node* result = CallRuntime(Runtime::kAllocateSeqTwoByteString, context, 1375 Node* result = CallRuntime(Runtime::kAllocateSeqTwoByteString, context,
1360 SmiFromWord(length)); 1376 SmiFromWord(length));
1361 var_result.Bind(result); 1377 var_result.Bind(result);
1362 Goto(&if_join); 1378 Goto(&if_join);
1363 } 1379 }
1364 1380
1365 Bind(&if_join); 1381 Bind(&if_join);
1366 return var_result.value(); 1382 return var_result.value();
1367 } 1383 }
1368 1384
1369 Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map, 1385 Node* CodeStubAssembler::AllocateUninitializedJSArrayWithoutElements(
1370 Node* capacity_node, Node* length_node, 1386 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site) {
1371 compiler::Node* allocation_site, 1387 Comment("begin allocation of JSArray without elements");
1372 ParameterMode mode) { 1388 int base_size = JSArray::kSize;
1373 bool is_double = IsFastDoubleElementsKind(kind);
1374 int base_size = JSArray::kSize + FixedArray::kHeaderSize;
1375 int elements_offset = JSArray::kSize;
1376
1377 Comment("begin allocation of JSArray");
1378 1389
1379 if (allocation_site != nullptr) { 1390 if (allocation_site != nullptr) {
1380 base_size += AllocationMemento::kSize; 1391 base_size += AllocationMemento::kSize;
1381 elements_offset += AllocationMemento::kSize;
1382 } 1392 }
1383 1393
1384 Node* total_size = 1394 Node* size = IntPtrConstant(base_size);
1385 ElementOffsetFromIndex(capacity_node, kind, mode, base_size); 1395 Node* array = AllocateUninitializedJSArray(kind, array_map, length,
1396 allocation_site, size);
1397 return array;
1398 }
1386 1399
1387 // Allocate both array and elements object, and initialize the JSArray. 1400 std::pair<Node*, Node*>
1388 Heap* heap = isolate()->heap(); 1401 CodeStubAssembler::AllocateUninitializedJSArrayWithElements(
1389 Node* array = Allocate(total_size); 1402 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site,
1403 Node* capacity, ParameterMode capacity_mode) {
1404 Comment("begin allocation of JSArray with elements");
1405 int base_size = JSArray::kSize;
1406
1407 if (allocation_site != nullptr) {
1408 base_size += AllocationMemento::kSize;
1409 }
1410
1411 int elements_offset = base_size;
1412
1413 // Compute space for elements
1414 base_size += FixedArray::kHeaderSize;
1415 Node* size = ElementOffsetFromIndex(capacity, kind, capacity_mode, base_size);
1416
1417 Node* array = AllocateUninitializedJSArray(kind, array_map, length,
1418 allocation_site, size);
1419
1420 Node* elements = InnerAllocate(array, elements_offset);
1421 StoreObjectField(array, JSObject::kElementsOffset, elements);
1422
1423 return {array, elements};
1424 }
1425
1426 Node* CodeStubAssembler::AllocateUninitializedJSArray(ElementsKind kind,
1427 Node* array_map,
1428 Node* length,
1429 Node* allocation_site,
1430 Node* size_in_bytes) {
1431 Node* array = Allocate(size_in_bytes);
1432
1433 Comment("write JSArray headers");
1390 StoreMapNoWriteBarrier(array, array_map); 1434 StoreMapNoWriteBarrier(array, array_map);
1391 Node* empty_properties = LoadRoot(Heap::kEmptyFixedArrayRootIndex); 1435
1392 StoreObjectFieldNoWriteBarrier(array, JSArray::kPropertiesOffset, 1436 StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length);
1393 empty_properties); 1437
1394 StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, 1438 StoreObjectFieldRoot(array, JSArray::kPropertiesOffset,
1395 TagParameter(length_node, mode)); 1439 Heap::kEmptyFixedArrayRootIndex);
1396 1440
1397 if (allocation_site != nullptr) { 1441 if (allocation_site != nullptr) {
1398 InitializeAllocationMemento(array, JSArray::kSize, allocation_site); 1442 InitializeAllocationMemento(array, JSArray::kSize, allocation_site);
1399 } 1443 }
1444 return array;
1445 }
1400 1446
1447 Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map,
1448 Node* capacity, Node* length,
1449 Node* allocation_site,
1450 ParameterMode mode) {
1451 bool is_double = IsFastDoubleElementsKind(kind);
1452
1453 // Allocate both array and elements object, and initialize the JSArray.
1454 Node *array, *elements;
1455 std::tie(array, elements) = AllocateUninitializedJSArrayWithElements(
1456 kind, array_map, TagParameter(length, mode), allocation_site, capacity,
1457 mode);
1401 // Setup elements object. 1458 // Setup elements object.
1402 Node* elements = InnerAllocate(array, elements_offset); 1459 Heap* heap = isolate()->heap();
1403 StoreObjectFieldNoWriteBarrier(array, JSArray::kElementsOffset, elements);
1404 Handle<Map> elements_map(is_double ? heap->fixed_double_array_map() 1460 Handle<Map> elements_map(is_double ? heap->fixed_double_array_map()
1405 : heap->fixed_array_map()); 1461 : heap->fixed_array_map());
1406 StoreMapNoWriteBarrier(elements, HeapConstant(elements_map)); 1462 StoreMapNoWriteBarrier(elements, HeapConstant(elements_map));
1407 StoreObjectFieldNoWriteBarrier(elements, FixedArray::kLengthOffset, 1463 StoreObjectFieldNoWriteBarrier(elements, FixedArray::kLengthOffset,
1408 TagParameter(capacity_node, mode)); 1464 TagParameter(capacity, mode));
1409 1465
1410 // Fill in the elements with holes. 1466 // Fill in the elements with holes.
1411 FillFixedArrayWithValue(kind, elements, IntPtrConstant(0), capacity_node, 1467 FillFixedArrayWithValue(kind, elements, IntPtrConstant(0), capacity,
1412 Heap::kTheHoleValueRootIndex, mode); 1468 Heap::kTheHoleValueRootIndex, mode);
1413 1469
1414 return array; 1470 return array;
1415 } 1471 }
1416 1472
1417 Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, 1473 Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind,
1418 Node* capacity_node, 1474 Node* capacity_node,
1419 ParameterMode mode, 1475 ParameterMode mode,
1420 AllocationFlags flags) { 1476 AllocationFlags flags) {
1421 Node* total_size = GetFixedAarrayAllocationSize(capacity_node, kind, mode); 1477 Node* total_size = GetFixedAarrayAllocationSize(capacity_node, kind, mode);
(...skipping 2430 matching lines...) Expand 10 before | Expand all | Expand 10 after
3852 Label* miss) { 3908 Label* miss) {
3853 Variable var_length(this, MachineType::PointerRepresentation()); 3909 Variable var_length(this, MachineType::PointerRepresentation());
3854 Label if_array(this), length_loaded(this, &var_length); 3910 Label if_array(this), length_loaded(this, &var_length);
3855 GotoIf(is_jsarray_condition, &if_array); 3911 GotoIf(is_jsarray_condition, &if_array);
3856 { 3912 {
3857 var_length.Bind(SmiUntag(LoadFixedArrayBaseLength(elements))); 3913 var_length.Bind(SmiUntag(LoadFixedArrayBaseLength(elements)));
3858 Goto(&length_loaded); 3914 Goto(&length_loaded);
3859 } 3915 }
3860 Bind(&if_array); 3916 Bind(&if_array);
3861 { 3917 {
3862 var_length.Bind(SmiUntag(LoadObjectField(object, JSArray::kLengthOffset))); 3918 var_length.Bind(SmiUntag(LoadJSArrayLength(object)));
3863 Goto(&length_loaded); 3919 Goto(&length_loaded);
3864 } 3920 }
3865 Bind(&length_loaded); 3921 Bind(&length_loaded);
3866 GotoUnless(UintPtrLessThan(intptr_index, var_length.value()), miss); 3922 GotoUnless(UintPtrLessThan(intptr_index, var_length.value()), miss);
3867 } 3923 }
3868 3924
3869 void CodeStubAssembler::EmitElementLoad(Node* object, Node* elements, 3925 void CodeStubAssembler::EmitElementLoad(Node* object, Node* elements,
3870 Node* elements_kind, Node* intptr_index, 3926 Node* elements_kind, Node* intptr_index,
3871 Node* is_jsarray_condition, 3927 Node* is_jsarray_condition,
3872 Label* if_hole, Label* rebox_double, 3928 Label* if_hole, Label* rebox_double,
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
4194 &var_handler, &try_polymorphic); 4250 &var_handler, &try_polymorphic);
4195 Bind(&if_handler); 4251 Bind(&if_handler);
4196 { 4252 {
4197 HandleLoadICHandlerCase(p, var_handler.value(), &miss); 4253 HandleLoadICHandlerCase(p, var_handler.value(), &miss);
4198 } 4254 }
4199 4255
4200 Bind(&try_polymorphic); 4256 Bind(&try_polymorphic);
4201 { 4257 {
4202 // Check polymorphic case. 4258 // Check polymorphic case.
4203 Comment("LoadIC_try_polymorphic"); 4259 Comment("LoadIC_try_polymorphic");
4204 GotoUnless( 4260 GotoUnless(WordEqual(LoadMap(feedback), FixedArrayMapConstant()),
4205 WordEqual(LoadMap(feedback), LoadRoot(Heap::kFixedArrayMapRootIndex)), 4261 &try_megamorphic);
4206 &try_megamorphic);
4207 HandlePolymorphicCase(p, receiver_map, feedback, &if_handler, &var_handler, 4262 HandlePolymorphicCase(p, receiver_map, feedback, &if_handler, &var_handler,
4208 &miss, 2); 4263 &miss, 2);
4209 } 4264 }
4210 4265
4211 Bind(&try_megamorphic); 4266 Bind(&try_megamorphic);
4212 { 4267 {
4213 // Check megamorphic case. 4268 // Check megamorphic case.
4214 GotoUnless( 4269 GotoUnless(
4215 WordEqual(feedback, LoadRoot(Heap::kmegamorphic_symbolRootIndex)), 4270 WordEqual(feedback, LoadRoot(Heap::kmegamorphic_symbolRootIndex)),
4216 &miss); 4271 &miss);
(...skipping 23 matching lines...) Expand all
4240 &var_handler, &try_polymorphic); 4295 &var_handler, &try_polymorphic);
4241 Bind(&if_handler); 4296 Bind(&if_handler);
4242 { 4297 {
4243 HandleLoadICHandlerCase(p, var_handler.value(), &miss, kSupportElements); 4298 HandleLoadICHandlerCase(p, var_handler.value(), &miss, kSupportElements);
4244 } 4299 }
4245 4300
4246 Bind(&try_polymorphic); 4301 Bind(&try_polymorphic);
4247 { 4302 {
4248 // Check polymorphic case. 4303 // Check polymorphic case.
4249 Comment("KeyedLoadIC_try_polymorphic"); 4304 Comment("KeyedLoadIC_try_polymorphic");
4250 GotoUnless( 4305 GotoUnless(WordEqual(LoadMap(feedback), FixedArrayMapConstant()),
4251 WordEqual(LoadMap(feedback), LoadRoot(Heap::kFixedArrayMapRootIndex)), 4306 &try_megamorphic);
4252 &try_megamorphic);
4253 HandlePolymorphicCase(p, receiver_map, feedback, &if_handler, &var_handler, 4307 HandlePolymorphicCase(p, receiver_map, feedback, &if_handler, &var_handler,
4254 &miss, 2); 4308 &miss, 2);
4255 } 4309 }
4256 4310
4257 Bind(&try_megamorphic); 4311 Bind(&try_megamorphic);
4258 { 4312 {
4259 // Check megamorphic case. 4313 // Check megamorphic case.
4260 Comment("KeyedLoadIC_try_megamorphic"); 4314 Comment("KeyedLoadIC_try_megamorphic");
4261 GotoUnless( 4315 GotoUnless(
4262 WordEqual(feedback, LoadRoot(Heap::kmegamorphic_symbolRootIndex)), 4316 WordEqual(feedback, LoadRoot(Heap::kmegamorphic_symbolRootIndex)),
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
4625 StoreFixedArrayElement(the_context, mapped_index, value, 4679 StoreFixedArrayElement(the_context, mapped_index, value,
4626 UPDATE_WRITE_BARRIER, INTPTR_PARAMETERS); 4680 UPDATE_WRITE_BARRIER, INTPTR_PARAMETERS);
4627 } 4681 }
4628 Goto(&end); 4682 Goto(&end);
4629 } 4683 }
4630 4684
4631 Bind(&if_unmapped); 4685 Bind(&if_unmapped);
4632 { 4686 {
4633 Node* backing_store = LoadFixedArrayElement(elements, IntPtrConstant(1), 0, 4687 Node* backing_store = LoadFixedArrayElement(elements, IntPtrConstant(1), 0,
4634 INTPTR_PARAMETERS); 4688 INTPTR_PARAMETERS);
4635 GotoIf(WordNotEqual(LoadMap(backing_store), 4689 GotoIf(WordNotEqual(LoadMap(backing_store), FixedArrayMapConstant()),
4636 LoadRoot(Heap::kFixedArrayMapRootIndex)),
4637 bailout); 4690 bailout);
4638 4691
4639 Node* backing_store_length = 4692 Node* backing_store_length =
4640 LoadAndUntagFixedArrayBaseLength(backing_store); 4693 LoadAndUntagFixedArrayBaseLength(backing_store);
4641 GotoIf(UintPtrGreaterThanOrEqual(key, backing_store_length), bailout); 4694 GotoIf(UintPtrGreaterThanOrEqual(key, backing_store_length), bailout);
4642 4695
4643 // The key falls into unmapped range. 4696 // The key falls into unmapped range.
4644 if (is_load) { 4697 if (is_load) {
4645 Node* result = 4698 Node* result =
4646 LoadFixedArrayElement(backing_store, key, 0, INTPTR_PARAMETERS); 4699 LoadFixedArrayElement(backing_store, key, 0, INTPTR_PARAMETERS);
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
5137 Heap::kTheHoleValueRootIndex); 5190 Heap::kTheHoleValueRootIndex);
5138 5191
5139 // Store the WeakCell in the feedback vector. 5192 // Store the WeakCell in the feedback vector.
5140 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 5193 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER,
5141 CodeStubAssembler::SMI_PARAMETERS); 5194 CodeStubAssembler::SMI_PARAMETERS);
5142 return cell; 5195 return cell;
5143 } 5196 }
5144 5197
5145 } // namespace internal 5198 } // namespace internal
5146 } // namespace v8 5199 } // namespace v8
OLDNEW
« src/code-stub-assembler.h ('K') | « src/code-stub-assembler.h ('k') | src/code-stubs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698