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 5489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5500 Bind(&key_is_smi); | 5500 Bind(&key_is_smi); |
5501 { | 5501 { |
5502 var_intptr_key.Bind(SmiUntag(key)); | 5502 var_intptr_key.Bind(SmiUntag(key)); |
5503 Goto(&done); | 5503 Goto(&done); |
5504 } | 5504 } |
5505 | 5505 |
5506 Bind(&done); | 5506 Bind(&done); |
5507 return var_intptr_key.value(); | 5507 return var_intptr_key.value(); |
5508 } | 5508 } |
5509 | 5509 |
5510 void CodeStubAssembler::ExtendPropertiesBackingStore(Node* object) { | |
5511 Node* properties = LoadProperties(object); | |
5512 Node* length = LoadFixedArrayBaseLength(properties); | |
5513 | |
5514 ParameterMode mode = OptimalParameterMode(); | |
5515 length = TaggedToParameter(length, mode); | |
5516 | |
5517 Node* delta = IntPtrOrSmiConstant(JSObject::kFieldsAdded, mode); | |
5518 Node* new_capacity = IntPtrOrSmiAdd(length, delta, mode); | |
5519 | |
5520 // Grow properties array. | |
5521 ElementsKind kind = FAST_ELEMENTS; | |
5522 DCHECK(kMaxNumberOfDescriptors + JSObject::kFieldsAdded < | |
5523 FixedArrayBase::GetMaxLengthForNewSpaceAllocation(kind)); | |
5524 // The size of a new properties backing store is guaranteed to be small | |
5525 // enough that the new backing store will be allocated in new space. | |
5526 CSA_ASSERT(this, | |
5527 UintPtrOrSmiLessThan( | |
5528 new_capacity, | |
5529 IntPtrOrSmiConstant( | |
5530 kMaxNumberOfDescriptors + JSObject::kFieldsAdded, mode), | |
5531 mode)); | |
5532 | |
5533 Node* new_properties = AllocateFixedArray(kind, new_capacity, mode); | |
5534 | |
5535 FillFixedArrayWithValue(kind, new_properties, length, new_capacity, | |
5536 Heap::kUndefinedValueRootIndex, mode); | |
5537 | |
5538 // |new_properties| is guaranteed to be in new space, so we can skip | |
5539 // the write barrier. | |
5540 CopyFixedArrayElements(kind, properties, new_properties, length, | |
5541 SKIP_WRITE_BARRIER, mode); | |
5542 | |
5543 StoreObjectField(object, JSObject::kPropertiesOffset, new_properties); | |
5544 } | |
5545 | |
5546 Node* CodeStubAssembler::PrepareValueForWrite(Node* value, | |
5547 Representation representation, | |
5548 Label* bailout) { | |
5549 if (representation.IsDouble()) { | |
5550 value = TryTaggedToFloat64(value, bailout); | |
5551 } else if (representation.IsHeapObject()) { | |
5552 // Field type is checked by the handler, here we only check if the value | |
5553 // is a heap object. | |
5554 GotoIf(TaggedIsSmi(value), bailout); | |
5555 } else if (representation.IsSmi()) { | |
5556 GotoUnless(TaggedIsSmi(value), bailout); | |
5557 } else { | |
5558 DCHECK(representation.IsTagged()); | |
5559 } | |
5560 return value; | |
5561 } | |
5562 | |
5563 void CodeStubAssembler::StoreNamedField(Node* object, FieldIndex index, | |
5564 Representation representation, | |
5565 Node* value, bool transition_to_field) { | |
5566 DCHECK_EQ(index.is_double(), representation.IsDouble()); | |
5567 | |
5568 StoreNamedField(object, IntPtrConstant(index.offset()), index.is_inobject(), | |
5569 representation, value, transition_to_field); | |
5570 } | |
5571 | |
5572 void CodeStubAssembler::StoreNamedField(Node* object, Node* offset, | |
5573 bool is_inobject, | |
5574 Representation representation, | |
5575 Node* value, bool transition_to_field) { | |
5576 bool store_value_as_double = representation.IsDouble(); | |
5577 Node* property_storage = object; | |
5578 if (!is_inobject) { | |
5579 property_storage = LoadProperties(object); | |
5580 } | |
5581 | |
5582 if (representation.IsDouble()) { | |
5583 if (!FLAG_unbox_double_fields || !is_inobject) { | |
5584 if (transition_to_field) { | |
5585 Node* heap_number = AllocateHeapNumberWithValue(value, MUTABLE); | |
5586 // Store the new mutable heap number into the object. | |
5587 value = heap_number; | |
5588 store_value_as_double = false; | |
5589 } else { | |
5590 // Load the heap number. | |
5591 property_storage = LoadObjectField(property_storage, offset); | |
5592 // Store the double value into it. | |
5593 offset = IntPtrConstant(HeapNumber::kValueOffset); | |
5594 } | |
5595 } | |
5596 } | |
5597 | |
5598 if (store_value_as_double) { | |
5599 StoreObjectFieldNoWriteBarrier(property_storage, offset, value, | |
5600 MachineRepresentation::kFloat64); | |
5601 } else if (representation.IsSmi()) { | |
5602 StoreObjectFieldNoWriteBarrier(property_storage, offset, value); | |
5603 } else { | |
5604 StoreObjectField(property_storage, offset, value); | |
5605 } | |
5606 } | |
5607 | |
5608 Node* CodeStubAssembler::EmitKeyedSloppyArguments(Node* receiver, Node* key, | 5510 Node* CodeStubAssembler::EmitKeyedSloppyArguments(Node* receiver, Node* key, |
5609 Node* value, Label* bailout) { | 5511 Node* value, Label* bailout) { |
5610 // Mapped arguments are actual arguments. Unmapped arguments are values added | 5512 // Mapped arguments are actual arguments. Unmapped arguments are values added |
5611 // to the arguments object after it was created for the call. Mapped arguments | 5513 // to the arguments object after it was created for the call. Mapped arguments |
5612 // are stored in the context at indexes given by elements[key + 2]. Unmapped | 5514 // are stored in the context at indexes given by elements[key + 2]. Unmapped |
5613 // arguments are stored as regular indexed properties in the arguments array, | 5515 // arguments are stored as regular indexed properties in the arguments array, |
5614 // held at elements[1]. See NewSloppyArguments() in runtime.cc for a detailed | 5516 // held at elements[1]. See NewSloppyArguments() in runtime.cc for a detailed |
5615 // look at argument object construction. | 5517 // look at argument object construction. |
5616 // | 5518 // |
5617 // The sloppy arguments elements array has a special format: | 5519 // The sloppy arguments elements array has a special format: |
(...skipping 2717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8335 StoreObjectFieldNoWriteBarrier(result, | 8237 StoreObjectFieldNoWriteBarrier(result, |
8336 PromiseReactionJobInfo::kDebugNameOffset, | 8238 PromiseReactionJobInfo::kDebugNameOffset, |
8337 SmiConstant(kDebugNotActive)); | 8239 SmiConstant(kDebugNotActive)); |
8338 StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kContextOffset, | 8240 StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kContextOffset, |
8339 context); | 8241 context); |
8340 return result; | 8242 return result; |
8341 } | 8243 } |
8342 | 8244 |
8343 } // namespace internal | 8245 } // namespace internal |
8344 } // namespace v8 | 8246 } // namespace v8 |
OLD | NEW |