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

Side by Side Diff: src/hydrogen.cc

Issue 1064083003: Recover performance of array buffer view field accesses in ICs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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/ic/ic.cc » ('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 3153 matching lines...) Expand 10 before | Expand all | Expand 10 after
3164 3164
3165 3165
3166 HInstruction* HGraphBuilder::BuildGetArrayFunction() { 3166 HInstruction* HGraphBuilder::BuildGetArrayFunction() {
3167 HInstruction* native_context = BuildGetNativeContext(); 3167 HInstruction* native_context = BuildGetNativeContext();
3168 HInstruction* index = 3168 HInstruction* index =
3169 Add<HConstant>(static_cast<int32_t>(Context::ARRAY_FUNCTION_INDEX)); 3169 Add<HConstant>(static_cast<int32_t>(Context::ARRAY_FUNCTION_INDEX));
3170 return Add<HLoadKeyed>(native_context, index, nullptr, FAST_ELEMENTS); 3170 return Add<HLoadKeyed>(native_context, index, nullptr, FAST_ELEMENTS);
3171 } 3171 }
3172 3172
3173 3173
3174 HInstruction* HGraphBuilder::BuildArrayBufferViewFieldAccessor(
3175 HValue* object, FieldIndex index) {
3176 NoObservableSideEffectsScope scope(this);
3177 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset(
3178 index.offset(), Representation::Tagged());
3179 HInstruction* buffer = Add<HLoadNamedField>(
3180 object, nullptr, HObjectAccess::ForJSArrayBufferViewBuffer());
3181 HInstruction* field = Add<HLoadNamedField>(object, nullptr, access);
3182
3183 IfBuilder if_has_buffer(this);
3184 if_has_buffer.IfNot<HIsSmiAndBranch>(buffer);
3185 if_has_buffer.Then();
3186 {
3187 HInstruction* flags = Add<HLoadNamedField>(
3188 buffer, nullptr, HObjectAccess::ForJSArrayBufferFlag());
3189 HValue* was_neutered_mask =
3190 Add<HConstant>(1 << JSArrayBuffer::kWasNeuteredBit);
3191 HValue* was_neutered_test =
3192 AddUncasted<HBitwise>(Token::BIT_AND, flags, was_neutered_mask);
3193
3194 IfBuilder if_was_neutered(this);
3195 if_was_neutered.If<HCompareNumericAndBranch>(
3196 was_neutered_test, graph()->GetConstant0(), Token::NE);
3197 if_was_neutered.Then();
3198 Push(graph()->GetConstant0());
3199 if_was_neutered.Else();
3200 Push(field);
3201 if_was_neutered.End();
3202 }
3203 if_has_buffer.Else();
3204 Push(field);
3205 if_has_buffer.End();
3206
3207 return HInstruction::cast(Pop());
3208 }
3209
3210
3174 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, 3211 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder,
3175 ElementsKind kind, 3212 ElementsKind kind,
3176 HValue* allocation_site_payload, 3213 HValue* allocation_site_payload,
3177 HValue* constructor_function, 3214 HValue* constructor_function,
3178 AllocationSiteOverrideMode override_mode) : 3215 AllocationSiteOverrideMode override_mode) :
3179 builder_(builder), 3216 builder_(builder),
3180 kind_(kind), 3217 kind_(kind),
3181 allocation_site_payload_(allocation_site_payload), 3218 allocation_site_payload_(allocation_site_payload),
3182 constructor_function_(constructor_function) { 3219 constructor_function_(constructor_function) {
3183 DCHECK(!allocation_site_payload->IsConstant() || 3220 DCHECK(!allocation_site_payload->IsConstant() ||
(...skipping 6740 matching lines...) Expand 10 before | Expand all | Expand 10 after
9924 CallRuntime* expr) { 9961 CallRuntime* expr) {
9925 DCHECK(expr->arguments()->length() == 1); 9962 DCHECK(expr->arguments()->length() == 1);
9926 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); 9963 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0)));
9927 HValue* buffer = Pop(); 9964 HValue* buffer = Pop();
9928 HInstruction* result = New<HLoadNamedField>( 9965 HInstruction* result = New<HLoadNamedField>(
9929 buffer, nullptr, HObjectAccess::ForJSArrayBufferByteLength()); 9966 buffer, nullptr, HObjectAccess::ForJSArrayBufferByteLength());
9930 return ast_context()->ReturnInstruction(result, expr->id()); 9967 return ast_context()->ReturnInstruction(result, expr->id());
9931 } 9968 }
9932 9969
9933 9970
9934 void HOptimizedGraphBuilder::GenerateArrayBufferViewIndirectAccessor(
9935 CallRuntime* expr, HObjectAccess access) {
9936 NoObservableSideEffectsScope scope(this);
9937 DCHECK(expr->arguments()->length() == 1);
9938 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0)));
9939 HValue* view = Pop();
9940 HInstruction* buffer = Add<HLoadNamedField>(
9941 view, nullptr, HObjectAccess::ForJSArrayBufferViewBuffer());
9942 HInstruction* field = Add<HLoadNamedField>(view, nullptr, access);
9943
9944 IfBuilder if_has_buffer(this);
9945 if_has_buffer.IfNot<HIsSmiAndBranch>(buffer);
9946 if_has_buffer.Then();
9947 {
9948 HInstruction* flags = Add<HLoadNamedField>(
9949 buffer, nullptr, HObjectAccess::ForJSArrayBufferFlag());
9950 HValue* was_neutered_mask =
9951 Add<HConstant>(1 << JSArrayBuffer::kWasNeuteredBit);
9952 HValue* was_neutered_test =
9953 AddUncasted<HBitwise>(Token::BIT_AND, flags, was_neutered_mask);
9954
9955 IfBuilder if_was_neutered(this);
9956 if_was_neutered.If<HCompareNumericAndBranch>(
9957 was_neutered_test, graph()->GetConstant0(), Token::NE);
9958 if_was_neutered.Then();
9959 Push(graph()->GetConstant0());
9960 if_was_neutered.Else();
9961 Push(field);
9962 if_was_neutered.End();
9963 }
9964 if_has_buffer.Else();
9965 Push(field);
9966 if_has_buffer.End();
9967
9968 return ast_context()->ReturnValue(Pop());
9969 }
9970
9971
9972 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteLength( 9971 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteLength(
9973 CallRuntime* expr) { 9972 CallRuntime* expr) {
9974 return GenerateArrayBufferViewIndirectAccessor( 9973 NoObservableSideEffectsScope scope(this);
9975 expr, HObjectAccess::ForJSArrayBufferViewByteLength()); 9974 DCHECK(expr->arguments()->length() == 1);
9975 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0)));
9976 HValue* view = Pop();
9977
9978 return ast_context()->ReturnValue(BuildArrayBufferViewFieldAccessor(
9979 view,
9980 FieldIndex::ForInObjectOffset(JSArrayBufferView::kByteLengthOffset)));
9976 } 9981 }
9977 9982
9978 9983
9979 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteOffset( 9984 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteOffset(
9980 CallRuntime* expr) { 9985 CallRuntime* expr) {
9981 return GenerateArrayBufferViewIndirectAccessor( 9986 NoObservableSideEffectsScope scope(this);
9982 expr, HObjectAccess::ForJSArrayBufferViewByteOffset()); 9987 DCHECK(expr->arguments()->length() == 1);
9988 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0)));
9989 HValue* view = Pop();
9990
9991 return ast_context()->ReturnValue(BuildArrayBufferViewFieldAccessor(
9992 view,
9993 FieldIndex::ForInObjectOffset(JSArrayBufferView::kByteOffsetOffset)));
9983 } 9994 }
9984 9995
9985 9996
9986 void HOptimizedGraphBuilder::GenerateTypedArrayGetLength( 9997 void HOptimizedGraphBuilder::GenerateTypedArrayGetLength(
9987 CallRuntime* expr) { 9998 CallRuntime* expr) {
9988 return GenerateArrayBufferViewIndirectAccessor( 9999 NoObservableSideEffectsScope scope(this);
9989 expr, HObjectAccess::ForJSTypedArrayLength()); 10000 DCHECK(expr->arguments()->length() == 1);
10001 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0)));
10002 HValue* view = Pop();
10003
10004 return ast_context()->ReturnValue(BuildArrayBufferViewFieldAccessor(
10005 view, FieldIndex::ForInObjectOffset(JSTypedArray::kLengthOffset)));
9990 } 10006 }
9991 10007
9992 10008
9993 void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) { 10009 void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) {
9994 DCHECK(!HasStackOverflow()); 10010 DCHECK(!HasStackOverflow());
9995 DCHECK(current_block() != NULL); 10011 DCHECK(current_block() != NULL);
9996 DCHECK(current_block()->HasPredecessor()); 10012 DCHECK(current_block()->HasPredecessor());
9997 if (expr->is_jsruntime()) { 10013 if (expr->is_jsruntime()) {
9998 return Bailout(kCallToAJavaScriptRuntimeFunction); 10014 return Bailout(kCallToAJavaScriptRuntimeFunction);
9999 } 10015 }
(...skipping 3027 matching lines...) Expand 10 before | Expand all | Expand 10 after
13027 if (ShouldProduceTraceOutput()) { 13043 if (ShouldProduceTraceOutput()) {
13028 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13044 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13029 } 13045 }
13030 13046
13031 #ifdef DEBUG 13047 #ifdef DEBUG
13032 graph_->Verify(false); // No full verify. 13048 graph_->Verify(false); // No full verify.
13033 #endif 13049 #endif
13034 } 13050 }
13035 13051
13036 } } // namespace v8::internal 13052 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/ic/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698