Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: src/hydrogen.cc

Issue 1109353003: Unify internal and external typed arrays a bit (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
9702 HValue* global_object = Add<HLoadNamedField>(
9703 context(), nullptr,
9704 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
9705 HValue* native_context = Add<HLoadNamedField>(
9706 global_object, nullptr, HObjectAccess::ForGlobalObjectNativeContext());
9707 Add<HStoreNamedField>(
9708 result, HObjectAccess::ForMap(),
9709 Add<HLoadNamedField>(
9710 native_context, nullptr,
9711 HObjectAccess::ForContextSlot(Context::ARRAY_BUFFER_MAP_INDEX)));
9712
9713 Add<HStoreNamedField>(result, HObjectAccess::ForJSArrayBufferBackingStore(),
9714 Add<HConstant>(ExternalReference()));
9715 Add<HStoreNamedField>(result, HObjectAccess::ForJSArrayBufferByteLength(),
9716 byte_length);
9717 Add<HStoreNamedField>(result, HObjectAccess::ForJSArrayBufferBitFieldSlot(),
9718 graph()->GetConstant0());
9719 Add<HStoreNamedField>(
9720 result, HObjectAccess::ForJSArrayBufferBitField(),
9721 Add<HConstant>((1 << JSArrayBuffer::IsExternal::kShift) |
9722 (1 << JSArrayBuffer::IsNeuterable::kShift)));
9723
9724 for (int field = 0; field < v8::ArrayBuffer::kInternalFieldCount; ++field) {
9725 Add<HStoreNamedField>(
9726 result,
9727 HObjectAccess::ForObservableJSObjectOffset(
9728 JSArrayBuffer::kSize + field * kPointerSize, Representation::Smi()),
9729 graph()->GetConstant0());
9730 }
9731
9732 return result;
9733 }
9734
9735
9705 template <class ViewClass> 9736 template <class ViewClass>
9706 void HGraphBuilder::BuildArrayBufferViewInitialization( 9737 void HGraphBuilder::BuildArrayBufferViewInitialization(
9707 HValue* obj, 9738 HValue* obj,
9708 HValue* buffer, 9739 HValue* buffer,
9709 HValue* byte_offset, 9740 HValue* byte_offset,
9710 HValue* byte_length) { 9741 HValue* byte_length) {
9711 9742
9712 for (int offset = ViewClass::kSize; 9743 for (int offset = ViewClass::kSize;
9713 offset < ViewClass::kSizeWithInternalFields; 9744 offset < ViewClass::kSizeWithInternalFields;
9714 offset += kPointerSize) { 9745 offset += kPointerSize) {
9715 Add<HStoreNamedField>(obj, 9746 Add<HStoreNamedField>(obj,
9716 HObjectAccess::ForObservableJSObjectOffset(offset), 9747 HObjectAccess::ForObservableJSObjectOffset(offset),
9717 graph()->GetConstant0()); 9748 graph()->GetConstant0());
9718 } 9749 }
9719 9750
9720 Add<HStoreNamedField>( 9751 Add<HStoreNamedField>(
9721 obj, 9752 obj,
9722 HObjectAccess::ForJSArrayBufferViewByteOffset(), 9753 HObjectAccess::ForJSArrayBufferViewByteOffset(),
9723 byte_offset); 9754 byte_offset);
9724 Add<HStoreNamedField>( 9755 Add<HStoreNamedField>(
9725 obj, 9756 obj,
9726 HObjectAccess::ForJSArrayBufferViewByteLength(), 9757 HObjectAccess::ForJSArrayBufferViewByteLength(),
9727 byte_length); 9758 byte_length);
9728 9759 Add<HStoreNamedField>(obj, HObjectAccess::ForJSArrayBufferViewBuffer(),
9729 if (buffer != NULL) { 9760 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 } 9761 }
9740 9762
9741 9763
9742 void HOptimizedGraphBuilder::GenerateDataViewInitialize( 9764 void HOptimizedGraphBuilder::GenerateDataViewInitialize(
9743 CallRuntime* expr) { 9765 CallRuntime* expr) {
9744 ZoneList<Expression*>* arguments = expr->arguments(); 9766 ZoneList<Expression*>* arguments = expr->arguments();
9745 9767
9746 DCHECK(arguments->length()== 4); 9768 DCHECK(arguments->length()== 4);
9747 CHECK_ALIVE(VisitForValue(arguments->at(0))); 9769 CHECK_ALIVE(VisitForValue(arguments->at(0)));
9748 HValue* obj = Pop(); 9770 HValue* obj = Pop();
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
9950 ElementsKind fixed_elements_kind = // Bogus initialization. 9972 ElementsKind fixed_elements_kind = // Bogus initialization.
9951 INT8_ELEMENTS; 9973 INT8_ELEMENTS;
9952 Runtime::ArrayIdToTypeAndSize(array_id, 9974 Runtime::ArrayIdToTypeAndSize(array_id,
9953 &array_type, 9975 &array_type,
9954 &external_elements_kind, 9976 &external_elements_kind,
9955 &fixed_elements_kind, 9977 &fixed_elements_kind,
9956 &element_size); 9978 &element_size);
9957 9979
9958 9980
9959 { // byte_offset is Smi. 9981 { // byte_offset is Smi.
9960 BuildArrayBufferViewInitialization<JSTypedArray>( 9982 HValue* allocated_buffer = buffer;
9961 obj, buffer, byte_offset, byte_length); 9983 if (buffer == NULL) {
9984 allocated_buffer = BuildAllocateEmptyArrayBuffer(byte_length);
9985 }
9986 BuildArrayBufferViewInitialization<JSTypedArray>(obj, allocated_buffer,
9987 byte_offset, byte_length);
9962 9988
9963 9989
9964 HInstruction* length = AddUncasted<HDiv>(byte_length, 9990 HInstruction* length = AddUncasted<HDiv>(byte_length,
9965 Add<HConstant>(static_cast<int32_t>(element_size))); 9991 Add<HConstant>(static_cast<int32_t>(element_size)));
9966 9992
9967 Add<HStoreNamedField>(obj, 9993 Add<HStoreNamedField>(obj,
9968 HObjectAccess::ForJSTypedArrayLength(), 9994 HObjectAccess::ForJSTypedArrayLength(),
9969 length); 9995 length);
9970 9996
9971 HValue* elements; 9997 HValue* elements;
(...skipping 3138 matching lines...) Expand 10 before | Expand all | Expand 10 after
13110 if (ShouldProduceTraceOutput()) { 13136 if (ShouldProduceTraceOutput()) {
13111 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13137 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13112 } 13138 }
13113 13139
13114 #ifdef DEBUG 13140 #ifdef DEBUG
13115 graph_->Verify(false); // No full verify. 13141 graph_->Verify(false); // No full verify.
13116 #endif 13142 #endif
13117 } 13143 }
13118 13144
13119 } } // namespace v8::internal 13145 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698