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

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

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