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

Side by Side Diff: src/ia32/builtins-ia32.cc

Issue 2031123003: Avoid creating weak cells for literal arrays that are empty of literals. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Created 4 years, 6 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/arm64/builtins-arm64.cc ('k') | src/mips/builtins-mips.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 #if V8_TARGET_ARCH_IA32 5 #if V8_TARGET_ARCH_IA32
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 SharedFunctionInfo::kOffsetToPreviousContext)); 889 SharedFunctionInfo::kOffsetToPreviousContext));
890 __ mov(temp, FieldOperand(temp, WeakCell::kValueOffset)); 890 __ mov(temp, FieldOperand(temp, WeakCell::kValueOffset));
891 __ cmp(temp, native_context); 891 __ cmp(temp, native_context);
892 __ j(not_equal, &loop_bottom); 892 __ j(not_equal, &loop_bottom);
893 // OSR id set to none? 893 // OSR id set to none?
894 __ mov(temp, FieldOperand(map, index, times_half_pointer_size, 894 __ mov(temp, FieldOperand(map, index, times_half_pointer_size,
895 SharedFunctionInfo::kOffsetToPreviousOsrAstId)); 895 SharedFunctionInfo::kOffsetToPreviousOsrAstId));
896 const int bailout_id = BailoutId::None().ToInt(); 896 const int bailout_id = BailoutId::None().ToInt();
897 __ cmp(temp, Immediate(Smi::FromInt(bailout_id))); 897 __ cmp(temp, Immediate(Smi::FromInt(bailout_id)));
898 __ j(not_equal, &loop_bottom); 898 __ j(not_equal, &loop_bottom);
899
899 // Literals available? 900 // Literals available?
901 Label got_literals, maybe_cleared_weakcell;
900 __ mov(temp, FieldOperand(map, index, times_half_pointer_size, 902 __ mov(temp, FieldOperand(map, index, times_half_pointer_size,
901 SharedFunctionInfo::kOffsetToPreviousLiterals)); 903 SharedFunctionInfo::kOffsetToPreviousLiterals));
904
905 // temp contains either a WeakCell pointing to the literals array or the
906 // literals array directly.
907 STATIC_ASSERT(WeakCell::kValueOffset == FixedArray::kLengthOffset);
908 __ JumpIfSmi(FieldOperand(temp, WeakCell::kValueOffset),
909 &maybe_cleared_weakcell);
910 // The WeakCell value is a pointer, therefore it's a valid literals array.
902 __ mov(temp, FieldOperand(temp, WeakCell::kValueOffset)); 911 __ mov(temp, FieldOperand(temp, WeakCell::kValueOffset));
903 __ JumpIfSmi(temp, &gotta_call_runtime); 912 __ jmp(&got_literals);
913
914 // We have a smi. If it's 0, then we are looking at a cleared WeakCell
915 // around the literals array, and we should visit the runtime. If it's > 0,
916 // then temp already contains the literals array.
917 __ bind(&maybe_cleared_weakcell);
918 __ cmp(FieldOperand(temp, WeakCell::kValueOffset), Immediate(0));
919 __ j(equal, &gotta_call_runtime);
904 920
905 // Save the literals in the closure. 921 // Save the literals in the closure.
922 __ bind(&got_literals);
906 __ mov(ecx, Operand(esp, 0)); 923 __ mov(ecx, Operand(esp, 0));
907 __ mov(FieldOperand(ecx, JSFunction::kLiteralsOffset), temp); 924 __ mov(FieldOperand(ecx, JSFunction::kLiteralsOffset), temp);
908 __ push(index); 925 __ push(index);
909 __ RecordWriteField(ecx, JSFunction::kLiteralsOffset, temp, index, 926 __ RecordWriteField(ecx, JSFunction::kLiteralsOffset, temp, index,
910 kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); 927 kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
911 __ pop(index); 928 __ pop(index);
912 929
913 // Code available? 930 // Code available?
914 Register entry = ecx; 931 Register entry = ecx;
915 __ mov(entry, FieldOperand(map, index, times_half_pointer_size, 932 __ mov(entry, FieldOperand(map, index, times_half_pointer_size,
(...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after
2882 // And "return" to the OSR entry point of the function. 2899 // And "return" to the OSR entry point of the function.
2883 __ ret(0); 2900 __ ret(0);
2884 } 2901 }
2885 2902
2886 2903
2887 #undef __ 2904 #undef __
2888 } // namespace internal 2905 } // namespace internal
2889 } // namespace v8 2906 } // namespace v8
2890 2907
2891 #endif // V8_TARGET_ARCH_IA32 2908 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm64/builtins-arm64.cc ('k') | src/mips/builtins-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698