OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #include "src/arm64/lithium-codegen-arm64.h" | 7 #include "src/arm64/lithium-codegen-arm64.h" |
8 #include "src/arm64/lithium-gap-resolver-arm64.h" | 8 #include "src/arm64/lithium-gap-resolver-arm64.h" |
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 5312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5323 DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); | 5323 DCHECK(ToRegister(instr->key()).is(StoreDescriptor::NameRegister())); |
5324 DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); | 5324 DCHECK(ToRegister(instr->value()).is(StoreDescriptor::ValueRegister())); |
5325 | 5325 |
5326 Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( | 5326 Handle<Code> ic = CodeFactory::KeyedStoreICInOptimizedCode( |
5327 isolate(), instr->language_mode(), | 5327 isolate(), instr->language_mode(), |
5328 instr->hydrogen()->initialization_state()).code(); | 5328 instr->hydrogen()->initialization_state()).code(); |
5329 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 5329 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
5330 } | 5330 } |
5331 | 5331 |
5332 | 5332 |
| 5333 void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) { |
| 5334 class DeferredMaybeGrowElements final : public LDeferredCode { |
| 5335 public: |
| 5336 DeferredMaybeGrowElements(LCodeGen* codegen, LMaybeGrowElements* instr) |
| 5337 : LDeferredCode(codegen), instr_(instr) {} |
| 5338 void Generate() override { codegen()->DoDeferredMaybeGrowElements(instr_); } |
| 5339 LInstruction* instr() override { return instr_; } |
| 5340 |
| 5341 private: |
| 5342 LMaybeGrowElements* instr_; |
| 5343 }; |
| 5344 |
| 5345 Register result = x0; |
| 5346 DeferredMaybeGrowElements* deferred = |
| 5347 new (zone()) DeferredMaybeGrowElements(this, instr); |
| 5348 LOperand* key = instr->key(); |
| 5349 LOperand* current_capacity = instr->current_capacity(); |
| 5350 |
| 5351 DCHECK(instr->hydrogen()->key()->representation().IsInteger32()); |
| 5352 DCHECK(instr->hydrogen()->current_capacity()->representation().IsInteger32()); |
| 5353 DCHECK(key->IsConstantOperand() || key->IsRegister()); |
| 5354 DCHECK(current_capacity->IsConstantOperand() || |
| 5355 current_capacity->IsRegister()); |
| 5356 |
| 5357 if (key->IsConstantOperand() && current_capacity->IsConstantOperand()) { |
| 5358 int32_t constant_key = ToInteger32(LConstantOperand::cast(key)); |
| 5359 int32_t constant_capacity = |
| 5360 ToInteger32(LConstantOperand::cast(current_capacity)); |
| 5361 if (constant_key >= constant_capacity) { |
| 5362 // Deferred case. |
| 5363 __ B(deferred->entry()); |
| 5364 } |
| 5365 } else if (key->IsConstantOperand()) { |
| 5366 int32_t constant_key = ToInteger32(LConstantOperand::cast(key)); |
| 5367 __ Cmp(ToRegister(current_capacity), Operand(constant_key)); |
| 5368 __ B(le, deferred->entry()); |
| 5369 } else if (current_capacity->IsConstantOperand()) { |
| 5370 int32_t constant_capacity = |
| 5371 ToInteger32(LConstantOperand::cast(current_capacity)); |
| 5372 __ Cmp(ToRegister(key), Operand(constant_capacity)); |
| 5373 __ B(ge, deferred->entry()); |
| 5374 } else { |
| 5375 __ Cmp(ToRegister(key), ToRegister(current_capacity)); |
| 5376 __ B(ge, deferred->entry()); |
| 5377 } |
| 5378 |
| 5379 __ Mov(result, ToRegister(instr->elements())); |
| 5380 |
| 5381 __ Bind(deferred->exit()); |
| 5382 } |
| 5383 |
| 5384 |
| 5385 void LCodeGen::DoDeferredMaybeGrowElements(LMaybeGrowElements* instr) { |
| 5386 // TODO(3095996): Get rid of this. For now, we need to make the |
| 5387 // result register contain a valid pointer because it is already |
| 5388 // contained in the register pointer map. |
| 5389 Register result = x0; |
| 5390 __ Mov(result, 0); |
| 5391 |
| 5392 // We have to call a stub. |
| 5393 { |
| 5394 PushSafepointRegistersScope scope(this); |
| 5395 __ Move(result, ToRegister(instr->object())); |
| 5396 |
| 5397 LOperand* key = instr->key(); |
| 5398 if (key->IsConstantOperand()) { |
| 5399 __ Mov(x3, Operand(ToSmi(LConstantOperand::cast(key)))); |
| 5400 } else { |
| 5401 __ Mov(x3, ToRegister(key)); |
| 5402 __ SmiTag(x3); |
| 5403 } |
| 5404 |
| 5405 GrowArrayElementsStub stub(isolate(), instr->hydrogen()->is_js_array(), |
| 5406 instr->hydrogen()->kind()); |
| 5407 __ CallStub(&stub); |
| 5408 RecordSafepointWithLazyDeopt( |
| 5409 instr, RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); |
| 5410 __ StoreToSafepointRegisterSlot(result, result); |
| 5411 } |
| 5412 |
| 5413 // Deopt on smi, which means the elements array changed to dictionary mode. |
| 5414 DeoptimizeIfSmi(result, instr, Deoptimizer::kSmi); |
| 5415 } |
| 5416 |
| 5417 |
5333 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { | 5418 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { |
5334 Representation representation = instr->representation(); | 5419 Representation representation = instr->representation(); |
5335 | 5420 |
5336 Register object = ToRegister(instr->object()); | 5421 Register object = ToRegister(instr->object()); |
5337 HObjectAccess access = instr->hydrogen()->access(); | 5422 HObjectAccess access = instr->hydrogen()->access(); |
5338 int offset = access.offset(); | 5423 int offset = access.offset(); |
5339 | 5424 |
5340 if (access.IsExternalMemory()) { | 5425 if (access.IsExternalMemory()) { |
5341 DCHECK(!instr->hydrogen()->has_transition()); | 5426 DCHECK(!instr->hydrogen()->has_transition()); |
5342 DCHECK(!instr->hydrogen()->NeedsWriteBarrier()); | 5427 DCHECK(!instr->hydrogen()->NeedsWriteBarrier()); |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6050 Handle<ScopeInfo> scope_info = instr->scope_info(); | 6135 Handle<ScopeInfo> scope_info = instr->scope_info(); |
6051 __ Push(scope_info); | 6136 __ Push(scope_info); |
6052 __ Push(ToRegister(instr->function())); | 6137 __ Push(ToRegister(instr->function())); |
6053 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6138 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6054 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6139 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6055 } | 6140 } |
6056 | 6141 |
6057 | 6142 |
6058 | 6143 |
6059 } } // namespace v8::internal | 6144 } } // namespace v8::internal |
OLD | NEW |