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

Side by Side Diff: runtime/vm/stub_code_ia32.cc

Issue 1226143011: Trace allocation of arrays (Closed) Base URL: git@github.com:dart-lang/sdk.git@try_allocate_realz
Patch Set: Created 5 years, 5 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
« no previous file with comments | « runtime/vm/stub_code_arm64.cc ('k') | runtime/vm/stub_code_mips.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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 // ECX : array element type (either NULL or an instantiated type). 582 // ECX : array element type (either NULL or an instantiated type).
583 // Uses EAX, EBX, ECX, EDI as temporary registers. 583 // Uses EAX, EBX, ECX, EDI as temporary registers.
584 // The newly allocated object is returned in EAX. 584 // The newly allocated object is returned in EAX.
585 void StubCode::GeneratePatchableAllocateArrayStub(Assembler* assembler, 585 void StubCode::GeneratePatchableAllocateArrayStub(Assembler* assembler,
586 uword* entry_patch_offset, uword* patch_code_pc_offset) { 586 uword* entry_patch_offset, uword* patch_code_pc_offset) {
587 *entry_patch_offset = assembler->CodeSize(); 587 *entry_patch_offset = assembler->CodeSize();
588 Label slow_case; 588 Label slow_case;
589 const Immediate& raw_null = 589 const Immediate& raw_null =
590 Immediate(reinterpret_cast<intptr_t>(Object::null())); 590 Immediate(reinterpret_cast<intptr_t>(Object::null()));
591 591
592 Isolate* isolate = Isolate::Current();
593 const Class& cls = Class::Handle(isolate->object_store()->array_class());
594 ASSERT(!cls.IsNull());
592 // Compute the size to be allocated, it is based on the array length 595 // Compute the size to be allocated, it is based on the array length
593 // and is computed as: 596 // and is computed as:
594 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)). 597 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
595 // Assert that length is a Smi. 598 // Assert that length is a Smi.
596 __ testl(EDX, Immediate(kSmiTagMask)); 599 __ testl(EDX, Immediate(kSmiTagMask));
597 if (FLAG_use_slow_path) { 600
601 if (FLAG_use_slow_path || cls.trace_allocation()) {
598 __ jmp(&slow_case); 602 __ jmp(&slow_case);
599 } else { 603 } else {
600 __ j(NOT_ZERO, &slow_case); 604 __ j(NOT_ZERO, &slow_case);
601 } 605 }
602 __ cmpl(EDX, Immediate(0)); 606 __ cmpl(EDX, Immediate(0));
603 __ j(LESS, &slow_case); 607 __ j(LESS, &slow_case);
604 608
605 // Check for maximum allowed length. 609 // Check for maximum allowed length.
606 const Immediate& max_len = 610 const Immediate& max_len =
607 Immediate(reinterpret_cast<int32_t>(Smi::New(Array::kMaxElements))); 611 Immediate(reinterpret_cast<int32_t>(Smi::New(Array::kMaxElements)));
608 __ cmpl(EDX, max_len); 612 __ cmpl(EDX, max_len);
609 __ j(GREATER, &slow_case); 613 __ j(GREATER, &slow_case);
610 614
611 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; 615 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1;
612 __ leal(EDI, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi. 616 __ leal(EDI, Address(EDX, TIMES_2, fixed_size)); // EDX is Smi.
613 ASSERT(kSmiTagShift == 1); 617 ASSERT(kSmiTagShift == 1);
614 __ andl(EDI, Immediate(-kObjectAlignment)); 618 __ andl(EDI, Immediate(-kObjectAlignment));
615 619
616 // ECX: array element type. 620 // ECX: array element type.
617 // EDX: array length as Smi. 621 // EDX: array length as Smi.
618 // EDI: allocation size. 622 // EDI: allocation size.
619 623
620 Isolate* isolate = Isolate::Current();
621 Heap* heap = isolate->heap(); 624 Heap* heap = isolate->heap();
622 const intptr_t cid = kArrayCid; 625 const intptr_t cid = kArrayCid;
623 Heap::Space space = heap->SpaceForAllocation(cid); 626 Heap::Space space = heap->SpaceForAllocation(cid);
624 __ movl(EAX, Address::Absolute(heap->TopAddress(space))); 627 __ movl(EAX, Address::Absolute(heap->TopAddress(space)));
625 __ movl(EBX, EAX); 628 __ movl(EBX, EAX);
626 629
627 // EDI: allocation size. 630 // EDI: allocation size.
628 __ addl(EBX, EDI); 631 __ addl(EBX, EDI);
629 __ j(CARRY, &slow_case); 632 __ j(CARRY, &slow_case);
630 633
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 // EBX: entry point. 2127 // EBX: entry point.
2125 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { 2128 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
2126 EmitMegamorphicLookup(assembler, EDI, EBX, EBX); 2129 EmitMegamorphicLookup(assembler, EDI, EBX, EBX);
2127 __ ret(); 2130 __ ret();
2128 } 2131 }
2129 2132
2130 2133
2131 } // namespace dart 2134 } // namespace dart
2132 2135
2133 #endif // defined TARGET_ARCH_IA32 2136 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_arm64.cc ('k') | runtime/vm/stub_code_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698