Chromium Code Reviews| 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 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 911 } | 911 } |
| 912 return value; | 912 return value; |
| 913 } | 913 } |
| 914 | 914 |
| 915 | 915 |
| 916 Handle<Code> StoreGlobalStub::GenerateCode() { | 916 Handle<Code> StoreGlobalStub::GenerateCode() { |
| 917 return DoGenerateCode(this); | 917 return DoGenerateCode(this); |
| 918 } | 918 } |
| 919 | 919 |
| 920 | 920 |
| 921 template<> | |
| 922 HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() { | |
| 923 ElementsTransitionAndStoreStub* stub = casted_stub(); | |
| 924 ElementsKind from_kind = stub->from(); | |
| 925 ElementsKind to_kind = stub->to(); | |
| 926 | |
| 927 HValue* value = GetParameter(0); | |
| 928 HValue* target_map = GetParameter(1); | |
| 929 HValue* key = GetParameter(2); | |
| 930 HValue* array = GetParameter(3); | |
| 931 | |
| 932 ASSERT(!IsFastHoleyElementsKind(from_kind) || | |
| 933 IsFastHoleyElementsKind(to_kind)); | |
| 934 if (FLAG_trace_elements_transitions) { | |
| 935 // Tracing elements transitions is the job of the runtime. | |
| 936 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll); | |
| 937 set_current_block(NULL); | |
|
danno
2013/07/10 09:52:37
I think it's cleaner if you return value here and
Benedikt Meurer
2013/07/10 12:23:09
Done.
| |
| 938 } else { | |
| 939 if (AllocationSite::GetMode(from_kind, to_kind) == TRACK_ALLOCATION_SITE) { | |
| 940 Add<HTrapAllocationMemento>(array); | |
| 941 } | |
| 942 if (IsFastDoubleElementsKind(from_kind) && | |
| 943 to_kind == FAST_HOLEY_DOUBLE_ELEMENTS) { | |
| 944 // Set transitioned map. | |
| 945 AddStore(array, HObjectAccess::ForMap(), target_map); | |
|
danno
2013/07/10 09:52:37
Why the special casing here? Either the stub shoul
Benedikt Meurer
2013/07/10 12:23:09
Done.
| |
| 946 | |
| 947 // Let the runtime handle the actual store. | |
| 948 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll); | |
| 949 set_current_block(NULL); | |
| 950 } else { | |
| 951 // Check if we need to transition the array elements first | |
| 952 // (either SMI -> Double or Double -> Object). | |
| 953 if ((IsFastSmiElementsKind(from_kind) && | |
| 954 IsFastDoubleElementsKind(to_kind)) || | |
| 955 (IsFastDoubleElementsKind(from_kind) && | |
| 956 IsFastObjectElementsKind(to_kind))) { | |
|
danno
2013/07/10 09:52:37
Can you create a predicate in elements-kind.h to t
Benedikt Meurer
2013/07/10 12:23:09
Done.
| |
| 957 HInstruction* elements = AddLoadElements(array); | |
| 958 HInstruction* elements_length = AddLoadFixedArrayLength(elements); | |
| 959 | |
| 960 IfBuilder if_fixed(this); | |
| 961 | |
| 962 // Check if we have any elements. | |
| 963 if_fixed.If<HCompareNumericAndBranch>(elements_length, | |
|
danno
2013/07/10 09:52:37
You can use IfNot here and then put the meat of th
Benedikt Meurer
2013/07/10 12:23:09
Done.
| |
| 964 graph()->GetConstant0(), | |
| 965 Token::EQ); | |
| 966 | |
| 967 if_fixed.Then(); | |
| 968 | |
| 969 // Nothing to do, just change the map. | |
| 970 | |
| 971 if_fixed.Else(); | |
| 972 | |
| 973 // Check if we can allocate in new space. | |
| 974 BuildNewSpaceArrayCheck(elements_length, to_kind); | |
|
danno
2013/07/10 09:52:37
Why can't you use the helper function "BuildGrowEl
Benedikt Meurer
2013/07/10 12:23:09
Done.
danno
2013/07/10 12:33:44
Done.
| |
| 975 | |
| 976 // Allocate new elements storage. | |
| 977 HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader( | |
| 978 context(), to_kind, elements_length); | |
| 979 | |
| 980 // Convert and copy the elements to new storage. | |
| 981 BuildCopyElements(context(), | |
| 982 elements, from_kind, | |
| 983 new_elements, to_kind, | |
| 984 elements_length, elements_length); | |
| 985 | |
| 986 // Set new elements pointer. | |
| 987 AddStore(array, HObjectAccess::ForElementsPointer(), new_elements); | |
| 988 | |
| 989 if_fixed.End(); | |
| 990 } | |
| 991 | |
| 992 // Set transitioned map. | |
| 993 AddStore(array, HObjectAccess::ForMap(), target_map); | |
| 994 | |
| 995 // Generate the actual store. | |
| 996 BuildUncheckedMonomorphicElementAccess(array, key, value, NULL, | |
|
danno
2013/07/10 09:52:37
You can probably factor this out to only be called
Benedikt Meurer
2013/07/10 12:23:09
Maybe I'm missing the point here, but BuildUncheck
| |
| 997 stub->is_jsarray(), to_kind, | |
| 998 true, ALLOW_RETURN_HOLE, | |
| 999 stub->store_mode()); | |
| 1000 } | |
| 1001 } | |
| 1002 return value; | |
| 1003 } | |
| 1004 | |
| 1005 | |
| 1006 Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() { | |
| 1007 return DoGenerateCode(this); | |
| 1008 } | |
| 1009 | |
| 1010 | |
| 921 } } // namespace v8::internal | 1011 } } // namespace v8::internal |
| OLD | NEW |