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

Side by Side Diff: src/mips64/lithium-codegen-mips64.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. 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
« no previous file with comments | « src/mips64/lithium-codegen-mips64.h ('k') | src/mips64/lithium-mips64.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/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/cpu-profiler.h" 9 #include "src/cpu-profiler.h"
10 #include "src/hydrogen-osr.h" 10 #include "src/hydrogen-osr.h"
(...skipping 4562 matching lines...) Expand 10 before | Expand all | Expand 10 after
4573 DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); 4573 DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister()));
4574 DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); 4574 DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister()));
4575 4575
4576 Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( 4576 Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode(
4577 isolate(), instr->language_mode(), 4577 isolate(), instr->language_mode(),
4578 instr->hydrogen()->initialization_state()).code(); 4578 instr->hydrogen()->initialization_state()).code();
4579 CallCode(ic, RelocInfo::CODE_TARGET, instr); 4579 CallCode(ic, RelocInfo::CODE_TARGET, instr);
4580 } 4580 }
4581 4581
4582 4582
4583 void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) {
4584 class DeferredMaybeGrowElements final : public LDeferredCode {
4585 public:
4586 DeferredMaybeGrowElements(LCodeGen* codegen, LMaybeGrowElements* instr)
4587 : LDeferredCode(codegen), instr_(instr) {}
4588 void Generate() override { codegen()->DoDeferredMaybeGrowElements(instr_); }
4589 LInstruction* instr() override { return instr_; }
4590
4591 private:
4592 LMaybeGrowElements* instr_;
4593 };
4594
4595 Register result = v0;
4596 DeferredMaybeGrowElements* deferred =
4597 new (zone()) DeferredMaybeGrowElements(this, instr);
4598 LOperand* key = instr->key();
4599 LOperand* current_capacity = instr->current_capacity();
4600
4601 DCHECK(instr->hydrogen()->key()->representation().IsInteger32());
4602 DCHECK(instr->hydrogen()->current_capacity()->representation().IsInteger32());
4603 DCHECK(key->IsConstantOperand() || key->IsRegister());
4604 DCHECK(current_capacity->IsConstantOperand() ||
4605 current_capacity->IsRegister());
4606
4607 if (key->IsConstantOperand() && current_capacity->IsConstantOperand()) {
4608 int32_t constant_key = ToInteger32(LConstantOperand::cast(key));
4609 int32_t constant_capacity =
4610 ToInteger32(LConstantOperand::cast(current_capacity));
4611 if (constant_key >= constant_capacity) {
4612 // Deferred case.
4613 __ jmp(deferred->entry());
4614 }
4615 } else if (key->IsConstantOperand()) {
4616 int32_t constant_key = ToInteger32(LConstantOperand::cast(key));
4617 __ Branch(deferred->entry(), le, ToRegister(current_capacity),
4618 Operand(constant_key));
4619 } else if (current_capacity->IsConstantOperand()) {
4620 int32_t constant_capacity =
4621 ToInteger32(LConstantOperand::cast(current_capacity));
4622 __ Branch(deferred->entry(), ge, ToRegister(key),
4623 Operand(constant_capacity));
4624 } else {
4625 __ Branch(deferred->entry(), ge, ToRegister(key),
4626 Operand(ToRegister(current_capacity)));
4627 }
4628
4629 if (instr->elements()->IsRegister()) {
4630 __ mov(result, ToRegister(instr->elements()));
4631 } else {
4632 __ ld(result, ToMemOperand(instr->elements()));
4633 }
4634
4635 __ bind(deferred->exit());
4636 }
4637
4638
4639 void LCodeGen::DoDeferredMaybeGrowElements(LMaybeGrowElements* instr) {
4640 // TODO(3095996): Get rid of this. For now, we need to make the
4641 // result register contain a valid pointer because it is already
4642 // contained in the register pointer map.
4643 Register result = v0;
4644 __ mov(result, zero_reg);
4645
4646 // We have to call a stub.
4647 {
4648 PushSafepointRegistersScope scope(this);
4649 if (instr->object()->IsRegister()) {
4650 __ mov(result, ToRegister(instr->object()));
4651 } else {
4652 __ ld(result, ToMemOperand(instr->object()));
4653 }
4654
4655 LOperand* key = instr->key();
4656 if (key->IsConstantOperand()) {
4657 __ li(a3, Operand(ToSmi(LConstantOperand::cast(key))));
4658 } else {
4659 __ mov(a3, ToRegister(key));
4660 __ SmiTag(a3);
4661 }
4662
4663 GrowArrayElementsStub stub(isolate(), instr->hydrogen()->is_js_array(),
4664 instr->hydrogen()->kind());
4665 __ mov(a0, result);
4666 __ CallStub(&stub);
4667 RecordSafepointWithLazyDeopt(
4668 instr, RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS);
4669 __ StoreToSafepointRegisterSlot(result, result);
4670 }
4671
4672 // Deopt on smi, which means the elements array changed to dictionary mode.
4673 __ SmiTst(result, at);
4674 DeoptimizeIf(eq, instr, Deoptimizer::kSmi, at, Operand(zero_reg));
4675 }
4676
4677
4583 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) { 4678 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) {
4584 Register object_reg = ToRegister(instr->object()); 4679 Register object_reg = ToRegister(instr->object());
4585 Register scratch = scratch0(); 4680 Register scratch = scratch0();
4586 4681
4587 Handle<Map> from_map = instr->original_map(); 4682 Handle<Map> from_map = instr->original_map();
4588 Handle<Map> to_map = instr->transitioned_map(); 4683 Handle<Map> to_map = instr->transitioned_map();
4589 ElementsKind from_kind = instr->from_kind(); 4684 ElementsKind from_kind = instr->from_kind();
4590 ElementsKind to_kind = instr->to_kind(); 4685 ElementsKind to_kind = instr->to_kind();
4591 4686
4592 Label not_applicable; 4687 Label not_applicable;
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after
6062 __ li(at, scope_info); 6157 __ li(at, scope_info);
6063 __ Push(at, ToRegister(instr->function())); 6158 __ Push(at, ToRegister(instr->function()));
6064 CallRuntime(Runtime::kPushBlockContext, 2, instr); 6159 CallRuntime(Runtime::kPushBlockContext, 2, instr);
6065 RecordSafepoint(Safepoint::kNoLazyDeopt); 6160 RecordSafepoint(Safepoint::kNoLazyDeopt);
6066 } 6161 }
6067 6162
6068 6163
6069 #undef __ 6164 #undef __
6070 6165
6071 } } // namespace v8::internal 6166 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips64/lithium-codegen-mips64.h ('k') | src/mips64/lithium-mips64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698