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

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

Issue 18881004: Turn ElementsTransitionAndStore stub into a HydrogenCodeStub. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/code-stubs.cc ('k') | src/elements-kind.h » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 } 902 }
903 return value; 903 return value;
904 } 904 }
905 905
906 906
907 Handle<Code> StoreGlobalStub::GenerateCode() { 907 Handle<Code> StoreGlobalStub::GenerateCode() {
908 return DoGenerateCode(this); 908 return DoGenerateCode(this);
909 } 909 }
910 910
911 911
912 template<>
913 HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() {
914 ElementsTransitionAndStoreStub* stub = casted_stub();
915 ElementsKind from_kind = stub->from();
916 ElementsKind to_kind = stub->to();
917
918 HValue* value = GetParameter(0);
919 HValue* target_map = GetParameter(1);
920 HValue* key = GetParameter(2);
921 HValue* object = GetParameter(3);
922
923 if (FLAG_trace_elements_transitions) {
924 // Tracing elements transitions is the job of the runtime.
925 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll);
926 set_current_block(NULL);
927 return value;
928 }
929
930 info()->MarkAsSavesCallerDoubles();
931
932 if (AllocationSite::GetMode(from_kind, to_kind) == TRACK_ALLOCATION_SITE) {
933 Add<HTrapAllocationMemento>(object);
934 }
935
936 // Check if we need to transition the array elements first
937 // (either SMI -> Double or Double -> Object).
938 if (DoesTransitionChangeElementsBufferFormat(from_kind, to_kind)) {
939 HInstruction* array_length = NULL;
940 if (stub->is_jsarray()) {
941 array_length = AddLoad(object, HObjectAccess::ForArrayLength());
942 } else {
943 array_length = AddLoadFixedArrayLength(AddLoadElements(object));
944 }
945 array_length->set_type(HType::Smi());
946
947 IfBuilder if_builder(this);
948
949 // Check if we have any elements.
950 if_builder.IfNot<HCompareNumericAndBranch>(array_length,
951 graph()->GetConstant0(),
952 Token::EQ);
953 if_builder.Then();
954
955 HInstruction* elements = AddLoadElements(object);
956
957 HInstruction* elements_length = AddLoadFixedArrayLength(elements);
958
959 BuildGrowElementsCapacity(object, elements, from_kind, to_kind,
960 array_length, elements_length);
961
962 if_builder.End();
963 }
964
965 // Set transitioned map.
966 AddStore(object, HObjectAccess::ForMap(), target_map);
967
968 // Generate the actual store.
969 BuildUncheckedMonomorphicElementAccess(object, key, value, NULL,
970 stub->is_jsarray(), to_kind,
971 true, ALLOW_RETURN_HOLE,
972 stub->store_mode());
973
974 return value;
975 }
976
977
978 Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() {
979 return DoGenerateCode(this);
980 }
981
982
912 } } // namespace v8::internal 983 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/elements-kind.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698