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

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: ia32 and x64 done. 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()->IsConstantOperand()) {
4427 LConstantOperand* constant_object =
4428 LConstantOperand::cast(instr->object());
4429 if (IsSmi(constant_object)) {
4430 Immediate immediate =
4431 ToImmediate(constant_object, Representation::Smi());
4432 __ mov(result, immediate);
4433 } else {
4434 Handle<Object> handle_value = ToHandle(constant_object);
4435 __ mov(result, handle_value);
4436 }
4437 } else if (instr->object()->IsRegister()) {
4438 __ Move(result, ToRegister(instr->object()));
4439 } else {
4440 __ mov(result, ToOperand(instr->object()));
4441 }
4442
4443 LOperand* key = instr->key();
4444 if (key->IsConstantOperand()) {
4445 __ mov(ebx, ToImmediate(key, Representation::Smi()));
4446 } else {
4447 __ Move(ebx, ToRegister(key));
4448 __ SmiTag(ebx);
4449 }
4450
4451 GrowArrayElementsStub stub(isolate(), instr->hydrogen()->is_js_array(),
4452 instr->hydrogen()->kind());
4453 __ CallStub(&stub);
4454 RecordSafepointWithLazyDeopt(
4455 instr, RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS);
4456 __ StoreToSafepointRegisterSlot(result, result);
4457 }
4458
4459 // Deoptimize if we got a smi back.
4460 __ test(result, Immediate(kSmiTagMask));
4461 DeoptimizeIf(equal, instr, Deoptimizer::kSmi);
4462 }
4463
4464
4365 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) { 4465 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) {
4366 Register object_reg = ToRegister(instr->object()); 4466 Register object_reg = ToRegister(instr->object());
4367 4467
4368 Handle<Map> from_map = instr->original_map(); 4468 Handle<Map> from_map = instr->original_map();
4369 Handle<Map> to_map = instr->transitioned_map(); 4469 Handle<Map> to_map = instr->transitioned_map();
4370 ElementsKind from_kind = instr->from_kind(); 4470 ElementsKind from_kind = instr->from_kind();
4371 ElementsKind to_kind = instr->to_kind(); 4471 ElementsKind to_kind = instr->to_kind();
4372 4472
4373 Label not_applicable; 4473 Label not_applicable;
4374 bool is_simple_map_transition = 4474 bool is_simple_map_transition =
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after
5771 CallRuntime(Runtime::kPushBlockContext, 2, instr); 5871 CallRuntime(Runtime::kPushBlockContext, 2, instr);
5772 RecordSafepoint(Safepoint::kNoLazyDeopt); 5872 RecordSafepoint(Safepoint::kNoLazyDeopt);
5773 } 5873 }
5774 5874
5775 5875
5776 #undef __ 5876 #undef __
5777 5877
5778 } } // namespace v8::internal 5878 } } // namespace v8::internal
5779 5879
5780 #endif // V8_TARGET_ARCH_IA32 5880 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698