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

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

Issue 1124443004: New hydrogen instruction to reduce cost of growing an array on keyed stores. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE to tip of tree. Created 5 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
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/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 4487 matching lines...) Expand 10 before | Expand all | Expand 10 after
4498 DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); 4498 DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister()));
4499 DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); 4499 DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister()));
4500 4500
4501 Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( 4501 Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode(
4502 isolate(), instr->language_mode(), 4502 isolate(), instr->language_mode(),
4503 instr->hydrogen()->initialization_state()).code(); 4503 instr->hydrogen()->initialization_state()).code();
4504 CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS); 4504 CallCode(ic, RelocInfo::CODE_TARGET, instr, NEVER_INLINE_TARGET_ADDRESS);
4505 } 4505 }
4506 4506
4507 4507
4508 void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) {
4509 class DeferredMaybeGrowElements final : public LDeferredCode {
4510 public:
4511 DeferredMaybeGrowElements(LCodeGen* codegen, LMaybeGrowElements* instr)
4512 : LDeferredCode(codegen), instr_(instr) {}
4513 void Generate() override { codegen()->DoDeferredMaybeGrowElements(instr_); }
4514 LInstruction* instr() override { return instr_; }
4515
4516 private:
4517 LMaybeGrowElements* instr_;
4518 };
4519
4520 Register result = r0;
4521 DeferredMaybeGrowElements* deferred =
4522 new (zone()) DeferredMaybeGrowElements(this, instr);
4523 LOperand* key = instr->key();
4524 LOperand* current_capacity = instr->current_capacity();
4525
4526 DCHECK(instr->hydrogen()->key()->representation().IsInteger32());
4527 DCHECK(instr->hydrogen()->current_capacity()->representation().IsInteger32());
4528 DCHECK(key->IsConstantOperand() || key->IsRegister());
4529 DCHECK(current_capacity->IsConstantOperand() ||
4530 current_capacity->IsRegister());
4531
4532 if (key->IsConstantOperand() && current_capacity->IsConstantOperand()) {
4533 int32_t constant_key = ToInteger32(LConstantOperand::cast(key));
4534 int32_t constant_capacity =
4535 ToInteger32(LConstantOperand::cast(current_capacity));
4536 if (constant_key >= constant_capacity) {
4537 // Deferred case.
4538 __ jmp(deferred->entry());
4539 }
4540 } else if (key->IsConstantOperand()) {
4541 int32_t constant_key = ToInteger32(LConstantOperand::cast(key));
4542 __ cmp(ToRegister(current_capacity), Operand(constant_key));
4543 __ b(le, deferred->entry());
4544 } else if (current_capacity->IsConstantOperand()) {
4545 int32_t constant_capacity =
4546 ToInteger32(LConstantOperand::cast(current_capacity));
4547 __ cmp(ToRegister(key), Operand(constant_capacity));
4548 __ b(ge, deferred->entry());
4549 } else {
4550 __ cmp(ToRegister(key), ToRegister(current_capacity));
4551 __ b(ge, deferred->entry());
4552 }
4553
4554 if (instr->elements()->IsRegister()) {
4555 __ Move(result, ToRegister(instr->elements()));
4556 } else {
4557 __ ldr(result, ToMemOperand(instr->elements()));
4558 }
4559
4560 __ bind(deferred->exit());
4561 }
4562
4563
4564 void LCodeGen::DoDeferredMaybeGrowElements(LMaybeGrowElements* instr) {
4565 // TODO(3095996): Get rid of this. For now, we need to make the
4566 // result register contain a valid pointer because it is already
4567 // contained in the register pointer map.
4568 Register result = r0;
4569 __ mov(result, Operand::Zero());
4570
4571 // We have to call a stub.
4572 {
4573 PushSafepointRegistersScope scope(this);
4574 if (instr->object()->IsRegister()) {
4575 __ Move(result, ToRegister(instr->object()));
4576 } else {
4577 __ ldr(result, ToMemOperand(instr->object()));
4578 }
4579
4580 LOperand* key = instr->key();
4581 if (key->IsConstantOperand()) {
4582 __ Move(r3, Operand(ToSmi(LConstantOperand::cast(key))));
4583 } else {
4584 __ Move(r3, ToRegister(key));
4585 __ SmiTag(r3);
4586 }
4587
4588 GrowArrayElementsStub stub(isolate(), instr->hydrogen()->is_js_array(),
4589 instr->hydrogen()->kind());
4590 __ CallStub(&stub);
4591 RecordSafepointWithLazyDeopt(
4592 instr, RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS);
4593 __ StoreToSafepointRegisterSlot(result, result);
4594 }
4595
4596 // Deoptimize if we got a smi back.
4597 __ SmiTst(result);
4598 DeoptimizeIf(eq, instr, Deoptimizer::kSmi);
4599 }
4600
4601
4508 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) { 4602 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) {
4509 Register object_reg = ToRegister(instr->object()); 4603 Register object_reg = ToRegister(instr->object());
4510 Register scratch = scratch0(); 4604 Register scratch = scratch0();
4511 4605
4512 Handle<Map> from_map = instr->original_map(); 4606 Handle<Map> from_map = instr->original_map();
4513 Handle<Map> to_map = instr->transitioned_map(); 4607 Handle<Map> to_map = instr->transitioned_map();
4514 ElementsKind from_kind = instr->from_kind(); 4608 ElementsKind from_kind = instr->from_kind();
4515 ElementsKind to_kind = instr->to_kind(); 4609 ElementsKind to_kind = instr->to_kind();
4516 4610
4517 Label not_applicable; 4611 Label not_applicable;
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after
5951 __ Push(scope_info); 6045 __ Push(scope_info);
5952 __ push(ToRegister(instr->function())); 6046 __ push(ToRegister(instr->function()));
5953 CallRuntime(Runtime::kPushBlockContext, 2, instr); 6047 CallRuntime(Runtime::kPushBlockContext, 2, instr);
5954 RecordSafepoint(Safepoint::kNoLazyDeopt); 6048 RecordSafepoint(Safepoint::kNoLazyDeopt);
5955 } 6049 }
5956 6050
5957 6051
5958 #undef __ 6052 #undef __
5959 6053
5960 } } // namespace v8::internal 6054 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698