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

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

Powered by Google App Engine
This is Rietveld 408576698