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

Side by Side Diff: src/ia32/lithium-codegen-ia32.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/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.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. 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 #if V8_TARGET_ARCH_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
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 4345 matching lines...) Expand 10 before | Expand all | Expand 10 after
4356 void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) { 4356 void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) {
4357 Register object = ToRegister(instr->object()); 4357 Register object = ToRegister(instr->object());
4358 Register temp = ToRegister(instr->temp()); 4358 Register temp = ToRegister(instr->temp());
4359 Label no_memento_found; 4359 Label no_memento_found;
4360 __ TestJSArrayForAllocationMemento(object, temp, &no_memento_found); 4360 __ TestJSArrayForAllocationMemento(object, temp, &no_memento_found);
4361 DeoptimizeIf(equal, instr, Deoptimizer::kMementoFound); 4361 DeoptimizeIf(equal, instr, Deoptimizer::kMementoFound);
4362 __ bind(&no_memento_found); 4362 __ bind(&no_memento_found);
4363 } 4363 }
4364 4364
4365 4365
4366 void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) {
4367 class DeferredMaybeGrowElements final : public LDeferredCode {
4368 public:
4369 DeferredMaybeGrowElements(LCodeGen* codegen, LMaybeGrowElements* instr)
4370 : LDeferredCode(codegen), instr_(instr) {}
4371 void Generate() override { codegen()->DoDeferredMaybeGrowElements(instr_); }
4372 LInstruction* instr() override { return instr_; }
4373
4374 private:
4375 LMaybeGrowElements* instr_;
4376 };
4377
4378 Register result = eax;
4379 DeferredMaybeGrowElements* deferred =
4380 new (zone()) DeferredMaybeGrowElements(this, instr);
4381 LOperand* key = instr->key();
4382 LOperand* current_capacity = instr->current_capacity();
4383
4384 DCHECK(instr->hydrogen()->key()->representation().IsInteger32());
4385 DCHECK(instr->hydrogen()->current_capacity()->representation().IsInteger32());
4386 DCHECK(key->IsConstantOperand() || key->IsRegister());
4387 DCHECK(current_capacity->IsConstantOperand() ||
4388 current_capacity->IsRegister());
4389
4390 if (key->IsConstantOperand() && current_capacity->IsConstantOperand()) {
4391 int32_t constant_key = ToInteger32(LConstantOperand::cast(key));
4392 int32_t constant_capacity =
4393 ToInteger32(LConstantOperand::cast(current_capacity));
4394 if (constant_key >= constant_capacity) {
4395 // Deferred case.
4396 __ jmp(deferred->entry());
4397 }
4398 } else if (key->IsConstantOperand()) {
4399 int32_t constant_key = ToInteger32(LConstantOperand::cast(key));
4400 __ cmp(ToOperand(current_capacity), Immediate(constant_key));
4401 __ j(less_equal, deferred->entry());
4402 } else if (current_capacity->IsConstantOperand()) {
4403 int32_t constant_capacity =
4404 ToInteger32(LConstantOperand::cast(current_capacity));
4405 __ cmp(ToRegister(key), Immediate(constant_capacity));
4406 __ j(greater_equal, deferred->entry());
4407 } else {
4408 __ cmp(ToRegister(key), ToRegister(current_capacity));
4409 __ j(greater_equal, deferred->entry());
4410 }
4411
4412 __ mov(result, ToOperand(instr->elements()));
4413 __ bind(deferred->exit());
4414 }
4415
4416
4417 void LCodeGen::DoDeferredMaybeGrowElements(LMaybeGrowElements* instr) {
4418 // TODO(3095996): Get rid of this. For now, we need to make the
4419 // result register contain a valid pointer because it is already
4420 // contained in the register pointer map.
4421 Register result = eax;
4422 __ Move(result, Immediate(0));
4423
4424 // We have to call a stub.
4425 {
4426 PushSafepointRegistersScope scope(this);
4427 if (instr->object()->IsRegister()) {
4428 __ Move(result, ToRegister(instr->object()));
4429 } else {
4430 __ mov(result, ToOperand(instr->object()));
4431 }
4432
4433 LOperand* key = instr->key();
4434 if (key->IsConstantOperand()) {
4435 __ mov(ebx, ToImmediate(key, Representation::Smi()));
4436 } else {
4437 __ Move(ebx, ToRegister(key));
4438 __ SmiTag(ebx);
4439 }
4440
4441 GrowArrayElementsStub stub(isolate(), instr->hydrogen()->is_js_array(),
4442 instr->hydrogen()->kind());
4443 __ CallStub(&stub);
4444 RecordSafepointWithLazyDeopt(
4445 instr, RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS);
4446 __ StoreToSafepointRegisterSlot(result, result);
4447 }
4448
4449 // Deopt on smi, which means the elements array changed to dictionary mode.
4450 __ test(result, Immediate(kSmiTagMask));
4451 DeoptimizeIf(equal, instr, Deoptimizer::kSmi);
4452 }
4453
4454
4366 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) { 4455 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) {
4367 Register object_reg = ToRegister(instr->object()); 4456 Register object_reg = ToRegister(instr->object());
4368 4457
4369 Handle<Map> from_map = instr->original_map(); 4458 Handle<Map> from_map = instr->original_map();
4370 Handle<Map> to_map = instr->transitioned_map(); 4459 Handle<Map> to_map = instr->transitioned_map();
4371 ElementsKind from_kind = instr->from_kind(); 4460 ElementsKind from_kind = instr->from_kind();
4372 ElementsKind to_kind = instr->to_kind(); 4461 ElementsKind to_kind = instr->to_kind();
4373 4462
4374 Label not_applicable; 4463 Label not_applicable;
4375 bool is_simple_map_transition = 4464 bool is_simple_map_transition =
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after
5775 CallRuntime(Runtime::kPushBlockContext, 2, instr); 5864 CallRuntime(Runtime::kPushBlockContext, 2, instr);
5776 RecordSafepoint(Safepoint::kNoLazyDeopt); 5865 RecordSafepoint(Safepoint::kNoLazyDeopt);
5777 } 5866 }
5778 5867
5779 5868
5780 #undef __ 5869 #undef __
5781 5870
5782 } } // namespace v8::internal 5871 } } // namespace v8::internal
5783 5872
5784 #endif // V8_TARGET_ARCH_IA32 5873 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698