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

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

Issue 295933012: Revert "Inobject slack tracking is done on a per-closure basis instead of per-shared info basis." (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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 409 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
421 Handle<Code> code = 410 Handle<Code> code =
422 masm->isolate()->builtins()->HandleApiCallConstruct(); 411 masm->isolate()->builtins()->HandleApiCallConstruct();
423 __ Call(code, RelocInfo::CODE_TARGET); 412 __ Call(code, RelocInfo::CODE_TARGET);
424 } else { 413 } else {
425 ParameterCount actual(rax); 414 ParameterCount actual(rax);
426 __ InvokeFunction(rdi, actual, CALL_FUNCTION, NullCallWrapper()); 415 __ InvokeFunction(rdi, actual, CALL_FUNCTION, NullCallWrapper());
427 } 416 }
428 417
429 // Store offset of return address for deoptimizer. 418 // Store offset of return address for deoptimizer.
430 if (!is_api_function) { 419 if (!is_api_function && !count_constructions) {
431 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); 420 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset());
432 } 421 }
433 422
434 // Restore context from the frame. 423 // Restore context from the frame.
435 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 424 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
436 425
437 // 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
438 // 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
439 // on page 74. 428 // on page 74.
440 Label use_receiver, exit; 429 Label use_receiver, exit;
(...skipping 22 matching lines...) Expand all
463 __ PopReturnAddressTo(rcx); 452 __ PopReturnAddressTo(rcx);
464 SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2); 453 SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2);
465 __ leap(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize)); 454 __ leap(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize));
466 __ PushReturnAddressFrom(rcx); 455 __ PushReturnAddressFrom(rcx);
467 Counters* counters = masm->isolate()->counters(); 456 Counters* counters = masm->isolate()->counters();
468 __ IncrementCounter(counters->constructed_objects(), 1); 457 __ IncrementCounter(counters->constructed_objects(), 1);
469 __ ret(0); 458 __ ret(0);
470 } 459 }
471 460
472 461
462 void Builtins::Generate_JSConstructStubCountdown(MacroAssembler* masm) {
463 Generate_JSConstructStubHelper(masm, false, true, false);
464 }
465
466
473 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { 467 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
474 Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new); 468 Generate_JSConstructStubHelper(masm, false, false, FLAG_pretenuring_call_new);
475 } 469 }
476 470
477 471
478 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { 472 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
479 Generate_JSConstructStubHelper(masm, true, false); 473 Generate_JSConstructStubHelper(masm, true, false, false);
480 } 474 }
481 475
482 476
483 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, 477 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
484 bool is_construct) { 478 bool is_construct) {
485 ProfileEntryHookStub::MaybeCallEntryHook(masm); 479 ProfileEntryHookStub::MaybeCallEntryHook(masm);
486 480
487 // Expects five C++ function parameters. 481 // Expects five C++ function parameters.
488 // - Address entry (ignored) 482 // - Address entry (ignored)
489 // - JSFunction* function ( 483 // - JSFunction* function (
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 __ bind(&ok); 1506 __ bind(&ok);
1513 __ ret(0); 1507 __ ret(0);
1514 } 1508 }
1515 1509
1516 1510
1517 #undef __ 1511 #undef __
1518 1512
1519 } } // namespace v8::internal 1513 } } // namespace v8::internal
1520 1514
1521 #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