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

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

Issue 292433016: Revert "Reland r21346 "Inobject slack tracking is done on a per-closure basis instead of per-shared… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-mementos.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 "v8.h" 5 #include "v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "codegen.h" 9 #include "codegen.h"
10 #include "deoptimizer.h" 10 #include "deoptimizer.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 CallRuntimePassFunction(masm, Runtime::kHiddenTryInstallOptimizedCode); 94 CallRuntimePassFunction(masm, Runtime::kHiddenTryInstallOptimizedCode);
95 GenerateTailCallToReturnedCode(masm); 95 GenerateTailCallToReturnedCode(masm);
96 96
97 __ bind(&ok); 97 __ bind(&ok);
98 GenerateTailCallToSharedCode(masm); 98 GenerateTailCallToSharedCode(masm);
99 } 99 }
100 100
101 101
102 static void Generate_JSConstructStubHelper(MacroAssembler* masm, 102 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
103 bool is_api_function, 103 bool is_api_function,
104 bool count_constructions,
104 bool create_memento) { 105 bool create_memento) {
105 // ----------- S t a t e ------------- 106 // ----------- S t a t e -------------
106 // -- rax: number of arguments 107 // -- rax: number of arguments
107 // -- rdi: constructor function 108 // -- rdi: constructor function
108 // -- rbx: allocation site or undefined 109 // -- rbx: allocation site or undefined
109 // ----------------------------------- 110 // -----------------------------------
110 111
112 // Should never count constructions for api objects.
113 ASSERT(!is_api_function || !count_constructions);\
114
111 // Should never create mementos for api functions. 115 // Should never create mementos for api functions.
112 ASSERT(!is_api_function || !create_memento); 116 ASSERT(!is_api_function || !create_memento);
113 117
118 // Should never create mementos before slack tracking is finished.
119 ASSERT(!count_constructions || !create_memento);
120
114 // Enter a construct frame. 121 // Enter a construct frame.
115 { 122 {
116 FrameScope scope(masm, StackFrame::CONSTRUCT); 123 FrameScope scope(masm, StackFrame::CONSTRUCT);
117 124
118 if (create_memento) { 125 if (create_memento) {
119 __ AssertUndefinedOrAllocationSite(rbx); 126 __ AssertUndefinedOrAllocationSite(rbx);
120 __ Push(rbx); 127 __ Push(rbx);
121 } 128 }
122 129
123 // Store a smi-tagged arguments count on the stack. 130 // Store a smi-tagged arguments count on the stack.
(...skipping 28 matching lines...) Expand all
152 __ j(not_equal, &rt_call); 159 __ j(not_equal, &rt_call);
153 160
154 // Check that the constructor is not constructing a JSFunction (see 161 // Check that the constructor is not constructing a JSFunction (see
155 // comments in Runtime_NewObject in runtime.cc). In which case the 162 // comments in Runtime_NewObject in runtime.cc). In which case the
156 // initial map's instance type would be JS_FUNCTION_TYPE. 163 // initial map's instance type would be JS_FUNCTION_TYPE.
157 // rdi: constructor 164 // rdi: constructor
158 // rax: initial map 165 // rax: initial map
159 __ CmpInstanceType(rax, JS_FUNCTION_TYPE); 166 __ CmpInstanceType(rax, JS_FUNCTION_TYPE);
160 __ j(equal, &rt_call); 167 __ j(equal, &rt_call);
161 168
162 if (!is_api_function) { 169 if (count_constructions) {
163 Label allocate; 170 Label allocate;
164 // The code below relies on these assumptions.
165 STATIC_ASSERT(JSFunction::kNoSlackTracking == 0);
166 STATIC_ASSERT(Map::ConstructionCount::kShift +
167 Map::ConstructionCount::kSize == 32);
168 // Check if slack tracking is enabled.
169 __ movl(rsi, FieldOperand(rax, Map::kBitField3Offset));
170 __ shrl(rsi, Immediate(Map::ConstructionCount::kShift));
171 __ j(zero, &allocate); // JSFunction::kNoSlackTracking
172 // Decrease generous allocation count. 171 // Decrease generous allocation count.
173 __ subl(FieldOperand(rax, Map::kBitField3Offset), 172 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
174 Immediate(1 << Map::ConstructionCount::kShift)); 173 __ decb(FieldOperand(rcx,
175 174 SharedFunctionInfo::kConstructionCountOffset));
176 __ cmpl(rsi, Immediate(JSFunction::kFinishSlackTracking)); 175 __ j(not_zero, &allocate);
177 __ 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
181 // The call will replace the stub, so the countdown is only done once.
183 __ CallRuntime(Runtime::kHiddenFinalizeInstanceSize, 1); 182 __ CallRuntime(Runtime::kHiddenFinalizeInstanceSize, 1);
184 183
185 __ Pop(rdi); 184 __ Pop(rdi);
186 __ Pop(rax); 185 __ Pop(rax);
187 __ xorl(rsi, rsi); // JSFunction::kNoSlackTracking
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 10 matching lines...) Expand all
208 // rbx: JSObject (not HeapObject tagged - the actual address). 206 // rbx: JSObject (not HeapObject tagged - the actual address).
209 // rdi: start of next object (including memento if create_memento) 207 // rdi: start of next object (including memento if create_memento)
210 __ movp(Operand(rbx, JSObject::kMapOffset), rax); 208 __ movp(Operand(rbx, JSObject::kMapOffset), rax);
211 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex); 209 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex);
212 __ movp(Operand(rbx, JSObject::kPropertiesOffset), rcx); 210 __ movp(Operand(rbx, JSObject::kPropertiesOffset), rcx);
213 __ movp(Operand(rbx, JSObject::kElementsOffset), rcx); 211 __ movp(Operand(rbx, JSObject::kElementsOffset), rcx);
214 // Set extra fields in the newly allocated object. 212 // Set extra fields in the newly allocated object.
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)
219 __ leap(rcx, Operand(rbx, JSObject::kHeaderSize)); 216 __ leap(rcx, Operand(rbx, JSObject::kHeaderSize));
220 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex); 217 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex);
221 if (!is_api_function) { 218 if (count_constructions) {
222 Label no_inobject_slack_tracking;
223
224 // Check if slack tracking is enabled.
225 __ cmpl(rsi, Immediate(JSFunction::kNoSlackTracking));
226 __ j(equal, &no_inobject_slack_tracking);
227
228 // Allocate object with a slack.
229 __ movzxbp(rsi, 219 __ movzxbp(rsi,
230 FieldOperand(rax, Map::kPreAllocatedPropertyFieldsOffset)); 220 FieldOperand(rax, Map::kPreAllocatedPropertyFieldsOffset));
231 __ leap(rsi, 221 __ leap(rsi,
232 Operand(rbx, rsi, times_pointer_size, JSObject::kHeaderSize)); 222 Operand(rbx, rsi, times_pointer_size, JSObject::kHeaderSize));
233 // rsi: offset of first field after pre-allocated fields 223 // rsi: offset of first field after pre-allocated fields
234 if (FLAG_debug_code) { 224 if (FLAG_debug_code) {
235 __ cmpp(rsi, rdi); 225 __ cmpp(rsi, rdi);
236 __ Assert(less_equal, 226 __ Assert(less_equal,
237 kUnexpectedNumberOfPreAllocatedPropertyFields); 227 kUnexpectedNumberOfPreAllocatedPropertyFields);
238 } 228 }
239 __ InitializeFieldsWithFiller(rcx, rsi, rdx); 229 __ InitializeFieldsWithFiller(rcx, rsi, rdx);
240 __ LoadRoot(rdx, Heap::kOnePointerFillerMapRootIndex); 230 __ LoadRoot(rdx, Heap::kOnePointerFillerMapRootIndex);
241 // Fill the remaining fields with one pointer filler map. 231 __ InitializeFieldsWithFiller(rcx, rdi, rdx);
242 232 } else if (create_memento) {
243 __ bind(&no_inobject_slack_tracking);
244 }
245 if (create_memento) {
246 __ leap(rsi, Operand(rdi, -AllocationMemento::kSize)); 233 __ leap(rsi, Operand(rdi, -AllocationMemento::kSize));
247 __ InitializeFieldsWithFiller(rcx, rsi, rdx); 234 __ InitializeFieldsWithFiller(rcx, rsi, rdx);
248 235
249 // Fill in memento fields if necessary. 236 // Fill in memento fields if necessary.
250 // rsi: points to the allocated but uninitialized memento. 237 // rsi: points to the allocated but uninitialized memento.
238 Handle<Map> allocation_memento_map = factory->allocation_memento_map();
251 __ Move(Operand(rsi, AllocationMemento::kMapOffset), 239 __ Move(Operand(rsi, AllocationMemento::kMapOffset),
252 factory->allocation_memento_map()); 240 allocation_memento_map);
253 // Get the cell or undefined. 241 // Get the cell or undefined.
254 __ movp(rdx, Operand(rsp, kPointerSize*2)); 242 __ movp(rdx, Operand(rsp, kPointerSize*2));
255 __ movp(Operand(rsi, AllocationMemento::kAllocationSiteOffset), rdx); 243 __ movp(Operand(rsi, AllocationMemento::kAllocationSiteOffset),
244 rdx);
256 } else { 245 } else {
257 __ InitializeFieldsWithFiller(rcx, rdi, rdx); 246 __ InitializeFieldsWithFiller(rcx, rdi, rdx);
258 } 247 }
259 248
260 // Add the object tag to make the JSObject real, so that we can continue 249 // Add the object tag to make the JSObject real, so that we can continue
261 // and jump into the continuation code at any time from now on. Any 250 // and jump into the continuation code at any time from now on. Any
262 // failures need to undo the allocation, so that the heap is in a 251 // failures need to undo the allocation, so that the heap is in a
263 // consistent state and verifiable. 252 // consistent state and verifiable.
264 // rax: initial map 253 // rax: initial map
265 // rbx: JSObject 254 // rbx: JSObject
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 // rdi: function (constructor) 337 // rdi: function (constructor)
349 __ bind(&rt_call); 338 __ bind(&rt_call);
350 int offset = 0; 339 int offset = 0;
351 if (create_memento) { 340 if (create_memento) {
352 // Get the cell or allocation site. 341 // Get the cell or allocation site.
353 __ movp(rdi, Operand(rsp, kPointerSize*2)); 342 __ movp(rdi, Operand(rsp, kPointerSize*2));
354 __ Push(rdi); 343 __ Push(rdi);
355 offset = kPointerSize; 344 offset = kPointerSize;
356 } 345 }
357 346
358 // Must restore rsi (context) and rdi (constructor) before calling runtime. 347 // Must restore rdi (constructor) before calling runtime.
359 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
360 __ movp(rdi, Operand(rsp, offset)); 348 __ movp(rdi, Operand(rsp, offset));
361 __ Push(rdi); 349 __ Push(rdi);
362 if (create_memento) { 350 if (create_memento) {
363 __ CallRuntime(Runtime::kHiddenNewObjectWithAllocationSite, 2); 351 __ CallRuntime(Runtime::kHiddenNewObjectWithAllocationSite, 2);
364 } else { 352 } else {
365 __ CallRuntime(Runtime::kHiddenNewObject, 1); 353 __ CallRuntime(Runtime::kHiddenNewObject, 1);
366 } 354 }
367 __ movp(rbx, rax); // store result in rbx 355 __ movp(rbx, rax); // store result in rbx
368 356
369 // If we ended up using the runtime, and we want a memento, then the 357 // If we ended up using the runtime, and we want a memento, then the
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 409 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
422 Handle<Code> code = 410 Handle<Code> code =
423 masm->isolate()->builtins()->HandleApiCallConstruct(); 411 masm->isolate()->builtins()->HandleApiCallConstruct();
424 __ Call(code, RelocInfo::CODE_TARGET); 412 __ Call(code, RelocInfo::CODE_TARGET);
425 } else { 413 } else {
426 ParameterCount actual(rax); 414 ParameterCount actual(rax);
427 __ InvokeFunction(rdi, actual, CALL_FUNCTION, NullCallWrapper()); 415 __ InvokeFunction(rdi, actual, CALL_FUNCTION, NullCallWrapper());
428 } 416 }
429 417
430 // Store offset of return address for deoptimizer. 418 // Store offset of return address for deoptimizer.
431 if (!is_api_function) { 419 if (!is_api_function && !count_constructions) {
432 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); 420 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset());
433 } 421 }
434 422
435 // Restore context from the frame. 423 // Restore context from the frame.
436 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 424 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
437 425
438 // If the result is an object (in the ECMA sense), we should get rid 426 // If the result is an object (in the ECMA sense), we should get rid
439 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 427 // of the receiver and use the result; see ECMA-262 section 13.2.2-7
440 // on page 74. 428 // on page 74.
441 Label use_receiver, exit; 429 Label use_receiver, exit;
(...skipping 22 matching lines...) Expand all
464 __ PopReturnAddressTo(rcx); 452 __ PopReturnAddressTo(rcx);
465 SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2); 453 SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2);
466 __ leap(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize)); 454 __ leap(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize));
467 __ PushReturnAddressFrom(rcx); 455 __ PushReturnAddressFrom(rcx);
468 Counters* counters = masm->isolate()->counters(); 456 Counters* counters = masm->isolate()->counters();
469 __ IncrementCounter(counters->constructed_objects(), 1); 457 __ IncrementCounter(counters->constructed_objects(), 1);
470 __ ret(0); 458 __ ret(0);
471 } 459 }
472 460
473 461
462 void Builtins::Generate_JSConstructStubCountdown(MacroAssembler* masm) {
463 Generate_JSConstructStubHelper(masm, false, true, false);
464 }
465
466
474 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { 467 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
475 Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new); 468 Generate_JSConstructStubHelper(masm, false, false, FLAG_pretenuring_call_new);
476 } 469 }
477 470
478 471
479 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { 472 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
480 Generate_JSConstructStubHelper(masm, true, false); 473 Generate_JSConstructStubHelper(masm, true, false, false);
481 } 474 }
482 475
483 476
484 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, 477 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
485 bool is_construct) { 478 bool is_construct) {
486 ProfileEntryHookStub::MaybeCallEntryHook(masm); 479 ProfileEntryHookStub::MaybeCallEntryHook(masm);
487 480
488 // Expects five C++ function parameters. 481 // Expects five C++ function parameters.
489 // - Address entry (ignored) 482 // - Address entry (ignored)
490 // - JSFunction* function ( 483 // - JSFunction* function (
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 __ bind(&ok); 1506 __ bind(&ok);
1514 __ ret(0); 1507 __ ret(0);
1515 } 1508 }
1516 1509
1517 1510
1518 #undef __ 1511 #undef __
1519 1512
1520 } } // namespace v8::internal 1513 } } // namespace v8::internal
1521 1514
1522 #endif // V8_TARGET_ARCH_X64 1515 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-mementos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698