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