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

Side by Side Diff: src/arm/lithium-codegen-arm.cc

Issue 330053002: ARM, ARM64: Optimize array copy (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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/arm/lithium-arm.cc ('k') | src/arm64/lithium-arm64.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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/arm/lithium-codegen-arm.h" 7 #include "src/arm/lithium-codegen-arm.h"
8 #include "src/arm/lithium-gap-resolver-arm.h" 8 #include "src/arm/lithium-gap-resolver-arm.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/stub-cache.h" 10 #include "src/stub-cache.h"
(...skipping 4326 matching lines...) Expand 10 before | Expand all | Expand 10 after
4337 value, 4337 value,
4338 GetLinkRegisterState(), 4338 GetLinkRegisterState(),
4339 kSaveFPRegs, 4339 kSaveFPRegs,
4340 EMIT_REMEMBERED_SET, 4340 EMIT_REMEMBERED_SET,
4341 check_needed, 4341 check_needed,
4342 instr->hydrogen()->PointersToHereCheckForValue()); 4342 instr->hydrogen()->PointersToHereCheckForValue());
4343 } 4343 }
4344 } 4344 }
4345 4345
4346 4346
4347 void LCodeGen::DoFillElements(LFillElements* instr) {
4348 Label end;
4349 Register elements = ToRegister(instr->elements());
4350 Register dst = scratch0();
4351 ASSERT(instr->hydrogen()->to()->representation().IsInteger32());
4352 ASSERT(instr->hydrogen()->from()->representation().IsInteger32());
4353 int shift_size =
4354 instr->value()->IsDoubleRegister() ? kDoubleSizeLog2 : kPointerSizeLog2;
4355 // We will be able to skip the first test (which checks that we have at
4356 // least one value to fill) if we know the number of values to copy.
4357 bool skip_first_test = false;
4358 Register remain;
4359 if (instr->from()->IsConstantOperand()) {
4360 int from = ToInteger32(LConstantOperand::cast(instr->from()));
4361 int start_offset =
4362 FixedDoubleArray::kHeaderSize - kHeapObjectTag + (from << shift_size);
4363 if (instr->to()->IsConstantOperand()) {
4364 int to = ToInteger32(LConstantOperand::cast(instr->to()));
4365 if (instr->scratch() == NULL) {
4366 // Scratch is null, if to - from was small enough to unroll the loop.
4367 int max = to - from;
4368 if (instr->value()->IsDoubleRegister()) {
4369 __ add(dst, elements, Operand(start_offset));
4370 DoubleRegister value = ToDoubleRegister(instr->value());
4371 for (int count = 0; count < max; count++) {
4372 __ vstr(value, dst, count * kDoubleSize);
4373 }
4374 } else {
4375 Register value = ToRegister(instr->value());
4376 for (int count = 0; count < max; count++) {
4377 __ str(value,
4378 MemOperand(elements, start_offset + count * kPointerSize));
4379 }
4380 }
4381 __ bind(&end);
4382 return;
4383 }
4384 __ add(dst, elements, Operand(start_offset));
4385 skip_first_test = true;
4386 remain = ToRegister(instr->scratch());
4387 __ mov(remain, Operand(to - from));
4388 } else {
4389 remain = ToRegister(instr->scratch());
4390 Register to = ToRegister(instr->to());
4391 if (from == 0) {
4392 __ mov(remain, Operand(to), SetCC);
4393 } else {
4394 __ sub(remain, to, Operand(from), SetCC);
4395 }
4396 __ add(dst, elements, Operand(start_offset));
4397 }
4398 } else {
4399 remain = ToRegister(instr->scratch());
4400 Register from = ToRegister(instr->from());
4401 if (instr->to()->IsConstantOperand()) {
4402 int to = ToInteger32(LConstantOperand::cast(instr->to()));
4403 __ rsb(remain, from, Operand(to), SetCC);
4404 } else {
4405 Register to = ToRegister(instr->to());
4406 __ sub(remain, to, Operand(from), SetCC);
4407 }
4408 __ add(dst, elements,
4409 Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag));
4410 __ add(dst, dst, Operand(from, LSL, shift_size));
4411 }
4412 Label loop, done;
4413 if (!skip_first_test) {
4414 __ b(le, &done);
4415 }
4416 __ bind(&loop);
4417 __ sub(remain, remain, Operand(1), SetCC);
4418 if (instr->value()->IsDoubleRegister()) {
4419 DoubleRegister value = ToDoubleRegister(instr->value());
4420 __ vstr(value, dst, 0);
4421 __ add(dst, dst, Operand(kDoubleSize));
4422 } else {
4423 Register value = ToRegister(instr->value());
4424 __ str(value, MemOperand(dst, kPointerSize, PostIndex));
4425 }
4426 __ b(gt, &loop);
4427 if (!skip_first_test) {
4428 __ bind(&done);
4429 }
4430 __ bind(&end);
4431 }
4432
4433
4434 void LCodeGen::DoCopyElements(LCopyElements* instr) {
4435 Label loop, done;
4436 Register dst = ToRegister(instr->dst());
4437 Register src = ToRegister(instr->src());
4438 Register length = ToRegister(instr->length());
4439 __ cmp(length, Operand::Zero());
4440 __ add(src, src, Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag));
4441 __ add(dst, dst,
4442 Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag));
4443 __ b(eq, &done);
4444 __ bind(&loop);
4445 if (instr->hydrogen()->length()->representation().IsSmi()) {
4446 __ sub(length, length, Operand(Smi::FromInt(1)), SetCC);
4447 } else {
4448 __ sub(length, length, Operand(1), SetCC);
4449 }
4450 if (IsFastSmiOrObjectElementsKind(instr->elements_kind())) {
4451 Register value = scratch0();
4452 __ ldr(value, MemOperand(src, kPointerSize, PostIndex));
4453 __ str(value, MemOperand(dst, kPointerSize, PostIndex));
4454 } else {
4455 DoubleRegister value = double_scratch0();
4456 __ vldr(value, src, 0);
4457 __ vstr(value, dst, 0);
4458 __ add(src, src, Operand(kDoubleSize));
4459 __ add(dst, dst, Operand(kDoubleSize));
4460 }
4461 __ b(gt, &loop);
4462 __ bind(&done);
4463 }
4464
4465
4347 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) { 4466 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) {
4348 // By cases: external, fast double 4467 // By cases: external, fast double
4349 if (instr->is_typed_elements()) { 4468 if (instr->is_typed_elements()) {
4350 DoStoreKeyedExternalArray(instr); 4469 DoStoreKeyedExternalArray(instr);
4351 } else if (instr->hydrogen()->value()->representation().IsDouble()) { 4470 } else if (instr->hydrogen()->value()->representation().IsDouble()) {
4352 DoStoreKeyedFixedDoubleArray(instr); 4471 DoStoreKeyedFixedDoubleArray(instr);
4353 } else { 4472 } else {
4354 DoStoreKeyedFixedArray(instr); 4473 DoStoreKeyedFixedArray(instr);
4355 } 4474 }
4356 } 4475 }
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
5833 __ Push(scope_info); 5952 __ Push(scope_info);
5834 __ push(ToRegister(instr->function())); 5953 __ push(ToRegister(instr->function()));
5835 CallRuntime(Runtime::kHiddenPushBlockContext, 2, instr); 5954 CallRuntime(Runtime::kHiddenPushBlockContext, 2, instr);
5836 RecordSafepoint(Safepoint::kNoLazyDeopt); 5955 RecordSafepoint(Safepoint::kNoLazyDeopt);
5837 } 5956 }
5838 5957
5839 5958
5840 #undef __ 5959 #undef __
5841 5960
5842 } } // namespace v8::internal 5961 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/arm64/lithium-arm64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698