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

Side by Side Diff: src/hydrogen.cc

Issue 779173010: Create optimized inline versions of Map and Set initialization (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Switch to StoreNamedField, shorten constant names Created 6 years 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/hydrogen-instructions.h » ('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 12630 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 kCapacity = CollectionType::kMinCapacity;
12654 static const int kBucketCount = kCapacity / CollectionType::kLoadFactor;
12655 static const int kFixedArrayLength = CollectionType::kHashTableStartIndex +
12656 kBucketCount +
12657 (kCapacity * CollectionType::kEntrySize);
12658 static const int kSizeInBytes =
12659 FixedArray::kHeaderSize + (kFixedArrayLength * kPointerSize);
12660
12661 // Allocate the table and add the proper map.
12662 HValue* table =
12663 Add<HAllocate>(Add<HConstant>(kSizeInBytes), HType::HeapObject(),
12664 NOT_TENURED, FIXED_ARRAY_TYPE);
12665 AddStoreMapConstant(table, isolate()->factory()->ordered_hash_table_map());
12666
12667 // Initialize the FixedArray...
12668 HValue* length = Add<HConstant>(kFixedArrayLength);
12669 Add<HStoreNamedField>(table, HObjectAccess::ForFixedArrayLength(), length);
12670
12671 // ...and the OrderedHashTable fields.
12672 Add<HStoreNamedField>(
12673 table,
12674 HObjectAccess::ForOrderedHashTableNumberOfBuckets<CollectionType>(),
12675 Add<HConstant>(kBucketCount));
12676 Add<HStoreNamedField>(
12677 table,
12678 HObjectAccess::ForOrderedHashTableNumberOfElements<CollectionType>(),
12679 graph()->GetConstant0());
12680 Add<HStoreNamedField>(
12681 table, HObjectAccess::ForOrderedHashTableNumberOfDeletedElements<
12682 CollectionType>(),
12683 graph()->GetConstant0());
12684
12685 // Fill the buckets with kNotFound.
12686 HValue* not_found = Add<HConstant>(CollectionType::kNotFound);
12687 for (int i = 0; i < kBucketCount; ++i) {
12688 Add<HStoreNamedField>(
12689 table, HObjectAccess::ForOrderedHashTableBucket<CollectionType>(i),
12690 not_found);
12691 }
12692
12693 // Fill the data table with undefined.
12694 HValue* undefined = graph()->GetConstantUndefined();
12695 for (int i = 0; i < (kCapacity * CollectionType::kEntrySize); ++i) {
12696 Add<HStoreNamedField>(table,
12697 HObjectAccess::ForOrderedHashTableDataTableIndex<
12698 CollectionType, kBucketCount>(i),
12699 undefined);
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...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698