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

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

Issue 1132743004: PPC: 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: 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/ppc/lithium-codegen-ppc.h ('k') | src/ppc/lithium-ppc.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/cpu-profiler.h" 10 #include "src/cpu-profiler.h"
(...skipping 4750 matching lines...) Expand 10 before | Expand all | Expand 10 after
4761 DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); 4761 DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister()));
4762 DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); 4762 DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister()));
4763 4763
4764 Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( 4764 Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode(
4765 isolate(), instr->language_mode(), 4765 isolate(), instr->language_mode(),
4766 instr->hydrogen()->initialization_state()).code(); 4766 instr->hydrogen()->initialization_state()).code();
4767 CallCode(ic, RelocInfo::CODE_TARGET, instr); 4767 CallCode(ic, RelocInfo::CODE_TARGET, instr);
4768 } 4768 }
4769 4769
4770 4770
4771 void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) {
4772 class DeferredMaybeGrowElements final : public LDeferredCode {
4773 public:
4774 DeferredMaybeGrowElements(LCodeGen* codegen, LMaybeGrowElements* instr)
4775 : LDeferredCode(codegen), instr_(instr) {}
4776 void Generate() override { codegen()->DoDeferredMaybeGrowElements(instr_); }
4777 LInstruction* instr() override { return instr_; }
4778
4779 private:
4780 LMaybeGrowElements* instr_;
4781 };
4782
4783 Register result = r3;
4784 DeferredMaybeGrowElements* deferred =
4785 new (zone()) DeferredMaybeGrowElements(this, instr);
4786 LOperand* key = instr->key();
4787 LOperand* current_capacity = instr->current_capacity();
4788
4789 DCHECK(instr->hydrogen()->key()->representation().IsInteger32());
4790 DCHECK(instr->hydrogen()->current_capacity()->representation().IsInteger32());
4791 DCHECK(key->IsConstantOperand() || key->IsRegister());
4792 DCHECK(current_capacity->IsConstantOperand() ||
4793 current_capacity->IsRegister());
4794
4795 if (key->IsConstantOperand() && current_capacity->IsConstantOperand()) {
4796 int32_t constant_key = ToInteger32(LConstantOperand::cast(key));
4797 int32_t constant_capacity =
4798 ToInteger32(LConstantOperand::cast(current_capacity));
4799 if (constant_key >= constant_capacity) {
4800 // Deferred case.
4801 __ b(deferred->entry());
4802 }
4803 } else if (key->IsConstantOperand()) {
4804 int32_t constant_key = ToInteger32(LConstantOperand::cast(key));
4805 __ Cmpwi(ToRegister(current_capacity), Operand(constant_key), r0);
4806 __ ble(deferred->entry());
4807 } else if (current_capacity->IsConstantOperand()) {
4808 int32_t constant_capacity =
4809 ToInteger32(LConstantOperand::cast(current_capacity));
4810 __ Cmpwi(ToRegister(key), Operand(constant_capacity), r0);
4811 __ bge(deferred->entry());
4812 } else {
4813 __ cmpw(ToRegister(key), ToRegister(current_capacity));
4814 __ bge(deferred->entry());
4815 }
4816
4817 if (instr->elements()->IsRegister()) {
4818 __ Move(result, ToRegister(instr->elements()));
4819 } else {
4820 __ LoadP(result, ToMemOperand(instr->elements()));
4821 }
4822
4823 __ bind(deferred->exit());
4824 }
4825
4826
4827 void LCodeGen::DoDeferredMaybeGrowElements(LMaybeGrowElements* instr) {
4828 // TODO(3095996): Get rid of this. For now, we need to make the
4829 // result register contain a valid pointer because it is already
4830 // contained in the register pointer map.
4831 Register result = r3;
4832 __ li(result, Operand::Zero());
4833
4834 // We have to call a stub.
4835 {
4836 PushSafepointRegistersScope scope(this);
4837 if (instr->object()->IsRegister()) {
4838 __ Move(result, ToRegister(instr->object()));
4839 } else {
4840 __ LoadP(result, ToMemOperand(instr->object()));
4841 }
4842
4843 LOperand* key = instr->key();
4844 if (key->IsConstantOperand()) {
4845 __ LoadSmiLiteral(r6, ToSmi(LConstantOperand::cast(key)));
4846 } else {
4847 __ SmiTag(r6, ToRegister(key));
4848 }
4849
4850 GrowArrayElementsStub stub(isolate(), instr->hydrogen()->is_js_array(),
4851 instr->hydrogen()->kind());
4852 __ CallStub(&stub);
4853 RecordSafepointWithLazyDeopt(
4854 instr, RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS);
4855 __ StoreToSafepointRegisterSlot(result, result);
4856 }
4857
4858 // Deopt on smi, which means the elements array changed to dictionary mode.
4859 __ TestIfSmi(result, r0);
4860 DeoptimizeIf(eq, instr, Deoptimizer::kSmi, cr0);
4861 }
4862
4863
4771 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) { 4864 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) {
4772 Register object_reg = ToRegister(instr->object()); 4865 Register object_reg = ToRegister(instr->object());
4773 Register scratch = scratch0(); 4866 Register scratch = scratch0();
4774 4867
4775 Handle<Map> from_map = instr->original_map(); 4868 Handle<Map> from_map = instr->original_map();
4776 Handle<Map> to_map = instr->transitioned_map(); 4869 Handle<Map> to_map = instr->transitioned_map();
4777 ElementsKind from_kind = instr->from_kind(); 4870 ElementsKind from_kind = instr->from_kind();
4778 ElementsKind to_kind = instr->to_kind(); 4871 ElementsKind to_kind = instr->to_kind();
4779 4872
4780 Label not_applicable; 4873 Label not_applicable;
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after
6214 __ Push(scope_info); 6307 __ Push(scope_info);
6215 __ push(ToRegister(instr->function())); 6308 __ push(ToRegister(instr->function()));
6216 CallRuntime(Runtime::kPushBlockContext, 2, instr); 6309 CallRuntime(Runtime::kPushBlockContext, 2, instr);
6217 RecordSafepoint(Safepoint::kNoLazyDeopt); 6310 RecordSafepoint(Safepoint::kNoLazyDeopt);
6218 } 6311 }
6219 6312
6220 6313
6221 #undef __ 6314 #undef __
6222 } 6315 }
6223 } // namespace v8::internal 6316 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ppc/lithium-codegen-ppc.h ('k') | src/ppc/lithium-ppc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698