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

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 2313093002: [stubs] Port StoreTransitionStub and ElementsTransitionAndStoreStub to TurboFan. (Closed)
Patch Set: Addressing comments 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
« no previous file with comments | « src/code-stubs.cc ('k') | src/crankshaft/hydrogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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-stubs.h" 5 #include "src/code-stubs.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/crankshaft/hydrogen.h" 10 #include "src/crankshaft/hydrogen.h"
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 } 906 }
907 } else if (representation.IsHeapObject()) { 907 } else if (representation.IsHeapObject()) {
908 BuildCheckHeapObject(value); 908 BuildCheckHeapObject(value);
909 } 909 }
910 910
911 Add<HStoreNamedField>(object, access, value, INITIALIZING_STORE); 911 Add<HStoreNamedField>(object, access, value, INITIALIZING_STORE);
912 } 912 }
913 913
914 914
915 template <> 915 template <>
916 HValue* CodeStubGraphBuilder<StoreTransitionStub>::BuildCodeStub() {
917 HValue* object = GetParameter(StoreTransitionHelper::ReceiverIndex());
918 HValue* value = GetParameter(StoreTransitionHelper::ValueIndex());
919 StoreTransitionStub::StoreMode store_mode = casted_stub()->store_mode();
920
921 if (store_mode != StoreTransitionStub::StoreMapOnly) {
922 value = GetParameter(StoreTransitionHelper::ValueIndex());
923 Representation representation = casted_stub()->representation();
924 if (representation.IsDouble()) {
925 // In case we are storing a double, assure that the value is a double
926 // before manipulating the properties backing store. Otherwise the actual
927 // store may deopt, leaving the backing store in an overallocated state.
928 value = AddUncasted<HForceRepresentation>(value, representation);
929 }
930 }
931
932 switch (store_mode) {
933 case StoreTransitionStub::ExtendStorageAndStoreMapAndValue: {
934 HValue* properties = Add<HLoadNamedField>(
935 object, nullptr, HObjectAccess::ForPropertiesPointer());
936 HValue* length = AddLoadFixedArrayLength(properties);
937 HValue* delta =
938 Add<HConstant>(static_cast<int32_t>(JSObject::kFieldsAdded));
939 HValue* new_capacity = AddUncasted<HAdd>(length, delta);
940
941 // Grow properties array.
942 ElementsKind kind = FAST_ELEMENTS;
943 Add<HBoundsCheck>(new_capacity,
944 Add<HConstant>((kMaxRegularHeapObjectSize -
945 FixedArray::kHeaderSize) >>
946 ElementsKindToShiftSize(kind)));
947
948 // Reuse this code for properties backing store allocation.
949 HValue* new_properties =
950 BuildAllocateAndInitializeArray(kind, new_capacity);
951
952 BuildCopyProperties(properties, new_properties, length, new_capacity);
953
954 Add<HStoreNamedField>(object, HObjectAccess::ForPropertiesPointer(),
955 new_properties);
956 }
957 // Fall through.
958 case StoreTransitionStub::StoreMapAndValue:
959 // Store the new value into the "extended" object.
960 BuildStoreNamedField(object, value, casted_stub()->index(),
961 casted_stub()->representation(), true);
962 // Fall through.
963
964 case StoreTransitionStub::StoreMapOnly:
965 // And finally update the map.
966 Add<HStoreNamedField>(object, HObjectAccess::ForMap(),
967 GetParameter(StoreTransitionHelper::MapIndex()));
968 break;
969 }
970 return value;
971 }
972
973
974 Handle<Code> StoreTransitionStub::GenerateCode() {
975 return DoGenerateCode(this);
976 }
977
978
979 template <>
980 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() { 916 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
981 ElementsKind const from_kind = casted_stub()->from_kind(); 917 ElementsKind const from_kind = casted_stub()->from_kind();
982 ElementsKind const to_kind = casted_stub()->to_kind(); 918 ElementsKind const to_kind = casted_stub()->to_kind();
983 HValue* const object = GetParameter(Descriptor::kObject); 919 HValue* const object = GetParameter(Descriptor::kObject);
984 HValue* const map = GetParameter(Descriptor::kMap); 920 HValue* const map = GetParameter(Descriptor::kMap);
985 921
986 // The {object} is known to be a JSObject (otherwise it wouldn't have elements 922 // The {object} is known to be a JSObject (otherwise it wouldn't have elements
987 // anyways). 923 // anyways).
988 object->set_type(HType::JSObject()); 924 object->set_type(HType::JSObject());
989 925
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 if_true.Then(); 1245 if_true.Then();
1310 if_true.Return(graph()->GetConstantTrue()); 1246 if_true.Return(graph()->GetConstantTrue());
1311 if_true.Else(); 1247 if_true.Else();
1312 if_true.End(); 1248 if_true.End();
1313 return graph()->GetConstantFalse(); 1249 return graph()->GetConstantFalse();
1314 } 1250 }
1315 1251
1316 Handle<Code> ToBooleanICStub::GenerateCode() { return DoGenerateCode(this); } 1252 Handle<Code> ToBooleanICStub::GenerateCode() { return DoGenerateCode(this); }
1317 1253
1318 template <> 1254 template <>
1319 HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() {
1320 HValue* object = GetParameter(StoreTransitionHelper::ReceiverIndex());
1321 HValue* key = GetParameter(StoreTransitionHelper::NameIndex());
1322 HValue* value = GetParameter(StoreTransitionHelper::ValueIndex());
1323 HValue* map = GetParameter(StoreTransitionHelper::MapIndex());
1324
1325 if (FLAG_trace_elements_transitions) {
1326 // Tracing elements transitions is the job of the runtime.
1327 Add<HDeoptimize>(DeoptimizeReason::kTracingElementsTransitions,
1328 Deoptimizer::EAGER);
1329 } else {
1330 info()->MarkAsSavesCallerDoubles();
1331
1332 BuildTransitionElementsKind(object, map,
1333 casted_stub()->from_kind(),
1334 casted_stub()->to_kind(),
1335 casted_stub()->is_jsarray());
1336
1337 BuildUncheckedMonomorphicElementAccess(object, key, value,
1338 casted_stub()->is_jsarray(),
1339 casted_stub()->to_kind(),
1340 STORE, ALLOW_RETURN_HOLE,
1341 casted_stub()->store_mode());
1342 }
1343
1344 return value;
1345 }
1346
1347
1348 Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() {
1349 return DoGenerateCode(this);
1350 }
1351
1352
1353 template <>
1354 HValue* CodeStubGraphBuilder<LoadDictionaryElementStub>::BuildCodeStub() { 1255 HValue* CodeStubGraphBuilder<LoadDictionaryElementStub>::BuildCodeStub() {
1355 HValue* receiver = GetParameter(Descriptor::kReceiver); 1256 HValue* receiver = GetParameter(Descriptor::kReceiver);
1356 HValue* key = GetParameter(Descriptor::kName); 1257 HValue* key = GetParameter(Descriptor::kName);
1357 1258
1358 Add<HCheckSmi>(key); 1259 Add<HCheckSmi>(key);
1359 1260
1360 HValue* elements = AddLoadElements(receiver); 1261 HValue* elements = AddLoadElements(receiver);
1361 1262
1362 HValue* hash = BuildElementIndexHash(key); 1263 HValue* hash = BuildElementIndexHash(key);
1363 1264
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 return Pop(); 1536 return Pop();
1636 } 1537 }
1637 1538
1638 1539
1639 Handle<Code> KeyedLoadGenericStub::GenerateCode() { 1540 Handle<Code> KeyedLoadGenericStub::GenerateCode() {
1640 return DoGenerateCode(this); 1541 return DoGenerateCode(this);
1641 } 1542 }
1642 1543
1643 } // namespace internal 1544 } // namespace internal
1644 } // namespace v8 1545 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/crankshaft/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698