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

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: Addressing review comments 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') | 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_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(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, Operand(JSFunction::kFinishSlackTracking));
384 __ ldrb(r4, constructor_count);
385 __ sub(r4, r4, Operand(1), SetCC);
386 __ strb(r4, constructor_count);
387 __ b(ne, &allocate); 383 __ b(ne, &allocate);
388 384
389 __ push(r1); 385 __ push(r1);
390 386
391 __ Push(r2, r1); // r1 = constructor 387 __ Push(r2, r1); // r1 = constructor
392 // The call will replace the stub, so the countdown is only done once.
393 __ CallRuntime(Runtime::kHiddenFinalizeInstanceSize, 1); 388 __ CallRuntime(Runtime::kHiddenFinalizeInstanceSize, 1);
394 389
395 __ pop(r2); 390 __ pop(r2);
396 __ pop(r1); 391 __ pop(r1);
397 392
398 __ bind(&allocate); 393 __ bind(&allocate);
399 } 394 }
400 395
401 // Now allocate the JSObject on the heap. 396 // Now allocate the JSObject on the heap.
402 // r1: constructor function 397 // r1: constructor function
(...skipping 20 matching lines...) Expand all
423 ASSERT_EQ(2 * kPointerSize, JSObject::kElementsOffset); 418 ASSERT_EQ(2 * kPointerSize, JSObject::kElementsOffset);
424 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); 419 __ str(r6, MemOperand(r5, kPointerSize, PostIndex));
425 420
426 // Fill all the in-object properties with the appropriate filler. 421 // Fill all the in-object properties with the appropriate filler.
427 // r1: constructor function 422 // r1: constructor function
428 // r2: initial map 423 // r2: initial map
429 // r3: object size (in words, including memento if create_memento) 424 // r3: object size (in words, including memento if create_memento)
430 // r4: JSObject (not tagged) 425 // r4: JSObject (not tagged)
431 // r5: First in-object property of JSObject (not tagged) 426 // r5: First in-object property of JSObject (not tagged)
432 ASSERT_EQ(3 * kPointerSize, JSObject::kHeaderSize); 427 ASSERT_EQ(3 * kPointerSize, JSObject::kHeaderSize);
428 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex);
433 429
434 if (count_constructions) { 430 if (!is_api_function) {
435 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); 431 Label no_inobject_slack_tracking;
432
433 // Check if slack tracking is enabled.
434 __ ldr(ip, FieldMemOperand(r2, Map::kBitField3Offset));
435 __ DecodeField<Map::ConstructionCount>(ip);
436 __ cmp(ip, Operand(JSFunction::kNoSlackTracking));
437 __ b(eq, &no_inobject_slack_tracking);
438
439 // Allocate object with a slack.
436 __ ldr(r0, FieldMemOperand(r2, Map::kInstanceSizesOffset)); 440 __ ldr(r0, FieldMemOperand(r2, Map::kInstanceSizesOffset));
437 __ Ubfx(r0, r0, Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte, 441 __ Ubfx(r0, r0, Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte,
438 kBitsPerByte); 442 kBitsPerByte);
439 __ add(r0, r5, Operand(r0, LSL, kPointerSizeLog2)); 443 __ add(r0, r5, Operand(r0, LSL, kPointerSizeLog2));
440 // r0: offset of first field after pre-allocated fields 444 // r0: offset of first field after pre-allocated fields
441 if (FLAG_debug_code) { 445 if (FLAG_debug_code) {
442 __ add(ip, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. 446 __ add(ip, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object.
443 __ cmp(r0, ip); 447 __ cmp(r0, ip);
444 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields); 448 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields);
445 } 449 }
446 __ InitializeFieldsWithFiller(r5, r0, r6); 450 __ InitializeFieldsWithFiller(r5, r0, r6);
447 // To allow for truncation. 451 // To allow for truncation.
448 __ LoadRoot(r6, Heap::kOnePointerFillerMapRootIndex); 452 __ LoadRoot(r6, Heap::kOnePointerFillerMapRootIndex);
449 __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. 453 // Fill the remaining fields with one pointer filler map.
450 __ InitializeFieldsWithFiller(r5, r0, r6); 454
451 } else if (create_memento) { 455 __ bind(&no_inobject_slack_tracking);
452 __ sub(r6, r3, Operand(AllocationMemento::kSize / kPointerSize)); 456 }
453 __ add(r0, r4, Operand(r6, LSL, kPointerSizeLog2)); // End of object. 457
454 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); 458 if (create_memento) {
459 __ sub(ip, r3, Operand(AllocationMemento::kSize / kPointerSize));
460 __ add(r0, r4, Operand(ip, LSL, kPointerSizeLog2)); // End of object.
455 __ InitializeFieldsWithFiller(r5, r0, r6); 461 __ InitializeFieldsWithFiller(r5, r0, r6);
456 462
457 // Fill in memento fields. 463 // Fill in memento fields.
458 // r5: points to the allocated but uninitialized memento. 464 // r5: points to the allocated but uninitialized memento.
459 __ LoadRoot(r6, Heap::kAllocationMementoMapRootIndex); 465 __ LoadRoot(r6, Heap::kAllocationMementoMapRootIndex);
460 ASSERT_EQ(0 * kPointerSize, AllocationMemento::kMapOffset); 466 ASSERT_EQ(0 * kPointerSize, AllocationMemento::kMapOffset);
461 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); 467 __ str(r6, MemOperand(r5, kPointerSize, PostIndex));
462 // Load the AllocationSite 468 // Load the AllocationSite
463 __ ldr(r6, MemOperand(sp, 2 * kPointerSize)); 469 __ ldr(r6, MemOperand(sp, 2 * kPointerSize));
464 ASSERT_EQ(1 * kPointerSize, AllocationMemento::kAllocationSiteOffset); 470 ASSERT_EQ(1 * kPointerSize, AllocationMemento::kAllocationSiteOffset);
465 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); 471 __ str(r6, MemOperand(r5, kPointerSize, PostIndex));
466 } else { 472 } else {
467 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex);
468 __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. 473 __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object.
469 __ InitializeFieldsWithFiller(r5, r0, r6); 474 __ InitializeFieldsWithFiller(r5, r0, r6);
470 } 475 }
471 476
472 // Add the object tag to make the JSObject real, so that we can continue 477 // 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 478 // 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 479 // failures need to undo the allocation, so that the heap is in a
475 // consistent state and verifiable. 480 // consistent state and verifiable.
476 __ add(r4, r4, Operand(kHeapObjectTag)); 481 __ add(r4, r4, Operand(kHeapObjectTag));
477 482
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); 653 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset));
649 Handle<Code> code = 654 Handle<Code> code =
650 masm->isolate()->builtins()->HandleApiCallConstruct(); 655 masm->isolate()->builtins()->HandleApiCallConstruct();
651 __ Call(code, RelocInfo::CODE_TARGET); 656 __ Call(code, RelocInfo::CODE_TARGET);
652 } else { 657 } else {
653 ParameterCount actual(r0); 658 ParameterCount actual(r0);
654 __ InvokeFunction(r1, actual, CALL_FUNCTION, NullCallWrapper()); 659 __ InvokeFunction(r1, actual, CALL_FUNCTION, NullCallWrapper());
655 } 660 }
656 661
657 // Store offset of return address for deoptimizer. 662 // Store offset of return address for deoptimizer.
658 if (!is_api_function && !count_constructions) { 663 if (!is_api_function) {
659 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); 664 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset());
660 } 665 }
661 666
662 // Restore context from the frame. 667 // Restore context from the frame.
663 // r0: result 668 // r0: result
664 // sp[0]: receiver 669 // sp[0]: receiver
665 // sp[1]: constructor function 670 // sp[1]: constructor function
666 // sp[2]: number of arguments (smi-tagged) 671 // sp[2]: number of arguments (smi-tagged)
667 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); 672 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
668 673
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 // Leave construct frame. 705 // Leave construct frame.
701 } 706 }
702 707
703 __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1)); 708 __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1));
704 __ add(sp, sp, Operand(kPointerSize)); 709 __ add(sp, sp, Operand(kPointerSize));
705 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r1, r2); 710 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r1, r2);
706 __ Jump(lr); 711 __ Jump(lr);
707 } 712 }
708 713
709 714
710 void Builtins::Generate_JSConstructStubCountdown(MacroAssembler* masm) {
711 Generate_JSConstructStubHelper(masm, false, true, false);
712 }
713
714
715 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { 715 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
716 Generate_JSConstructStubHelper(masm, false, false, FLAG_pretenuring_call_new); 716 Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new);
717 } 717 }
718 718
719 719
720 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { 720 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
721 Generate_JSConstructStubHelper(masm, true, false, false); 721 Generate_JSConstructStubHelper(masm, true, false);
722 } 722 }
723 723
724 724
725 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, 725 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
726 bool is_construct) { 726 bool is_construct) {
727 // Called from Generate_JS_Entry 727 // Called from Generate_JS_Entry
728 // r0: code entry 728 // r0: code entry
729 // r1: function 729 // r1: function
730 // r2: receiver 730 // r2: receiver
731 // r3: argc 731 // r3: argc
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 __ bkpt(0); 1551 __ bkpt(0);
1552 } 1552 }
1553 } 1553 }
1554 1554
1555 1555
1556 #undef __ 1556 #undef __
1557 1557
1558 } } // namespace v8::internal 1558 } } // namespace v8::internal
1559 1559
1560 #endif // V8_TARGET_ARCH_ARM 1560 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/macro-assembler-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698