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

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

Issue 627103005: Unrolls array initialization loop for small arrays. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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 | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_ia32.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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" // Needed here to get TARGET_ARCH_ARM64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64.
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 const intptr_t kNumTemps = 0; 1966 const intptr_t kNumTemps = 0;
1967 LocationSummary* locs = new(isolate) LocationSummary( 1967 LocationSummary* locs = new(isolate) LocationSummary(
1968 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); 1968 isolate, kNumInputs, kNumTemps, LocationSummary::kCall);
1969 locs->set_in(kElementTypePos, Location::RegisterLocation(R1)); 1969 locs->set_in(kElementTypePos, Location::RegisterLocation(R1));
1970 locs->set_in(kLengthPos, Location::RegisterLocation(R2)); 1970 locs->set_in(kLengthPos, Location::RegisterLocation(R2));
1971 locs->set_out(0, Location::RegisterLocation(R0)); 1971 locs->set_out(0, Location::RegisterLocation(R0));
1972 return locs; 1972 return locs;
1973 } 1973 }
1974 1974
1975 1975
1976 // Inlines array allocation for known constant values.
1977 static void InlineArrayAllocation(FlowGraphCompiler* compiler,
1978 intptr_t num_elements,
1979 Label* slow_path,
1980 Label* done) {
1981 const int kInlineArraySize = 12; // Same as kInlineInstanceSize.
1982 const Register kLengthReg = R2;
1983 const Register kElemTypeReg = R1;
1984 const intptr_t instance_size = Array::InstanceSize(num_elements);
1985
1986 __ TryAllocateArray(kArrayCid, instance_size, slow_path,
1987 R0, // instance
1988 R3, // end address
1989 R6,
1990 R8);
1991 // R0: new object start as a tagged pointer.
1992 // R3: new object end address.
1993
1994 // Store the type argument field.
1995 __ StoreIntoObjectNoBarrier(R0,
1996 FieldAddress(R0, Array::type_arguments_offset()),
1997 kElemTypeReg);
1998
1999 // Set the length field.
2000 __ StoreIntoObjectNoBarrier(R0,
2001 FieldAddress(R0, Array::length_offset()),
2002 kLengthReg);
2003
2004 // TODO(zra): Use stp once added.
2005 // Initialize all array elements to raw_null.
2006 // R0: new object start as a tagged pointer.
2007 // R3: new object end address.
2008 // R8: iterator which initially points to the start of the variable
2009 // data area to be initialized.
2010 // R6: null
2011 if (num_elements > 0) {
2012 const intptr_t array_size = instance_size - sizeof(RawArray);
2013 __ LoadObject(R6, Object::null_object(), PP);
2014 __ AddImmediate(R8, R0, sizeof(RawArray) - kHeapObjectTag, PP);
2015 if (array_size < (kInlineArraySize * kWordSize)) {
2016 intptr_t current_offset = 0;
2017 while (current_offset < array_size) {
2018 __ str(R6, Address(R8, current_offset));
2019 current_offset += kWordSize;
2020 }
2021 } else {
2022 Label end_loop, init_loop;
2023 __ Bind(&init_loop);
2024 __ CompareRegisters(R8, R3);
2025 __ b(&end_loop, CS);
2026 __ str(R6, Address(R8));
2027 __ AddImmediate(R8, R8, kWordSize, kNoPP);
2028 __ b(&init_loop);
2029 __ Bind(&end_loop);
2030 }
2031 }
2032 __ b(done);
2033 }
2034
2035
1976 void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2036 void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1977 // Allocate the array. R2 = length, R1 = element type. 2037 const Register kLengthReg = R2;
1978 ASSERT(locs()->in(kElementTypePos).reg() == R1); 2038 const Register kElemTypeReg = R1;
1979 ASSERT(locs()->in(kLengthPos).reg() == R2); 2039 const Register kResultReg = R0;
2040
2041 ASSERT(locs()->in(kElementTypePos).reg() == kElemTypeReg);
2042 ASSERT(locs()->in(kLengthPos).reg() == kLengthReg);
2043
2044 if (num_elements()->BindsToConstant() &&
2045 num_elements()->BoundConstant().IsSmi()) {
2046 const intptr_t length = Smi::Cast(num_elements()->BoundConstant()).Value();
2047 if ((length >= 0) && (length <= Array::kMaxElements)) {
2048 Label slow_path, done;
2049 InlineArrayAllocation(compiler, length, &slow_path, &done);
2050 __ Bind(&slow_path);
2051 __ PushObject(Object::null_object(), PP); // Make room for the result.
2052 __ Push(kLengthReg); // length.
2053 __ Push(kElemTypeReg);
2054 compiler->GenerateRuntimeCall(token_pos(),
2055 deopt_id(),
2056 kAllocateArrayRuntimeEntry,
2057 2,
2058 locs());
2059 __ Drop(2);
2060 __ Pop(kResultReg);
2061 __ Bind(&done);
2062 return;
2063 }
2064 }
1980 Isolate* isolate = compiler->isolate(); 2065 Isolate* isolate = compiler->isolate();
1981 const Code& stub = Code::Handle( 2066 const Code& stub = Code::Handle(
1982 isolate, isolate->stub_code()->GetAllocateArrayStub()); 2067 isolate, isolate->stub_code()->GetAllocateArrayStub());
1983 const ExternalLabel label(stub.EntryPoint()); 2068 const ExternalLabel label(stub.EntryPoint());
1984 compiler->GenerateCall(token_pos(), 2069 compiler->GenerateCall(token_pos(),
1985 &label, 2070 &label,
1986 RawPcDescriptors::kOther, 2071 RawPcDescriptors::kOther,
1987 locs()); 2072 locs());
1988 compiler->AddStubCallTarget(stub); 2073 compiler->AddStubCallTarget(stub);
1989 ASSERT(locs()->out(0).reg() == R0); 2074 ASSERT(locs()->out(0).reg() == kResultReg);
1990 } 2075 }
1991 2076
1992 2077
1993 LocationSummary* LoadFieldInstr::MakeLocationSummary(Isolate* isolate, 2078 LocationSummary* LoadFieldInstr::MakeLocationSummary(Isolate* isolate,
1994 bool opt) const { 2079 bool opt) const {
1995 const intptr_t kNumInputs = 1; 2080 const intptr_t kNumInputs = 1;
1996 const intptr_t kNumTemps = 2081 const intptr_t kNumTemps =
1997 (IsUnboxedLoad() && opt) ? 1 : 2082 (IsUnboxedLoad() && opt) ? 1 :
1998 ((IsPotentialUnboxedLoad()) ? 1 : 0); 2083 ((IsPotentialUnboxedLoad()) ? 1 : 0);
1999 LocationSummary* locs = new(isolate) LocationSummary( 2084 LocationSummary* locs = new(isolate) LocationSummary(
(...skipping 3481 matching lines...) Expand 10 before | Expand all | Expand 10 after
5481 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); 5566 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs());
5482 #if defined(DEBUG) 5567 #if defined(DEBUG)
5483 __ LoadImmediate(R4, kInvalidObjectPointer, kNoPP); 5568 __ LoadImmediate(R4, kInvalidObjectPointer, kNoPP);
5484 __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP); 5569 __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP);
5485 #endif 5570 #endif
5486 } 5571 }
5487 5572
5488 } // namespace dart 5573 } // namespace dart
5489 5574
5490 #endif // defined TARGET_ARCH_ARM64 5575 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698