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 12630 matching lines...) Loading... | |
12641 HValue* receiver = Pop(); | 12641 HValue* receiver = Pop(); |
12642 HValue* table = Add<HLoadNamedField>(receiver, static_cast<HValue*>(NULL), | 12642 HValue* table = Add<HLoadNamedField>(receiver, static_cast<HValue*>(NULL), |
12643 HObjectAccess::ForJSCollectionTable()); | 12643 HObjectAccess::ForJSCollectionTable()); |
12644 HInstruction* result = New<HLoadNamedField>( | 12644 HInstruction* result = New<HLoadNamedField>( |
12645 table, static_cast<HValue*>(NULL), | 12645 table, static_cast<HValue*>(NULL), |
12646 HObjectAccess::ForOrderedHashTableNumberOfElements<OrderedHashMap>()); | 12646 HObjectAccess::ForOrderedHashTableNumberOfElements<OrderedHashMap>()); |
12647 return ast_context()->ReturnInstruction(result, call->id()); | 12647 return ast_context()->ReturnInstruction(result, call->id()); |
12648 } | 12648 } |
12649 | 12649 |
12650 | 12650 |
12651 template <typename CollectionType> | |
12652 HValue* HOptimizedGraphBuilder::BuildAllocateOrderedHashTable() { | |
12653 static const int kInitialCapacity = CollectionType::kMinCapacity; | |
12654 static const int kInitialNumBuckets = | |
12655 kInitialCapacity / CollectionType::kLoadFactor; | |
12656 static const int kInitialFixedArrayLength = | |
12657 CollectionType::kHashTableStartIndex + kInitialNumBuckets + | |
12658 (kInitialCapacity * CollectionType::kEntrySize); | |
12659 static const int kSizeInBytes = | |
12660 FixedArray::kHeaderSize + (kInitialFixedArrayLength * kPointerSize); | |
12661 | |
12662 // Allocate the table and add the proper map. | |
12663 HValue* table = | |
12664 Add<HAllocate>(Add<HConstant>(kSizeInBytes), HType::HeapObject(), | |
12665 NOT_TENURED, FIXED_ARRAY_TYPE); | |
12666 AddStoreMapConstant(table, isolate()->factory()->ordered_hash_table_map()); | |
12667 | |
12668 // Initialize the FixedArray... | |
12669 HValue* length = Add<HConstant>(kInitialFixedArrayLength); | |
12670 Add<HStoreNamedField>(table, HObjectAccess::ForFixedArrayLength(), length); | |
12671 | |
12672 // ...and the OrderedHashTable fields. | |
12673 Add<HStoreNamedField>( | |
12674 table, | |
12675 HObjectAccess::ForOrderedHashTableNumberOfBuckets<CollectionType>(), | |
12676 Add<HConstant>(kInitialNumBuckets)); | |
12677 Add<HStoreNamedField>( | |
12678 table, | |
12679 HObjectAccess::ForOrderedHashTableNumberOfElements<CollectionType>(), | |
12680 graph()->GetConstant0()); | |
12681 Add<HStoreNamedField>( | |
12682 table, HObjectAccess::ForOrderedHashTableNumberOfDeletedElements< | |
12683 CollectionType>(), | |
12684 graph()->GetConstant0()); | |
12685 | |
12686 static const int kDataTableStartIndex = | |
12687 CollectionType::kHashTableStartIndex + kInitialNumBuckets; | |
12688 | |
12689 // Fill the buckets with kNotFound. | |
12690 HValue* not_found = Add<HConstant>(CollectionType::kNotFound); | |
12691 for (int i = CollectionType::kHashTableStartIndex; i < kDataTableStartIndex; | |
12692 ++i) { | |
12693 Add<HStoreKeyed>(table, Add<HConstant>(i), not_found, FAST_ELEMENTS); | |
Dmitry Lomov (no reviews)
2014/12/09 20:48:51
This should use HStoreNamedField.
adamk
2014/12/09 21:16:59
What do you have in mind? There's a variety of HOb
Dmitry Lomov (no reviews)
2014/12/09 21:31:56
Two different methods sound most semantically clea
| |
12694 } | |
12695 | |
12696 // Fill the data table with undefined. | |
12697 HValue* undefined = graph()->GetConstantUndefined(); | |
12698 for (int i = kDataTableStartIndex; i < kInitialFixedArrayLength; ++i) { | |
12699 Add<HStoreKeyed>(table, Add<HConstant>(i), undefined, FAST_ELEMENTS); | |
Dmitry Lomov (no reviews)
2014/12/09 20:48:51
Ditto.
| |
12700 } | |
12701 | |
12702 return table; | |
12703 } | |
12704 | |
12705 | |
12706 void HOptimizedGraphBuilder::GenerateSetInitialize(CallRuntime* call) { | |
12707 DCHECK(call->arguments()->length() == 1); | |
12708 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | |
12709 HValue* receiver = Pop(); | |
12710 | |
12711 NoObservableSideEffectsScope no_effects(this); | |
12712 HValue* table = BuildAllocateOrderedHashTable<OrderedHashSet>(); | |
12713 Add<HStoreNamedField>(receiver, HObjectAccess::ForJSCollectionTable(), table); | |
12714 return ast_context()->ReturnValue(receiver); | |
12715 } | |
12716 | |
12717 | |
12718 void HOptimizedGraphBuilder::GenerateMapInitialize(CallRuntime* call) { | |
12719 DCHECK(call->arguments()->length() == 1); | |
12720 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | |
12721 HValue* receiver = Pop(); | |
12722 | |
12723 NoObservableSideEffectsScope no_effects(this); | |
12724 HValue* table = BuildAllocateOrderedHashTable<OrderedHashMap>(); | |
12725 Add<HStoreNamedField>(receiver, HObjectAccess::ForJSCollectionTable(), table); | |
12726 return ast_context()->ReturnValue(receiver); | |
12727 } | |
12728 | |
12729 | |
12651 void HOptimizedGraphBuilder::GenerateGetCachedArrayIndex(CallRuntime* call) { | 12730 void HOptimizedGraphBuilder::GenerateGetCachedArrayIndex(CallRuntime* call) { |
12652 DCHECK(call->arguments()->length() == 1); | 12731 DCHECK(call->arguments()->length() == 1); |
12653 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 12732 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
12654 HValue* value = Pop(); | 12733 HValue* value = Pop(); |
12655 HGetCachedArrayIndex* result = New<HGetCachedArrayIndex>(value); | 12734 HGetCachedArrayIndex* result = New<HGetCachedArrayIndex>(value); |
12656 return ast_context()->ReturnInstruction(result, call->id()); | 12735 return ast_context()->ReturnInstruction(result, call->id()); |
12657 } | 12736 } |
12658 | 12737 |
12659 | 12738 |
12660 void HOptimizedGraphBuilder::GenerateFastOneByteArrayJoin(CallRuntime* call) { | 12739 void HOptimizedGraphBuilder::GenerateFastOneByteArrayJoin(CallRuntime* call) { |
(...skipping 707 matching lines...) Loading... | |
13368 if (ShouldProduceTraceOutput()) { | 13447 if (ShouldProduceTraceOutput()) { |
13369 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13448 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13370 } | 13449 } |
13371 | 13450 |
13372 #ifdef DEBUG | 13451 #ifdef DEBUG |
13373 graph_->Verify(false); // No full verify. | 13452 graph_->Verify(false); // No full verify. |
13374 #endif | 13453 #endif |
13375 } | 13454 } |
13376 | 13455 |
13377 } } // namespace v8::internal | 13456 } } // namespace v8::internal |
OLD | NEW |