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

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