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

Powered by Google App Engine
This is Rietveld 408576698