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 #include "src/code-stub-assembler.h" | 4 #include "src/code-stub-assembler.h" |
5 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/frames-inl.h" | 6 #include "src/frames-inl.h" |
7 #include "src/frames.h" | 7 #include "src/frames.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 return Store(MachineRepresentation::kTagged, context, offset, value); | 1308 return Store(MachineRepresentation::kTagged, context, offset, value); |
1309 } | 1309 } |
1310 | 1310 |
1311 Node* CodeStubAssembler::LoadNativeContext(Node* context) { | 1311 Node* CodeStubAssembler::LoadNativeContext(Node* context) { |
1312 return LoadContextElement(context, Context::NATIVE_CONTEXT_INDEX); | 1312 return LoadContextElement(context, Context::NATIVE_CONTEXT_INDEX); |
1313 } | 1313 } |
1314 | 1314 |
1315 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, | 1315 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, |
1316 Node* native_context) { | 1316 Node* native_context) { |
1317 CSA_ASSERT(this, IsNativeContext(native_context)); | 1317 CSA_ASSERT(this, IsNativeContext(native_context)); |
1318 return LoadFixedArrayElement(native_context, | 1318 return LoadContextElement(native_context, Context::ArrayMapIndex(kind)); |
1319 IntPtrConstant(Context::ArrayMapIndex(kind))); | |
1320 } | 1319 } |
1321 | 1320 |
1322 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { | 1321 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { |
1323 return StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value, | 1322 return StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value, |
1324 MachineRepresentation::kFloat64); | 1323 MachineRepresentation::kFloat64); |
1325 } | 1324 } |
1326 | 1325 |
1327 Node* CodeStubAssembler::StoreObjectField( | 1326 Node* CodeStubAssembler::StoreObjectField( |
1328 Node* object, int offset, Node* value) { | 1327 Node* object, int offset, Node* value) { |
1329 return Store(MachineRepresentation::kTagged, object, | 1328 return Store(MachineRepresentation::kTagged, object, |
(...skipping 2938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4268 return IntPtrMax(capacity, IntPtrConstant(HashTableBase::kMinCapacity)); | 4267 return IntPtrMax(capacity, IntPtrConstant(HashTableBase::kMinCapacity)); |
4269 } | 4268 } |
4270 | 4269 |
4271 Node* CodeStubAssembler::IntPtrMax(Node* left, Node* right) { | 4270 Node* CodeStubAssembler::IntPtrMax(Node* left, Node* right) { |
4272 return Select(IntPtrGreaterThanOrEqual(left, right), left, right, | 4271 return Select(IntPtrGreaterThanOrEqual(left, right), left, right, |
4273 MachineType::PointerRepresentation()); | 4272 MachineType::PointerRepresentation()); |
4274 } | 4273 } |
4275 | 4274 |
4276 template <class Dictionary> | 4275 template <class Dictionary> |
4277 Node* CodeStubAssembler::GetNumberOfElements(Node* dictionary) { | 4276 Node* CodeStubAssembler::GetNumberOfElements(Node* dictionary) { |
4278 return LoadFixedArrayElement( | 4277 return LoadFixedArrayElement(dictionary, Dictionary::kNumberOfElementsIndex); |
4279 dictionary, IntPtrConstant(Dictionary::kNumberOfElementsIndex), 0, | |
4280 INTPTR_PARAMETERS); | |
4281 } | 4278 } |
4282 | 4279 |
4283 template <class Dictionary> | 4280 template <class Dictionary> |
4284 void CodeStubAssembler::SetNumberOfElements(Node* dictionary, | 4281 void CodeStubAssembler::SetNumberOfElements(Node* dictionary, |
4285 Node* num_elements_smi) { | 4282 Node* num_elements_smi) { |
4286 StoreFixedArrayElement(dictionary, Dictionary::kNumberOfElementsIndex, | 4283 StoreFixedArrayElement(dictionary, Dictionary::kNumberOfElementsIndex, |
4287 num_elements_smi, SKIP_WRITE_BARRIER); | 4284 num_elements_smi, SKIP_WRITE_BARRIER); |
4288 } | 4285 } |
4289 | 4286 |
4290 template <class Dictionary> | 4287 template <class Dictionary> |
4291 Node* CodeStubAssembler::GetNumberOfDeletedElements(Node* dictionary) { | 4288 Node* CodeStubAssembler::GetNumberOfDeletedElements(Node* dictionary) { |
4292 return LoadFixedArrayElement( | 4289 return LoadFixedArrayElement(dictionary, |
4293 dictionary, IntPtrConstant(Dictionary::kNumberOfDeletedElementsIndex), 0, | 4290 Dictionary::kNumberOfDeletedElementsIndex); |
4294 INTPTR_PARAMETERS); | |
4295 } | 4291 } |
4296 | 4292 |
4297 template <class Dictionary> | 4293 template <class Dictionary> |
4298 Node* CodeStubAssembler::GetCapacity(Node* dictionary) { | 4294 Node* CodeStubAssembler::GetCapacity(Node* dictionary) { |
4299 return LoadFixedArrayElement(dictionary, | 4295 return LoadFixedArrayElement(dictionary, Dictionary::kCapacityIndex); |
4300 IntPtrConstant(Dictionary::kCapacityIndex), 0, | |
4301 INTPTR_PARAMETERS); | |
4302 } | 4296 } |
4303 | 4297 |
4304 template <class Dictionary> | 4298 template <class Dictionary> |
4305 Node* CodeStubAssembler::GetNextEnumerationIndex(Node* dictionary) { | 4299 Node* CodeStubAssembler::GetNextEnumerationIndex(Node* dictionary) { |
4306 return LoadFixedArrayElement( | 4300 return LoadFixedArrayElement(dictionary, |
4307 dictionary, IntPtrConstant(Dictionary::kNextEnumerationIndexIndex), 0, | 4301 Dictionary::kNextEnumerationIndexIndex); |
4308 INTPTR_PARAMETERS); | |
4309 } | 4302 } |
4310 | 4303 |
4311 template <class Dictionary> | 4304 template <class Dictionary> |
4312 void CodeStubAssembler::SetNextEnumerationIndex(Node* dictionary, | 4305 void CodeStubAssembler::SetNextEnumerationIndex(Node* dictionary, |
4313 Node* next_enum_index_smi) { | 4306 Node* next_enum_index_smi) { |
4314 StoreFixedArrayElement(dictionary, Dictionary::kNextEnumerationIndexIndex, | 4307 StoreFixedArrayElement(dictionary, Dictionary::kNextEnumerationIndexIndex, |
4315 next_enum_index_smi, SKIP_WRITE_BARRIER); | 4308 next_enum_index_smi, SKIP_WRITE_BARRIER); |
4316 } | 4309 } |
4317 | 4310 |
4318 template <typename Dictionary> | 4311 template <typename Dictionary> |
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5571 GotoIf(UintPtrGreaterThanOrEqual(key, adjusted_length), &if_unmapped); | 5564 GotoIf(UintPtrGreaterThanOrEqual(key, adjusted_length), &if_unmapped); |
5572 | 5565 |
5573 Node* mapped_index = LoadFixedArrayElement( | 5566 Node* mapped_index = LoadFixedArrayElement( |
5574 elements, IntPtrAdd(key, intptr_two), 0, INTPTR_PARAMETERS); | 5567 elements, IntPtrAdd(key, intptr_two), 0, INTPTR_PARAMETERS); |
5575 Branch(WordEqual(mapped_index, TheHoleConstant()), &if_unmapped, &if_mapped); | 5568 Branch(WordEqual(mapped_index, TheHoleConstant()), &if_unmapped, &if_mapped); |
5576 | 5569 |
5577 Bind(&if_mapped); | 5570 Bind(&if_mapped); |
5578 { | 5571 { |
5579 CSA_ASSERT(this, TaggedIsSmi(mapped_index)); | 5572 CSA_ASSERT(this, TaggedIsSmi(mapped_index)); |
5580 mapped_index = SmiUntag(mapped_index); | 5573 mapped_index = SmiUntag(mapped_index); |
5581 Node* the_context = LoadFixedArrayElement(elements, IntPtrConstant(0), 0, | 5574 Node* the_context = LoadFixedArrayElement(elements, 0); |
5582 INTPTR_PARAMETERS); | |
5583 // Assert that we can use LoadFixedArrayElement/StoreFixedArrayElement | 5575 // Assert that we can use LoadFixedArrayElement/StoreFixedArrayElement |
5584 // methods for accessing Context. | 5576 // methods for accessing Context. |
5585 STATIC_ASSERT(Context::kHeaderSize == FixedArray::kHeaderSize); | 5577 STATIC_ASSERT(Context::kHeaderSize == FixedArray::kHeaderSize); |
5586 DCHECK_EQ(Context::SlotOffset(0) + kHeapObjectTag, | 5578 DCHECK_EQ(Context::SlotOffset(0) + kHeapObjectTag, |
5587 FixedArray::OffsetOfElementAt(0)); | 5579 FixedArray::OffsetOfElementAt(0)); |
5588 if (is_load) { | 5580 if (is_load) { |
5589 Node* result = LoadFixedArrayElement(the_context, mapped_index, 0, | 5581 Node* result = LoadFixedArrayElement(the_context, mapped_index, 0, |
5590 INTPTR_PARAMETERS); | 5582 INTPTR_PARAMETERS); |
5591 CSA_ASSERT(this, WordNotEqual(result, TheHoleConstant())); | 5583 CSA_ASSERT(this, WordNotEqual(result, TheHoleConstant())); |
5592 var_result.Bind(result); | 5584 var_result.Bind(result); |
5593 } else { | 5585 } else { |
5594 StoreFixedArrayElement(the_context, mapped_index, value, | 5586 StoreFixedArrayElement(the_context, mapped_index, value, |
5595 UPDATE_WRITE_BARRIER, 0, INTPTR_PARAMETERS); | 5587 UPDATE_WRITE_BARRIER, 0, INTPTR_PARAMETERS); |
5596 } | 5588 } |
5597 Goto(&end); | 5589 Goto(&end); |
5598 } | 5590 } |
5599 | 5591 |
5600 Bind(&if_unmapped); | 5592 Bind(&if_unmapped); |
5601 { | 5593 { |
5602 Node* backing_store = LoadFixedArrayElement(elements, IntPtrConstant(1), 0, | 5594 Node* backing_store = LoadFixedArrayElement(elements, 1); |
5603 INTPTR_PARAMETERS); | |
5604 GotoIf(WordNotEqual(LoadMap(backing_store), FixedArrayMapConstant()), | 5595 GotoIf(WordNotEqual(LoadMap(backing_store), FixedArrayMapConstant()), |
5605 bailout); | 5596 bailout); |
5606 | 5597 |
5607 Node* backing_store_length = | 5598 Node* backing_store_length = |
5608 LoadAndUntagFixedArrayBaseLength(backing_store); | 5599 LoadAndUntagFixedArrayBaseLength(backing_store); |
5609 GotoIf(UintPtrGreaterThanOrEqual(key, backing_store_length), bailout); | 5600 GotoIf(UintPtrGreaterThanOrEqual(key, backing_store_length), bailout); |
5610 | 5601 |
5611 // The key falls into unmapped range. | 5602 // The key falls into unmapped range. |
5612 if (is_load) { | 5603 if (is_load) { |
5613 Node* result = | 5604 Node* result = |
(...skipping 2553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8167 | 8158 |
8168 Node* CodeStubAssembler::IsDebugActive() { | 8159 Node* CodeStubAssembler::IsDebugActive() { |
8169 Node* is_debug_active = Load( | 8160 Node* is_debug_active = Load( |
8170 MachineType::Uint8(), | 8161 MachineType::Uint8(), |
8171 ExternalConstant(ExternalReference::debug_is_active_address(isolate()))); | 8162 ExternalConstant(ExternalReference::debug_is_active_address(isolate()))); |
8172 return WordNotEqual(is_debug_active, Int32Constant(0)); | 8163 return WordNotEqual(is_debug_active, Int32Constant(0)); |
8173 } | 8164 } |
8174 | 8165 |
8175 } // namespace internal | 8166 } // namespace internal |
8176 } // namespace v8 | 8167 } // namespace v8 |
OLD | NEW |