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