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

Side by Side Diff: src/ic/accessor-assembler.cc

Issue 2711353002: [LoadIC] Use LoadIC_Uninitialized for 0->PRE transitions (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « src/ic/accessor-assembler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ic/accessor-assembler.h" 5 #include "src/ic/accessor-assembler.h"
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/counters.h" 9 #include "src/counters.h"
10 #include "src/ic/handler-configuration.h" 10 #include "src/ic/handler-configuration.h"
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 BranchIfPrototypesHaveNoElements(receiver_map, &return_undefined, slow); 1187 BranchIfPrototypesHaveNoElements(receiver_map, &return_undefined, slow);
1188 1188
1189 Bind(&return_undefined); 1189 Bind(&return_undefined);
1190 Return(UndefinedConstant()); 1190 Return(UndefinedConstant());
1191 } 1191 }
1192 } 1192 }
1193 1193
1194 void AccessorAssembler::GenericPropertyLoad(Node* receiver, Node* receiver_map, 1194 void AccessorAssembler::GenericPropertyLoad(Node* receiver, Node* receiver_map,
1195 Node* instance_type, Node* key, 1195 Node* instance_type, Node* key,
1196 const LoadICParameters* p, 1196 const LoadICParameters* p,
1197 Label* slow) { 1197 Label* slow,
1198 UseStubCache use_stub_cache) {
1198 Comment("key is unique name"); 1199 Comment("key is unique name");
1199 Label if_found_on_receiver(this), if_property_dictionary(this), 1200 Label if_found_on_receiver(this), if_property_dictionary(this),
1200 lookup_prototype_chain(this); 1201 lookup_prototype_chain(this);
1201 Variable var_details(this, MachineRepresentation::kWord32); 1202 Variable var_details(this, MachineRepresentation::kWord32);
1202 Variable var_value(this, MachineRepresentation::kTagged); 1203 Variable var_value(this, MachineRepresentation::kTagged);
1203 1204
1204 // Receivers requiring non-standard accesses (interceptors, access 1205 // Receivers requiring non-standard accesses (interceptors, access
1205 // checks, strings and string wrappers, proxies) are handled in the runtime. 1206 // checks, strings and string wrappers, proxies) are handled in the runtime.
1206 GotoIf(Int32LessThanOrEqual(instance_type, 1207 GotoIf(Int32LessThanOrEqual(instance_type,
1207 Int32Constant(LAST_SPECIAL_RECEIVER_TYPE)), 1208 Int32Constant(LAST_SPECIAL_RECEIVER_TYPE)),
1208 slow); 1209 slow);
1209 1210
1210 // Check if the receiver has fast or slow properties. 1211 // Check if the receiver has fast or slow properties.
1211 Node* properties = LoadProperties(receiver); 1212 Node* properties = LoadProperties(receiver);
1212 Node* properties_map = LoadMap(properties); 1213 Node* properties_map = LoadMap(properties);
1213 GotoIf(WordEqual(properties_map, LoadRoot(Heap::kHashTableMapRootIndex)), 1214 GotoIf(WordEqual(properties_map, LoadRoot(Heap::kHashTableMapRootIndex)),
1214 &if_property_dictionary); 1215 &if_property_dictionary);
1215 1216
1216 // Try looking up the property on the receiver; if unsuccessful, look 1217 // Try looking up the property on the receiver; if unsuccessful, look
1217 // for a handler in the stub cache. 1218 // for a handler in the stub cache.
1218 Node* bitfield3 = LoadMapBitField3(receiver_map); 1219 Node* bitfield3 = LoadMapBitField3(receiver_map);
1219 Node* descriptors = LoadMapDescriptors(receiver_map); 1220 Node* descriptors = LoadMapDescriptors(receiver_map);
1220 1221
1221 Label if_descriptor_found(this), stub_cache(this); 1222 Label if_descriptor_found(this), stub_cache(this);
1222 Variable var_name_index(this, MachineType::PointerRepresentation()); 1223 Variable var_name_index(this, MachineType::PointerRepresentation());
1224 Label* notfound =
1225 use_stub_cache == kUseStubCache ? &stub_cache : &lookup_prototype_chain;
1223 DescriptorLookup(key, descriptors, bitfield3, &if_descriptor_found, 1226 DescriptorLookup(key, descriptors, bitfield3, &if_descriptor_found,
1224 &var_name_index, &stub_cache); 1227 &var_name_index, notfound);
1225 1228
1226 Bind(&if_descriptor_found); 1229 Bind(&if_descriptor_found);
1227 { 1230 {
1228 LoadPropertyFromFastObject(receiver, receiver_map, descriptors, 1231 LoadPropertyFromFastObject(receiver, receiver_map, descriptors,
1229 var_name_index.value(), &var_details, 1232 var_name_index.value(), &var_details,
1230 &var_value); 1233 &var_value);
1231 Goto(&if_found_on_receiver); 1234 Goto(&if_found_on_receiver);
1232 } 1235 }
1233 1236
1234 Bind(&stub_cache); 1237 if (use_stub_cache == kUseStubCache) {
1235 { 1238 Bind(&stub_cache);
1236 Comment("stub cache probe for fast property load"); 1239 Comment("stub cache probe for fast property load");
1237 Variable var_handler(this, MachineRepresentation::kTagged); 1240 Variable var_handler(this, MachineRepresentation::kTagged);
1238 Label found_handler(this, &var_handler), stub_cache_miss(this); 1241 Label found_handler(this, &var_handler), stub_cache_miss(this);
1239 TryProbeStubCache(isolate()->load_stub_cache(), receiver, key, 1242 TryProbeStubCache(isolate()->load_stub_cache(), receiver, key,
1240 &found_handler, &var_handler, &stub_cache_miss); 1243 &found_handler, &var_handler, &stub_cache_miss);
1241 Bind(&found_handler); 1244 Bind(&found_handler);
1242 { HandleLoadICHandlerCase(p, var_handler.value(), slow); } 1245 { HandleLoadICHandlerCase(p, var_handler.value(), slow); }
1243 1246
1244 Bind(&stub_cache_miss); 1247 Bind(&stub_cache_miss);
1245 { 1248 {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 } 1448 }
1446 } 1449 }
1447 1450
1448 //////////////////// Entry points into private implementation (one per stub). 1451 //////////////////// Entry points into private implementation (one per stub).
1449 1452
1450 void AccessorAssembler::LoadIC(const LoadICParameters* p) { 1453 void AccessorAssembler::LoadIC(const LoadICParameters* p) {
1451 Variable var_handler(this, MachineRepresentation::kTagged); 1454 Variable var_handler(this, MachineRepresentation::kTagged);
1452 // TODO(ishell): defer blocks when it works. 1455 // TODO(ishell): defer blocks when it works.
1453 Label if_handler(this, &var_handler), try_polymorphic(this), 1456 Label if_handler(this, &var_handler), try_polymorphic(this),
1454 try_megamorphic(this /*, Label::kDeferred*/), 1457 try_megamorphic(this /*, Label::kDeferred*/),
1458 try_uninitialized(this /*, Label::kDeferred*/),
1455 miss(this /*, Label::kDeferred*/); 1459 miss(this /*, Label::kDeferred*/);
1456 1460
1457 Node* receiver_map = LoadReceiverMap(p->receiver); 1461 Node* receiver_map = LoadReceiverMap(p->receiver);
1458 GotoIf(IsSetWord32<Map::Deprecated>(LoadMapBitField3(receiver_map)), &miss); 1462 GotoIf(IsSetWord32<Map::Deprecated>(LoadMapBitField3(receiver_map)), &miss);
1459 1463
1460 // Check monomorphic case. 1464 // Check monomorphic case.
1461 Node* feedback = 1465 Node* feedback =
1462 TryMonomorphicCase(p->slot, p->vector, receiver_map, &if_handler, 1466 TryMonomorphicCase(p->slot, p->vector, receiver_map, &if_handler,
1463 &var_handler, &try_polymorphic); 1467 &var_handler, &try_polymorphic);
1464 Bind(&if_handler); 1468 Bind(&if_handler);
1465 { HandleLoadICHandlerCase(p, var_handler.value(), &miss); } 1469 { HandleLoadICHandlerCase(p, var_handler.value(), &miss); }
1466 1470
1467 Bind(&try_polymorphic); 1471 Bind(&try_polymorphic);
1468 { 1472 {
1469 // Check polymorphic case. 1473 // Check polymorphic case.
1470 Comment("LoadIC_try_polymorphic"); 1474 Comment("LoadIC_try_polymorphic");
1471 GotoIfNot(WordEqual(LoadMap(feedback), FixedArrayMapConstant()), 1475 GotoIfNot(WordEqual(LoadMap(feedback), FixedArrayMapConstant()),
1472 &try_megamorphic); 1476 &try_megamorphic);
1473 HandlePolymorphicCase(receiver_map, feedback, &if_handler, &var_handler, 1477 HandlePolymorphicCase(receiver_map, feedback, &if_handler, &var_handler,
1474 &miss, 2); 1478 &miss, 2);
1475 } 1479 }
1476 1480
1477 Bind(&try_megamorphic); 1481 Bind(&try_megamorphic);
1478 { 1482 {
1479 // Check megamorphic case. 1483 // Check megamorphic case.
1480 GotoIfNot(WordEqual(feedback, LoadRoot(Heap::kmegamorphic_symbolRootIndex)), 1484 GotoIfNot(WordEqual(feedback, LoadRoot(Heap::kmegamorphic_symbolRootIndex)),
1481 &miss); 1485 &try_uninitialized);
1482 1486
1483 TryProbeStubCache(isolate()->load_stub_cache(), p->receiver, p->name, 1487 TryProbeStubCache(isolate()->load_stub_cache(), p->receiver, p->name,
1484 &if_handler, &var_handler, &miss); 1488 &if_handler, &var_handler, &miss);
1485 } 1489 }
1490 Bind(&try_uninitialized);
1491 {
1492 // Check uninitialized case.
1493 GotoIfNot(
1494 WordEqual(feedback, LoadRoot(Heap::kuninitialized_symbolRootIndex)),
1495 &miss);
1496 TailCallStub(CodeFactory::LoadIC_Uninitialized(isolate()), p->context,
1497 p->receiver, p->name, p->slot, p->vector);
1498 }
1486 Bind(&miss); 1499 Bind(&miss);
1487 { 1500 {
1488 TailCallRuntime(Runtime::kLoadIC_Miss, p->context, p->receiver, p->name, 1501 TailCallRuntime(Runtime::kLoadIC_Miss, p->context, p->receiver, p->name,
1489 p->slot, p->vector); 1502 p->slot, p->vector);
1490 } 1503 }
1504 }
1505
1506 void AccessorAssembler::LoadIC_Uninitialized(const LoadICParameters* p) {
1507 Label miss(this);
1508 Node* receiver = p->receiver;
1509 GotoIf(TaggedIsSmi(receiver), &miss);
1510 Node* receiver_map = LoadMap(receiver);
1511 Node* instance_type = LoadMapInstanceType(receiver_map);
1512
1513 // Optimistically write the state transition to the vector.
1514 StoreFixedArrayElement(p->vector, p->slot,
1515 LoadRoot(Heap::kpremonomorphic_symbolRootIndex),
1516 SKIP_WRITE_BARRIER, 0, SMI_PARAMETERS);
1517
1518 Label not_function_prototype(this);
1519 GotoIf(Word32NotEqual(instance_type, Int32Constant(JS_FUNCTION_TYPE)),
1520 &not_function_prototype);
1521 GotoIfNot(WordEqual(p->name, LoadRoot(Heap::kprototype_stringRootIndex)),
1522 &not_function_prototype);
1523 Node* bit_field = LoadMapBitField(receiver_map);
1524 GotoIf(IsSetWord32(bit_field, 1 << Map::kHasNonInstancePrototype),
1525 &not_function_prototype);
1526 // Function.prototype load.
1527 {
1528 // TODO(jkummerow): Unify with LoadIC_FunctionPrototype builtin
1529 // (when we have a shared CSA base class for all builtins).
1530 Node* proto_or_map =
1531 LoadObjectField(receiver, JSFunction::kPrototypeOrInitialMapOffset);
1532 GotoIf(IsTheHole(proto_or_map), &miss);
1533
1534 Variable var_result(this, MachineRepresentation::kTagged, proto_or_map);
1535 Label done(this, &var_result);
1536 GotoIfNot(IsMap(proto_or_map), &done);
1537
1538 var_result.Bind(LoadMapPrototype(proto_or_map));
1539 Goto(&done);
1540
1541 Bind(&done);
1542 Return(var_result.value());
1543 }
1544 Bind(&not_function_prototype);
1545
1546 GenericPropertyLoad(receiver, receiver_map, instance_type, p->name, p, &miss,
1547 kDontUseStubCache);
1548
1549 Bind(&miss);
1550 {
1551 // Undo the optimistic state transition.
1552 StoreFixedArrayElement(p->vector, p->slot,
1553 LoadRoot(Heap::kuninitialized_symbolRootIndex),
1554 SKIP_WRITE_BARRIER, 0, SMI_PARAMETERS);
1555
1556 TailCallRuntime(Runtime::kLoadIC_Miss, p->context, p->receiver, p->name,
1557 p->slot, p->vector);
1558 }
1491 } 1559 }
1492 1560
1493 void AccessorAssembler::LoadICProtoArray( 1561 void AccessorAssembler::LoadICProtoArray(
1494 const LoadICParameters* p, Node* handler, 1562 const LoadICParameters* p, Node* handler,
1495 bool throw_reference_error_if_nonexistent) { 1563 bool throw_reference_error_if_nonexistent) {
1496 Label miss(this); 1564 Label miss(this);
1497 CSA_ASSERT(this, Word32BinaryNot(TaggedIsSmi(handler))); 1565 CSA_ASSERT(this, Word32BinaryNot(TaggedIsSmi(handler)));
1498 CSA_ASSERT(this, IsFixedArrayMap(LoadMap(handler))); 1566 CSA_ASSERT(this, IsFixedArrayMap(LoadMap(handler)));
1499 1567
1500 ExitPoint direct_exit(this); 1568 ExitPoint direct_exit(this);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 Node* receiver = Parameter(Descriptor::kReceiver); 1917 Node* receiver = Parameter(Descriptor::kReceiver);
1850 Node* name = Parameter(Descriptor::kName); 1918 Node* name = Parameter(Descriptor::kName);
1851 Node* slot = Parameter(Descriptor::kSlot); 1919 Node* slot = Parameter(Descriptor::kSlot);
1852 Node* vector = Parameter(Descriptor::kVector); 1920 Node* vector = Parameter(Descriptor::kVector);
1853 Node* context = Parameter(Descriptor::kContext); 1921 Node* context = Parameter(Descriptor::kContext);
1854 1922
1855 LoadICParameters p(context, receiver, name, slot, vector); 1923 LoadICParameters p(context, receiver, name, slot, vector);
1856 LoadIC(&p); 1924 LoadIC(&p);
1857 } 1925 }
1858 1926
1927 void AccessorAssembler::GenerateLoadIC_Uninitialized() {
1928 typedef LoadWithVectorDescriptor Descriptor;
1929
1930 Node* receiver = Parameter(Descriptor::kReceiver);
1931 Node* name = Parameter(Descriptor::kName);
1932 Node* slot = Parameter(Descriptor::kSlot);
1933 Node* vector = Parameter(Descriptor::kVector);
1934 Node* context = Parameter(Descriptor::kContext);
1935
1936 LoadICParameters p(context, receiver, name, slot, vector);
1937 LoadIC_Uninitialized(&p);
1938 }
1939
1859 void AccessorAssembler::GenerateLoadICTrampoline() { 1940 void AccessorAssembler::GenerateLoadICTrampoline() {
1860 typedef LoadDescriptor Descriptor; 1941 typedef LoadDescriptor Descriptor;
1861 1942
1862 Node* receiver = Parameter(Descriptor::kReceiver); 1943 Node* receiver = Parameter(Descriptor::kReceiver);
1863 Node* name = Parameter(Descriptor::kName); 1944 Node* name = Parameter(Descriptor::kName);
1864 Node* slot = Parameter(Descriptor::kSlot); 1945 Node* slot = Parameter(Descriptor::kSlot);
1865 Node* context = Parameter(Descriptor::kContext); 1946 Node* context = Parameter(Descriptor::kContext);
1866 Node* vector = LoadFeedbackVectorForStub(); 1947 Node* vector = LoadFeedbackVectorForStub();
1867 1948
1868 LoadICParameters p(context, receiver, name, slot, vector); 1949 LoadICParameters p(context, receiver, name, slot, vector);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 Node* slot = Parameter(Descriptor::kSlot); 2096 Node* slot = Parameter(Descriptor::kSlot);
2016 Node* context = Parameter(Descriptor::kContext); 2097 Node* context = Parameter(Descriptor::kContext);
2017 Node* vector = LoadFeedbackVectorForStub(); 2098 Node* vector = LoadFeedbackVectorForStub();
2018 2099
2019 StoreICParameters p(context, receiver, name, value, slot, vector); 2100 StoreICParameters p(context, receiver, name, value, slot, vector);
2020 KeyedStoreIC(&p, language_mode); 2101 KeyedStoreIC(&p, language_mode);
2021 } 2102 }
2022 2103
2023 } // namespace internal 2104 } // namespace internal
2024 } // namespace v8 2105 } // namespace v8
OLDNEW
« no previous file with comments | « src/ic/accessor-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698