OLD | NEW |
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_X87 | 7 #if V8_TARGET_ARCH_X87 |
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 4797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4808 void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) { | 4808 void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) { |
4809 Register object = ToRegister(instr->object()); | 4809 Register object = ToRegister(instr->object()); |
4810 Register temp = ToRegister(instr->temp()); | 4810 Register temp = ToRegister(instr->temp()); |
4811 Label no_memento_found; | 4811 Label no_memento_found; |
4812 __ TestJSArrayForAllocationMemento(object, temp, &no_memento_found); | 4812 __ TestJSArrayForAllocationMemento(object, temp, &no_memento_found); |
4813 DeoptimizeIf(equal, instr, Deoptimizer::kMementoFound); | 4813 DeoptimizeIf(equal, instr, Deoptimizer::kMementoFound); |
4814 __ bind(&no_memento_found); | 4814 __ bind(&no_memento_found); |
4815 } | 4815 } |
4816 | 4816 |
4817 | 4817 |
| 4818 void LCodeGen::DoMaybeGrowElements(LMaybeGrowElements* instr) { |
| 4819 class DeferredMaybeGrowElements final : public LDeferredCode { |
| 4820 public: |
| 4821 DeferredMaybeGrowElements(LCodeGen* codegen, |
| 4822 LMaybeGrowElements* instr, |
| 4823 const X87Stack& x87_stack) |
| 4824 : LDeferredCode(codegen, x87_stack), instr_(instr) {} |
| 4825 void Generate() override { codegen()->DoDeferredMaybeGrowElements(instr_); } |
| 4826 LInstruction* instr() override { return instr_; } |
| 4827 |
| 4828 private: |
| 4829 LMaybeGrowElements* instr_; |
| 4830 }; |
| 4831 |
| 4832 Register result = eax; |
| 4833 DeferredMaybeGrowElements* deferred = |
| 4834 new (zone()) DeferredMaybeGrowElements(this, instr, x87_stack_); |
| 4835 LOperand* key = instr->key(); |
| 4836 LOperand* current_capacity = instr->current_capacity(); |
| 4837 |
| 4838 DCHECK(instr->hydrogen()->key()->representation().IsInteger32()); |
| 4839 DCHECK(instr->hydrogen()->current_capacity()->representation().IsInteger32()); |
| 4840 DCHECK(key->IsConstantOperand() || key->IsRegister()); |
| 4841 DCHECK(current_capacity->IsConstantOperand() || |
| 4842 current_capacity->IsRegister()); |
| 4843 |
| 4844 if (key->IsConstantOperand() && current_capacity->IsConstantOperand()) { |
| 4845 int32_t constant_key = ToInteger32(LConstantOperand::cast(key)); |
| 4846 int32_t constant_capacity = |
| 4847 ToInteger32(LConstantOperand::cast(current_capacity)); |
| 4848 if (constant_key >= constant_capacity) { |
| 4849 // Deferred case. |
| 4850 __ jmp(deferred->entry()); |
| 4851 } |
| 4852 } else if (key->IsConstantOperand()) { |
| 4853 int32_t constant_key = ToInteger32(LConstantOperand::cast(key)); |
| 4854 __ cmp(ToOperand(current_capacity), Immediate(constant_key)); |
| 4855 __ j(less_equal, deferred->entry()); |
| 4856 } else if (current_capacity->IsConstantOperand()) { |
| 4857 int32_t constant_capacity = |
| 4858 ToInteger32(LConstantOperand::cast(current_capacity)); |
| 4859 __ cmp(ToRegister(key), Immediate(constant_capacity)); |
| 4860 __ j(greater_equal, deferred->entry()); |
| 4861 } else { |
| 4862 __ cmp(ToRegister(key), ToRegister(current_capacity)); |
| 4863 __ j(greater_equal, deferred->entry()); |
| 4864 } |
| 4865 |
| 4866 __ mov(result, ToOperand(instr->elements())); |
| 4867 __ bind(deferred->exit()); |
| 4868 } |
| 4869 |
| 4870 |
| 4871 void LCodeGen::DoDeferredMaybeGrowElements(LMaybeGrowElements* instr) { |
| 4872 // TODO(3095996): Get rid of this. For now, we need to make the |
| 4873 // result register contain a valid pointer because it is already |
| 4874 // contained in the register pointer map. |
| 4875 Register result = eax; |
| 4876 __ Move(result, Immediate(0)); |
| 4877 |
| 4878 // We have to call a stub. |
| 4879 { |
| 4880 PushSafepointRegistersScope scope(this); |
| 4881 if (instr->object()->IsRegister()) { |
| 4882 __ Move(result, ToRegister(instr->object())); |
| 4883 } else { |
| 4884 __ mov(result, ToOperand(instr->object())); |
| 4885 } |
| 4886 |
| 4887 LOperand* key = instr->key(); |
| 4888 if (key->IsConstantOperand()) { |
| 4889 __ mov(ebx, ToImmediate(key, Representation::Smi())); |
| 4890 } else { |
| 4891 __ Move(ebx, ToRegister(key)); |
| 4892 __ SmiTag(ebx); |
| 4893 } |
| 4894 |
| 4895 GrowArrayElementsStub stub(isolate(), instr->hydrogen()->is_js_array(), |
| 4896 instr->hydrogen()->kind()); |
| 4897 __ CallStub(&stub); |
| 4898 RecordSafepointWithLazyDeopt( |
| 4899 instr, RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); |
| 4900 __ StoreToSafepointRegisterSlot(result, result); |
| 4901 } |
| 4902 |
| 4903 // Deopt on smi, which means the elements array changed to dictionary mode. |
| 4904 __ test(result, Immediate(kSmiTagMask)); |
| 4905 DeoptimizeIf(equal, instr, Deoptimizer::kSmi); |
| 4906 } |
| 4907 |
| 4908 |
4818 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) { | 4909 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) { |
4819 Register object_reg = ToRegister(instr->object()); | 4910 Register object_reg = ToRegister(instr->object()); |
4820 | 4911 |
4821 Handle<Map> from_map = instr->original_map(); | 4912 Handle<Map> from_map = instr->original_map(); |
4822 Handle<Map> to_map = instr->transitioned_map(); | 4913 Handle<Map> to_map = instr->transitioned_map(); |
4823 ElementsKind from_kind = instr->from_kind(); | 4914 ElementsKind from_kind = instr->from_kind(); |
4824 ElementsKind to_kind = instr->to_kind(); | 4915 ElementsKind to_kind = instr->to_kind(); |
4825 | 4916 |
4826 Label not_applicable; | 4917 Label not_applicable; |
4827 bool is_simple_map_transition = | 4918 bool is_simple_map_transition = |
(...skipping 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6383 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6474 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6384 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6475 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6385 } | 6476 } |
6386 | 6477 |
6387 | 6478 |
6388 #undef __ | 6479 #undef __ |
6389 | 6480 |
6390 } } // namespace v8::internal | 6481 } } // namespace v8::internal |
6391 | 6482 |
6392 #endif // V8_TARGET_ARCH_X87 | 6483 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |