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 | |
2446 backing_store = Add<HLoadNamedField>( | 2430 backing_store = Add<HLoadNamedField>( |
2447 elements, nullptr, HObjectAccess::ForExternalArrayExternalPointer()); | 2431 elements, nullptr, HObjectAccess::ForExternalArrayExternalPointer()); |
2448 } else { | 2432 } else { |
2449 backing_store = elements; | 2433 backing_store = elements; |
2450 } | 2434 } |
2451 if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) { | 2435 if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) { |
2452 NoObservableSideEffectsScope no_effects(this); | 2436 NoObservableSideEffectsScope no_effects(this); |
2453 IfBuilder length_checker(this); | 2437 IfBuilder length_checker(this); |
2454 length_checker.If<HCompareNumericAndBranch>(key, length, Token::LT); | 2438 length_checker.If<HCompareNumericAndBranch>(key, length, Token::LT); |
2455 length_checker.Then(); | 2439 length_checker.Then(); |
(...skipping 7166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9622 byte_offset); | 9606 byte_offset); |
9623 Add<HStoreNamedField>( | 9607 Add<HStoreNamedField>( |
9624 obj, | 9608 obj, |
9625 HObjectAccess::ForJSArrayBufferViewByteLength(), | 9609 HObjectAccess::ForJSArrayBufferViewByteLength(), |
9626 byte_length); | 9610 byte_length); |
9627 | 9611 |
9628 if (buffer != NULL) { | 9612 if (buffer != NULL) { |
9629 Add<HStoreNamedField>( | 9613 Add<HStoreNamedField>( |
9630 obj, | 9614 obj, |
9631 HObjectAccess::ForJSArrayBufferViewBuffer(), buffer); | 9615 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); |
9632 } else { | 9622 } else { |
9633 Add<HStoreNamedField>( | 9623 Add<HStoreNamedField>( |
9634 obj, | 9624 obj, |
9635 HObjectAccess::ForJSArrayBufferViewBuffer(), | 9625 HObjectAccess::ForJSArrayBufferViewBuffer(), |
9636 Add<HConstant>(static_cast<int32_t>(0))); | 9626 Add<HConstant>(static_cast<int32_t>(0))); |
| 9627 Add<HStoreNamedField>(obj, |
| 9628 HObjectAccess::ForJSArrayBufferViewWeakNext(), |
| 9629 graph()->GetConstantUndefined()); |
9637 } | 9630 } |
9638 } | 9631 } |
9639 | 9632 |
9640 | 9633 |
9641 void HOptimizedGraphBuilder::GenerateDataViewInitialize( | 9634 void HOptimizedGraphBuilder::GenerateDataViewInitialize( |
9642 CallRuntime* expr) { | 9635 CallRuntime* expr) { |
9643 ZoneList<Expression*>* arguments = expr->arguments(); | 9636 ZoneList<Expression*>* arguments = expr->arguments(); |
9644 | 9637 |
9645 DCHECK(arguments->length()== 4); | 9638 DCHECK(arguments->length()== 4); |
9646 CHECK_ALIVE(VisitForValue(arguments->at(0))); | 9639 CHECK_ALIVE(VisitForValue(arguments->at(0))); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9920 CallRuntime* expr) { | 9913 CallRuntime* expr) { |
9921 DCHECK(expr->arguments()->length() == 1); | 9914 DCHECK(expr->arguments()->length() == 1); |
9922 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); | 9915 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); |
9923 HValue* buffer = Pop(); | 9916 HValue* buffer = Pop(); |
9924 HInstruction* result = New<HLoadNamedField>( | 9917 HInstruction* result = New<HLoadNamedField>( |
9925 buffer, nullptr, HObjectAccess::ForJSArrayBufferByteLength()); | 9918 buffer, nullptr, HObjectAccess::ForJSArrayBufferByteLength()); |
9926 return ast_context()->ReturnInstruction(result, expr->id()); | 9919 return ast_context()->ReturnInstruction(result, expr->id()); |
9927 } | 9920 } |
9928 | 9921 |
9929 | 9922 |
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 | |
9968 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteLength( | 9923 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteLength( |
9969 CallRuntime* expr) { | 9924 CallRuntime* expr) { |
9970 return GenerateArrayBufferViewIndirectAccessor( | 9925 DCHECK(expr->arguments()->length() == 1); |
9971 expr, HObjectAccess::ForJSArrayBufferViewByteLength()); | 9926 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); |
| 9927 HValue* buffer = Pop(); |
| 9928 HInstruction* result = New<HLoadNamedField>( |
| 9929 buffer, nullptr, HObjectAccess::ForJSArrayBufferViewByteLength()); |
| 9930 return ast_context()->ReturnInstruction(result, expr->id()); |
9972 } | 9931 } |
9973 | 9932 |
9974 | 9933 |
9975 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteOffset( | 9934 void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteOffset( |
9976 CallRuntime* expr) { | 9935 CallRuntime* expr) { |
9977 return GenerateArrayBufferViewIndirectAccessor( | 9936 DCHECK(expr->arguments()->length() == 1); |
9978 expr, HObjectAccess::ForJSArrayBufferViewByteOffset()); | 9937 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); |
| 9938 HValue* buffer = Pop(); |
| 9939 HInstruction* result = New<HLoadNamedField>( |
| 9940 buffer, nullptr, HObjectAccess::ForJSArrayBufferViewByteOffset()); |
| 9941 return ast_context()->ReturnInstruction(result, expr->id()); |
9979 } | 9942 } |
9980 | 9943 |
9981 | 9944 |
9982 void HOptimizedGraphBuilder::GenerateTypedArrayGetLength( | 9945 void HOptimizedGraphBuilder::GenerateTypedArrayGetLength( |
9983 CallRuntime* expr) { | 9946 CallRuntime* expr) { |
9984 return GenerateArrayBufferViewIndirectAccessor( | 9947 DCHECK(expr->arguments()->length() == 1); |
9985 expr, HObjectAccess::ForJSTypedArrayLength()); | 9948 CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); |
| 9949 HValue* buffer = Pop(); |
| 9950 HInstruction* result = New<HLoadNamedField>( |
| 9951 buffer, nullptr, HObjectAccess::ForJSTypedArrayLength()); |
| 9952 return ast_context()->ReturnInstruction(result, expr->id()); |
9986 } | 9953 } |
9987 | 9954 |
9988 | 9955 |
9989 void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) { | 9956 void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) { |
9990 DCHECK(!HasStackOverflow()); | 9957 DCHECK(!HasStackOverflow()); |
9991 DCHECK(current_block() != NULL); | 9958 DCHECK(current_block() != NULL); |
9992 DCHECK(current_block()->HasPredecessor()); | 9959 DCHECK(current_block()->HasPredecessor()); |
9993 if (expr->is_jsruntime()) { | 9960 if (expr->is_jsruntime()) { |
9994 return Bailout(kCallToAJavaScriptRuntimeFunction); | 9961 return Bailout(kCallToAJavaScriptRuntimeFunction); |
9995 } | 9962 } |
(...skipping 3027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13023 if (ShouldProduceTraceOutput()) { | 12990 if (ShouldProduceTraceOutput()) { |
13024 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12991 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13025 } | 12992 } |
13026 | 12993 |
13027 #ifdef DEBUG | 12994 #ifdef DEBUG |
13028 graph_->Verify(false); // No full verify. | 12995 graph_->Verify(false); // No full verify. |
13029 #endif | 12996 #endif |
13030 } | 12997 } |
13031 | 12998 |
13032 } } // namespace v8::internal | 12999 } } // namespace v8::internal |
OLD | NEW |