| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/code-stub-assembler.h" | 5 #include "src/code-stub-assembler.h" |
| 6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
| 7 #include "src/frames-inl.h" | 7 #include "src/frames-inl.h" |
| 8 #include "src/frames.h" | 8 #include "src/frames.h" |
| 9 #include "src/ic/handler-configuration.h" | 9 #include "src/ic/handler-configuration.h" |
| 10 #include "src/ic/stub-cache.h" | 10 #include "src/ic/stub-cache.h" |
| (...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 if_hole); | 1165 if_hole); |
| 1166 } | 1166 } |
| 1167 } | 1167 } |
| 1168 if (machine_type.IsNone()) { | 1168 if (machine_type.IsNone()) { |
| 1169 // This means the actual value is not needed. | 1169 // This means the actual value is not needed. |
| 1170 return nullptr; | 1170 return nullptr; |
| 1171 } | 1171 } |
| 1172 return Load(machine_type, base, offset); | 1172 return Load(machine_type, base, offset); |
| 1173 } | 1173 } |
| 1174 | 1174 |
| 1175 Node* CodeStubAssembler::LoadContextElement(Node* context, int slot_index) { |
| 1176 int offset = Context::SlotOffset(slot_index); |
| 1177 return Load(MachineType::AnyTagged(), context, IntPtrConstant(offset)); |
| 1178 } |
| 1179 |
| 1175 Node* CodeStubAssembler::LoadNativeContext(Node* context) { | 1180 Node* CodeStubAssembler::LoadNativeContext(Node* context) { |
| 1176 return LoadFixedArrayElement(context, | 1181 return LoadContextElement(context, Context::NATIVE_CONTEXT_INDEX); |
| 1177 IntPtrConstant(Context::NATIVE_CONTEXT_INDEX)); | |
| 1178 } | 1182 } |
| 1179 | 1183 |
| 1180 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, | 1184 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, |
| 1181 Node* native_context) { | 1185 Node* native_context) { |
| 1182 return LoadFixedArrayElement(native_context, | 1186 return LoadFixedArrayElement(native_context, |
| 1183 IntPtrConstant(Context::ArrayMapIndex(kind))); | 1187 IntPtrConstant(Context::ArrayMapIndex(kind))); |
| 1184 } | 1188 } |
| 1185 | 1189 |
| 1186 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { | 1190 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { |
| 1187 return StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value, | 1191 return StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value, |
| (...skipping 3239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4427 { | 4431 { |
| 4428 Node* handler = | 4432 Node* handler = |
| 4429 LoadFixedArrayElement(p->vector, p->slot, kPointerSize, SMI_PARAMETERS); | 4433 LoadFixedArrayElement(p->vector, p->slot, kPointerSize, SMI_PARAMETERS); |
| 4430 GotoIf(WordEqual(handler, LoadRoot(Heap::kuninitialized_symbolRootIndex)), | 4434 GotoIf(WordEqual(handler, LoadRoot(Heap::kuninitialized_symbolRootIndex)), |
| 4431 &miss); | 4435 &miss); |
| 4432 | 4436 |
| 4433 // In this case {handler} must be a Code object. | 4437 // In this case {handler} must be a Code object. |
| 4434 AssertInstanceType(handler, CODE_TYPE); | 4438 AssertInstanceType(handler, CODE_TYPE); |
| 4435 LoadWithVectorDescriptor descriptor(isolate()); | 4439 LoadWithVectorDescriptor descriptor(isolate()); |
| 4436 Node* native_context = LoadNativeContext(p->context); | 4440 Node* native_context = LoadNativeContext(p->context); |
| 4437 Node* receiver = LoadFixedArrayElement( | 4441 Node* receiver = |
| 4438 native_context, IntPtrConstant(Context::EXTENSION_INDEX), 0, | 4442 LoadContextElement(native_context, Context::EXTENSION_INDEX); |
| 4439 INTPTR_PARAMETERS); | |
| 4440 Node* fake_name = IntPtrConstant(0); | 4443 Node* fake_name = IntPtrConstant(0); |
| 4441 TailCallStub(descriptor, handler, p->context, receiver, fake_name, p->slot, | 4444 TailCallStub(descriptor, handler, p->context, receiver, fake_name, p->slot, |
| 4442 p->vector); | 4445 p->vector); |
| 4443 } | 4446 } |
| 4444 Bind(&miss); | 4447 Bind(&miss); |
| 4445 { | 4448 { |
| 4446 TailCallRuntime(Runtime::kLoadGlobalIC_Miss, p->context, p->slot, | 4449 TailCallRuntime(Runtime::kLoadGlobalIC_Miss, p->context, p->slot, |
| 4447 p->vector); | 4450 p->vector); |
| 4448 } | 4451 } |
| 4449 } | 4452 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4570 Node* mapped_index = LoadFixedArrayElement( | 4573 Node* mapped_index = LoadFixedArrayElement( |
| 4571 elements, IntPtrAdd(key, intptr_two), 0, INTPTR_PARAMETERS); | 4574 elements, IntPtrAdd(key, intptr_two), 0, INTPTR_PARAMETERS); |
| 4572 Branch(WordEqual(mapped_index, TheHoleConstant()), &if_unmapped, &if_mapped); | 4575 Branch(WordEqual(mapped_index, TheHoleConstant()), &if_unmapped, &if_mapped); |
| 4573 | 4576 |
| 4574 Bind(&if_mapped); | 4577 Bind(&if_mapped); |
| 4575 { | 4578 { |
| 4576 Assert(WordIsSmi(mapped_index)); | 4579 Assert(WordIsSmi(mapped_index)); |
| 4577 mapped_index = SmiUntag(mapped_index); | 4580 mapped_index = SmiUntag(mapped_index); |
| 4578 Node* the_context = LoadFixedArrayElement(elements, IntPtrConstant(0), 0, | 4581 Node* the_context = LoadFixedArrayElement(elements, IntPtrConstant(0), 0, |
| 4579 INTPTR_PARAMETERS); | 4582 INTPTR_PARAMETERS); |
| 4583 // Assert that we can use LoadFixedArrayElement/StoreFixedArrayElement |
| 4584 // methods for accessing Context. |
| 4580 STATIC_ASSERT(Context::kHeaderSize == FixedArray::kHeaderSize); | 4585 STATIC_ASSERT(Context::kHeaderSize == FixedArray::kHeaderSize); |
| 4586 DCHECK_EQ(Context::SlotOffset(0) + kHeapObjectTag, |
| 4587 FixedArray::OffsetOfElementAt(0)); |
| 4581 if (is_load) { | 4588 if (is_load) { |
| 4582 Node* result = LoadFixedArrayElement(the_context, mapped_index, 0, | 4589 Node* result = LoadFixedArrayElement(the_context, mapped_index, 0, |
| 4583 INTPTR_PARAMETERS); | 4590 INTPTR_PARAMETERS); |
| 4584 Assert(WordNotEqual(result, TheHoleConstant())); | 4591 Assert(WordNotEqual(result, TheHoleConstant())); |
| 4585 var_result.Bind(result); | 4592 var_result.Bind(result); |
| 4586 } else { | 4593 } else { |
| 4587 StoreFixedArrayElement(the_context, mapped_index, value, | 4594 StoreFixedArrayElement(the_context, mapped_index, value, |
| 4588 UPDATE_WRITE_BARRIER, INTPTR_PARAMETERS); | 4595 UPDATE_WRITE_BARRIER, INTPTR_PARAMETERS); |
| 4589 } | 4596 } |
| 4590 Goto(&end); | 4597 Goto(&end); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4612 StoreFixedArrayElement(backing_store, key, value, UPDATE_WRITE_BARRIER, | 4619 StoreFixedArrayElement(backing_store, key, value, UPDATE_WRITE_BARRIER, |
| 4613 INTPTR_PARAMETERS); | 4620 INTPTR_PARAMETERS); |
| 4614 } | 4621 } |
| 4615 Goto(&end); | 4622 Goto(&end); |
| 4616 } | 4623 } |
| 4617 | 4624 |
| 4618 Bind(&end); | 4625 Bind(&end); |
| 4619 return var_result.value(); | 4626 return var_result.value(); |
| 4620 } | 4627 } |
| 4621 | 4628 |
| 4629 Node* CodeStubAssembler::LoadScriptContext(Node* context, int context_index) { |
| 4630 Node* native_context = LoadNativeContext(context); |
| 4631 Node* script_context_table = |
| 4632 LoadContextElement(native_context, Context::SCRIPT_CONTEXT_TABLE_INDEX); |
| 4633 |
| 4634 int offset = |
| 4635 ScriptContextTable::GetContextOffset(context_index) - kHeapObjectTag; |
| 4636 return Load(MachineType::AnyTagged(), script_context_table, |
| 4637 IntPtrConstant(offset)); |
| 4638 } |
| 4639 |
| 4622 Node* CodeStubAssembler::EnumLength(Node* map) { | 4640 Node* CodeStubAssembler::EnumLength(Node* map) { |
| 4623 Node* bitfield_3 = LoadMapBitField3(map); | 4641 Node* bitfield_3 = LoadMapBitField3(map); |
| 4624 Node* enum_length = BitFieldDecode<Map::EnumLengthBits>(bitfield_3); | 4642 Node* enum_length = BitFieldDecode<Map::EnumLengthBits>(bitfield_3); |
| 4625 return SmiTag(enum_length); | 4643 return SmiTag(enum_length); |
| 4626 } | 4644 } |
| 4627 | 4645 |
| 4628 void CodeStubAssembler::CheckEnumCache(Node* receiver, Label* use_cache, | 4646 void CodeStubAssembler::CheckEnumCache(Node* receiver, Label* use_cache, |
| 4629 Label* use_runtime) { | 4647 Label* use_runtime) { |
| 4630 Variable current_js_object(this, MachineRepresentation::kTagged); | 4648 Variable current_js_object(this, MachineRepresentation::kTagged); |
| 4631 current_js_object.Bind(receiver); | 4649 current_js_object.Bind(receiver); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4699 Heap::kTheHoleValueRootIndex); | 4717 Heap::kTheHoleValueRootIndex); |
| 4700 | 4718 |
| 4701 // Store the WeakCell in the feedback vector. | 4719 // Store the WeakCell in the feedback vector. |
| 4702 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, | 4720 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, |
| 4703 CodeStubAssembler::SMI_PARAMETERS); | 4721 CodeStubAssembler::SMI_PARAMETERS); |
| 4704 return cell; | 4722 return cell; |
| 4705 } | 4723 } |
| 4706 | 4724 |
| 4707 } // namespace internal | 4725 } // namespace internal |
| 4708 } // namespace v8 | 4726 } // namespace v8 |
| OLD | NEW |