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 #include "src/ic/handler-configuration.h" | 8 #include "src/ic/handler-configuration.h" |
9 #include "src/ic/stub-cache.h" | 9 #include "src/ic/stub-cache.h" |
10 | 10 |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 | 993 |
994 Node* CodeStubAssembler::LoadInstanceType(Node* object) { | 994 Node* CodeStubAssembler::LoadInstanceType(Node* object) { |
995 return LoadMapInstanceType(LoadMap(object)); | 995 return LoadMapInstanceType(LoadMap(object)); |
996 } | 996 } |
997 | 997 |
998 Node* CodeStubAssembler::HasInstanceType(Node* object, | 998 Node* CodeStubAssembler::HasInstanceType(Node* object, |
999 InstanceType instance_type) { | 999 InstanceType instance_type) { |
1000 return Word32Equal(LoadInstanceType(object), Int32Constant(instance_type)); | 1000 return Word32Equal(LoadInstanceType(object), Int32Constant(instance_type)); |
1001 } | 1001 } |
1002 | 1002 |
1003 void CodeStubAssembler::AssertInstanceType(Node* object, | |
1004 InstanceType instance_type) { | |
1005 CSA_ASSERT(HasInstanceType(object, instance_type)); | |
1006 } | |
1007 | |
1008 Node* CodeStubAssembler::LoadProperties(Node* object) { | 1003 Node* CodeStubAssembler::LoadProperties(Node* object) { |
1009 return LoadObjectField(object, JSObject::kPropertiesOffset); | 1004 return LoadObjectField(object, JSObject::kPropertiesOffset); |
1010 } | 1005 } |
1011 | 1006 |
1012 Node* CodeStubAssembler::LoadElements(Node* object) { | 1007 Node* CodeStubAssembler::LoadElements(Node* object) { |
1013 return LoadObjectField(object, JSObject::kElementsOffset); | 1008 return LoadObjectField(object, JSObject::kElementsOffset); |
1014 } | 1009 } |
1015 | 1010 |
1016 Node* CodeStubAssembler::LoadJSArrayLength(compiler::Node* array) { | 1011 Node* CodeStubAssembler::LoadJSArrayLength(compiler::Node* array) { |
1017 return LoadObjectField(array, JSArray::kLengthOffset); | 1012 return LoadObjectField(array, JSArray::kLengthOffset); |
(...skipping 3358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4376 | 4371 |
4377 Node* kind = DecodeWord32<PropertyDetails::KindField>(details); | 4372 Node* kind = DecodeWord32<PropertyDetails::KindField>(details); |
4378 GotoIf(Word32Equal(kind, Int32Constant(kData)), &done); | 4373 GotoIf(Word32Equal(kind, Int32Constant(kData)), &done); |
4379 | 4374 |
4380 // Accessor case. | 4375 // Accessor case. |
4381 { | 4376 { |
4382 Node* accessor_pair = value; | 4377 Node* accessor_pair = value; |
4383 GotoIf(Word32Equal(LoadInstanceType(accessor_pair), | 4378 GotoIf(Word32Equal(LoadInstanceType(accessor_pair), |
4384 Int32Constant(ACCESSOR_INFO_TYPE)), | 4379 Int32Constant(ACCESSOR_INFO_TYPE)), |
4385 if_bailout); | 4380 if_bailout); |
4386 AssertInstanceType(accessor_pair, ACCESSOR_PAIR_TYPE); | 4381 CSA_ASSERT(HasInstanceType(accessor_pair, ACCESSOR_PAIR_TYPE)); |
4387 Node* getter = LoadObjectField(accessor_pair, AccessorPair::kGetterOffset); | 4382 Node* getter = LoadObjectField(accessor_pair, AccessorPair::kGetterOffset); |
4388 Node* getter_map = LoadMap(getter); | 4383 Node* getter_map = LoadMap(getter); |
4389 Node* instance_type = LoadMapInstanceType(getter_map); | 4384 Node* instance_type = LoadMapInstanceType(getter_map); |
4390 // FunctionTemplateInfo getters are not supported yet. | 4385 // FunctionTemplateInfo getters are not supported yet. |
4391 GotoIf( | 4386 GotoIf( |
4392 Word32Equal(instance_type, Int32Constant(FUNCTION_TEMPLATE_INFO_TYPE)), | 4387 Word32Equal(instance_type, Int32Constant(FUNCTION_TEMPLATE_INFO_TYPE)), |
4393 if_bailout); | 4388 if_bailout); |
4394 | 4389 |
4395 // Return undefined if the {getter} is not callable. | 4390 // Return undefined if the {getter} is not callable. |
4396 var_value.Bind(UndefinedConstant()); | 4391 var_value.Bind(UndefinedConstant()); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4531 } | 4526 } |
4532 Bind(&if_isdictionary); | 4527 Bind(&if_isdictionary); |
4533 { | 4528 { |
4534 Variable var_entry(this, MachineType::PointerRepresentation()); | 4529 Variable var_entry(this, MachineType::PointerRepresentation()); |
4535 Node* elements = LoadElements(object); | 4530 Node* elements = LoadElements(object); |
4536 NumberDictionaryLookup<SeededNumberDictionary>( | 4531 NumberDictionaryLookup<SeededNumberDictionary>( |
4537 elements, intptr_index, if_found, &var_entry, if_not_found); | 4532 elements, intptr_index, if_found, &var_entry, if_not_found); |
4538 } | 4533 } |
4539 Bind(&if_isfaststringwrapper); | 4534 Bind(&if_isfaststringwrapper); |
4540 { | 4535 { |
4541 AssertInstanceType(object, JS_VALUE_TYPE); | 4536 CSA_ASSERT(HasInstanceType(object, JS_VALUE_TYPE)); |
4542 Node* string = LoadJSValueValue(object); | 4537 Node* string = LoadJSValueValue(object); |
4543 CSA_ASSERT(IsStringInstanceType(LoadInstanceType(string))); | 4538 CSA_ASSERT(IsStringInstanceType(LoadInstanceType(string))); |
4544 Node* length = LoadStringLength(string); | 4539 Node* length = LoadStringLength(string); |
4545 GotoIf(UintPtrLessThan(intptr_index, SmiUntag(length)), if_found); | 4540 GotoIf(UintPtrLessThan(intptr_index, SmiUntag(length)), if_found); |
4546 Goto(&if_isobjectorsmi); | 4541 Goto(&if_isobjectorsmi); |
4547 } | 4542 } |
4548 Bind(&if_isslowstringwrapper); | 4543 Bind(&if_isslowstringwrapper); |
4549 { | 4544 { |
4550 AssertInstanceType(object, JS_VALUE_TYPE); | 4545 CSA_ASSERT(HasInstanceType(object, JS_VALUE_TYPE)); |
4551 Node* string = LoadJSValueValue(object); | 4546 Node* string = LoadJSValueValue(object); |
4552 CSA_ASSERT(IsStringInstanceType(LoadInstanceType(string))); | 4547 CSA_ASSERT(IsStringInstanceType(LoadInstanceType(string))); |
4553 Node* length = LoadStringLength(string); | 4548 Node* length = LoadStringLength(string); |
4554 GotoIf(UintPtrLessThan(intptr_index, SmiUntag(length)), if_found); | 4549 GotoIf(UintPtrLessThan(intptr_index, SmiUntag(length)), if_found); |
4555 Goto(&if_isdictionary); | 4550 Goto(&if_isdictionary); |
4556 } | 4551 } |
4557 Bind(&if_oob); | 4552 Bind(&if_oob); |
4558 { | 4553 { |
4559 // Positive OOB indices mean "not found", negative indices must be | 4554 // Positive OOB indices mean "not found", negative indices must be |
4560 // converted to property names. | 4555 // converted to property names. |
(...skipping 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6150 Comment("KeyedStoreIC_miss"); | 6145 Comment("KeyedStoreIC_miss"); |
6151 TailCallRuntime(Runtime::kKeyedStoreIC_Miss, p->context, p->value, p->slot, | 6146 TailCallRuntime(Runtime::kKeyedStoreIC_Miss, p->context, p->value, p->slot, |
6152 p->vector, p->receiver, p->name); | 6147 p->vector, p->receiver, p->name); |
6153 } | 6148 } |
6154 } | 6149 } |
6155 | 6150 |
6156 void CodeStubAssembler::LoadGlobalIC(const LoadICParameters* p) { | 6151 void CodeStubAssembler::LoadGlobalIC(const LoadICParameters* p) { |
6157 Label try_handler(this), miss(this); | 6152 Label try_handler(this), miss(this); |
6158 Node* weak_cell = | 6153 Node* weak_cell = |
6159 LoadFixedArrayElement(p->vector, p->slot, 0, SMI_PARAMETERS); | 6154 LoadFixedArrayElement(p->vector, p->slot, 0, SMI_PARAMETERS); |
6160 AssertInstanceType(weak_cell, WEAK_CELL_TYPE); | 6155 CSA_ASSERT(HasInstanceType(weak_cell, WEAK_CELL_TYPE)); |
6161 | 6156 |
6162 // Load value or try handler case if the {weak_cell} is cleared. | 6157 // Load value or try handler case if the {weak_cell} is cleared. |
6163 Node* property_cell = LoadWeakCellValue(weak_cell, &try_handler); | 6158 Node* property_cell = LoadWeakCellValue(weak_cell, &try_handler); |
6164 AssertInstanceType(property_cell, PROPERTY_CELL_TYPE); | 6159 CSA_ASSERT(HasInstanceType(property_cell, PROPERTY_CELL_TYPE)); |
6165 | 6160 |
6166 Node* value = LoadObjectField(property_cell, PropertyCell::kValueOffset); | 6161 Node* value = LoadObjectField(property_cell, PropertyCell::kValueOffset); |
6167 GotoIf(WordEqual(value, TheHoleConstant()), &miss); | 6162 GotoIf(WordEqual(value, TheHoleConstant()), &miss); |
6168 Return(value); | 6163 Return(value); |
6169 | 6164 |
6170 Bind(&try_handler); | 6165 Bind(&try_handler); |
6171 { | 6166 { |
6172 Node* handler = | 6167 Node* handler = |
6173 LoadFixedArrayElement(p->vector, p->slot, kPointerSize, SMI_PARAMETERS); | 6168 LoadFixedArrayElement(p->vector, p->slot, kPointerSize, SMI_PARAMETERS); |
6174 GotoIf(WordEqual(handler, LoadRoot(Heap::kuninitialized_symbolRootIndex)), | 6169 GotoIf(WordEqual(handler, LoadRoot(Heap::kuninitialized_symbolRootIndex)), |
6175 &miss); | 6170 &miss); |
6176 | 6171 |
6177 // In this case {handler} must be a Code object. | 6172 // In this case {handler} must be a Code object. |
6178 AssertInstanceType(handler, CODE_TYPE); | 6173 CSA_ASSERT(HasInstanceType(handler, CODE_TYPE)); |
6179 LoadWithVectorDescriptor descriptor(isolate()); | 6174 LoadWithVectorDescriptor descriptor(isolate()); |
6180 Node* native_context = LoadNativeContext(p->context); | 6175 Node* native_context = LoadNativeContext(p->context); |
6181 Node* receiver = | 6176 Node* receiver = |
6182 LoadContextElement(native_context, Context::EXTENSION_INDEX); | 6177 LoadContextElement(native_context, Context::EXTENSION_INDEX); |
6183 Node* fake_name = IntPtrConstant(0); | 6178 Node* fake_name = IntPtrConstant(0); |
6184 TailCallStub(descriptor, handler, p->context, receiver, fake_name, p->slot, | 6179 TailCallStub(descriptor, handler, p->context, receiver, fake_name, p->slot, |
6185 p->vector); | 6180 p->vector); |
6186 } | 6181 } |
6187 Bind(&miss); | 6182 Bind(&miss); |
6188 { | 6183 { |
(...skipping 2450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8639 StoreObjectFieldNoWriteBarrier(iterator, | 8634 StoreObjectFieldNoWriteBarrier(iterator, |
8640 JSArrayIterator::kIteratedObjectOffset, array); | 8635 JSArrayIterator::kIteratedObjectOffset, array); |
8641 StoreObjectFieldNoWriteBarrier(iterator, JSArrayIterator::kNextIndexOffset, | 8636 StoreObjectFieldNoWriteBarrier(iterator, JSArrayIterator::kNextIndexOffset, |
8642 SmiConstant(Smi::FromInt(0))); | 8637 SmiConstant(Smi::FromInt(0))); |
8643 StoreObjectFieldNoWriteBarrier( | 8638 StoreObjectFieldNoWriteBarrier( |
8644 iterator, JSArrayIterator::kIteratedObjectMapOffset, array_map); | 8639 iterator, JSArrayIterator::kIteratedObjectMapOffset, array_map); |
8645 return iterator; | 8640 return iterator; |
8646 } | 8641 } |
8647 | 8642 |
8648 compiler::Node* CodeStubAssembler::IsDetachedBuffer(compiler::Node* buffer) { | 8643 compiler::Node* CodeStubAssembler::IsDetachedBuffer(compiler::Node* buffer) { |
8649 AssertInstanceType(buffer, JS_ARRAY_BUFFER_TYPE); | 8644 CSA_ASSERT(HasInstanceType(buffer, JS_ARRAY_BUFFER_TYPE)); |
8650 | 8645 |
8651 Node* buffer_bit_field = LoadObjectField( | 8646 Node* buffer_bit_field = LoadObjectField( |
8652 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); | 8647 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); |
8653 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask); | 8648 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask); |
8654 | 8649 |
8655 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask), | 8650 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask), |
8656 Int32Constant(0)); | 8651 Int32Constant(0)); |
8657 } | 8652 } |
8658 | 8653 |
8659 } // namespace internal | 8654 } // namespace internal |
8660 } // namespace v8 | 8655 } // namespace v8 |
OLD | NEW |