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

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

Issue 767253002: Refactor Map::ConstructionCount. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix assert Created 6 years 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/objects-inl.h ('k') | src/x87/builtins-x87.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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 __ CmpObjectType(rax, MAP_TYPE, rbx); 151 __ CmpObjectType(rax, MAP_TYPE, rbx);
152 __ j(not_equal, &rt_call); 152 __ j(not_equal, &rt_call);
153 153
154 // Check that the constructor is not constructing a JSFunction (see 154 // Check that the constructor is not constructing a JSFunction (see
155 // comments in Runtime_NewObject in runtime.cc). In which case the 155 // comments in Runtime_NewObject in runtime.cc). In which case the
156 // initial map's instance type would be JS_FUNCTION_TYPE. 156 // initial map's instance type would be JS_FUNCTION_TYPE.
157 // rdi: constructor 157 // rdi: constructor
158 // rax: initial map 158 // rax: initial map
159 __ CmpInstanceType(rax, JS_FUNCTION_TYPE); 159 __ CmpInstanceType(rax, JS_FUNCTION_TYPE);
160 __ j(equal, &rt_call); 160 __ j(equal, &rt_call);
161
162 if (!is_api_function) { 161 if (!is_api_function) {
163 Label allocate; 162 Label allocate;
164 // The code below relies on these assumptions. 163 // The code below relies on these assumptions.
165 STATIC_ASSERT(JSFunction::kNoSlackTracking == 0); 164 STATIC_ASSERT(Map::Counter::kShift + Map::Counter::kSize == 32);
166 STATIC_ASSERT(Map::ConstructionCount::kShift +
167 Map::ConstructionCount::kSize == 32);
168 // Check if slack tracking is enabled. 165 // Check if slack tracking is enabled.
169 __ movl(rsi, FieldOperand(rax, Map::kBitField3Offset)); 166 __ movl(rsi, FieldOperand(rax, Map::kBitField3Offset));
170 __ shrl(rsi, Immediate(Map::ConstructionCount::kShift)); 167 __ shrl(rsi, Immediate(Map::Counter::kShift));
171 __ j(zero, &allocate); // JSFunction::kNoSlackTracking 168 __ cmpl(rsi, Immediate(Map::kSlackTrackingCounterEnd));
169 __ j(less, &allocate);
172 // Decrease generous allocation count. 170 // Decrease generous allocation count.
173 __ subl(FieldOperand(rax, Map::kBitField3Offset), 171 __ subl(FieldOperand(rax, Map::kBitField3Offset),
174 Immediate(1 << Map::ConstructionCount::kShift)); 172 Immediate(1 << Map::Counter::kShift));
175 173
176 __ cmpl(rsi, Immediate(JSFunction::kFinishSlackTracking)); 174 __ cmpl(rsi, Immediate(Map::kSlackTrackingCounterEnd));
177 __ j(not_equal, &allocate); 175 __ j(not_equal, &allocate);
178 176
179 __ Push(rax); 177 __ Push(rax);
180 __ Push(rdi); 178 __ Push(rdi);
181 179
182 __ Push(rdi); // constructor 180 __ Push(rdi); // constructor
183 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1); 181 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1);
184 182
185 __ Pop(rdi); 183 __ Pop(rdi);
186 __ Pop(rax); 184 __ Pop(rax);
187 __ xorl(rsi, rsi); // JSFunction::kNoSlackTracking 185 __ movl(rsi, Immediate(Map::kSlackTrackingCounterEnd - 1));
188 186
189 __ bind(&allocate); 187 __ bind(&allocate);
190 } 188 }
191 189
192 // Now allocate the JSObject on the heap. 190 // Now allocate the JSObject on the heap.
193 __ movzxbp(rdi, FieldOperand(rax, Map::kInstanceSizeOffset)); 191 __ movzxbp(rdi, FieldOperand(rax, Map::kInstanceSizeOffset));
194 __ shlp(rdi, Immediate(kPointerSizeLog2)); 192 __ shlp(rdi, Immediate(kPointerSizeLog2));
195 if (create_memento) { 193 if (create_memento) {
196 __ addp(rdi, Immediate(AllocationMemento::kSize)); 194 __ addp(rdi, Immediate(AllocationMemento::kSize));
197 } 195 }
(...skipping 17 matching lines...) Expand all
215 // rax: initial map 213 // rax: initial map
216 // rbx: JSObject 214 // rbx: JSObject
217 // rdi: start of next object (including memento if create_memento) 215 // rdi: start of next object (including memento if create_memento)
218 // rsi: slack tracking counter (non-API function case) 216 // rsi: slack tracking counter (non-API function case)
219 __ leap(rcx, Operand(rbx, JSObject::kHeaderSize)); 217 __ leap(rcx, Operand(rbx, JSObject::kHeaderSize));
220 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex); 218 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex);
221 if (!is_api_function) { 219 if (!is_api_function) {
222 Label no_inobject_slack_tracking; 220 Label no_inobject_slack_tracking;
223 221
224 // Check if slack tracking is enabled. 222 // Check if slack tracking is enabled.
225 __ cmpl(rsi, Immediate(JSFunction::kNoSlackTracking)); 223 __ cmpl(rsi, Immediate(Map::kSlackTrackingCounterEnd));
226 __ j(equal, &no_inobject_slack_tracking); 224 __ j(less, &no_inobject_slack_tracking);
227 225
228 // Allocate object with a slack. 226 // Allocate object with a slack.
229 __ movzxbp(rsi, 227 __ movzxbp(rsi,
230 FieldOperand(rax, Map::kPreAllocatedPropertyFieldsOffset)); 228 FieldOperand(rax, Map::kPreAllocatedPropertyFieldsOffset));
231 __ leap(rsi, 229 __ leap(rsi,
232 Operand(rbx, rsi, times_pointer_size, JSObject::kHeaderSize)); 230 Operand(rbx, rsi, times_pointer_size, JSObject::kHeaderSize));
233 // rsi: offset of first field after pre-allocated fields 231 // rsi: offset of first field after pre-allocated fields
234 if (FLAG_debug_code) { 232 if (FLAG_debug_code) {
235 __ cmpp(rsi, rdi); 233 __ cmpp(rsi, rdi);
236 __ Assert(less_equal, 234 __ Assert(less_equal,
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 __ bind(&ok); 1520 __ bind(&ok);
1523 __ ret(0); 1521 __ ret(0);
1524 } 1522 }
1525 1523
1526 1524
1527 #undef __ 1525 #undef __
1528 1526
1529 } } // namespace v8::internal 1527 } } // namespace v8::internal
1530 1528
1531 #endif // V8_TARGET_ARCH_X64 1529 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/x87/builtins-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698