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

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: 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/runtime/runtime.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 kInitialCapacity = CollectionType::kMinCapacity;
12654 static const int kInitialNumBuckets =
12655 kInitialCapacity / CollectionType::kLoadFactor;
12656 HValue* size = Add<HConstant>(
12657 FixedArray::kHeaderSize + CollectionType::kHashTableStartIndex +
12658 kInitialNumBuckets + (kInitialCapacity * CollectionType::kEntrySize));
12659 HValue* table =
12660 Add<HAllocate>(size, HType::HeapObject(), NOT_TENURED, FIXED_ARRAY_TYPE);
adamk 2014/12/08 21:41:14 One question about HAllocate: do I need to add cod
Dmitry Lomov (no reviews) 2014/12/09 12:05:39 Yes. See HOGB::BuildAllocateFixedTypedArray for in
adamk 2014/12/09 19:24:23 Added a bunch of proper initialization. Now the co
12661 Add<HStoreNamedField>(
12662 table, HObjectAccess::ForMap(),
12663 Add<HConstant>(isolate()->factory()->ordered_hash_table_map()));
12664 HValue* not_found = Add<HConstant>(CollectionType::kNotFound);
12665 for (int i = 0; i < kInitialNumBuckets; ++i) {
12666 Add<HStoreKeyed>(table,
12667 Add<HConstant>(CollectionType::kHashTableStartIndex + i),
12668 not_found, FAST_ELEMENTS);
12669 }
12670 Add<HStoreNamedField>(
12671 table,
12672 HObjectAccess::ForOrderedHashTableNumberOfBuckets<CollectionType>(),
12673 Add<HConstant>(kInitialNumBuckets));
12674 Add<HStoreNamedField>(
12675 table,
12676 HObjectAccess::ForOrderedHashTableNumberOfElements<CollectionType>(),
12677 graph()->GetConstant0());
12678 Add<HStoreNamedField>(
12679 table, HObjectAccess::ForOrderedHashTableNumberOfDeletedElements<
12680 CollectionType>(),
12681 graph()->GetConstant0());
12682 return table;
12683 }
12684
12685
12686 void HOptimizedGraphBuilder::GenerateSetInitialize(CallRuntime* call) {
12687 DCHECK(call->arguments()->length() == 1);
12688 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
12689 HValue* receiver = Pop();
12690 HValue* table = BuildAllocateOrderedHashTable<OrderedHashSet>();
12691 Add<HStoreNamedField>(receiver, HObjectAccess::ForJSCollectionTable(), table);
12692 return ast_context()->ReturnValue(receiver);
12693 }
12694
12695
12696 void HOptimizedGraphBuilder::GenerateMapInitialize(CallRuntime* call) {
12697 DCHECK(call->arguments()->length() == 1);
12698 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
12699 HValue* receiver = Pop();
12700 HValue* table = BuildAllocateOrderedHashTable<OrderedHashMap>();
12701 Add<HStoreNamedField>(receiver, HObjectAccess::ForJSCollectionTable(), table);
12702 return ast_context()->ReturnValue(receiver);
12703 }
12704
12705
12651 void HOptimizedGraphBuilder::GenerateGetCachedArrayIndex(CallRuntime* call) { 12706 void HOptimizedGraphBuilder::GenerateGetCachedArrayIndex(CallRuntime* call) {
12652 DCHECK(call->arguments()->length() == 1); 12707 DCHECK(call->arguments()->length() == 1);
12653 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 12708 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
12654 HValue* value = Pop(); 12709 HValue* value = Pop();
12655 HGetCachedArrayIndex* result = New<HGetCachedArrayIndex>(value); 12710 HGetCachedArrayIndex* result = New<HGetCachedArrayIndex>(value);
12656 return ast_context()->ReturnInstruction(result, call->id()); 12711 return ast_context()->ReturnInstruction(result, call->id());
12657 } 12712 }
12658 12713
12659 12714
12660 void HOptimizedGraphBuilder::GenerateFastOneByteArrayJoin(CallRuntime* call) { 12715 void HOptimizedGraphBuilder::GenerateFastOneByteArrayJoin(CallRuntime* call) {
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
13368 if (ShouldProduceTraceOutput()) { 13423 if (ShouldProduceTraceOutput()) {
13369 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13424 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13370 } 13425 }
13371 13426
13372 #ifdef DEBUG 13427 #ifdef DEBUG
13373 graph_->Verify(false); // No full verify. 13428 graph_->Verify(false); // No full verify.
13374 #endif 13429 #endif
13375 } 13430 }
13376 13431
13377 } } // namespace v8::internal 13432 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698