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

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

Issue 283383006: 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: Bugfixes, improvements, cleanup 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 | « no previous file | src/arm/macro-assembler-arm.h » ('j') | src/ia32/builtins-ia32.cc » ('J')
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_ARM 7 #if V8_TARGET_ARCH_ARM
8 8
9 #include "codegen.h" 9 #include "codegen.h"
10 #include "debug.h" 10 #include "debug.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 CallRuntimePassFunction(masm, Runtime::kHiddenTryInstallOptimizedCode); 306 CallRuntimePassFunction(masm, Runtime::kHiddenTryInstallOptimizedCode);
307 GenerateTailCallToReturnedCode(masm); 307 GenerateTailCallToReturnedCode(masm);
308 308
309 __ bind(&ok); 309 __ bind(&ok);
310 GenerateTailCallToSharedCode(masm); 310 GenerateTailCallToSharedCode(masm);
311 } 311 }
312 312
313 313
314 static void Generate_JSConstructStubHelper(MacroAssembler* masm, 314 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
315 bool is_api_function, 315 bool is_api_function,
316 bool count_constructions,
317 bool create_memento) { 316 bool create_memento) {
318 // ----------- S t a t e ------------- 317 // ----------- S t a t e -------------
319 // -- r0 : number of arguments 318 // -- r0 : number of arguments
320 // -- r1 : constructor function 319 // -- r1 : constructor function
321 // -- r2 : allocation site or undefined 320 // -- r2 : allocation site or undefined
322 // -- lr : return address 321 // -- lr : return address
323 // -- sp[...]: constructor arguments 322 // -- sp[...]: constructor arguments
324 // ----------------------------------- 323 // -----------------------------------
325 324
326 // Should never count constructions for api objects.
327 ASSERT(!is_api_function || !count_constructions);
328
329 // Should never create mementos for api functions. 325 // Should never create mementos for api functions.
330 ASSERT(!is_api_function || !create_memento); 326 ASSERT(!is_api_function || !create_memento);
331 327
332 // Should never create mementos before slack tracking is finished.
333 ASSERT(!count_constructions || !create_memento);
334
335 Isolate* isolate = masm->isolate(); 328 Isolate* isolate = masm->isolate();
336 329
337 // Enter a construct frame. 330 // Enter a construct frame.
338 { 331 {
339 FrameAndConstantPoolScope scope(masm, StackFrame::CONSTRUCT); 332 FrameAndConstantPoolScope scope(masm, StackFrame::CONSTRUCT);
340 333
341 if (create_memento) { 334 if (create_memento) {
342 __ AssertUndefinedOrAllocationSite(r2, r3); 335 __ AssertUndefinedOrAllocationSite(r2, r3);
343 __ push(r2); 336 __ push(r2);
344 } 337 }
(...skipping 23 matching lines...) Expand all
368 __ b(ne, &rt_call); 361 __ b(ne, &rt_call);
369 362
370 // Check that the constructor is not constructing a JSFunction (see 363 // Check that the constructor is not constructing a JSFunction (see
371 // comments in Runtime_NewObject in runtime.cc). In which case the 364 // comments in Runtime_NewObject in runtime.cc). In which case the
372 // initial map's instance type would be JS_FUNCTION_TYPE. 365 // initial map's instance type would be JS_FUNCTION_TYPE.
373 // r1: constructor function 366 // r1: constructor function
374 // r2: initial map 367 // r2: initial map
375 __ CompareInstanceType(r2, r3, JS_FUNCTION_TYPE); 368 __ CompareInstanceType(r2, r3, JS_FUNCTION_TYPE);
376 __ b(eq, &rt_call); 369 __ b(eq, &rt_call);
377 370
378 if (count_constructions) { 371 if (!is_api_function) {
379 Label allocate; 372 Label allocate;
373 MemOperand bit_field3 = FieldMemOperand(r2, Map::kBitField3Offset);
374 // Check if slack tracking is enabled.
375 __ ldr(r4, bit_field3);
376 __ DecodeField<Map::ConstructionCount>(r3, r4);
377 __ cmp(r3, Operand(static_cast<int32_t>(JSFunction::kNoSlackTracking)));
378 __ b(eq, &allocate);
380 // Decrease generous allocation count. 379 // Decrease generous allocation count.
381 __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); 380 __ sub(r4, r4, Operand(1 << Map::ConstructionCount::kShift));
382 MemOperand constructor_count = 381 __ str(r4, bit_field3);
383 FieldMemOperand(r3, SharedFunctionInfo::kConstructionCountOffset); 382 __ cmp(r3,
384 __ ldrb(r4, constructor_count); 383 Operand(static_cast<int32_t>(JSFunction::kFinishSlackTracking)));
385 __ sub(r4, r4, Operand(1), SetCC);
386 __ strb(r4, constructor_count);
387 __ b(ne, &allocate); 384 __ b(ne, &allocate);
388 385
389 __ push(r1); 386 __ push(r1);
390 387
391 __ Push(r2, r1); // r1 = constructor 388 __ Push(r2, r1); // r1 = constructor
392 // The call will replace the stub, so the countdown is only done once.
393 __ CallRuntime(Runtime::kHiddenFinalizeInstanceSize, 1); 389 __ CallRuntime(Runtime::kHiddenFinalizeInstanceSize, 1);
394 390
395 __ pop(r2); 391 __ pop(r2);
396 __ pop(r1); 392 __ pop(r1);
397 393
398 __ bind(&allocate); 394 __ bind(&allocate);
399 } 395 }
400 396
401 // Now allocate the JSObject on the heap. 397 // Now allocate the JSObject on the heap.
402 // r1: constructor function 398 // r1: constructor function
(...skipping 21 matching lines...) Expand all
424 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); 420 __ str(r6, MemOperand(r5, kPointerSize, PostIndex));
425 421
426 // Fill all the in-object properties with the appropriate filler. 422 // Fill all the in-object properties with the appropriate filler.
427 // r1: constructor function 423 // r1: constructor function
428 // r2: initial map 424 // r2: initial map
429 // r3: object size (in words, including memento if create_memento) 425 // r3: object size (in words, including memento if create_memento)
430 // r4: JSObject (not tagged) 426 // r4: JSObject (not tagged)
431 // r5: First in-object property of JSObject (not tagged) 427 // r5: First in-object property of JSObject (not tagged)
432 ASSERT_EQ(3 * kPointerSize, JSObject::kHeaderSize); 428 ASSERT_EQ(3 * kPointerSize, JSObject::kHeaderSize);
433 429
434 if (count_constructions) { 430 if (is_api_function) {
431 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex);
432 __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object.
433 __ InitializeFieldsWithFiller(r5, r0, r6);
434 } else {
435 Label no_inobject_slack_tracking, done_field_initialization;
436
437 // Check if slack tracking is enabled.
438 __ ldr(r6, FieldMemOperand(r2, Map::kBitField3Offset));
439 __ DecodeField<Map::ConstructionCount>(r6);
440 __ cmp(r6, Operand(static_cast<int32_t>(JSFunction::kNoSlackTracking)));
441 __ b(eq, &no_inobject_slack_tracking);
442
443 // Allocate object with a slack.
435 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); 444 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex);
436 __ ldr(r0, FieldMemOperand(r2, Map::kInstanceSizesOffset)); 445 __ ldr(r0, FieldMemOperand(r2, Map::kInstanceSizesOffset));
437 __ Ubfx(r0, r0, Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte, 446 __ Ubfx(r0, r0, Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte,
438 kBitsPerByte); 447 kBitsPerByte);
439 __ add(r0, r5, Operand(r0, LSL, kPointerSizeLog2)); 448 __ add(r0, r5, Operand(r0, LSL, kPointerSizeLog2));
440 // r0: offset of first field after pre-allocated fields 449 // r0: offset of first field after pre-allocated fields
441 if (FLAG_debug_code) { 450 if (FLAG_debug_code) {
442 __ add(ip, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. 451 __ add(ip, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object.
443 __ cmp(r0, ip); 452 __ cmp(r0, ip);
444 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields); 453 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields);
445 } 454 }
446 __ InitializeFieldsWithFiller(r5, r0, r6); 455 __ InitializeFieldsWithFiller(r5, r0, r6);
447 // To allow for truncation. 456 // To allow for truncation.
448 __ LoadRoot(r6, Heap::kOnePointerFillerMapRootIndex); 457 __ LoadRoot(r6, Heap::kOnePointerFillerMapRootIndex);
449 __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. 458 __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object.
450 __ InitializeFieldsWithFiller(r5, r0, r6); 459 __ InitializeFieldsWithFiller(r5, r0, r6);
451 } else if (create_memento) { 460 __ b(&done_field_initialization);
452 __ sub(r6, r3, Operand(AllocationMemento::kSize / kPointerSize));
453 __ add(r0, r4, Operand(r6, LSL, kPointerSizeLog2)); // End of object.
454 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex);
455 __ InitializeFieldsWithFiller(r5, r0, r6);
456 461
457 // Fill in memento fields. 462 __ bind(&no_inobject_slack_tracking);
458 // r5: points to the allocated but uninitialized memento. 463
459 __ LoadRoot(r6, Heap::kAllocationMementoMapRootIndex); 464 if (create_memento) {
460 ASSERT_EQ(0 * kPointerSize, AllocationMemento::kMapOffset); 465 __ sub(r6, r3, Operand(AllocationMemento::kSize / kPointerSize));
461 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); 466 __ add(r0, r4, Operand(r6, LSL, kPointerSizeLog2)); // End of object.
462 // Load the AllocationSite 467 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex);
463 __ ldr(r6, MemOperand(sp, 2 * kPointerSize)); 468 __ InitializeFieldsWithFiller(r5, r0, r6);
464 ASSERT_EQ(1 * kPointerSize, AllocationMemento::kAllocationSiteOffset); 469
465 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); 470 // Fill in memento fields.
466 } else { 471 // r5: points to the allocated but uninitialized memento.
467 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); 472 __ LoadRoot(r6, Heap::kAllocationMementoMapRootIndex);
468 __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. 473 ASSERT_EQ(0 * kPointerSize, AllocationMemento::kMapOffset);
469 __ InitializeFieldsWithFiller(r5, r0, r6); 474 __ str(r6, MemOperand(r5, kPointerSize, PostIndex));
475 // Load the AllocationSite
476 __ ldr(r6, MemOperand(sp, 2 * kPointerSize));
477 ASSERT_EQ(1 * kPointerSize, AllocationMemento::kAllocationSiteOffset);
478 __ str(r6, MemOperand(r5, kPointerSize, PostIndex));
479 } else {
480 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex);
481 __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object.
482 __ InitializeFieldsWithFiller(r5, r0, r6);
483 }
484 __ bind(&done_field_initialization);
470 } 485 }
471 486
472 // Add the object tag to make the JSObject real, so that we can continue 487 // Add the object tag to make the JSObject real, so that we can continue
473 // and jump into the continuation code at any time from now on. Any 488 // and jump into the continuation code at any time from now on. Any
474 // failures need to undo the allocation, so that the heap is in a 489 // failures need to undo the allocation, so that the heap is in a
475 // consistent state and verifiable. 490 // consistent state and verifiable.
476 __ add(r4, r4, Operand(kHeapObjectTag)); 491 __ add(r4, r4, Operand(kHeapObjectTag));
477 492
478 // Check if a non-empty properties array is needed. Continue with 493 // Check if a non-empty properties array is needed. Continue with
479 // allocated object if not fall through to runtime call if it is. 494 // allocated object if not fall through to runtime call if it is.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); 663 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset));
649 Handle<Code> code = 664 Handle<Code> code =
650 masm->isolate()->builtins()->HandleApiCallConstruct(); 665 masm->isolate()->builtins()->HandleApiCallConstruct();
651 __ Call(code, RelocInfo::CODE_TARGET); 666 __ Call(code, RelocInfo::CODE_TARGET);
652 } else { 667 } else {
653 ParameterCount actual(r0); 668 ParameterCount actual(r0);
654 __ InvokeFunction(r1, actual, CALL_FUNCTION, NullCallWrapper()); 669 __ InvokeFunction(r1, actual, CALL_FUNCTION, NullCallWrapper());
655 } 670 }
656 671
657 // Store offset of return address for deoptimizer. 672 // Store offset of return address for deoptimizer.
658 if (!is_api_function && !count_constructions) { 673 if (!is_api_function) {
659 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); 674 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset());
660 } 675 }
661 676
662 // Restore context from the frame. 677 // Restore context from the frame.
663 // r0: result 678 // r0: result
664 // sp[0]: receiver 679 // sp[0]: receiver
665 // sp[1]: constructor function 680 // sp[1]: constructor function
666 // sp[2]: number of arguments (smi-tagged) 681 // sp[2]: number of arguments (smi-tagged)
667 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); 682 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
668 683
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 // Leave construct frame. 715 // Leave construct frame.
701 } 716 }
702 717
703 __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1)); 718 __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1));
704 __ add(sp, sp, Operand(kPointerSize)); 719 __ add(sp, sp, Operand(kPointerSize));
705 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r1, r2); 720 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r1, r2);
706 __ Jump(lr); 721 __ Jump(lr);
707 } 722 }
708 723
709 724
710 void Builtins::Generate_JSConstructStubCountdown(MacroAssembler* masm) {
711 Generate_JSConstructStubHelper(masm, false, true, false);
712 }
713
714
715 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { 725 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
716 Generate_JSConstructStubHelper(masm, false, false, FLAG_pretenuring_call_new); 726 Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new);
717 } 727 }
718 728
719 729
720 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { 730 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
721 Generate_JSConstructStubHelper(masm, true, false, false); 731 Generate_JSConstructStubHelper(masm, true, false);
722 } 732 }
723 733
724 734
725 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, 735 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
726 bool is_construct) { 736 bool is_construct) {
727 // Called from Generate_JS_Entry 737 // Called from Generate_JS_Entry
728 // r0: code entry 738 // r0: code entry
729 // r1: function 739 // r1: function
730 // r2: receiver 740 // r2: receiver
731 // r3: argc 741 // r3: argc
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 __ bkpt(0); 1561 __ bkpt(0);
1552 } 1562 }
1553 } 1563 }
1554 1564
1555 1565
1556 #undef __ 1566 #undef __
1557 1567
1558 } } // namespace v8::internal 1568 } } // namespace v8::internal
1559 1569
1560 #endif // V8_TARGET_ARCH_ARM 1570 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/macro-assembler-arm.h » ('j') | src/ia32/builtins-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698