Index: src/ppc/lithium-codegen-ppc.cc |
diff --git a/src/ppc/lithium-codegen-ppc.cc b/src/ppc/lithium-codegen-ppc.cc |
index 2f2871703e059318abfb951c3747ae7dfc7ad6b0..f3d9c825055c939e9ac9b5dc3116dedba3aa276f 100644 |
--- a/src/ppc/lithium-codegen-ppc.cc |
+++ b/src/ppc/lithium-codegen-ppc.cc |
@@ -4768,6 +4768,99 @@ void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { |
} |
+void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) { |
+ class DeferredMaybeGrowElements final : public LDeferredCode { |
+ public: |
+ DeferredMaybeGrowElements(LCodeGen* codegen, LMaybeGrowElements* instr) |
+ : LDeferredCode(codegen), instr_(instr) {} |
+ void Generate() override { codegen()->DoDeferredMaybeGrowElements(instr_); } |
+ LInstruction* instr() override { return instr_; } |
+ |
+ private: |
+ LMaybeGrowElements* instr_; |
+ }; |
+ |
+ Register result = r3; |
+ DeferredMaybeGrowElements* deferred = |
+ new (zone()) DeferredMaybeGrowElements(this, instr); |
+ LOperand* key = instr->key(); |
+ LOperand* current_capacity = instr->current_capacity(); |
+ |
+ DCHECK(instr->hydrogen()->key()->representation().IsInteger32()); |
+ DCHECK(instr->hydrogen()->current_capacity()->representation().IsInteger32()); |
+ DCHECK(key->IsConstantOperand() || key->IsRegister()); |
+ DCHECK(current_capacity->IsConstantOperand() || |
+ current_capacity->IsRegister()); |
+ |
+ if (key->IsConstantOperand() && current_capacity->IsConstantOperand()) { |
+ int32_t constant_key = ToInteger32(LConstantOperand::cast(key)); |
+ int32_t constant_capacity = |
+ ToInteger32(LConstantOperand::cast(current_capacity)); |
+ if (constant_key >= constant_capacity) { |
+ // Deferred case. |
+ __ b(deferred->entry()); |
+ } |
+ } else if (key->IsConstantOperand()) { |
+ int32_t constant_key = ToInteger32(LConstantOperand::cast(key)); |
+ __ Cmpwi(ToRegister(current_capacity), Operand(constant_key), r0); |
+ __ ble(deferred->entry()); |
+ } else if (current_capacity->IsConstantOperand()) { |
+ int32_t constant_capacity = |
+ ToInteger32(LConstantOperand::cast(current_capacity)); |
+ __ Cmpwi(ToRegister(key), Operand(constant_capacity), r0); |
+ __ bge(deferred->entry()); |
+ } else { |
+ __ cmpw(ToRegister(key), ToRegister(current_capacity)); |
+ __ bge(deferred->entry()); |
+ } |
+ |
+ if (instr->elements()->IsRegister()) { |
+ __ Move(result, ToRegister(instr->elements())); |
+ } else { |
+ __ LoadP(result, ToMemOperand(instr->elements())); |
+ } |
+ |
+ __ bind(deferred->exit()); |
+} |
+ |
+ |
+void LCodeGen::DoDeferredMaybeGrowElements(LMaybeGrowElements* instr) { |
+ // TODO(3095996): Get rid of this. For now, we need to make the |
+ // result register contain a valid pointer because it is already |
+ // contained in the register pointer map. |
+ Register result = r3; |
+ __ li(result, Operand::Zero()); |
+ |
+ // We have to call a stub. |
+ { |
+ PushSafepointRegistersScope scope(this); |
+ if (instr->object()->IsRegister()) { |
+ __ Move(result, ToRegister(instr->object())); |
+ } else { |
+ __ LoadP(result, ToMemOperand(instr->object())); |
+ } |
+ |
+ LOperand* key = instr->key(); |
+ if (key->IsConstantOperand()) { |
+ __ LoadSmiLiteral(r6, ToSmi(LConstantOperand::cast(key))); |
+ } else { |
+ __ SmiTag(r6, ToRegister(key)); |
+ } |
+ |
+ GrowArrayElementsStub stub(isolate(), instr->hydrogen()->is_js_array(), |
+ instr->hydrogen()->kind()); |
+ __ CallStub(&stub); |
+ RecordSafepointWithLazyDeopt( |
+ instr, RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); |
+ __ StoreToSafepointRegisterSlot(result, result); |
+ } |
+ |
+ // Deopt on smi, which means the elements array changed to dictionary mode. |
+ __ TestIfSmi(result, r0); |
+ DeoptimizeIf(eq, instr, Deoptimizer::kSmi, cr0); |
+} |
+ |
+ |
void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) { |
Register object_reg = ToRegister(instr->object()); |
Register scratch = scratch0(); |