Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/hydrogen.h" | 5 #include "src/hydrogen.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| (...skipping 3149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3160 HValue* HGraphBuilder::BuildArrayBufferViewFieldAccessor(HValue* object, | 3160 HValue* HGraphBuilder::BuildArrayBufferViewFieldAccessor(HValue* object, |
| 3161 HValue* checked_object, | 3161 HValue* checked_object, |
| 3162 FieldIndex index) { | 3162 FieldIndex index) { |
| 3163 NoObservableSideEffectsScope scope(this); | 3163 NoObservableSideEffectsScope scope(this); |
| 3164 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset( | 3164 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset( |
| 3165 index.offset(), Representation::Tagged()); | 3165 index.offset(), Representation::Tagged()); |
| 3166 HInstruction* buffer = Add<HLoadNamedField>( | 3166 HInstruction* buffer = Add<HLoadNamedField>( |
| 3167 object, checked_object, HObjectAccess::ForJSArrayBufferViewBuffer()); | 3167 object, checked_object, HObjectAccess::ForJSArrayBufferViewBuffer()); |
| 3168 HInstruction* field = Add<HLoadNamedField>(object, checked_object, access); | 3168 HInstruction* field = Add<HLoadNamedField>(object, checked_object, access); |
| 3169 | 3169 |
| 3170 IfBuilder if_has_buffer(this); | 3170 HInstruction* flags = Add<HLoadNamedField>( |
| 3171 HValue* has_buffer = if_has_buffer.IfNot<HIsSmiAndBranch>(buffer); | 3171 buffer, nullptr, HObjectAccess::ForJSArrayBufferBitField()); |
| 3172 if_has_buffer.Then(); | 3172 HValue* was_neutered_mask = |
| 3173 { | 3173 Add<HConstant>(1 << JSArrayBuffer::WasNeutered::kShift); |
| 3174 HInstruction* flags = Add<HLoadNamedField>( | 3174 HValue* was_neutered_test = |
| 3175 buffer, has_buffer, HObjectAccess::ForJSArrayBufferBitField()); | 3175 AddUncasted<HBitwise>(Token::BIT_AND, flags, was_neutered_mask); |
| 3176 HValue* was_neutered_mask = | |
| 3177 Add<HConstant>(1 << JSArrayBuffer::WasNeutered::kShift); | |
| 3178 HValue* was_neutered_test = | |
| 3179 AddUncasted<HBitwise>(Token::BIT_AND, flags, was_neutered_mask); | |
| 3180 | 3176 |
| 3181 IfBuilder if_was_neutered(this); | 3177 IfBuilder if_was_neutered(this); |
| 3182 if_was_neutered.If<HCompareNumericAndBranch>( | 3178 if_was_neutered.If<HCompareNumericAndBranch>( |
| 3183 was_neutered_test, graph()->GetConstant0(), Token::NE); | 3179 was_neutered_test, graph()->GetConstant0(), Token::NE); |
| 3184 if_was_neutered.Then(); | 3180 if_was_neutered.Then(); |
| 3185 Push(graph()->GetConstant0()); | 3181 Push(graph()->GetConstant0()); |
| 3186 if_was_neutered.Else(); | 3182 if_was_neutered.Else(); |
| 3187 Push(field); | |
| 3188 if_was_neutered.End(); | |
| 3189 } | |
| 3190 if_has_buffer.Else(); | |
| 3191 Push(field); | 3183 Push(field); |
| 3192 if_has_buffer.End(); | 3184 if_was_neutered.End(); |
| 3193 | 3185 |
| 3194 return Pop(); | 3186 return Pop(); |
| 3195 } | 3187 } |
| 3196 | 3188 |
| 3197 | 3189 |
| 3198 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, | 3190 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
| 3199 ElementsKind kind, | 3191 ElementsKind kind, |
| 3200 HValue* allocation_site_payload, | 3192 HValue* allocation_site_payload, |
| 3201 HValue* constructor_function, | 3193 HValue* constructor_function, |
| 3202 AllocationSiteOverrideMode override_mode) : | 3194 AllocationSiteOverrideMode override_mode) : |
| (...skipping 6492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9695 // argument to the construct call. | 9687 // argument to the construct call. |
| 9696 if (TryHandleArrayCallNew(expr, function)) return; | 9688 if (TryHandleArrayCallNew(expr, function)) return; |
| 9697 | 9689 |
| 9698 HInstruction* call = | 9690 HInstruction* call = |
| 9699 PreProcessCall(New<HCallNew>(function, argument_count)); | 9691 PreProcessCall(New<HCallNew>(function, argument_count)); |
| 9700 return ast_context()->ReturnInstruction(call, expr->id()); | 9692 return ast_context()->ReturnInstruction(call, expr->id()); |
| 9701 } | 9693 } |
| 9702 } | 9694 } |
| 9703 | 9695 |
| 9704 | 9696 |
| 9697 HValue* HGraphBuilder::BuildAllocateEmptyArrayBuffer(HValue* byte_length) { | |
| 9698 HAllocate* result = | |
| 9699 BuildAllocate(Add<HConstant>(JSArrayBuffer::kSizeWithInternalFields), | |
| 9700 HType::JSObject(), JS_ARRAY_BUFFER_TYPE, HAllocationMode()); | |
| 9701 result->MakePrefillWithFiller(); | |
|
Hannes Payer (out of office)
2015/04/30 10:50:18
Make prefill with filler is not the right thing he
| |
| 9702 | |
| 9703 HValue* global_object = Add<HLoadNamedField>( | |
| 9704 context(), nullptr, | |
| 9705 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); | |
| 9706 HValue* native_context = Add<HLoadNamedField>( | |
| 9707 global_object, nullptr, HObjectAccess::ForGlobalObjectNativeContext()); | |
| 9708 Add<HStoreNamedField>( | |
| 9709 result, HObjectAccess::ForMap(), | |
| 9710 Add<HLoadNamedField>( | |
| 9711 native_context, nullptr, | |
| 9712 HObjectAccess::ForContextSlot(Context::ARRAY_BUFFER_MAP_INDEX))); | |
| 9713 | |
| 9714 Add<HStoreNamedField>(result, HObjectAccess::ForJSArrayBufferBackingStore(), | |
| 9715 Add<HConstant>(ExternalReference())); | |
| 9716 Add<HStoreNamedField>(result, HObjectAccess::ForJSArrayBufferByteLength(), | |
| 9717 byte_length); | |
| 9718 Add<HStoreNamedField>(result, HObjectAccess::ForJSArrayBufferBitFieldSlot(), | |
| 9719 graph()->GetConstant0()); | |
| 9720 Add<HStoreNamedField>( | |
| 9721 result, HObjectAccess::ForJSArrayBufferBitField(), | |
| 9722 Add<HConstant>((1 << JSArrayBuffer::IsExternal::kShift) | | |
| 9723 (1 << JSArrayBuffer::IsNeuterable::kShift))); | |
| 9724 | |
| 9725 return result; | |
| 9726 } | |
| 9727 | |
| 9728 | |
| 9705 template <class ViewClass> | 9729 template <class ViewClass> |
| 9706 void HGraphBuilder::BuildArrayBufferViewInitialization( | 9730 void HGraphBuilder::BuildArrayBufferViewInitialization( |
| 9707 HValue* obj, | 9731 HValue* obj, |
| 9708 HValue* buffer, | 9732 HValue* buffer, |
| 9709 HValue* byte_offset, | 9733 HValue* byte_offset, |
| 9710 HValue* byte_length) { | 9734 HValue* byte_length) { |
| 9711 | 9735 |
| 9712 for (int offset = ViewClass::kSize; | 9736 for (int offset = ViewClass::kSize; |
| 9713 offset < ViewClass::kSizeWithInternalFields; | 9737 offset < ViewClass::kSizeWithInternalFields; |
| 9714 offset += kPointerSize) { | 9738 offset += kPointerSize) { |
| 9715 Add<HStoreNamedField>(obj, | 9739 Add<HStoreNamedField>(obj, |
| 9716 HObjectAccess::ForObservableJSObjectOffset(offset), | 9740 HObjectAccess::ForObservableJSObjectOffset(offset), |
| 9717 graph()->GetConstant0()); | 9741 graph()->GetConstant0()); |
| 9718 } | 9742 } |
| 9719 | 9743 |
| 9720 Add<HStoreNamedField>( | 9744 Add<HStoreNamedField>( |
| 9721 obj, | 9745 obj, |
| 9722 HObjectAccess::ForJSArrayBufferViewByteOffset(), | 9746 HObjectAccess::ForJSArrayBufferViewByteOffset(), |
| 9723 byte_offset); | 9747 byte_offset); |
| 9724 Add<HStoreNamedField>( | 9748 Add<HStoreNamedField>( |
| 9725 obj, | 9749 obj, |
| 9726 HObjectAccess::ForJSArrayBufferViewByteLength(), | 9750 HObjectAccess::ForJSArrayBufferViewByteLength(), |
| 9727 byte_length); | 9751 byte_length); |
| 9728 | 9752 Add<HStoreNamedField>(obj, HObjectAccess::ForJSArrayBufferViewBuffer(), |
| 9729 if (buffer != NULL) { | 9753 buffer); |
| 9730 Add<HStoreNamedField>( | |
| 9731 obj, | |
| 9732 HObjectAccess::ForJSArrayBufferViewBuffer(), buffer); | |
| 9733 } else { | |
| 9734 Add<HStoreNamedField>( | |
| 9735 obj, | |
| 9736 HObjectAccess::ForJSArrayBufferViewBuffer(), | |
| 9737 Add<HConstant>(static_cast<int32_t>(0))); | |
| 9738 } | |
| 9739 } | 9754 } |
| 9740 | 9755 |
| 9741 | 9756 |
| 9742 void HOptimizedGraphBuilder::GenerateDataViewInitialize( | 9757 void HOptimizedGraphBuilder::GenerateDataViewInitialize( |
| 9743 CallRuntime* expr) { | 9758 CallRuntime* expr) { |
| 9744 ZoneList<Expression*>* arguments = expr->arguments(); | 9759 ZoneList<Expression*>* arguments = expr->arguments(); |
| 9745 | 9760 |
| 9746 DCHECK(arguments->length()== 4); | 9761 DCHECK(arguments->length()== 4); |
| 9747 CHECK_ALIVE(VisitForValue(arguments->at(0))); | 9762 CHECK_ALIVE(VisitForValue(arguments->at(0))); |
| 9748 HValue* obj = Pop(); | 9763 HValue* obj = Pop(); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9950 ElementsKind fixed_elements_kind = // Bogus initialization. | 9965 ElementsKind fixed_elements_kind = // Bogus initialization. |
| 9951 INT8_ELEMENTS; | 9966 INT8_ELEMENTS; |
| 9952 Runtime::ArrayIdToTypeAndSize(array_id, | 9967 Runtime::ArrayIdToTypeAndSize(array_id, |
| 9953 &array_type, | 9968 &array_type, |
| 9954 &external_elements_kind, | 9969 &external_elements_kind, |
| 9955 &fixed_elements_kind, | 9970 &fixed_elements_kind, |
| 9956 &element_size); | 9971 &element_size); |
| 9957 | 9972 |
| 9958 | 9973 |
| 9959 { // byte_offset is Smi. | 9974 { // byte_offset is Smi. |
| 9960 BuildArrayBufferViewInitialization<JSTypedArray>( | 9975 HValue* allocated_buffer = buffer; |
| 9961 obj, buffer, byte_offset, byte_length); | 9976 if (buffer == NULL) { |
| 9977 allocated_buffer = BuildAllocateEmptyArrayBuffer(byte_length); | |
| 9978 } | |
| 9979 BuildArrayBufferViewInitialization<JSTypedArray>(obj, allocated_buffer, | |
| 9980 byte_offset, byte_length); | |
| 9962 | 9981 |
| 9963 | 9982 |
| 9964 HInstruction* length = AddUncasted<HDiv>(byte_length, | 9983 HInstruction* length = AddUncasted<HDiv>(byte_length, |
| 9965 Add<HConstant>(static_cast<int32_t>(element_size))); | 9984 Add<HConstant>(static_cast<int32_t>(element_size))); |
| 9966 | 9985 |
| 9967 Add<HStoreNamedField>(obj, | 9986 Add<HStoreNamedField>(obj, |
| 9968 HObjectAccess::ForJSTypedArrayLength(), | 9987 HObjectAccess::ForJSTypedArrayLength(), |
| 9969 length); | 9988 length); |
| 9970 | 9989 |
| 9971 HValue* elements; | 9990 HValue* elements; |
| (...skipping 3134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13106 if (ShouldProduceTraceOutput()) { | 13125 if (ShouldProduceTraceOutput()) { |
| 13107 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13126 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13108 } | 13127 } |
| 13109 | 13128 |
| 13110 #ifdef DEBUG | 13129 #ifdef DEBUG |
| 13111 graph_->Verify(false); // No full verify. | 13130 graph_->Verify(false); // No full verify. |
| 13112 #endif | 13131 #endif |
| 13113 } | 13132 } |
| 13114 | 13133 |
| 13115 } } // namespace v8::internal | 13134 } } // namespace v8::internal |
| OLD | NEW |