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

Side by Side Diff: src/mips/lithium-codegen-mips.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/mips/lithium-codegen-mips.h ('k') | src/mips/lithium-mips.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.7 1 // Copyright 2012 the V8 project authors. All rights reserved.7
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4467 matching lines...) Expand 10 before | Expand all | Expand 10 after
4478 DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); 4478 DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister()));
4479 DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); 4479 DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister()));
4480 4480
4481 Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( 4481 Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode(
4482 isolate(), instr->language_mode(), 4482 isolate(), instr->language_mode(),
4483 instr->hydrogen()->initialization_state()).code(); 4483 instr->hydrogen()->initialization_state()).code();
4484 CallCode(ic, RelocInfo::CODE_TARGET, instr); 4484 CallCode(ic, RelocInfo::CODE_TARGET, instr);
4485 } 4485 }
4486 4486
4487 4487
4488 void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) {
4489 class DeferredMaybeGrowElements final : public LDeferredCode {
4490 public:
4491 DeferredMaybeGrowElements(LCodeGen* codegen, LMaybeGrowElements* instr)
4492 : LDeferredCode(codegen), instr_(instr) {}
4493 void Generate() override { codegen()->DoDeferredMaybeGrowElements(instr_); }
4494 LInstruction* instr() override { return instr_; }
4495
4496 private:
4497 LMaybeGrowElements* instr_;
4498 };
4499
4500 Register result = v0;
4501 DeferredMaybeGrowElements* deferred =
4502 new (zone()) DeferredMaybeGrowElements(this, instr);
4503 LOperand* key = instr->key();
4504 LOperand* current_capacity = instr->current_capacity();
4505
4506 DCHECK(instr->hydrogen()->key()->representation().IsInteger32());
4507 DCHECK(instr->hydrogen()->current_capacity()->representation().IsInteger32());
4508 DCHECK(key->IsConstantOperand() || key->IsRegister());
4509 DCHECK(current_capacity->IsConstantOperand() ||
4510 current_capacity->IsRegister());
4511
4512 if (key->IsConstantOperand() && current_capacity->IsConstantOperand()) {
4513 int32_t constant_key = ToInteger32(LConstantOperand::cast(key));
4514 int32_t constant_capacity =
4515 ToInteger32(LConstantOperand::cast(current_capacity));
4516 if (constant_key >= constant_capacity) {
4517 // Deferred case.
4518 __ jmp(deferred->entry());
4519 }
4520 } else if (key->IsConstantOperand()) {
4521 int32_t constant_key = ToInteger32(LConstantOperand::cast(key));
4522 __ Branch(deferred->entry(), le, ToRegister(current_capacity),
4523 Operand(constant_key));
4524 } else if (current_capacity->IsConstantOperand()) {
4525 int32_t constant_capacity =
4526 ToInteger32(LConstantOperand::cast(current_capacity));
4527 __ Branch(deferred->entry(), ge, ToRegister(key),
4528 Operand(constant_capacity));
4529 } else {
4530 __ Branch(deferred->entry(), ge, ToRegister(key),
4531 Operand(ToRegister(current_capacity)));
4532 }
4533
4534 if (instr->elements()->IsRegister()) {
4535 __ mov(result, ToRegister(instr->elements()));
4536 } else {
4537 __ lw(result, ToMemOperand(instr->elements()));
4538 }
4539
4540 __ bind(deferred->exit());
4541 }
4542
4543
4544 void LCodeGen::DoDeferredMaybeGrowElements(LMaybeGrowElements* instr) {
4545 // TODO(3095996): Get rid of this. For now, we need to make the
4546 // result register contain a valid pointer because it is already
4547 // contained in the register pointer map.
4548 Register result = v0;
4549 __ mov(result, zero_reg);
4550
4551 // We have to call a stub.
4552 {
4553 PushSafepointRegistersScope scope(this);
4554 if (instr->object()->IsRegister()) {
4555 __ mov(result, ToRegister(instr->object()));
4556 } else {
4557 __ lw(result, ToMemOperand(instr->object()));
4558 }
4559
4560 LOperand* key = instr->key();
4561 if (key->IsConstantOperand()) {
4562 __ li(a3, Operand(ToSmi(LConstantOperand::cast(key))));
4563 } else {
4564 __ mov(a3, ToRegister(key));
4565 __ SmiTag(a3);
4566 }
4567
4568 GrowArrayElementsStub stub(isolate(), instr->hydrogen()->is_js_array(),
4569 instr->hydrogen()->kind());
4570 __ mov(a0, result);
4571 __ CallStub(&stub);
4572 RecordSafepointWithLazyDeopt(
4573 instr, RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS);
4574 __ StoreToSafepointRegisterSlot(result, result);
4575 }
4576
4577 // Deoptimize if we got a smi back.
4578 __ SmiTst(result, at);
4579 DeoptimizeIf(eq, instr, Deoptimizer::kSmi, at, Operand(zero_reg));
4580 }
4581
4582
4488 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) { 4583 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) {
4489 Register object_reg = ToRegister(instr->object()); 4584 Register object_reg = ToRegister(instr->object());
4490 Register scratch = scratch0(); 4585 Register scratch = scratch0();
4491 4586
4492 Handle<Map> from_map = instr->original_map(); 4587 Handle<Map> from_map = instr->original_map();
4493 Handle<Map> to_map = instr->transitioned_map(); 4588 Handle<Map> to_map = instr->transitioned_map();
4494 ElementsKind from_kind = instr->from_kind(); 4589 ElementsKind from_kind = instr->from_kind();
4495 ElementsKind to_kind = instr->to_kind(); 4590 ElementsKind to_kind = instr->to_kind();
4496 4591
4497 Label not_applicable; 4592 Label not_applicable;
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after
6000 __ li(at, scope_info); 6095 __ li(at, scope_info);
6001 __ Push(at, ToRegister(instr->function())); 6096 __ Push(at, ToRegister(instr->function()));
6002 CallRuntime(Runtime::kPushBlockContext, 2, instr); 6097 CallRuntime(Runtime::kPushBlockContext, 2, instr);
6003 RecordSafepoint(Safepoint::kNoLazyDeopt); 6098 RecordSafepoint(Safepoint::kNoLazyDeopt);
6004 } 6099 }
6005 6100
6006 6101
6007 #undef __ 6102 #undef __
6008 6103
6009 } } // namespace v8::internal 6104 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/lithium-codegen-mips.h ('k') | src/mips/lithium-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698