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 7166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9606 byte_offset); | 9622 byte_offset); |
9607 Add<HStoreNamedField>( | 9623 Add<HStoreNamedField>( |
9608 obj, | 9624 obj, |
9609 HObjectAccess::ForJSArrayBufferViewByteLength(), | 9625 HObjectAccess::ForJSArrayBufferViewByteLength(), |
9610 byte_length); | 9626 byte_length); |
9611 | 9627 |
9612 if (buffer != NULL) { | 9628 if (buffer != NULL) { |
9613 Add<HStoreNamedField>( | 9629 Add<HStoreNamedField>( |
9614 obj, | 9630 obj, |
9615 HObjectAccess::ForJSArrayBufferViewBuffer(), buffer); | 9631 HObjectAccess::ForJSArrayBufferViewBuffer(), buffer); |
9616 HObjectAccess weak_first_view_access = | |
9617 HObjectAccess::ForJSArrayBufferWeakFirstView(); | |
9618 Add<HStoreNamedField>( | |
9619 obj, HObjectAccess::ForJSArrayBufferViewWeakNext(), | |
9620 Add<HLoadNamedField>(buffer, nullptr, weak_first_view_access)); | |
9621 Add<HStoreNamedField>(buffer, weak_first_view_access, obj); | |
9622 } else { | 9632 } else { |
9623 Add<HStoreNamedField>( | 9633 Add<HStoreNamedField>( |
9624 obj, | 9634 obj, |
9625 HObjectAccess::ForJSArrayBufferViewBuffer(), | 9635 HObjectAccess::ForJSArrayBufferViewBuffer(), |
9626 Add<HConstant>(static_cast<int32_t>(0))); | 9636 Add<HConstant>(static_cast<int32_t>(0))); |
9627 Add<HStoreNamedField>(obj, | |
9628 HObjectAccess::ForJSArrayBufferViewWeakNext(), | |
9629 graph()->GetConstantUndefined()); | |
9630 } | 9637 } |
9631 } | 9638 } |
9632 | 9639 |
9633 | 9640 |
9634 void HOptimizedGraphBuilder::GenerateDataViewInitialize( | 9641 void HOptimizedGraphBuilder::GenerateDataViewInitialize( |
9635 CallRuntime* expr) { | 9642 CallRuntime* expr) { |
9636 ZoneList<Expression*>* arguments = expr->arguments(); | 9643 ZoneList<Expression*>* arguments = expr->arguments(); |
9637 | 9644 |
9638 DCHECK(arguments->length()== 4); | 9645 DCHECK(arguments->length()== 4); |
9639 CHECK_ALIVE(VisitForValue(arguments->at(0))); | 9646 CHECK_ALIVE(VisitForValue(arguments->at(0))); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9913 CallRuntime* expr) { | 9920 CallRuntime* expr) { |
9914 DCHECK(expr->arguments()->length() == 1); | 9921 DCHECK(expr->arguments()->length() == 1); |
9915 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); | 9922 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); |
9916 HValue* buffer = Pop(); | 9923 HValue* buffer = Pop(); |
9917 HInstruction* result = New<HLoadNamedField>( | 9924 HInstruction* result = New<HLoadNamedField>( |
9918 buffer, nullptr, HObjectAccess::ForJSArrayBufferByteLength()); | 9925 buffer, nullptr, HObjectAccess::ForJSArrayBufferByteLength()); |
9919 return ast_context()->ReturnInstruction(result, expr->id()); | 9926 return ast_context()->ReturnInstruction(result, expr->id()); |
9920 } | 9927 } |
9921 | 9928 |
9922 | 9929 |
| 9930 void HOptimizedGraphBuilder::GenerateArrayBufferViewIndirectAccessor( |
| 9931 CallRuntime* expr, HObjectAccess access) { |
| 9932 NoObservableSideEffectsScope scope(this); |
| 9933 DCHECK(expr->arguments()->length() == 1); |
| 9934 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); |
| 9935 HValue* view = Pop(); |
| 9936 HInstruction* buffer = Add<HLoadNamedField>( |
| 9937 view, nullptr, HObjectAccess::ForJSArrayBufferViewBuffer()); |
| 9938 HInstruction* field = Add<HLoadNamedField>(view, nullptr, access); |
| 9939 |
| 9940 IfBuilder if_has_buffer(this); |
| 9941 if_has_buffer.IfNot<HIsSmiAndBranch>(buffer); |
| 9942 if_has_buffer.Then(); |
| 9943 { |
| 9944 HInstruction* flags = Add<HLoadNamedField>( |
| 9945 buffer, nullptr, HObjectAccess::ForJSArrayBufferFlag()); |
| 9946 HValue* was_neutered_mask = |
| 9947 Add<HConstant>(1 << JSArrayBuffer::kWasNeuteredBit); |
| 9948 HValue* was_neutered_test = |
| 9949 AddUncasted<HBitwise>(Token::BIT_AND, flags, was_neutered_mask); |
| 9950 |
| 9951 IfBuilder if_was_neutered(this); |
| 9952 if_was_neutered.If<HCompareNumericAndBranch>( |
| 9953 was_neutered_test, graph()->GetConstant0(), Token::NE); |
| 9954 if_was_neutered.Then(); |
| 9955 Push(graph()->GetConstant0()); |
| 9956 if_was_neutered.Else(); |
| 9957 Push(field); |
| 9958 if_was_neutered.End(); |
| 9959 } |
| 9960 if_has_buffer.Else(); |
| 9961 Push(field); |
| 9962 if_has_buffer.End(); |
| 9963 |
| 9964 return ast_context()->ReturnValue(Pop()); |
| 9965 } |
| 9966 |
| 9967 |
9923 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteLength( | 9968 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteLength( |
9924 CallRuntime* expr) { | 9969 CallRuntime* expr) { |
9925 DCHECK(expr->arguments()->length() == 1); | 9970 return GenerateArrayBufferViewIndirectAccessor( |
9926 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); | 9971 expr, HObjectAccess::ForJSArrayBufferViewByteLength()); |
9927 HValue* buffer = Pop(); | |
9928 HInstruction* result = New<HLoadNamedField>( | |
9929 buffer, nullptr, HObjectAccess::ForJSArrayBufferViewByteLength()); | |
9930 return ast_context()->ReturnInstruction(result, expr->id()); | |
9931 } | 9972 } |
9932 | 9973 |
9933 | 9974 |
9934 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteOffset( | 9975 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteOffset( |
9935 CallRuntime* expr) { | 9976 CallRuntime* expr) { |
9936 DCHECK(expr->arguments()->length() == 1); | 9977 return GenerateArrayBufferViewIndirectAccessor( |
9937 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); | 9978 expr, HObjectAccess::ForJSArrayBufferViewByteOffset()); |
9938 HValue* buffer = Pop(); | |
9939 HInstruction* result = New<HLoadNamedField>( | |
9940 buffer, nullptr, HObjectAccess::ForJSArrayBufferViewByteOffset()); | |
9941 return ast_context()->ReturnInstruction(result, expr->id()); | |
9942 } | 9979 } |
9943 | 9980 |
9944 | 9981 |
9945 void HOptimizedGraphBuilder::GenerateTypedArrayGetLength( | 9982 void HOptimizedGraphBuilder::GenerateTypedArrayGetLength( |
9946 CallRuntime* expr) { | 9983 CallRuntime* expr) { |
9947 DCHECK(expr->arguments()->length() == 1); | 9984 return GenerateArrayBufferViewIndirectAccessor( |
9948 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); | 9985 expr, HObjectAccess::ForJSTypedArrayLength()); |
9949 HValue* buffer = Pop(); | |
9950 HInstruction* result = New<HLoadNamedField>( | |
9951 buffer, nullptr, HObjectAccess::ForJSTypedArrayLength()); | |
9952 return ast_context()->ReturnInstruction(result, expr->id()); | |
9953 } | 9986 } |
9954 | 9987 |
9955 | 9988 |
9956 void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) { | 9989 void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) { |
9957 DCHECK(!HasStackOverflow()); | 9990 DCHECK(!HasStackOverflow()); |
9958 DCHECK(current_block() != NULL); | 9991 DCHECK(current_block() != NULL); |
9959 DCHECK(current_block()->HasPredecessor()); | 9992 DCHECK(current_block()->HasPredecessor()); |
9960 if (expr->is_jsruntime()) { | 9993 if (expr->is_jsruntime()) { |
9961 return Bailout(kCallToAJavaScriptRuntimeFunction); | 9994 return Bailout(kCallToAJavaScriptRuntimeFunction); |
9962 } | 9995 } |
(...skipping 3027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12990 if (ShouldProduceTraceOutput()) { | 13023 if (ShouldProduceTraceOutput()) { |
12991 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13024 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
12992 } | 13025 } |
12993 | 13026 |
12994 #ifdef DEBUG | 13027 #ifdef DEBUG |
12995 graph_->Verify(false); // No full verify. | 13028 graph_->Verify(false); // No full verify. |
12996 #endif | 13029 #endif |
12997 } | 13030 } |
12998 | 13031 |
12999 } } // namespace v8::internal | 13032 } } // namespace v8::internal |
OLD | NEW |