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 2409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2420 HObjectAccess::ForArrayLength(elements_kind)); | 2420 HObjectAccess::ForArrayLength(elements_kind)); |
2421 } else { | 2421 } else { |
2422 length = AddLoadFixedArrayLength(elements); | 2422 length = AddLoadFixedArrayLength(elements); |
2423 } | 2423 } |
2424 length->set_type(HType::Smi()); | 2424 length->set_type(HType::Smi()); |
2425 HValue* checked_key = NULL; | 2425 HValue* checked_key = NULL; |
2426 if (IsExternalArrayElementsKind(elements_kind) || | 2426 if (IsExternalArrayElementsKind(elements_kind) || |
2427 IsFixedTypedArrayElementsKind(elements_kind)) { | 2427 IsFixedTypedArrayElementsKind(elements_kind)) { |
2428 HValue* backing_store; | 2428 HValue* backing_store; |
2429 if (IsExternalArrayElementsKind(elements_kind)) { | 2429 if (IsExternalArrayElementsKind(elements_kind)) { |
2430 NoObservableSideEffectsScope no_effects(this); | |
2431 HInstruction* buffer = Add<HLoadNamedField>( | |
2432 checked_object, nullptr, HObjectAccess::ForJSArrayBufferViewBuffer()); | |
2433 HInstruction* flags = Add<HLoadNamedField>( | |
2434 buffer, nullptr, HObjectAccess::ForJSArrayBufferFlag()); | |
2435 HValue* was_neutered_mask = | |
2436 Add<HConstant>(1 << JSArrayBuffer::kWasNeuteredBit); | |
2437 HValue* was_neutered_test = | |
2438 AddUncasted<HBitwise>(Token::BIT_AND, flags, was_neutered_mask); | |
2439 | |
2440 IfBuilder if_was_neutered(this); | |
2441 if_was_neutered.If<HCompareNumericAndBranch>( | |
2442 was_neutered_test, graph()->GetConstant0(), Token::NE); | |
2443 if_was_neutered.ThenDeopt(Deoptimizer::kOutOfBounds); | |
2444 if_was_neutered.End(); | |
2445 | |
2430 backing_store = Add<HLoadNamedField>( | 2446 backing_store = Add<HLoadNamedField>( |
2431 elements, nullptr, HObjectAccess::ForExternalArrayExternalPointer()); | 2447 elements, nullptr, HObjectAccess::ForExternalArrayExternalPointer()); |
2432 } else { | 2448 } else { |
2433 backing_store = elements; | 2449 backing_store = elements; |
2434 } | 2450 } |
2435 if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) { | 2451 if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) { |
2436 NoObservableSideEffectsScope no_effects(this); | 2452 NoObservableSideEffectsScope no_effects(this); |
2437 IfBuilder length_checker(this); | 2453 IfBuilder length_checker(this); |
2438 length_checker.If<HCompareNumericAndBranch>(key, length, Token::LT); | 2454 length_checker.If<HCompareNumericAndBranch>(key, length, Token::LT); |
2439 length_checker.Then(); | 2455 length_checker.Then(); |
(...skipping 7146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9586 byte_offset); | 9602 byte_offset); |
9587 Add<HStoreNamedField>( | 9603 Add<HStoreNamedField>( |
9588 obj, | 9604 obj, |
9589 HObjectAccess::ForJSArrayBufferViewByteLength(), | 9605 HObjectAccess::ForJSArrayBufferViewByteLength(), |
9590 byte_length); | 9606 byte_length); |
9591 | 9607 |
9592 if (buffer != NULL) { | 9608 if (buffer != NULL) { |
9593 Add<HStoreNamedField>( | 9609 Add<HStoreNamedField>( |
9594 obj, | 9610 obj, |
9595 HObjectAccess::ForJSArrayBufferViewBuffer(), buffer); | 9611 HObjectAccess::ForJSArrayBufferViewBuffer(), buffer); |
9596 HObjectAccess weak_first_view_access = | |
9597 HObjectAccess::ForJSArrayBufferWeakFirstView(); | |
9598 Add<HStoreNamedField>( | |
9599 obj, HObjectAccess::ForJSArrayBufferViewWeakNext(), | |
9600 Add<HLoadNamedField>(buffer, nullptr, weak_first_view_access)); | |
9601 Add<HStoreNamedField>(buffer, weak_first_view_access, obj); | |
9602 } else { | 9612 } else { |
9603 Add<HStoreNamedField>( | 9613 Add<HStoreNamedField>( |
9604 obj, | 9614 obj, |
9605 HObjectAccess::ForJSArrayBufferViewBuffer(), | 9615 HObjectAccess::ForJSArrayBufferViewBuffer(), |
9606 Add<HConstant>(static_cast<int32_t>(0))); | 9616 Add<HConstant>(static_cast<int32_t>(0))); |
9607 Add<HStoreNamedField>(obj, | |
9608 HObjectAccess::ForJSArrayBufferViewWeakNext(), | |
9609 graph()->GetConstantUndefined()); | |
9610 } | 9617 } |
9611 } | 9618 } |
9612 | 9619 |
9613 | 9620 |
9614 void HOptimizedGraphBuilder::GenerateDataViewInitialize( | 9621 void HOptimizedGraphBuilder::GenerateDataViewInitialize( |
9615 CallRuntime* expr) { | 9622 CallRuntime* expr) { |
9616 ZoneList<Expression*>* arguments = expr->arguments(); | 9623 ZoneList<Expression*>* arguments = expr->arguments(); |
9617 | 9624 |
9618 DCHECK(arguments->length()== 4); | 9625 DCHECK(arguments->length()== 4); |
9619 CHECK_ALIVE(VisitForValue(arguments->at(0))); | 9626 CHECK_ALIVE(VisitForValue(arguments->at(0))); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9893 CallRuntime* expr) { | 9900 CallRuntime* expr) { |
9894 DCHECK(expr->arguments()->length() == 1); | 9901 DCHECK(expr->arguments()->length() == 1); |
9895 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); | 9902 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); |
9896 HValue* buffer = Pop(); | 9903 HValue* buffer = Pop(); |
9897 HInstruction* result = New<HLoadNamedField>( | 9904 HInstruction* result = New<HLoadNamedField>( |
9898 buffer, nullptr, HObjectAccess::ForJSArrayBufferByteLength()); | 9905 buffer, nullptr, HObjectAccess::ForJSArrayBufferByteLength()); |
9899 return ast_context()->ReturnInstruction(result, expr->id()); | 9906 return ast_context()->ReturnInstruction(result, expr->id()); |
9900 } | 9907 } |
9901 | 9908 |
9902 | 9909 |
9910 void HOptimizedGraphBuilder::GenerateArrayBufferViewIndirectAccessor( | |
9911 CallRuntime* expr, HObjectAccess access) { | |
9912 NoObservableSideEffectsScope scope(this); | |
9913 DCHECK(expr->arguments()->length() == 1); | |
9914 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); | |
9915 HValue* view = Pop(); | |
9916 HInstruction* buffer = Add<HLoadNamedField>( | |
9917 view, nullptr, HObjectAccess::ForJSArrayBufferViewBuffer()); | |
9918 HInstruction* field = Add<HLoadNamedField>(view, nullptr, access); | |
9919 | |
9920 IfBuilder if_has_buffer(this); | |
9921 if_has_buffer.IfNot<HIsSmiAndBranch>(buffer); | |
9922 if_has_buffer.Then(); | |
9923 { | |
9924 HInstruction* flags = Add<HLoadNamedField>( | |
9925 buffer, nullptr, HObjectAccess::ForJSArrayBufferFlag()); | |
9926 HValue* was_neutered_mask = | |
9927 Add<HConstant>(1 << JSArrayBuffer::kWasNeuteredBit); | |
9928 HValue* was_neutered_test = | |
Toon Verwaest
2015/04/17 13:25:55
For now this is fine by me, but we should at least
| |
9929 AddUncasted<HBitwise>(Token::BIT_AND, flags, was_neutered_mask); | |
9930 | |
9931 IfBuilder if_was_neutered(this); | |
9932 if_was_neutered.If<HCompareNumericAndBranch>( | |
9933 was_neutered_test, graph()->GetConstant0(), Token::NE); | |
9934 if_was_neutered.Then(); | |
9935 Push(graph()->GetConstant0()); | |
9936 if_was_neutered.Else(); | |
9937 Push(field); | |
9938 if_was_neutered.End(); | |
9939 } | |
9940 if_has_buffer.Else(); | |
9941 Push(field); | |
9942 if_has_buffer.End(); | |
9943 | |
9944 return ast_context()->ReturnValue(Pop()); | |
9945 } | |
9946 | |
9947 | |
9903 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteLength( | 9948 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteLength( |
9904 CallRuntime* expr) { | 9949 CallRuntime* expr) { |
9905 DCHECK(expr->arguments()->length() == 1); | 9950 return GenerateArrayBufferViewIndirectAccessor( |
9906 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); | 9951 expr, HObjectAccess::ForJSArrayBufferViewByteLength()); |
9907 HValue* buffer = Pop(); | |
9908 HInstruction* result = New<HLoadNamedField>( | |
9909 buffer, nullptr, HObjectAccess::ForJSArrayBufferViewByteLength()); | |
9910 return ast_context()->ReturnInstruction(result, expr->id()); | |
9911 } | 9952 } |
9912 | 9953 |
9913 | 9954 |
9914 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteOffset( | 9955 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteOffset( |
9915 CallRuntime* expr) { | 9956 CallRuntime* expr) { |
9916 DCHECK(expr->arguments()->length() == 1); | 9957 return GenerateArrayBufferViewIndirectAccessor( |
9917 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); | 9958 expr, HObjectAccess::ForJSArrayBufferViewByteOffset()); |
9918 HValue* buffer = Pop(); | |
9919 HInstruction* result = New<HLoadNamedField>( | |
9920 buffer, nullptr, HObjectAccess::ForJSArrayBufferViewByteOffset()); | |
9921 return ast_context()->ReturnInstruction(result, expr->id()); | |
9922 } | 9959 } |
9923 | 9960 |
9924 | 9961 |
9925 void HOptimizedGraphBuilder::GenerateTypedArrayGetLength( | 9962 void HOptimizedGraphBuilder::GenerateTypedArrayGetLength( |
9926 CallRuntime* expr) { | 9963 CallRuntime* expr) { |
9927 DCHECK(expr->arguments()->length() == 1); | 9964 return GenerateArrayBufferViewIndirectAccessor( |
9928 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); | 9965 expr, HObjectAccess::ForJSTypedArrayLength()); |
9929 HValue* buffer = Pop(); | |
9930 HInstruction* result = New<HLoadNamedField>( | |
9931 buffer, nullptr, HObjectAccess::ForJSTypedArrayLength()); | |
9932 return ast_context()->ReturnInstruction(result, expr->id()); | |
9933 } | 9966 } |
9934 | 9967 |
9935 | 9968 |
9936 void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) { | 9969 void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) { |
9937 DCHECK(!HasStackOverflow()); | 9970 DCHECK(!HasStackOverflow()); |
9938 DCHECK(current_block() != NULL); | 9971 DCHECK(current_block() != NULL); |
9939 DCHECK(current_block()->HasPredecessor()); | 9972 DCHECK(current_block()->HasPredecessor()); |
9940 if (expr->is_jsruntime()) { | 9973 if (expr->is_jsruntime()) { |
9941 return Bailout(kCallToAJavaScriptRuntimeFunction); | 9974 return Bailout(kCallToAJavaScriptRuntimeFunction); |
9942 } | 9975 } |
(...skipping 3018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12961 if (ShouldProduceTraceOutput()) { | 12994 if (ShouldProduceTraceOutput()) { |
12962 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12995 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
12963 } | 12996 } |
12964 | 12997 |
12965 #ifdef DEBUG | 12998 #ifdef DEBUG |
12966 graph_->Verify(false); // No full verify. | 12999 graph_->Verify(false); // No full verify. |
12967 #endif | 13000 #endif |
12968 } | 13001 } |
12969 | 13002 |
12970 } } // namespace v8::internal | 13003 } } // namespace v8::internal |
OLD | NEW |