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

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 Ross 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 HeapConstant(isolate()->factory()->fixed_array_map());
51 // return LoadRoot(Heap::kFixedArrayMapRootIndex);
52 }
53
54 Node* CodeStubAssembler::FixedCowArrayMapConstant() {
55 return HeapConstant(isolate()->factory()->fixed_cow_array_map());
56 // return LoadRoot(Heap::kFixedCOWArrayMapRootIndex);
57 }
58
59 Node* CodeStubAssembler::FixedDoubleArrayMapConstant() {
60 return HeapConstant(isolate()->factory()->fixed_double_array_map());
61 // return LoadRoot(Heap::kFixedDoubleArrayMapRootIndex);
62 }
63
49 Node* CodeStubAssembler::HeapNumberMapConstant() { 64 Node* CodeStubAssembler::HeapNumberMapConstant() {
50 return LoadRoot(Heap::kHeapNumberMapRootIndex); 65 return LoadRoot(Heap::kHeapNumberMapRootIndex);
51 } 66 }
52 67
53 Node* CodeStubAssembler::NoContextConstant() { 68 Node* CodeStubAssembler::NoContextConstant() {
54 return SmiConstant(Smi::FromInt(0)); 69 return SmiConstant(Smi::FromInt(0));
55 } 70 }
56 71
57 Node* CodeStubAssembler::MinusZeroConstant() { 72 Node* CodeStubAssembler::MinusZeroConstant() {
58 return LoadRoot(Heap::kMinusZeroValueRootIndex); 73 return LoadRoot(Heap::kMinusZeroValueRootIndex);
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 } 1008 }
994 1009
995 Node* CodeStubAssembler::LoadProperties(Node* object) { 1010 Node* CodeStubAssembler::LoadProperties(Node* object) {
996 return LoadObjectField(object, JSObject::kPropertiesOffset); 1011 return LoadObjectField(object, JSObject::kPropertiesOffset);
997 } 1012 }
998 1013
999 Node* CodeStubAssembler::LoadElements(Node* object) { 1014 Node* CodeStubAssembler::LoadElements(Node* object) {
1000 return LoadObjectField(object, JSObject::kElementsOffset); 1015 return LoadObjectField(object, JSObject::kElementsOffset);
1001 } 1016 }
1002 1017
1018 Node* CodeStubAssembler::LoadJSArrayLength(compiler::Node* array) {
1019 return LoadObjectField(array, JSArray::kLengthOffset);
1020 }
1021
1003 Node* CodeStubAssembler::LoadFixedArrayBaseLength(compiler::Node* array) { 1022 Node* CodeStubAssembler::LoadFixedArrayBaseLength(compiler::Node* array) {
1004 return LoadObjectField(array, FixedArrayBase::kLengthOffset); 1023 return LoadObjectField(array, FixedArrayBase::kLengthOffset);
1005 } 1024 }
1006 1025
1007 Node* CodeStubAssembler::LoadAndUntagFixedArrayBaseLength(Node* array) { 1026 Node* CodeStubAssembler::LoadAndUntagFixedArrayBaseLength(Node* array) {
1008 return LoadAndUntagObjectField(array, FixedArrayBase::kLengthOffset); 1027 return LoadAndUntagObjectField(array, FixedArrayBase::kLengthOffset);
1009 } 1028 }
1010 1029
1011 Node* CodeStubAssembler::LoadMapBitField(Node* map) { 1030 Node* CodeStubAssembler::LoadMapBitField(Node* map) {
1012 return LoadObjectField(map, Map::kBitFieldOffset, MachineType::Uint8()); 1031 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, 1378 Node* result = CallRuntime(Runtime::kAllocateSeqTwoByteString, context,
1360 SmiFromWord(length)); 1379 SmiFromWord(length));
1361 var_result.Bind(result); 1380 var_result.Bind(result);
1362 Goto(&if_join); 1381 Goto(&if_join);
1363 } 1382 }
1364 1383
1365 Bind(&if_join); 1384 Bind(&if_join);
1366 return var_result.value(); 1385 return var_result.value();
1367 } 1386 }
1368 1387
1369 Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map, 1388 Node* CodeStubAssembler::AllocateUninitializedJSArrayWithoutElements(
1370 Node* capacity_node, Node* length_node, 1389 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site) {
1371 compiler::Node* allocation_site, 1390 return AllocateUninitializedJSArray(kind, array_map, length, allocation_site)
1372 ParameterMode mode) { 1391 .first;
1373 bool is_double = IsFastDoubleElementsKind(kind); 1392 }
1374 int base_size = JSArray::kSize + FixedArray::kHeaderSize;
1375 int elements_offset = JSArray::kSize;
1376 1393
1394 std::pair<Node*, Node*> CodeStubAssembler::AllocateUninitializedJSArray(
1395 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site,
1396 Node* capacity, ParameterMode capacity_mode) {
1377 Comment("begin allocation of JSArray"); 1397 Comment("begin allocation of JSArray");
1378 1398
1399 int base_size = JSArray::kSize;
1400
1379 if (allocation_site != nullptr) { 1401 if (allocation_site != nullptr) {
1380 base_size += AllocationMemento::kSize; 1402 base_size += AllocationMemento::kSize;
1381 elements_offset += AllocationMemento::kSize;
1382 } 1403 }
1383 1404
1384 Node* total_size = 1405 int elements_offset = base_size;
1385 ElementOffsetFromIndex(capacity_node, kind, mode, base_size); 1406 Node* total_size;
1407
1408 // Compute space for elements if capacity is not null.
1409 if (capacity != nullptr) {
rmcilroy 2016/09/16 08:53:51 Not a great fan of this being an optional nullptr
klaasb 2016/09/19 12:17:59 Done.
1410 base_size += FixedArray::kHeaderSize;
1411 total_size =
1412 ElementOffsetFromIndex(capacity, kind, capacity_mode, base_size);
1413 } else {
1414 total_size = IntPtrConstant(base_size);
1415 }
1386 1416
1387 // Allocate both array and elements object, and initialize the JSArray. 1417 // Allocate both array and elements object, and initialize the JSArray.
1388 Heap* heap = isolate()->heap();
1389 Node* array = Allocate(total_size); 1418 Node* array = Allocate(total_size);
1419
1420 Comment("write JSArray headers");
1390 StoreMapNoWriteBarrier(array, array_map); 1421 StoreMapNoWriteBarrier(array, array_map);
1391 Node* empty_properties = LoadRoot(Heap::kEmptyFixedArrayRootIndex); 1422
1392 StoreObjectFieldNoWriteBarrier(array, JSArray::kPropertiesOffset, 1423 StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length);
1393 empty_properties); 1424
1394 StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, 1425 StoreObjectFieldRoot(array, JSArray::kPropertiesOffset,
1395 TagParameter(length_node, mode)); 1426 Heap::kEmptyFixedArrayRootIndex);
1396 1427
1397 if (allocation_site != nullptr) { 1428 if (allocation_site != nullptr) {
1398 InitializeAllocationMemento(array, JSArray::kSize, allocation_site); 1429 InitializeAllocationMemento(array, JSArray::kSize, allocation_site);
1399 } 1430 }
1400 1431
1432 if (capacity != nullptr) {
1433 Node* elements = InnerAllocate(array, elements_offset);
1434 StoreObjectField(array, JSObject::kElementsOffset, elements);
1435 return {array, elements};
1436 }
1437
1438 return {array, nullptr};
rmcilroy 2016/09/16 08:53:51 Also not keen on this maybe returning a nullptr. M
klaasb 2016/09/19 12:17:59 Done.
1439 }
1440
1441 Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map,
1442 Node* capacity, Node* length,
1443 Node* allocation_site,
1444 ParameterMode mode) {
1445 bool is_double = IsFastDoubleElementsKind(kind);
1446
1447 // Allocate both array and elements object, and initialize the JSArray.
1448 Node *array, *elements;
1449 std::tie(array, elements) =
1450 AllocateUninitializedJSArray(kind, array_map, TagParameter(length, mode),
1451 allocation_site, capacity, mode);
1452
1401 // Setup elements object. 1453 // Setup elements object.
1402 Node* elements = InnerAllocate(array, elements_offset); 1454 Heap* heap = isolate()->heap();
1403 StoreObjectFieldNoWriteBarrier(array, JSArray::kElementsOffset, elements);
1404 Handle<Map> elements_map(is_double ? heap->fixed_double_array_map() 1455 Handle<Map> elements_map(is_double ? heap->fixed_double_array_map()
1405 : heap->fixed_array_map()); 1456 : heap->fixed_array_map());
1406 StoreMapNoWriteBarrier(elements, HeapConstant(elements_map)); 1457 StoreMapNoWriteBarrier(elements, HeapConstant(elements_map));
1407 StoreObjectFieldNoWriteBarrier(elements, FixedArray::kLengthOffset, 1458 StoreObjectFieldNoWriteBarrier(elements, FixedArray::kLengthOffset,
1408 TagParameter(capacity_node, mode)); 1459 TagParameter(capacity, mode));
1409 1460
1410 // Fill in the elements with holes. 1461 // Fill in the elements with holes.
1411 FillFixedArrayWithValue(kind, elements, IntPtrConstant(0), capacity_node, 1462 FillFixedArrayWithValue(kind, elements, IntPtrConstant(0), capacity,
1412 Heap::kTheHoleValueRootIndex, mode); 1463 Heap::kTheHoleValueRootIndex, mode);
1413 1464
1414 return array; 1465 return array;
1415 } 1466 }
1416 1467
1417 Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, 1468 Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind,
1418 Node* capacity_node, 1469 Node* capacity_node,
1419 ParameterMode mode, 1470 ParameterMode mode,
1420 AllocationFlags flags) { 1471 AllocationFlags flags) {
1421 Node* total_size = GetFixedAarrayAllocationSize(capacity_node, kind, mode); 1472 Node* total_size = GetFixedAarrayAllocationSize(capacity_node, kind, mode);
(...skipping 2431 matching lines...) Expand 10 before | Expand all | Expand 10 after
3853 Label* miss) { 3904 Label* miss) {
3854 Variable var_length(this, MachineType::PointerRepresentation()); 3905 Variable var_length(this, MachineType::PointerRepresentation());
3855 Label if_array(this), length_loaded(this, &var_length); 3906 Label if_array(this), length_loaded(this, &var_length);
3856 GotoIf(is_jsarray_condition, &if_array); 3907 GotoIf(is_jsarray_condition, &if_array);
3857 { 3908 {
3858 var_length.Bind(SmiUntag(LoadFixedArrayBaseLength(elements))); 3909 var_length.Bind(SmiUntag(LoadFixedArrayBaseLength(elements)));
3859 Goto(&length_loaded); 3910 Goto(&length_loaded);
3860 } 3911 }
3861 Bind(&if_array); 3912 Bind(&if_array);
3862 { 3913 {
3863 var_length.Bind(SmiUntag(LoadObjectField(object, JSArray::kLengthOffset))); 3914 var_length.Bind(SmiUntag(LoadJSArrayLength(object)));
3864 Goto(&length_loaded); 3915 Goto(&length_loaded);
3865 } 3916 }
3866 Bind(&length_loaded); 3917 Bind(&length_loaded);
3867 GotoUnless(UintPtrLessThan(intptr_index, var_length.value()), miss); 3918 GotoUnless(UintPtrLessThan(intptr_index, var_length.value()), miss);
3868 } 3919 }
3869 3920
3870 void CodeStubAssembler::EmitElementLoad(Node* object, Node* elements, 3921 void CodeStubAssembler::EmitElementLoad(Node* object, Node* elements,
3871 Node* elements_kind, Node* intptr_index, 3922 Node* elements_kind, Node* intptr_index,
3872 Node* is_jsarray_condition, 3923 Node* is_jsarray_condition,
3873 Label* if_hole, Label* rebox_double, 3924 Label* if_hole, Label* rebox_double,
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
4195 &var_handler, &try_polymorphic); 4246 &var_handler, &try_polymorphic);
4196 Bind(&if_handler); 4247 Bind(&if_handler);
4197 { 4248 {
4198 HandleLoadICHandlerCase(p, var_handler.value(), &miss); 4249 HandleLoadICHandlerCase(p, var_handler.value(), &miss);
4199 } 4250 }
4200 4251
4201 Bind(&try_polymorphic); 4252 Bind(&try_polymorphic);
4202 { 4253 {
4203 // Check polymorphic case. 4254 // Check polymorphic case.
4204 Comment("LoadIC_try_polymorphic"); 4255 Comment("LoadIC_try_polymorphic");
4205 GotoUnless( 4256 GotoUnless(WordEqual(LoadMap(feedback), FixedArrayMapConstant()),
4206 WordEqual(LoadMap(feedback), LoadRoot(Heap::kFixedArrayMapRootIndex)), 4257 &try_megamorphic);
4207 &try_megamorphic);
4208 HandlePolymorphicCase(p, receiver_map, feedback, &if_handler, &var_handler, 4258 HandlePolymorphicCase(p, receiver_map, feedback, &if_handler, &var_handler,
4209 &miss, 2); 4259 &miss, 2);
4210 } 4260 }
4211 4261
4212 Bind(&try_megamorphic); 4262 Bind(&try_megamorphic);
4213 { 4263 {
4214 // Check megamorphic case. 4264 // Check megamorphic case.
4215 GotoUnless( 4265 GotoUnless(
4216 WordEqual(feedback, LoadRoot(Heap::kmegamorphic_symbolRootIndex)), 4266 WordEqual(feedback, LoadRoot(Heap::kmegamorphic_symbolRootIndex)),
4217 &miss); 4267 &miss);
(...skipping 23 matching lines...) Expand all
4241 &var_handler, &try_polymorphic); 4291 &var_handler, &try_polymorphic);
4242 Bind(&if_handler); 4292 Bind(&if_handler);
4243 { 4293 {
4244 HandleLoadICHandlerCase(p, var_handler.value(), &miss, kSupportElements); 4294 HandleLoadICHandlerCase(p, var_handler.value(), &miss, kSupportElements);
4245 } 4295 }
4246 4296
4247 Bind(&try_polymorphic); 4297 Bind(&try_polymorphic);
4248 { 4298 {
4249 // Check polymorphic case. 4299 // Check polymorphic case.
4250 Comment("KeyedLoadIC_try_polymorphic"); 4300 Comment("KeyedLoadIC_try_polymorphic");
4251 GotoUnless( 4301 GotoUnless(WordEqual(LoadMap(feedback), FixedArrayMapConstant()),
4252 WordEqual(LoadMap(feedback), LoadRoot(Heap::kFixedArrayMapRootIndex)), 4302 &try_megamorphic);
4253 &try_megamorphic);
4254 HandlePolymorphicCase(p, receiver_map, feedback, &if_handler, &var_handler, 4303 HandlePolymorphicCase(p, receiver_map, feedback, &if_handler, &var_handler,
4255 &miss, 2); 4304 &miss, 2);
4256 } 4305 }
4257 4306
4258 Bind(&try_megamorphic); 4307 Bind(&try_megamorphic);
4259 { 4308 {
4260 // Check megamorphic case. 4309 // Check megamorphic case.
4261 Comment("KeyedLoadIC_try_megamorphic"); 4310 Comment("KeyedLoadIC_try_megamorphic");
4262 GotoUnless( 4311 GotoUnless(
4263 WordEqual(feedback, LoadRoot(Heap::kmegamorphic_symbolRootIndex)), 4312 WordEqual(feedback, LoadRoot(Heap::kmegamorphic_symbolRootIndex)),
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
4594 StoreFixedArrayElement(the_context, mapped_index, value, 4643 StoreFixedArrayElement(the_context, mapped_index, value,
4595 UPDATE_WRITE_BARRIER, INTPTR_PARAMETERS); 4644 UPDATE_WRITE_BARRIER, INTPTR_PARAMETERS);
4596 } 4645 }
4597 Goto(&end); 4646 Goto(&end);
4598 } 4647 }
4599 4648
4600 Bind(&if_unmapped); 4649 Bind(&if_unmapped);
4601 { 4650 {
4602 Node* backing_store = LoadFixedArrayElement(elements, IntPtrConstant(1), 0, 4651 Node* backing_store = LoadFixedArrayElement(elements, IntPtrConstant(1), 0,
4603 INTPTR_PARAMETERS); 4652 INTPTR_PARAMETERS);
4604 GotoIf(WordNotEqual(LoadMap(backing_store), 4653 GotoIf(WordNotEqual(LoadMap(backing_store), FixedArrayMapConstant()),
4605 LoadRoot(Heap::kFixedArrayMapRootIndex)),
4606 bailout); 4654 bailout);
4607 4655
4608 Node* backing_store_length = 4656 Node* backing_store_length =
4609 LoadAndUntagFixedArrayBaseLength(backing_store); 4657 LoadAndUntagFixedArrayBaseLength(backing_store);
4610 GotoIf(UintPtrGreaterThanOrEqual(key, backing_store_length), bailout); 4658 GotoIf(UintPtrGreaterThanOrEqual(key, backing_store_length), bailout);
4611 4659
4612 // The key falls into unmapped range. 4660 // The key falls into unmapped range.
4613 if (is_load) { 4661 if (is_load) {
4614 Node* result = 4662 Node* result =
4615 LoadFixedArrayElement(backing_store, key, 0, INTPTR_PARAMETERS); 4663 LoadFixedArrayElement(backing_store, key, 0, INTPTR_PARAMETERS);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
4717 Heap::kTheHoleValueRootIndex); 4765 Heap::kTheHoleValueRootIndex);
4718 4766
4719 // Store the WeakCell in the feedback vector. 4767 // Store the WeakCell in the feedback vector.
4720 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 4768 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER,
4721 CodeStubAssembler::SMI_PARAMETERS); 4769 CodeStubAssembler::SMI_PARAMETERS);
4722 return cell; 4770 return cell;
4723 } 4771 }
4724 4772
4725 } // namespace internal 4773 } // namespace internal
4726 } // namespace v8 4774 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/code-stubs.h » ('j') | src/code-stubs.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698