OLD | NEW |
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 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 } | 901 } |
902 return value; | 902 return value; |
903 } | 903 } |
904 | 904 |
905 | 905 |
906 Handle<Code> StoreGlobalStub::GenerateCode() { | 906 Handle<Code> StoreGlobalStub::GenerateCode() { |
907 return DoGenerateCode(this); | 907 return DoGenerateCode(this); |
908 } | 908 } |
909 | 909 |
910 | 910 |
911 template<> | |
912 HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() { | |
913 ElementsTransitionAndStoreStub* stub = casted_stub(); | |
914 ElementsKind from_kind = stub->from(); | |
915 ElementsKind to_kind = stub->to(); | |
916 | |
917 HValue* value = GetParameter(0); | |
918 HValue* target_map = GetParameter(1); | |
919 HValue* key = GetParameter(2); | |
920 HValue* object = GetParameter(3); | |
921 | |
922 if (FLAG_trace_elements_transitions) { | |
923 // Tracing elements transitions is the job of the runtime. | |
924 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll); | |
925 set_current_block(NULL); | |
926 return value; | |
927 } | |
928 | |
929 info()->MarkAsSavesCallerDoubles(); | |
930 | |
931 if (AllocationSite::GetMode(from_kind, to_kind) == TRACK_ALLOCATION_SITE) { | |
932 Add<HTrapAllocationMemento>(object); | |
933 } | |
934 | |
935 // Check if we need to transition the array elements first | |
936 // (either SMI -> Double or Double -> Object). | |
937 if (DoesTransitionChangeElementsBufferFormat(from_kind, to_kind)) { | |
938 HInstruction* array_length = NULL; | |
939 if (stub->is_jsarray()) { | |
940 array_length = AddLoad(object, HObjectAccess::ForArrayLength()); | |
941 } else { | |
942 array_length = AddLoadFixedArrayLength(AddLoadElements(object)); | |
943 } | |
944 array_length->set_type(HType::Smi()); | |
945 | |
946 IfBuilder if_builder(this); | |
947 | |
948 // Check if we have any elements. | |
949 if_builder.IfNot<HCompareNumericAndBranch>(array_length, | |
950 graph()->GetConstant0(), | |
951 Token::EQ); | |
952 if_builder.Then(); | |
953 | |
954 HInstruction* elements = AddLoadElements(object); | |
955 | |
956 HInstruction* elements_length = AddLoadFixedArrayLength(elements); | |
957 | |
958 BuildGrowElementsCapacity(object, elements, from_kind, to_kind, | |
959 array_length, elements_length); | |
960 | |
961 if_builder.End(); | |
962 } | |
963 | |
964 // Set transitioned map. | |
965 AddStore(object, HObjectAccess::ForMap(), target_map); | |
966 | |
967 // Generate the actual store. | |
968 BuildUncheckedMonomorphicElementAccess(object, key, value, NULL, | |
969 stub->is_jsarray(), to_kind, | |
970 true, ALLOW_RETURN_HOLE, | |
971 stub->store_mode()); | |
972 | |
973 return value; | |
974 } | |
975 | |
976 | |
977 Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() { | |
978 return DoGenerateCode(this); | |
979 } | |
980 | |
981 | |
982 } } // namespace v8::internal | 911 } } // namespace v8::internal |
OLD | NEW |