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

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

Issue 1413003008: Support fast-path allocation for subclass constructors with correctly initialized initial maps. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 // Try to allocate the object without transitioning into C code. If any of 145 // Try to allocate the object without transitioning into C code. If any of
146 // the preconditions is not met, the code bails out to the runtime call. 146 // the preconditions is not met, the code bails out to the runtime call.
147 Label rt_call, allocated; 147 Label rt_call, allocated;
148 if (FLAG_inline_new) { 148 if (FLAG_inline_new) {
149 ExternalReference debug_step_in_fp = 149 ExternalReference debug_step_in_fp =
150 ExternalReference::debug_step_in_fp_address(masm->isolate()); 150 ExternalReference::debug_step_in_fp_address(masm->isolate());
151 __ cmp(Operand::StaticVariable(debug_step_in_fp), Immediate(0)); 151 __ cmp(Operand::StaticVariable(debug_step_in_fp), Immediate(0));
152 __ j(not_equal, &rt_call); 152 __ j(not_equal, &rt_call);
153 153
154 // Fall back to runtime if the original constructor and function differ. 154 // Verify that the original constructor is a JSFunction.
155 __ cmp(edx, edi); 155 __ CmpObjectType(edx, JS_FUNCTION_TYPE, ebx);
156 __ j(not_equal, &rt_call); 156 __ j(not_equal, &rt_call);
157 157
158 // Verified that the constructor is a JSFunction.
159 // Load the initial map and verify that it is in fact a map. 158 // Load the initial map and verify that it is in fact a map.
160 // edi: constructor 159 // edx: original constructor
161 __ mov(eax, FieldOperand(edi, JSFunction::kPrototypeOrInitialMapOffset)); 160 __ mov(eax, FieldOperand(edx, JSFunction::kPrototypeOrInitialMapOffset));
162 // Will both indicate a NULL and a Smi 161 // Will both indicate a NULL and a Smi
163 __ JumpIfSmi(eax, &rt_call); 162 __ JumpIfSmi(eax, &rt_call);
164 // edi: constructor 163 // edi: constructor
165 // eax: initial map (if proven valid below) 164 // eax: initial map (if proven valid below)
166 __ CmpObjectType(eax, MAP_TYPE, ebx); 165 __ CmpObjectType(eax, MAP_TYPE, ebx);
167 __ j(not_equal, &rt_call); 166 __ j(not_equal, &rt_call);
168 167
168 // Fall back to runtime if the expected base constructor and base
169 // constructor differ.
170 __ cmp(edi, FieldOperand(eax, Map::kConstructorOrBackPointerOffset));
171 __ j(not_equal, &rt_call);
172
169 // Check that the constructor is not constructing a JSFunction (see 173 // Check that the constructor is not constructing a JSFunction (see
170 // comments in Runtime_NewObject in runtime.cc). In which case the 174 // comments in Runtime_NewObject in runtime.cc). In which case the
171 // initial map's instance type would be JS_FUNCTION_TYPE. 175 // initial map's instance type would be JS_FUNCTION_TYPE.
172 // edi: constructor 176 // edi: constructor
173 // eax: initial map 177 // eax: initial map
174 __ CmpInstanceType(eax, JS_FUNCTION_TYPE); 178 __ CmpInstanceType(eax, JS_FUNCTION_TYPE);
175 __ j(equal, &rt_call); 179 __ j(equal, &rt_call);
176 180
177 if (!is_api_function) { 181 if (!is_api_function) {
178 Label allocate; 182 Label allocate;
179 // The code below relies on these assumptions. 183 // The code below relies on these assumptions.
180 STATIC_ASSERT(Map::Counter::kShift + Map::Counter::kSize == 32); 184 STATIC_ASSERT(Map::Counter::kShift + Map::Counter::kSize == 32);
181 // Check if slack tracking is enabled. 185 // Check if slack tracking is enabled.
182 __ mov(esi, FieldOperand(eax, Map::kBitField3Offset)); 186 __ mov(esi, FieldOperand(eax, Map::kBitField3Offset));
183 __ shr(esi, Map::Counter::kShift); 187 __ shr(esi, Map::Counter::kShift);
184 __ cmp(esi, Map::kSlackTrackingCounterEnd); 188 __ cmp(esi, Map::kSlackTrackingCounterEnd);
185 __ j(less, &allocate); 189 __ j(less, &allocate);
186 // Decrease generous allocation count. 190 // Decrease generous allocation count.
187 __ sub(FieldOperand(eax, Map::kBitField3Offset), 191 __ sub(FieldOperand(eax, Map::kBitField3Offset),
188 Immediate(1 << Map::Counter::kShift)); 192 Immediate(1 << Map::Counter::kShift));
189 193
190 __ cmp(esi, Map::kSlackTrackingCounterEnd); 194 __ cmp(esi, Map::kSlackTrackingCounterEnd);
191 __ j(not_equal, &allocate); 195 __ j(not_equal, &allocate);
192 196
193 __ push(eax); 197 __ push(eax);
194 __ push(edx); 198 __ push(edx);
195 __ push(edi); 199 __ push(edi);
196 200
197 __ push(edi); // constructor 201 __ push(eax); // initial map
198 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1); 202 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1);
199 203
200 __ pop(edi); 204 __ pop(edi);
201 __ pop(edx); 205 __ pop(edx);
202 __ pop(eax); 206 __ pop(eax);
203 __ mov(esi, Map::kSlackTrackingCounterEnd - 1); 207 __ mov(esi, Map::kSlackTrackingCounterEnd - 1);
204 208
205 __ bind(&allocate); 209 __ bind(&allocate);
206 } 210 }
207 211
(...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 1945
1942 __ bind(&ok); 1946 __ bind(&ok);
1943 __ ret(0); 1947 __ ret(0);
1944 } 1948 }
1945 1949
1946 #undef __ 1950 #undef __
1947 } // namespace internal 1951 } // namespace internal
1948 } // namespace v8 1952 } // namespace v8
1949 1953
1950 #endif // V8_TARGET_ARCH_IA32 1954 #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